@linzumi/cli 1.0.208 → 1.0.210

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.
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
2
2
  const require = __linzumiBundleCreateRequire(import.meta.url);
3
- var sS=Object.create;var au=Object.defineProperty;var aS=Object.getOwnPropertyDescriptor;var cS=Object.getOwnPropertyNames;var lS=Object.getPrototypeOf,uS=Object.prototype.hasOwnProperty;var wn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cu=(e,t)=>{for(var r in t)au(e,r,{get:t[r],enumerable:!0})},dS=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cS(t))!uS.call(e,i)&&i!==r&&au(e,i,{get:()=>t[i],enumerable:!(n=aS(t,i))||n.enumerable});return e};var lu=(e,t,r)=>(r=e!=null?sS(lS(e)):{},dS(t||!e||!e.__esModule?au(r,"default",{value:e,enumerable:!0}):r,e));var _y=E((BZ,gy)=>{var Rn=wn("constants"),Oz=process.cwd,fc=null,Az=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return fc||(fc=Oz.call(process)),fc};try{process.cwd()}catch{}typeof process.chdir=="function"&&(od=process.chdir,process.chdir=function(e){fc=null,od.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,od));var od;gy.exports=Pz;function Pz(e){Rn.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(l,d,h){h&&process.nextTick(h)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(l,d,h,m){m&&process.nextTick(m)},e.lchownSync=function(){}),Az==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(l){function d(h,m,p){var f=Date.now(),g=0;l(h,m,function y(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-f<6e4){setTimeout(function(){e.stat(m,function(b,w){b&&b.code==="ENOENT"?l(h,m,y):p(v)})},g),g<100&&(g+=10);return}p&&p(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(l){function d(h,m,p,f,g,y){var v;if(y&&typeof y=="function"){var b=0;v=function(w,S,q){if(w&&w.code==="EAGAIN"&&b<10)return b++,l.call(e,h,m,p,f,g,v);y.apply(this,arguments)}}return l.call(e,h,m,p,f,g,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(l){return function(d,h,m,p,f){for(var g=0;;)try{return l.call(e,d,h,m,p,f)}catch(y){if(y.code==="EAGAIN"&&g<10){g++;continue}throw y}}})(e.readSync);function t(l){l.lchmod=function(d,h,m){l.open(d,Rn.O_WRONLY|Rn.O_SYMLINK,h,function(p,f){if(p){m&&m(p);return}l.fchmod(f,h,function(g){l.close(f,function(y){m&&m(g||y)})})})},l.lchmodSync=function(d,h){var m=l.openSync(d,Rn.O_WRONLY|Rn.O_SYMLINK,h),p=!0,f;try{f=l.fchmodSync(m,h),p=!1}finally{if(p)try{l.closeSync(m)}catch{}else l.closeSync(m)}return f}}function r(l){Rn.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(d,h,m,p){l.open(d,Rn.O_SYMLINK,function(f,g){if(f){p&&p(f);return}l.futimes(g,h,m,function(y){l.close(g,function(v){p&&p(y||v)})})})},l.lutimesSync=function(d,h,m){var p=l.openSync(d,Rn.O_SYMLINK),f,g=!0;try{f=l.futimesSync(p,h,m),g=!1}finally{if(g)try{l.closeSync(p)}catch{}else l.closeSync(p)}return f}):l.futimes&&(l.lutimes=function(d,h,m,p){p&&process.nextTick(p)},l.lutimesSync=function(){})}function n(l){return l&&function(d,h,m){return l.call(e,d,h,function(p){c(p)&&(p=null),m&&m.apply(this,arguments)})}}function i(l){return l&&function(d,h){try{return l.call(e,d,h)}catch(m){if(!c(m))throw m}}}function o(l){return l&&function(d,h,m,p){return l.call(e,d,h,m,function(f){c(f)&&(f=null),p&&p.apply(this,arguments)})}}function s(l){return l&&function(d,h,m){try{return l.call(e,d,h,m)}catch(p){if(!c(p))throw p}}}function a(l){return l&&function(d,h,m){typeof h=="function"&&(m=h,h=null);function p(f,g){g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),m&&m.apply(this,arguments)}return h?l.call(e,d,h,p):l.call(e,d,p)}}function u(l){return l&&function(d,h){var m=h?l.call(e,d,h):l.call(e,d);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function c(l){if(!l||l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var by=E((JZ,vy)=>{var yy=wn("stream").Stream;vy.exports=Cz;function Cz(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);yy.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),a=0,u=s.length;a<u;a++){var c=s[a];this[c]=i[c]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);yy.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,a=o.length;s<a;s++){var u=o[s];this[u]=i[u]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var xy=E((WZ,wy)=>{"use strict";wy.exports=Iz;var Rz=Object.getPrototypeOf||function(e){return e.__proto__};function Iz(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:Rz(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ld=E((HZ,cd)=>{var Be=wn("fs"),jz=_y(),Nz=by(),Mz=xy(),mc=wn("util"),mt,hc;typeof Symbol=="function"&&typeof Symbol.for=="function"?(mt=Symbol.for("graceful-fs.queue"),hc=Symbol.for("graceful-fs.previous")):(mt="___graceful-fs.queue",hc="___graceful-fs.previous");function Dz(){}function Ty(e,t){Object.defineProperty(e,mt,{get:function(){return t}})}var ki=Dz;mc.debuglog?ki=mc.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ki=function(){var e=mc.format.apply(mc,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});Be[mt]||(ky=global[mt]||[],Ty(Be,ky),Be.close=(function(e){function t(r,n){return e.call(Be,r,function(i){i||Sy(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,hc,{value:e}),t})(Be.close),Be.closeSync=(function(e){function t(r){e.apply(Be,arguments),Sy()}return Object.defineProperty(t,hc,{value:e}),t})(Be.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ki(Be[mt]),wn("assert").equal(Be[mt].length,0)}));var ky;global[mt]||Ty(global,Be[mt]);cd.exports=sd(Mz(Be));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Be.__patched&&(cd.exports=sd(Be),Be.__patched=!0);function sd(e){jz(e),e.gracefulify=sd,e.createReadStream=S,e.createWriteStream=q;var t=e.readFile;e.readFile=r;function r(C,V,H){return typeof V=="function"&&(H=V,V=null),fe(C,V,H);function fe(ge,j,$,R){return t(ge,j,function(N){N&&(N.code==="EMFILE"||N.code==="ENFILE")?_o([fe,[ge,j,$],N,R||Date.now(),Date.now()]):typeof $=="function"&&$.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return n(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return o(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=u);function u(C,V,H,fe){return typeof H=="function"&&(fe=H,H=0),ge(C,V,H,fe);function ge(j,$,R,N,I){return a(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var c=e.readdir;e.readdir=d;var l=/^v[0-5]\./;function d(C,V,H){typeof V=="function"&&(H=V,V=null);var fe=l.test(process.version)?function($,R,N,I){return c($,ge($,R,N,I))}:function($,R,N,I){return c($,R,ge($,R,N,I))};return fe(C,V,H);function ge(j,$,R,N){return function(I,G){I&&(I.code==="EMFILE"||I.code==="ENFILE")?_o([fe,[j,$,R],I,N||Date.now(),Date.now()]):(G&&G.sort&&G.sort(),typeof R=="function"&&R.call(this,I,G))}}}if(process.version.substr(0,4)==="v0.8"){var h=Nz(e);y=h.ReadStream,b=h.WriteStream}var m=e.ReadStream;m&&(y.prototype=Object.create(m.prototype),y.prototype.open=v);var p=e.WriteStream;p&&(b.prototype=Object.create(p.prototype),b.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(C){y=C},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return b},set:function(C){b=C},enumerable:!0,configurable:!0});var f=y;Object.defineProperty(e,"FileReadStream",{get:function(){return f},set:function(C){f=C},enumerable:!0,configurable:!0});var g=b;Object.defineProperty(e,"FileWriteStream",{get:function(){return g},set:function(C){g=C},enumerable:!0,configurable:!0});function y(C,V){return this instanceof y?(m.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function v(){var C=this;ce(C.path,C.flags,C.mode,function(V,H){V?(C.autoClose&&C.destroy(),C.emit("error",V)):(C.fd=H,C.emit("open",H),C.read())})}function b(C,V){return this instanceof b?(p.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function w(){var C=this;ce(C.path,C.flags,C.mode,function(V,H){V?(C.destroy(),C.emit("error",V)):(C.fd=H,C.emit("open",H))})}function S(C,V){return new e.ReadStream(C,V)}function q(C,V){return new e.WriteStream(C,V)}var K=e.open;e.open=ce;function ce(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return K(j,$,R,function(G,ye){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}return e}function _o(e){ki("ENQUEUE",e[0].name,e[1]),Be[mt].push(e),ad()}var pc;function Sy(){for(var e=Date.now(),t=0;t<Be[mt].length;++t)Be[mt][t].length>2&&(Be[mt][t][3]=e,Be[mt][t][4]=e);ad()}function ad(){if(clearTimeout(pc),pc=void 0,Be[mt].length!==0){var e=Be[mt].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ki("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ki("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,u=Math.max(o-i,1),c=Math.min(u*1.2,100);a>=c?(ki("RETRY",t.name,r),t.apply(null,r.concat([i]))):Be[mt].push(e)}pc===void 0&&(pc=setTimeout(ad,0))}}});var zy=E((KZ,$y)=>{function ar(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}$y.exports=ar;ar.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ar.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};ar.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};ar.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};ar.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ar.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ar.prototype.start=ar.prototype.try;ar.prototype.errors=function(){return this._errors};ar.prototype.attempts=function(){return this._attempts};ar.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=i,r=s)}return t}});var Ey=E(Si=>{var Zz=zy();Si.operation=function(e){var t=Si.timeouts(e);return new Zz(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Si.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(o,s){return o-s}),n};Si.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};Si.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],s=e[o];e[o]=function(u){var c=Si.operation(t),l=Array.prototype.slice.call(arguments,1),d=l.pop();l.push(function(h){c.retry(h)||(h&&(arguments[0]=c.mainError()),d.apply(this,arguments))}),c.attempt(function(){u.apply(e,l)})}.bind(e,s),e[o].options=t}}});var Ay=E((XZ,Oy)=>{Oy.exports=Ey()});var Py=E((YZ,gc)=>{gc.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&gc.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&gc.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Ny=E((eL,bo)=>{var Ne=global.process,Ti=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};Ti(Ne)?(Cy=wn("assert"),yo=Py(),Ry=/^win/i.test(Ne.platform),ks=wn("events"),typeof ks!="function"&&(ks=ks.EventEmitter),Ne.__signal_exit_emitter__?at=Ne.__signal_exit_emitter__:(at=Ne.__signal_exit_emitter__=new ks,at.count=0,at.emitted={}),at.infinite||(at.setMaxListeners(1/0),at.infinite=!0),bo.exports=function(e,t){if(!Ti(global.process))return function(){};Cy.equal(typeof e,"function","a callback must be provided for exit handler"),vo===!1&&ud();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){at.removeListener(r,e),at.listeners("exit").length===0&&at.listeners("afterexit").length===0&&_c()};return at.on(r,e),n},_c=function(){!vo||!Ti(global.process)||(vo=!1,yo.forEach(function(t){try{Ne.removeListener(t,yc[t])}catch{}}),Ne.emit=vc,Ne.reallyExit=dd,at.count-=1)},bo.exports.unload=_c,$i=function(t,r,n){at.emitted[t]||(at.emitted[t]=!0,at.emit(t,r,n))},yc={},yo.forEach(function(e){yc[e]=function(){if(Ti(global.process)){var r=Ne.listeners(e);r.length===at.count&&(_c(),$i("exit",null,e),$i("afterexit",null,e),Ry&&e==="SIGHUP"&&(e="SIGINT"),Ne.kill(Ne.pid,e))}}}),bo.exports.signals=function(){return yo},vo=!1,ud=function(){vo||!Ti(global.process)||(vo=!0,at.count+=1,yo=yo.filter(function(t){try{return Ne.on(t,yc[t]),!0}catch{return!1}}),Ne.emit=jy,Ne.reallyExit=Iy)},bo.exports.load=ud,dd=Ne.reallyExit,Iy=function(t){Ti(global.process)&&(Ne.exitCode=t||0,$i("exit",Ne.exitCode,null),$i("afterexit",Ne.exitCode,null),dd.call(Ne,Ne.exitCode))},vc=Ne.emit,jy=function(t,r){if(t==="exit"&&Ti(global.process)){r!==void 0&&(Ne.exitCode=r);var n=vc.apply(this,arguments);return $i("exit",Ne.exitCode,null),$i("afterexit",Ne.exitCode,null),n}else return vc.apply(this,arguments)}):bo.exports=function(){return function(){}};var Cy,yo,Ry,ks,at,_c,$i,yc,vo,ud,dd,Iy,vc,jy});var qy=E((tL,Ss)=>{"use strict";var Lz=wn("path"),pd=ld(),qz=Ay(),Fz=Ny(),un={};function wo(e,t){return t.lockfilePath||`${e}.lock`}function hd(e,t,r){if(!t.realpath)return r(null,Lz.resolve(e));t.fs.realpath(e,r)}function fd(e,t,r){t.fs.mkdir(wo(e,t),n=>{if(!n)return r();if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(wo(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?fd(e,{...t,stale:0},r):r(i);if(!Dy(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Zy(e,t,s=>{if(s)return r(s);fd(e,{...t,stale:0},r)})})})}function Dy(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Zy(e,t,r){t.fs.rmdir(wo(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function md(e,t){let r=un[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(wo(e,t),n,n,i=>{if(!r.released){if(r.lastUpdate<=Date.now()-t.stale&&r.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(r.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return My(e,r,o)}if(i)return i.code==="ENOENT"?My(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,md(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,md(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function My(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),un[e]===t&&delete un[e],t.options.onCompromised(r)}function Uz(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:pd,onCompromised:n=>{throw n},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),hd(e,t,(n,i)=>{if(n)return r(n);let o=qz.operation(t.retries);o.attempt(()=>{fd(i,t,s=>{if(o.retry(s))return;if(s)return r(o.mainError());let a=un[i]={options:t,lastUpdate:Date.now()};md(i,t),r(null,u=>{if(a.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Ly(i,{...t,realpath:!1},u)})})})})}function Ly(e,t,r){t={fs:pd,realpath:!0,...t},hd(e,t,(n,i)=>{if(n)return r(n);let o=un[i];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete un[i],Zy(i,t,r)})}function Vz(e,t,r){t={stale:1e4,realpath:!0,fs:pd,...t},t.stale=Math.max(t.stale||0,2e3),hd(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(wo(i,t),(o,s)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Dy(s,t)))})}function Gz(){return un}Fz(()=>{for(let e in un){let t=un[e].options;try{t.fs.rmdirSync(wo(e,t))}catch{}}});Ss.exports.lock=Uz;Ss.exports.unlock=Ly;Ss.exports.check=Vz;Ss.exports.getLocks=Gz});var Uy=E((rL,Fy)=>{"use strict";var Bz=ld();function Jz(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),s;try{s=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,s)}}),r}function Wz(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function Hz(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function Kz(e){if(e={...e},e.fs=Jz(e.fs||Bz),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Fy.exports={toPromise:Wz,toSync:Hz,toSyncOptions:Kz}});var Gy=E((nL,In)=>{"use strict";var xo=qy(),{toPromise:bc,toSync:wc,toSyncOptions:gd}=Uy();async function Vy(e,t){let r=await bc(xo.lock)(e,t);return bc(r)}function Qz(e,t){let r=wc(xo.lock)(e,gd(t));return wc(r)}function Xz(e,t){return bc(xo.unlock)(e,t)}function Yz(e,t){return wc(xo.unlock)(e,gd(t))}function eE(e,t){return bc(xo.check)(e,t)}function tE(e,t){return wc(xo.check)(e,gd(t))}In.exports=Vy;In.exports.lock=Vy;In.exports.unlock=Xz;In.exports.lockSync=Qz;In.exports.unlockSync=Yz;In.exports.check=eE;In.exports.checkSync=tE});var ea=E(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.regexpCode=pe.getEsmExportName=pe.getProperty=pe.safeStringify=pe.stringify=pe.strConcat=pe.addCodeArg=pe.str=pe._=pe.nil=pe._Code=pe.Name=pe.IDENTIFIER=pe._CodeOrName=void 0;var Xs=class{};pe._CodeOrName=Xs;pe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Mi=class extends Xs{constructor(t){if(super(),!pe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};pe.Name=Mi;var dr=class extends Xs{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Mi&&(r[n.str]=(r[n.str]||0)+1),r),{})}};pe._Code=dr;pe.nil=new dr("");function r0(e,...t){let r=[e[0]],n=0;for(;n<t.length;)pp(r,t[n]),r.push(e[++n]);return new dr(r)}pe._=r0;var mp=new dr("+");function n0(e,...t){let r=[Ys(e[0])],n=0;for(;n<t.length;)r.push(mp),pp(r,t[n]),r.push(mp,Ys(e[++n]));return zC(r),new dr(r)}pe.str=n0;function pp(e,t){t instanceof dr?e.push(...t._items):t instanceof Mi?e.push(t):e.push(AC(t))}pe.addCodeArg=pp;function zC(e){let t=1;for(;t<e.length-1;){if(e[t]===mp){let r=EC(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function EC(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Mi||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Mi))return`"${e}${t.slice(1)}`}function OC(e,t){return t.emptyStr()?e:e.emptyStr()?t:n0`${e}${t}`}pe.strConcat=OC;function AC(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Ys(Array.isArray(e)?e.join(","):e)}function PC(e){return new dr(Ys(e))}pe.stringify=PC;function Ys(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}pe.safeStringify=Ys;function CC(e){return typeof e=="string"&&pe.IDENTIFIER.test(e)?new dr(`.${e}`):r0`[${e}]`}pe.getProperty=CC;function RC(e){if(typeof e=="string"&&pe.IDENTIFIER.test(e))return new dr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}pe.getEsmExportName=RC;function IC(e){return new dr(e.toString())}pe.regexpCode=IC});var _p=E(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.ValueScope=Vt.ValueScopeName=Vt.Scope=Vt.varKinds=Vt.UsedValueState=void 0;var Ut=ea(),hp=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},_l;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(_l||(Vt.UsedValueState=_l={}));Vt.varKinds={const:new Ut.Name("const"),let:new Ut.Name("let"),var:new Ut.Name("var")};var yl=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ut.Name?t:this.name(t)}name(t){return new Ut.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Vt.Scope=yl;var vl=class extends Ut.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ut._)`.${new Ut.Name(r)}[${n}]`}};Vt.ValueScopeName=vl;var jC=(0,Ut._)`\n`,gp=class extends yl{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?jC:Ut.nil}}get(){return this._scope}name(t){return new vl(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(s);if(l)return l}else a=this._values[o]=new Map;a.set(s,i);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,i.setValue(r,{property:o,itemIndex:c}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ut._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=Ut.nil;for(let s in t){let a=t[s];if(!a)continue;let u=n[s]=n[s]||new Map;a.forEach(c=>{if(u.has(c))return;u.set(c,_l.Started);let l=r(c);if(l){let d=this.opts.es5?Vt.varKinds.var:Vt.varKinds.const;o=(0,Ut._)`${o}${d} ${c} = ${l};${this.opts._n}`}else if(l=i?.(c))o=(0,Ut._)`${o}${l}${this.opts._n}`;else throw new hp(c);u.set(c,_l.Completed)})}return o}};Vt.ValueScope=gp});var ne=E(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.or=ie.and=ie.not=ie.CodeGen=ie.operators=ie.varKinds=ie.ValueScopeName=ie.ValueScope=ie.Scope=ie.Name=ie.regexpCode=ie.stringify=ie.getProperty=ie.nil=ie.strConcat=ie.str=ie._=void 0;var de=ea(),Tr=_p(),qn=ea();Object.defineProperty(ie,"_",{enumerable:!0,get:function(){return qn._}});Object.defineProperty(ie,"str",{enumerable:!0,get:function(){return qn.str}});Object.defineProperty(ie,"strConcat",{enumerable:!0,get:function(){return qn.strConcat}});Object.defineProperty(ie,"nil",{enumerable:!0,get:function(){return qn.nil}});Object.defineProperty(ie,"getProperty",{enumerable:!0,get:function(){return qn.getProperty}});Object.defineProperty(ie,"stringify",{enumerable:!0,get:function(){return qn.stringify}});Object.defineProperty(ie,"regexpCode",{enumerable:!0,get:function(){return qn.regexpCode}});Object.defineProperty(ie,"Name",{enumerable:!0,get:function(){return qn.Name}});var kl=_p();Object.defineProperty(ie,"Scope",{enumerable:!0,get:function(){return kl.Scope}});Object.defineProperty(ie,"ValueScope",{enumerable:!0,get:function(){return kl.ValueScope}});Object.defineProperty(ie,"ValueScopeName",{enumerable:!0,get:function(){return kl.ValueScopeName}});Object.defineProperty(ie,"varKinds",{enumerable:!0,get:function(){return kl.varKinds}});ie.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var pn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},yp=class extends pn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Tr.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=jo(this.rhs,t,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}},bl=class extends pn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof de.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=jo(this.rhs,t,r),this}get names(){let t=this.lhs instanceof de.Name?{}:{...this.lhs.names};return xl(t,this.rhs)}},vp=class extends bl{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},bp=class extends pn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},wp=class extends pn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},xp=class extends pn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},kp=class extends pn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=jo(this.code,t,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}},ta=class extends pn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(NC(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Li(t,r.names),{})}},hn=class extends ta{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Sp=class extends ta{},Io=class extends hn{};Io.kind="else";var Di=class e extends hn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Io(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(i0(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=jo(this.condition,t,r),this}get names(){let t=super.names;return xl(t,this.condition),this.else&&Li(t,this.else.names),t}};Di.kind="if";var Zi=class extends hn{};Zi.kind="for";var Tp=class extends Zi{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=jo(this.iteration,t,r),this}get names(){return Li(super.names,this.iteration.names)}},$p=class extends Zi{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?Tr.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=xl(super.names,this.from);return xl(t,this.to)}},wl=class extends Zi{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=jo(this.iterable,t,r),this}get names(){return Li(super.names,this.iterable.names)}},ra=class extends hn{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};ra.kind="func";var na=class extends ta{render(t){return"return "+super.render(t)}};na.kind="return";var zp=class extends hn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Li(t,this.catch.names),this.finally&&Li(t,this.finally.names),t}},ia=class extends hn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};ia.kind="catch";var oa=class extends hn{render(t){return"finally"+super.render(t)}};oa.kind="finally";var Ep=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
- `:""},this._extScope=t,this._scope=new Tr.Scope({parent:t}),this._nodes=[new Sp]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new yp(t,o,n)),o}const(t,r,n){return this._def(Tr.varKinds.const,t,r,n)}let(t,r,n){return this._def(Tr.varKinds.let,t,r,n)}var(t,r,n){return this._def(Tr.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new bl(t,r,n))}add(t,r){return this._leafNode(new vp(t,ie.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==de.nil&&this._leafNode(new kp(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,i));return r.push("}"),new de._Code(r)}if(t,r,n){if(this._blockNode(new Di(t)),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(t){return this._elseNode(new Di(t))}else(){return this._elseNode(new Io)}endIf(){return this._endBlockNode(Di,Io)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Tp(t),r)}forRange(t,r,n,i,o=this.opts.es5?Tr.varKinds.var:Tr.varKinds.let){let s=this._scope.toName(t);return this._for(new $p(o,s,r,n),()=>i(s))}forOf(t,r,n,i=Tr.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${s}.length`,a=>{this.var(o,(0,de._)`${s}[${a}]`),n(o)})}return this._for(new wl("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?Tr.varKinds.var:Tr.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,de._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new wl("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Zi)}label(t){return this._leafNode(new bp(t))}break(t){return this._leafNode(new wp(t))}return(t){let r=new na;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(na)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new zp;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new ia(o),r(o)}return n&&(this._currNode=i.finally=new oa,this.code(n)),this._endBlockNode(ia,oa)}throw(t){return this._leafNode(new xp(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){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||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=de.nil,n,i){return this._blockNode(new ra(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(ra)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Di))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};ie.CodeGen=Ep;function Li(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function xl(e,t){return t instanceof de._CodeOrName?Li(e,t.names):e}function jo(e,t,r){if(e instanceof de.Name)return n(e);if(!i(e))return e;return new de._Code(e._items.reduce((o,s)=>(s instanceof de.Name&&(s=n(s)),s instanceof de._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function i(o){return o instanceof de._Code&&o._items.some(s=>s instanceof de.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function NC(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function i0(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,de._)`!${Op(e)}`}ie.not=i0;var MC=o0(ie.operators.AND);function DC(...e){return e.reduce(MC)}ie.and=DC;var ZC=o0(ie.operators.OR);function LC(...e){return e.reduce(ZC)}ie.or=LC;function o0(e){return(t,r)=>t===de.nil?r:r===de.nil?t:(0,de._)`${Op(t)} ${e} ${Op(r)}`}function Op(e){return e instanceof de.Name?e:(0,de._)`(${e})`}});var he=E(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;var $e=ne(),qC=ea();function FC(e){let t={};for(let r of e)t[r]=!0;return t}oe.toHash=FC;function UC(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(c0(e,t),!l0(t,e.self.RULES.all))}oe.alwaysValidSchema=UC;function c0(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||f0(e,`unknown keyword: "${o}"`)}oe.checkUnknownRules=c0;function l0(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}oe.schemaHasRules=l0;function VC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}oe.schemaHasRulesButRef=VC;function GC({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}oe.schemaRefOrVal=GC;function BC(e){return u0(decodeURIComponent(e))}oe.unescapeFragment=BC;function JC(e){return encodeURIComponent(Pp(e))}oe.escapeFragment=JC;function Pp(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=Pp;function u0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=u0;function WC(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}oe.eachItem=WC;function s0({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let u=s===void 0?o:s instanceof $e.Name?(o instanceof $e.Name?e(i,o,s):t(i,o,s),s):o instanceof $e.Name?(t(i,s,o),o):r(o,s);return a===$e.Name&&!(u instanceof $e.Name)?n(i,u):u}}oe.mergeEvaluated={props:s0({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),Cp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:d0}),items:s0({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function d0(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,$e._)`{}`);return t!==void 0&&Cp(e,r,t),r}oe.evaluatedPropsToName=d0;function Cp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}oe.setEvaluated=Cp;var a0={};function HC(e,t){return e.scopeValue("func",{ref:t,code:a0[t.code]||(a0[t.code]=new qC._Code(t.code))})}oe.useFunc=HC;var Ap;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ap||(oe.Type=Ap={}));function KC(e,t,r){if(e instanceof $e.Name){let n=t===Ap.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+Pp(e)}oe.getErrorPath=KC;function f0(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}oe.checkStrictMode=f0});var gn=E(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var Tt=ne(),QC={data:new Tt.Name("data"),valCxt:new Tt.Name("valCxt"),instancePath:new Tt.Name("instancePath"),parentData:new Tt.Name("parentData"),parentDataProperty:new Tt.Name("parentDataProperty"),rootData:new Tt.Name("rootData"),dynamicAnchors:new Tt.Name("dynamicAnchors"),vErrors:new Tt.Name("vErrors"),errors:new Tt.Name("errors"),this:new Tt.Name("this"),self:new Tt.Name("self"),scope:new Tt.Name("scope"),json:new Tt.Name("json"),jsonPos:new Tt.Name("jsonPos"),jsonLen:new Tt.Name("jsonLen"),jsonPart:new Tt.Name("jsonPart")};Rp.default=QC});var sa=E($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.extendErrors=$t.resetErrorsCount=$t.reportExtraError=$t.reportError=$t.keyword$DataError=$t.keywordError=void 0;var me=ne(),Sl=he(),jt=gn();$t.keywordError={message:({keyword:e})=>(0,me.str)`must pass "${e}" keyword validation`};$t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,me.str)`"${e}" keyword must be ${t} ($data)`:(0,me.str)`"${e}" keyword is invalid ($data)`};function XC(e,t=$t.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:s,allErrors:a}=i,u=h0(e,t,r);n??(s||a)?m0(o,u):p0(i,(0,me._)`[${u}]`)}$t.reportError=XC;function YC(e,t=$t.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,a=h0(e,t,r);m0(i,a),o||s||p0(n,jt.default.vErrors)}$t.reportExtraError=YC;function e1(e,t){e.assign(jt.default.errors,t),e.if((0,me._)`${jt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,me._)`${jt.default.vErrors}.length`,t),()=>e.assign(jt.default.vErrors,null)))}$t.resetErrorsCount=e1;function t1({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",i,jt.default.errors,a=>{e.const(s,(0,me._)`${jt.default.vErrors}[${a}]`),e.if((0,me._)`${s}.instancePath === undefined`,()=>e.assign((0,me._)`${s}.instancePath`,(0,me.strConcat)(jt.default.instancePath,o.errorPath))),e.assign((0,me._)`${s}.schemaPath`,(0,me.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,me._)`${s}.schema`,r),e.assign((0,me._)`${s}.data`,n))})}$t.extendErrors=t1;function m0(e,t){let r=e.const("err",t);e.if((0,me._)`${jt.default.vErrors} === null`,()=>e.assign(jt.default.vErrors,(0,me._)`[${r}]`),(0,me._)`${jt.default.vErrors}.push(${r})`),e.code((0,me._)`${jt.default.errors}++`)}function p0(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,me._)`new ${e.ValidationError}(${t})`):(r.assign((0,me._)`${n}.errors`,t),r.return(!1))}var qi={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function h0(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,me._)`{}`:r1(e,t,r)}function r1(e,t,r={}){let{gen:n,it:i}=e,o=[n1(i,r),i1(e,r)];return o1(e,t,o),n.object(...o)}function n1({errorPath:e},{instancePath:t}){let r=t?(0,me.str)`${e}${(0,Sl.getErrorPath)(t,Sl.Type.Str)}`:e;return[jt.default.instancePath,(0,me.strConcat)(jt.default.instancePath,r)]}function i1({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,me.str)`${t}/${e}`;return r&&(i=(0,me.str)`${i}${(0,Sl.getErrorPath)(r,Sl.Type.Str)}`),[qi.schemaPath,i]}function o1(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=e,{opts:u,propertyName:c,topSchemaRef:l,schemaPath:d}=a;n.push([qi.keyword,i],[qi.params,typeof t=="function"?t(e):t||(0,me._)`{}`]),u.messages&&n.push([qi.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([qi.schema,s],[qi.parentSchema,(0,me._)`${l}${d}`],[jt.default.data,o]),c&&n.push([qi.propertyName,c])}});var _0=E(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.boolOrEmptySchema=No.topBoolOrEmptySchema=void 0;var s1=sa(),a1=ne(),c1=gn(),l1={message:"boolean schema is false"};function u1(e){let{gen:t,schema:r,validateName:n}=e;r===!1?g0(e,!1):typeof r=="object"&&r.$async===!0?t.return(c1.default.data):(t.assign((0,a1._)`${n}.errors`,null),t.return(!0))}No.topBoolOrEmptySchema=u1;function d1(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),g0(e)):r.var(t,!0)}No.boolOrEmptySchema=d1;function g0(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,s1.reportError)(i,l1,void 0,t)}});var Ip=E(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.getRules=Mo.isJSONType=void 0;var f1=["string","number","integer","boolean","null","object","array"],m1=new Set(f1);function p1(e){return typeof e=="string"&&m1.has(e)}Mo.isJSONType=p1;function h1(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Mo.getRules=h1});var jp=E(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.shouldUseRule=Fn.shouldUseGroup=Fn.schemaHasRulesForType=void 0;function g1({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&y0(e,n)}Fn.schemaHasRulesForType=g1;function y0(e,t){return t.rules.some(r=>v0(e,r))}Fn.shouldUseGroup=y0;function v0(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Fn.shouldUseRule=v0});var aa=E(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.reportTypeError=zt.checkDataTypes=zt.checkDataType=zt.coerceAndCheckDataType=zt.getJSONTypes=zt.getSchemaTypes=zt.DataType=void 0;var _1=Ip(),y1=jp(),v1=sa(),te=ne(),b0=he(),Do;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Do||(zt.DataType=Do={}));function b1(e){let t=w0(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}zt.getSchemaTypes=b1;function w0(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(_1.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}zt.getJSONTypes=w0;function w1(e,t){let{gen:r,data:n,opts:i}=e,o=x1(t,i.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,y1.schemaHasRulesForType)(e,t[0]));if(s){let a=Mp(t,n,i.strictNumbers,Do.Wrong);r.if(a,()=>{o.length?k1(e,t,o):Dp(e)})}return s}zt.coerceAndCheckDataType=w1;var x0=new Set(["string","number","integer","boolean","null"]);function x1(e,t){return t?e.filter(r=>x0.has(r)||t==="array"&&r==="array"):[]}function k1(e,t,r){let{gen:n,data:i,opts:o}=e,s=n.let("dataType",(0,te._)`typeof ${i}`),a=n.let("coerced",(0,te._)`undefined`);o.coerceTypes==="array"&&n.if((0,te._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,te._)`${i}[0]`).assign(s,(0,te._)`typeof ${i}`).if(Mp(t,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,te._)`${a} !== undefined`);for(let c of r)(x0.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),Dp(e),n.endIf(),n.if((0,te._)`${a} !== undefined`,()=>{n.assign(i,a),S1(e,a)});function u(c){switch(c){case"string":n.elseIf((0,te._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,te._)`"" + ${i}`).elseIf((0,te._)`${i} === null`).assign(a,(0,te._)`""`);return;case"number":n.elseIf((0,te._)`${s} == "boolean" || ${i} === null
3
+ var lS=Object.create;var au=Object.defineProperty;var uS=Object.getOwnPropertyDescriptor;var dS=Object.getOwnPropertyNames;var fS=Object.getPrototypeOf,mS=Object.prototype.hasOwnProperty;var wn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),cu=(e,t)=>{for(var r in t)au(e,r,{get:t[r],enumerable:!0})},pS=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dS(t))!mS.call(e,i)&&i!==r&&au(e,i,{get:()=>t[i],enumerable:!(n=uS(t,i))||n.enumerable});return e};var lu=(e,t,r)=>(r=e!=null?lS(fS(e)):{},pS(t||!e||!e.__esModule?au(r,"default",{value:e,enumerable:!0}):r,e));var yy=z((QZ,_y)=>{var Rn=wn("constants"),IE=process.cwd,fc=null,jE=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return fc||(fc=IE.call(process)),fc};try{process.cwd()}catch{}typeof process.chdir=="function"&&(od=process.chdir,process.chdir=function(e){fc=null,od.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,od));var od;_y.exports=NE;function NE(e){Rn.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(l,d,h){h&&process.nextTick(h)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(l,d,h,m){m&&process.nextTick(m)},e.lchownSync=function(){}),jE==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(l){function d(h,m,p){var f=Date.now(),g=0;l(h,m,function y(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-f<6e4){setTimeout(function(){e.stat(m,function(b,w){b&&b.code==="ENOENT"?l(h,m,y):p(v)})},g),g<100&&(g+=10);return}p&&p(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(l){function d(h,m,p,f,g,y){var v;if(y&&typeof y=="function"){var b=0;v=function(w,S,q){if(w&&w.code==="EAGAIN"&&b<10)return b++,l.call(e,h,m,p,f,g,v);y.apply(this,arguments)}}return l.call(e,h,m,p,f,g,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(l){return function(d,h,m,p,f){for(var g=0;;)try{return l.call(e,d,h,m,p,f)}catch(y){if(y.code==="EAGAIN"&&g<10){g++;continue}throw y}}})(e.readSync);function t(l){l.lchmod=function(d,h,m){l.open(d,Rn.O_WRONLY|Rn.O_SYMLINK,h,function(p,f){if(p){m&&m(p);return}l.fchmod(f,h,function(g){l.close(f,function(y){m&&m(g||y)})})})},l.lchmodSync=function(d,h){var m=l.openSync(d,Rn.O_WRONLY|Rn.O_SYMLINK,h),p=!0,f;try{f=l.fchmodSync(m,h),p=!1}finally{if(p)try{l.closeSync(m)}catch{}else l.closeSync(m)}return f}}function r(l){Rn.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(d,h,m,p){l.open(d,Rn.O_SYMLINK,function(f,g){if(f){p&&p(f);return}l.futimes(g,h,m,function(y){l.close(g,function(v){p&&p(y||v)})})})},l.lutimesSync=function(d,h,m){var p=l.openSync(d,Rn.O_SYMLINK),f,g=!0;try{f=l.futimesSync(p,h,m),g=!1}finally{if(g)try{l.closeSync(p)}catch{}else l.closeSync(p)}return f}):l.futimes&&(l.lutimes=function(d,h,m,p){p&&process.nextTick(p)},l.lutimesSync=function(){})}function n(l){return l&&function(d,h,m){return l.call(e,d,h,function(p){c(p)&&(p=null),m&&m.apply(this,arguments)})}}function i(l){return l&&function(d,h){try{return l.call(e,d,h)}catch(m){if(!c(m))throw m}}}function o(l){return l&&function(d,h,m,p){return l.call(e,d,h,m,function(f){c(f)&&(f=null),p&&p.apply(this,arguments)})}}function s(l){return l&&function(d,h,m){try{return l.call(e,d,h,m)}catch(p){if(!c(p))throw p}}}function a(l){return l&&function(d,h,m){typeof h=="function"&&(m=h,h=null);function p(f,g){g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),m&&m.apply(this,arguments)}return h?l.call(e,d,h,p):l.call(e,d,p)}}function u(l){return l&&function(d,h){var m=h?l.call(e,d,h):l.call(e,d);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function c(l){if(!l||l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var wy=z((XZ,by)=>{var vy=wn("stream").Stream;by.exports=ME;function ME(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);vy.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),a=0,u=s.length;a<u;a++){var c=s[a];this[c]=i[c]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);vy.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,a=o.length;s<a;s++){var u=o[s];this[u]=i[u]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var ky=z((YZ,xy)=>{"use strict";xy.exports=ZE;var DE=Object.getPrototypeOf||function(e){return e.__proto__};function ZE(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:DE(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ld=z((eL,cd)=>{var Be=wn("fs"),LE=yy(),qE=wy(),FE=ky(),mc=wn("util"),mt,hc;typeof Symbol=="function"&&typeof Symbol.for=="function"?(mt=Symbol.for("graceful-fs.queue"),hc=Symbol.for("graceful-fs.previous")):(mt="___graceful-fs.queue",hc="___graceful-fs.previous");function UE(){}function $y(e,t){Object.defineProperty(e,mt,{get:function(){return t}})}var ki=UE;mc.debuglog?ki=mc.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ki=function(){var e=mc.format.apply(mc,arguments);e="GFS4: "+e.split(/\n/).join(`
4
+ GFS4: `),console.error(e)});Be[mt]||(Sy=global[mt]||[],$y(Be,Sy),Be.close=(function(e){function t(r,n){return e.call(Be,r,function(i){i||Ty(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,hc,{value:e}),t})(Be.close),Be.closeSync=(function(e){function t(r){e.apply(Be,arguments),Ty()}return Object.defineProperty(t,hc,{value:e}),t})(Be.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ki(Be[mt]),wn("assert").equal(Be[mt].length,0)}));var Sy;global[mt]||$y(global,Be[mt]);cd.exports=sd(FE(Be));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Be.__patched&&(cd.exports=sd(Be),Be.__patched=!0);function sd(e){LE(e),e.gracefulify=sd,e.createReadStream=S,e.createWriteStream=q;var t=e.readFile;e.readFile=r;function r(C,V,H){return typeof V=="function"&&(H=V,V=null),fe(C,V,H);function fe(ge,j,$,R){return t(ge,j,function(N){N&&(N.code==="EMFILE"||N.code==="ENFILE")?_o([fe,[ge,j,$],N,R||Date.now(),Date.now()]):typeof $=="function"&&$.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return n(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return o(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=u);function u(C,V,H,fe){return typeof H=="function"&&(fe=H,H=0),ge(C,V,H,fe);function ge(j,$,R,N,I){return a(j,$,R,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var c=e.readdir;e.readdir=d;var l=/^v[0-5]\./;function d(C,V,H){typeof V=="function"&&(H=V,V=null);var fe=l.test(process.version)?function($,R,N,I){return c($,ge($,R,N,I))}:function($,R,N,I){return c($,R,ge($,R,N,I))};return fe(C,V,H);function ge(j,$,R,N){return function(I,G){I&&(I.code==="EMFILE"||I.code==="ENFILE")?_o([fe,[j,$,R],I,N||Date.now(),Date.now()]):(G&&G.sort&&G.sort(),typeof R=="function"&&R.call(this,I,G))}}}if(process.version.substr(0,4)==="v0.8"){var h=qE(e);y=h.ReadStream,b=h.WriteStream}var m=e.ReadStream;m&&(y.prototype=Object.create(m.prototype),y.prototype.open=v);var p=e.WriteStream;p&&(b.prototype=Object.create(p.prototype),b.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(C){y=C},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return b},set:function(C){b=C},enumerable:!0,configurable:!0});var f=y;Object.defineProperty(e,"FileReadStream",{get:function(){return f},set:function(C){f=C},enumerable:!0,configurable:!0});var g=b;Object.defineProperty(e,"FileWriteStream",{get:function(){return g},set:function(C){g=C},enumerable:!0,configurable:!0});function y(C,V){return this instanceof y?(m.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function v(){var C=this;ce(C.path,C.flags,C.mode,function(V,H){V?(C.autoClose&&C.destroy(),C.emit("error",V)):(C.fd=H,C.emit("open",H),C.read())})}function b(C,V){return this instanceof b?(p.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function w(){var C=this;ce(C.path,C.flags,C.mode,function(V,H){V?(C.destroy(),C.emit("error",V)):(C.fd=H,C.emit("open",H))})}function S(C,V){return new e.ReadStream(C,V)}function q(C,V){return new e.WriteStream(C,V)}var K=e.open;e.open=ce;function ce(C,V,H,fe){return typeof H=="function"&&(fe=H,H=null),ge(C,V,H,fe);function ge(j,$,R,N,I){return K(j,$,R,function(G,ye){G&&(G.code==="EMFILE"||G.code==="ENFILE")?_o([ge,[j,$,R,N],G,I||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}return e}function _o(e){ki("ENQUEUE",e[0].name,e[1]),Be[mt].push(e),ad()}var pc;function Ty(){for(var e=Date.now(),t=0;t<Be[mt].length;++t)Be[mt][t].length>2&&(Be[mt][t][3]=e,Be[mt][t][4]=e);ad()}function ad(){if(clearTimeout(pc),pc=void 0,Be[mt].length!==0){var e=Be[mt].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ki("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ki("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,u=Math.max(o-i,1),c=Math.min(u*1.2,100);a>=c?(ki("RETRY",t.name,r),t.apply(null,r.concat([i]))):Be[mt].push(e)}pc===void 0&&(pc=setTimeout(ad,0))}}});var zy=z((tL,Ey)=>{function ar(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Ey.exports=ar;ar.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ar.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};ar.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};ar.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};ar.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ar.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ar.prototype.start=ar.prototype.try;ar.prototype.errors=function(){return this._errors};ar.prototype.attempts=function(){return this._attempts};ar.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=i,r=s)}return t}});var Oy=z(Si=>{var VE=zy();Si.operation=function(e){var t=Si.timeouts(e);return new VE(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Si.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(o,s){return o-s}),n};Si.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};Si.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],s=e[o];e[o]=function(u){var c=Si.operation(t),l=Array.prototype.slice.call(arguments,1),d=l.pop();l.push(function(h){c.retry(h)||(h&&(arguments[0]=c.mainError()),d.apply(this,arguments))}),c.attempt(function(){u.apply(e,l)})}.bind(e,s),e[o].options=t}}});var Py=z((nL,Ay)=>{Ay.exports=Oy()});var Cy=z((iL,gc)=>{gc.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&gc.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&gc.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var My=z((oL,bo)=>{var Ne=global.process,Ti=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};Ti(Ne)?(Ry=wn("assert"),yo=Cy(),Iy=/^win/i.test(Ne.platform),ks=wn("events"),typeof ks!="function"&&(ks=ks.EventEmitter),Ne.__signal_exit_emitter__?at=Ne.__signal_exit_emitter__:(at=Ne.__signal_exit_emitter__=new ks,at.count=0,at.emitted={}),at.infinite||(at.setMaxListeners(1/0),at.infinite=!0),bo.exports=function(e,t){if(!Ti(global.process))return function(){};Ry.equal(typeof e,"function","a callback must be provided for exit handler"),vo===!1&&ud();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){at.removeListener(r,e),at.listeners("exit").length===0&&at.listeners("afterexit").length===0&&_c()};return at.on(r,e),n},_c=function(){!vo||!Ti(global.process)||(vo=!1,yo.forEach(function(t){try{Ne.removeListener(t,yc[t])}catch{}}),Ne.emit=vc,Ne.reallyExit=dd,at.count-=1)},bo.exports.unload=_c,$i=function(t,r,n){at.emitted[t]||(at.emitted[t]=!0,at.emit(t,r,n))},yc={},yo.forEach(function(e){yc[e]=function(){if(Ti(global.process)){var r=Ne.listeners(e);r.length===at.count&&(_c(),$i("exit",null,e),$i("afterexit",null,e),Iy&&e==="SIGHUP"&&(e="SIGINT"),Ne.kill(Ne.pid,e))}}}),bo.exports.signals=function(){return yo},vo=!1,ud=function(){vo||!Ti(global.process)||(vo=!0,at.count+=1,yo=yo.filter(function(t){try{return Ne.on(t,yc[t]),!0}catch{return!1}}),Ne.emit=Ny,Ne.reallyExit=jy)},bo.exports.load=ud,dd=Ne.reallyExit,jy=function(t){Ti(global.process)&&(Ne.exitCode=t||0,$i("exit",Ne.exitCode,null),$i("afterexit",Ne.exitCode,null),dd.call(Ne,Ne.exitCode))},vc=Ne.emit,Ny=function(t,r){if(t==="exit"&&Ti(global.process)){r!==void 0&&(Ne.exitCode=r);var n=vc.apply(this,arguments);return $i("exit",Ne.exitCode,null),$i("afterexit",Ne.exitCode,null),n}else return vc.apply(this,arguments)}):bo.exports=function(){return function(){}};var Ry,yo,Iy,ks,at,_c,$i,yc,vo,ud,dd,jy,vc,Ny});var Fy=z((sL,Ss)=>{"use strict";var GE=wn("path"),pd=ld(),BE=Py(),JE=My(),un={};function wo(e,t){return t.lockfilePath||`${e}.lock`}function hd(e,t,r){if(!t.realpath)return r(null,GE.resolve(e));t.fs.realpath(e,r)}function fd(e,t,r){t.fs.mkdir(wo(e,t),n=>{if(!n)return r();if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(wo(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?fd(e,{...t,stale:0},r):r(i);if(!Zy(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Ly(e,t,s=>{if(s)return r(s);fd(e,{...t,stale:0},r)})})})}function Zy(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Ly(e,t,r){t.fs.rmdir(wo(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function md(e,t){let r=un[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(wo(e,t),n,n,i=>{if(!r.released){if(r.lastUpdate<=Date.now()-t.stale&&r.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(r.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return Dy(e,r,o)}if(i)return i.code==="ENOENT"?Dy(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,md(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,md(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Dy(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),un[e]===t&&delete un[e],t.options.onCompromised(r)}function WE(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:pd,onCompromised:n=>{throw n},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),hd(e,t,(n,i)=>{if(n)return r(n);let o=BE.operation(t.retries);o.attempt(()=>{fd(i,t,s=>{if(o.retry(s))return;if(s)return r(o.mainError());let a=un[i]={options:t,lastUpdate:Date.now()};md(i,t),r(null,u=>{if(a.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));qy(i,{...t,realpath:!1},u)})})})})}function qy(e,t,r){t={fs:pd,realpath:!0,...t},hd(e,t,(n,i)=>{if(n)return r(n);let o=un[i];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete un[i],Ly(i,t,r)})}function HE(e,t,r){t={stale:1e4,realpath:!0,fs:pd,...t},t.stale=Math.max(t.stale||0,2e3),hd(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(wo(i,t),(o,s)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Zy(s,t)))})}function KE(){return un}JE(()=>{for(let e in un){let t=un[e].options;try{t.fs.rmdirSync(wo(e,t))}catch{}}});Ss.exports.lock=WE;Ss.exports.unlock=qy;Ss.exports.check=HE;Ss.exports.getLocks=KE});var Vy=z((aL,Uy)=>{"use strict";var QE=ld();function XE(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),s;try{s=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,s)}}),r}function YE(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function ez(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function tz(e){if(e={...e},e.fs=XE(e.fs||QE),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Uy.exports={toPromise:YE,toSync:ez,toSyncOptions:tz}});var By=z((cL,In)=>{"use strict";var xo=Fy(),{toPromise:bc,toSync:wc,toSyncOptions:gd}=Vy();async function Gy(e,t){let r=await bc(xo.lock)(e,t);return bc(r)}function rz(e,t){let r=wc(xo.lock)(e,gd(t));return wc(r)}function nz(e,t){return bc(xo.unlock)(e,t)}function iz(e,t){return wc(xo.unlock)(e,gd(t))}function oz(e,t){return bc(xo.check)(e,t)}function sz(e,t){return wc(xo.check)(e,gd(t))}In.exports=Gy;In.exports.lock=Gy;In.exports.unlock=nz;In.exports.lockSync=rz;In.exports.unlockSync=iz;In.exports.check=oz;In.exports.checkSync=sz});var ea=z(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.regexpCode=pe.getEsmExportName=pe.getProperty=pe.safeStringify=pe.stringify=pe.strConcat=pe.addCodeArg=pe.str=pe._=pe.nil=pe._Code=pe.Name=pe.IDENTIFIER=pe._CodeOrName=void 0;var Xs=class{};pe._CodeOrName=Xs;pe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Mi=class extends Xs{constructor(t){if(super(),!pe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};pe.Name=Mi;var dr=class extends Xs{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Mi&&(r[n.str]=(r[n.str]||0)+1),r),{})}};pe._Code=dr;pe.nil=new dr("");function o0(e,...t){let r=[e[0]],n=0;for(;n<t.length;)pp(r,t[n]),r.push(e[++n]);return new dr(r)}pe._=o0;var mp=new dr("+");function s0(e,...t){let r=[Ys(e[0])],n=0;for(;n<t.length;)r.push(mp),pp(r,t[n]),r.push(mp,Ys(e[++n]));return CC(r),new dr(r)}pe.str=s0;function pp(e,t){t instanceof dr?e.push(...t._items):t instanceof Mi?e.push(t):e.push(jC(t))}pe.addCodeArg=pp;function CC(e){let t=1;for(;t<e.length-1;){if(e[t]===mp){let r=RC(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function RC(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Mi||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Mi))return`"${e}${t.slice(1)}`}function IC(e,t){return t.emptyStr()?e:e.emptyStr()?t:s0`${e}${t}`}pe.strConcat=IC;function jC(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Ys(Array.isArray(e)?e.join(","):e)}function NC(e){return new dr(Ys(e))}pe.stringify=NC;function Ys(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}pe.safeStringify=Ys;function MC(e){return typeof e=="string"&&pe.IDENTIFIER.test(e)?new dr(`.${e}`):o0`[${e}]`}pe.getProperty=MC;function DC(e){if(typeof e=="string"&&pe.IDENTIFIER.test(e))return new dr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}pe.getEsmExportName=DC;function ZC(e){return new dr(e.toString())}pe.regexpCode=ZC});var _p=z(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.ValueScope=Vt.ValueScopeName=Vt.Scope=Vt.varKinds=Vt.UsedValueState=void 0;var Ut=ea(),hp=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},_l;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(_l||(Vt.UsedValueState=_l={}));Vt.varKinds={const:new Ut.Name("const"),let:new Ut.Name("let"),var:new Ut.Name("var")};var yl=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ut.Name?t:this.name(t)}name(t){return new Ut.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Vt.Scope=yl;var vl=class extends Ut.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ut._)`.${new Ut.Name(r)}[${n}]`}};Vt.ValueScopeName=vl;var LC=(0,Ut._)`\n`,gp=class extends yl{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?LC:Ut.nil}}get(){return this._scope}name(t){return new vl(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(s);if(l)return l}else a=this._values[o]=new Map;a.set(s,i);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,i.setValue(r,{property:o,itemIndex:c}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ut._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=Ut.nil;for(let s in t){let a=t[s];if(!a)continue;let u=n[s]=n[s]||new Map;a.forEach(c=>{if(u.has(c))return;u.set(c,_l.Started);let l=r(c);if(l){let d=this.opts.es5?Vt.varKinds.var:Vt.varKinds.const;o=(0,Ut._)`${o}${d} ${c} = ${l};${this.opts._n}`}else if(l=i?.(c))o=(0,Ut._)`${o}${l}${this.opts._n}`;else throw new hp(c);u.set(c,_l.Completed)})}return o}};Vt.ValueScope=gp});var ne=z(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.or=ie.and=ie.not=ie.CodeGen=ie.operators=ie.varKinds=ie.ValueScopeName=ie.ValueScope=ie.Scope=ie.Name=ie.regexpCode=ie.stringify=ie.getProperty=ie.nil=ie.strConcat=ie.str=ie._=void 0;var de=ea(),Tr=_p(),qn=ea();Object.defineProperty(ie,"_",{enumerable:!0,get:function(){return qn._}});Object.defineProperty(ie,"str",{enumerable:!0,get:function(){return qn.str}});Object.defineProperty(ie,"strConcat",{enumerable:!0,get:function(){return qn.strConcat}});Object.defineProperty(ie,"nil",{enumerable:!0,get:function(){return qn.nil}});Object.defineProperty(ie,"getProperty",{enumerable:!0,get:function(){return qn.getProperty}});Object.defineProperty(ie,"stringify",{enumerable:!0,get:function(){return qn.stringify}});Object.defineProperty(ie,"regexpCode",{enumerable:!0,get:function(){return qn.regexpCode}});Object.defineProperty(ie,"Name",{enumerable:!0,get:function(){return qn.Name}});var kl=_p();Object.defineProperty(ie,"Scope",{enumerable:!0,get:function(){return kl.Scope}});Object.defineProperty(ie,"ValueScope",{enumerable:!0,get:function(){return kl.ValueScope}});Object.defineProperty(ie,"ValueScopeName",{enumerable:!0,get:function(){return kl.ValueScopeName}});Object.defineProperty(ie,"varKinds",{enumerable:!0,get:function(){return kl.varKinds}});ie.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var pn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},yp=class extends pn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Tr.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=jo(this.rhs,t,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}},bl=class extends pn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof de.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=jo(this.rhs,t,r),this}get names(){let t=this.lhs instanceof de.Name?{}:{...this.lhs.names};return xl(t,this.rhs)}},vp=class extends bl{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},bp=class extends pn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},wp=class extends pn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},xp=class extends pn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},kp=class extends pn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=jo(this.code,t,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}},ta=class extends pn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(qC(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Li(t,r.names),{})}},hn=class extends ta{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Sp=class extends ta{},Io=class extends hn{};Io.kind="else";var Di=class e extends hn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Io(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(a0(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=jo(this.condition,t,r),this}get names(){let t=super.names;return xl(t,this.condition),this.else&&Li(t,this.else.names),t}};Di.kind="if";var Zi=class extends hn{};Zi.kind="for";var Tp=class extends Zi{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=jo(this.iteration,t,r),this}get names(){return Li(super.names,this.iteration.names)}},$p=class extends Zi{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?Tr.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=xl(super.names,this.from);return xl(t,this.to)}},wl=class extends Zi{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=jo(this.iterable,t,r),this}get names(){return Li(super.names,this.iterable.names)}},ra=class extends hn{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};ra.kind="func";var na=class extends ta{render(t){return"return "+super.render(t)}};na.kind="return";var Ep=class extends hn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Li(t,this.catch.names),this.finally&&Li(t,this.finally.names),t}},ia=class extends hn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};ia.kind="catch";var oa=class extends hn{render(t){return"finally"+super.render(t)}};oa.kind="finally";var zp=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
+ `:""},this._extScope=t,this._scope=new Tr.Scope({parent:t}),this._nodes=[new Sp]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new yp(t,o,n)),o}const(t,r,n){return this._def(Tr.varKinds.const,t,r,n)}let(t,r,n){return this._def(Tr.varKinds.let,t,r,n)}var(t,r,n){return this._def(Tr.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new bl(t,r,n))}add(t,r){return this._leafNode(new vp(t,ie.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==de.nil&&this._leafNode(new kp(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,i));return r.push("}"),new de._Code(r)}if(t,r,n){if(this._blockNode(new Di(t)),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(t){return this._elseNode(new Di(t))}else(){return this._elseNode(new Io)}endIf(){return this._endBlockNode(Di,Io)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Tp(t),r)}forRange(t,r,n,i,o=this.opts.es5?Tr.varKinds.var:Tr.varKinds.let){let s=this._scope.toName(t);return this._for(new $p(o,s,r,n),()=>i(s))}forOf(t,r,n,i=Tr.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${s}.length`,a=>{this.var(o,(0,de._)`${s}[${a}]`),n(o)})}return this._for(new wl("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?Tr.varKinds.var:Tr.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,de._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new wl("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Zi)}label(t){return this._leafNode(new bp(t))}break(t){return this._leafNode(new wp(t))}return(t){let r=new na;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(na)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Ep;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new ia(o),r(o)}return n&&(this._currNode=i.finally=new oa,this.code(n)),this._endBlockNode(ia,oa)}throw(t){return this._leafNode(new xp(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){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||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=de.nil,n,i){return this._blockNode(new ra(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(ra)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Di))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};ie.CodeGen=zp;function Li(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function xl(e,t){return t instanceof de._CodeOrName?Li(e,t.names):e}function jo(e,t,r){if(e instanceof de.Name)return n(e);if(!i(e))return e;return new de._Code(e._items.reduce((o,s)=>(s instanceof de.Name&&(s=n(s)),s instanceof de._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function i(o){return o instanceof de._Code&&o._items.some(s=>s instanceof de.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function qC(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function a0(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,de._)`!${Op(e)}`}ie.not=a0;var FC=c0(ie.operators.AND);function UC(...e){return e.reduce(FC)}ie.and=UC;var VC=c0(ie.operators.OR);function GC(...e){return e.reduce(VC)}ie.or=GC;function c0(e){return(t,r)=>t===de.nil?r:r===de.nil?t:(0,de._)`${Op(t)} ${e} ${Op(r)}`}function Op(e){return e instanceof de.Name?e:(0,de._)`(${e})`}});var he=z(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;var $e=ne(),BC=ea();function JC(e){let t={};for(let r of e)t[r]=!0;return t}oe.toHash=JC;function WC(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(d0(e,t),!f0(t,e.self.RULES.all))}oe.alwaysValidSchema=WC;function d0(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||h0(e,`unknown keyword: "${o}"`)}oe.checkUnknownRules=d0;function f0(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}oe.schemaHasRules=f0;function HC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}oe.schemaHasRulesButRef=HC;function KC({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}oe.schemaRefOrVal=KC;function QC(e){return m0(decodeURIComponent(e))}oe.unescapeFragment=QC;function XC(e){return encodeURIComponent(Pp(e))}oe.escapeFragment=XC;function Pp(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=Pp;function m0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=m0;function YC(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}oe.eachItem=YC;function l0({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let u=s===void 0?o:s instanceof $e.Name?(o instanceof $e.Name?e(i,o,s):t(i,o,s),s):o instanceof $e.Name?(t(i,s,o),o):r(o,s);return a===$e.Name&&!(u instanceof $e.Name)?n(i,u):u}}oe.mergeEvaluated={props:l0({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),Cp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:p0}),items:l0({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function p0(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,$e._)`{}`);return t!==void 0&&Cp(e,r,t),r}oe.evaluatedPropsToName=p0;function Cp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}oe.setEvaluated=Cp;var u0={};function e1(e,t){return e.scopeValue("func",{ref:t,code:u0[t.code]||(u0[t.code]=new BC._Code(t.code))})}oe.useFunc=e1;var Ap;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ap||(oe.Type=Ap={}));function t1(e,t,r){if(e instanceof $e.Name){let n=t===Ap.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+Pp(e)}oe.getErrorPath=t1;function h0(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}oe.checkStrictMode=h0});var gn=z(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var Tt=ne(),r1={data:new Tt.Name("data"),valCxt:new Tt.Name("valCxt"),instancePath:new Tt.Name("instancePath"),parentData:new Tt.Name("parentData"),parentDataProperty:new Tt.Name("parentDataProperty"),rootData:new Tt.Name("rootData"),dynamicAnchors:new Tt.Name("dynamicAnchors"),vErrors:new Tt.Name("vErrors"),errors:new Tt.Name("errors"),this:new Tt.Name("this"),self:new Tt.Name("self"),scope:new Tt.Name("scope"),json:new Tt.Name("json"),jsonPos:new Tt.Name("jsonPos"),jsonLen:new Tt.Name("jsonLen"),jsonPart:new Tt.Name("jsonPart")};Rp.default=r1});var sa=z($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.extendErrors=$t.resetErrorsCount=$t.reportExtraError=$t.reportError=$t.keyword$DataError=$t.keywordError=void 0;var me=ne(),Sl=he(),jt=gn();$t.keywordError={message:({keyword:e})=>(0,me.str)`must pass "${e}" keyword validation`};$t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,me.str)`"${e}" keyword must be ${t} ($data)`:(0,me.str)`"${e}" keyword is invalid ($data)`};function n1(e,t=$t.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:s,allErrors:a}=i,u=y0(e,t,r);n??(s||a)?g0(o,u):_0(i,(0,me._)`[${u}]`)}$t.reportError=n1;function i1(e,t=$t.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,a=y0(e,t,r);g0(i,a),o||s||_0(n,jt.default.vErrors)}$t.reportExtraError=i1;function o1(e,t){e.assign(jt.default.errors,t),e.if((0,me._)`${jt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,me._)`${jt.default.vErrors}.length`,t),()=>e.assign(jt.default.vErrors,null)))}$t.resetErrorsCount=o1;function s1({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",i,jt.default.errors,a=>{e.const(s,(0,me._)`${jt.default.vErrors}[${a}]`),e.if((0,me._)`${s}.instancePath === undefined`,()=>e.assign((0,me._)`${s}.instancePath`,(0,me.strConcat)(jt.default.instancePath,o.errorPath))),e.assign((0,me._)`${s}.schemaPath`,(0,me.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,me._)`${s}.schema`,r),e.assign((0,me._)`${s}.data`,n))})}$t.extendErrors=s1;function g0(e,t){let r=e.const("err",t);e.if((0,me._)`${jt.default.vErrors} === null`,()=>e.assign(jt.default.vErrors,(0,me._)`[${r}]`),(0,me._)`${jt.default.vErrors}.push(${r})`),e.code((0,me._)`${jt.default.errors}++`)}function _0(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,me._)`new ${e.ValidationError}(${t})`):(r.assign((0,me._)`${n}.errors`,t),r.return(!1))}var qi={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function y0(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,me._)`{}`:a1(e,t,r)}function a1(e,t,r={}){let{gen:n,it:i}=e,o=[c1(i,r),l1(e,r)];return u1(e,t,o),n.object(...o)}function c1({errorPath:e},{instancePath:t}){let r=t?(0,me.str)`${e}${(0,Sl.getErrorPath)(t,Sl.Type.Str)}`:e;return[jt.default.instancePath,(0,me.strConcat)(jt.default.instancePath,r)]}function l1({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,me.str)`${t}/${e}`;return r&&(i=(0,me.str)`${i}${(0,Sl.getErrorPath)(r,Sl.Type.Str)}`),[qi.schemaPath,i]}function u1(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=e,{opts:u,propertyName:c,topSchemaRef:l,schemaPath:d}=a;n.push([qi.keyword,i],[qi.params,typeof t=="function"?t(e):t||(0,me._)`{}`]),u.messages&&n.push([qi.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([qi.schema,s],[qi.parentSchema,(0,me._)`${l}${d}`],[jt.default.data,o]),c&&n.push([qi.propertyName,c])}});var b0=z(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.boolOrEmptySchema=No.topBoolOrEmptySchema=void 0;var d1=sa(),f1=ne(),m1=gn(),p1={message:"boolean schema is false"};function h1(e){let{gen:t,schema:r,validateName:n}=e;r===!1?v0(e,!1):typeof r=="object"&&r.$async===!0?t.return(m1.default.data):(t.assign((0,f1._)`${n}.errors`,null),t.return(!0))}No.topBoolOrEmptySchema=h1;function g1(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),v0(e)):r.var(t,!0)}No.boolOrEmptySchema=g1;function v0(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,d1.reportError)(i,p1,void 0,t)}});var Ip=z(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.getRules=Mo.isJSONType=void 0;var _1=["string","number","integer","boolean","null","object","array"],y1=new Set(_1);function v1(e){return typeof e=="string"&&y1.has(e)}Mo.isJSONType=v1;function b1(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Mo.getRules=b1});var jp=z(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.shouldUseRule=Fn.shouldUseGroup=Fn.schemaHasRulesForType=void 0;function w1({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&w0(e,n)}Fn.schemaHasRulesForType=w1;function w0(e,t){return t.rules.some(r=>x0(e,r))}Fn.shouldUseGroup=w0;function x0(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Fn.shouldUseRule=x0});var aa=z(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.reportTypeError=Et.checkDataTypes=Et.checkDataType=Et.coerceAndCheckDataType=Et.getJSONTypes=Et.getSchemaTypes=Et.DataType=void 0;var x1=Ip(),k1=jp(),S1=sa(),te=ne(),k0=he(),Do;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Do||(Et.DataType=Do={}));function T1(e){let t=S0(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Et.getSchemaTypes=T1;function S0(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(x1.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Et.getJSONTypes=S0;function $1(e,t){let{gen:r,data:n,opts:i}=e,o=E1(t,i.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,k1.schemaHasRulesForType)(e,t[0]));if(s){let a=Mp(t,n,i.strictNumbers,Do.Wrong);r.if(a,()=>{o.length?z1(e,t,o):Dp(e)})}return s}Et.coerceAndCheckDataType=$1;var T0=new Set(["string","number","integer","boolean","null"]);function E1(e,t){return t?e.filter(r=>T0.has(r)||t==="array"&&r==="array"):[]}function z1(e,t,r){let{gen:n,data:i,opts:o}=e,s=n.let("dataType",(0,te._)`typeof ${i}`),a=n.let("coerced",(0,te._)`undefined`);o.coerceTypes==="array"&&n.if((0,te._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,te._)`${i}[0]`).assign(s,(0,te._)`typeof ${i}`).if(Mp(t,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,te._)`${a} !== undefined`);for(let c of r)(T0.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),Dp(e),n.endIf(),n.if((0,te._)`${a} !== undefined`,()=>{n.assign(i,a),O1(e,a)});function u(c){switch(c){case"string":n.elseIf((0,te._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,te._)`"" + ${i}`).elseIf((0,te._)`${i} === null`).assign(a,(0,te._)`""`);return;case"number":n.elseIf((0,te._)`${s} == "boolean" || ${i} === null
6
6
  || (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,te._)`+${i}`);return;case"integer":n.elseIf((0,te._)`${s} === "boolean" || ${i} === null
7
7
  || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,te._)`+${i}`);return;case"boolean":n.elseIf((0,te._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,te._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,te._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,te._)`${s} === "string" || ${s} === "number"
8
- || ${s} === "boolean" || ${i} === null`).assign(a,(0,te._)`[${i}]`)}}}function S1({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,n))}function Np(e,t,r,n=Do.Correct){let i=n===Do.Correct?te.operators.EQ:te.operators.NEQ,o;switch(e){case"null":return(0,te._)`${t} ${i} null`;case"array":o=(0,te._)`Array.isArray(${t})`;break;case"object":o=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,te._)`typeof ${t} ${i} ${e}`}return n===Do.Correct?o:(0,te.not)(o);function s(a=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,a,r?(0,te._)`isFinite(${t})`:te.nil)}}zt.checkDataType=Np;function Mp(e,t,r,n){if(e.length===1)return Np(e[0],t,r,n);let i,o=(0,b0.toHash)(e);if(o.array&&o.object){let s=(0,te._)`typeof ${t} != "object"`;i=o.null?s:(0,te._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else i=te.nil;o.number&&delete o.integer;for(let s in o)i=(0,te.and)(i,Np(s,t,r,n));return i}zt.checkDataTypes=Mp;var T1={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Dp(e){let t=$1(e);(0,v1.reportError)(t,T1)}zt.reportTypeError=Dp;function $1(e){let{gen:t,data:r,schema:n}=e,i=(0,b0.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:e}}});var S0=E(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.assignDefaults=void 0;var Zo=ne(),z1=he();function E1(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let i in r)k0(e,i,r[i].default);else t==="array"&&Array.isArray(n)&&n.forEach((i,o)=>k0(e,o,i.default))}Tl.assignDefaults=E1;function k0(e,t,r){let{gen:n,compositeRule:i,data:o,opts:s}=e;if(r===void 0)return;let a=(0,Zo._)`${o}${(0,Zo.getProperty)(t)}`;if(i){(0,z1.checkStrictMode)(e,`default is ignored for: ${a}`);return}let u=(0,Zo._)`${a} === undefined`;s.useDefaults==="empty"&&(u=(0,Zo._)`${u} || ${a} === null || ${a} === ""`),n.if(u,(0,Zo._)`${a} = ${(0,Zo.stringify)(r)}`)}});var fr=E(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var Re=ne(),Zp=he(),Un=gn(),O1=he();function A1(e,t){let{gen:r,data:n,it:i}=e;r.if(qp(r,n,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}Te.checkReportMissingProp=A1;function P1({gen:e,data:t,it:{opts:r}},n,i){return(0,Re.or)(...n.map(o=>(0,Re.and)(qp(e,t,o,r.ownProperties),(0,Re._)`${i} = ${o}`)))}Te.checkMissingProp=P1;function C1(e,t){e.setParams({missingProperty:t},!0),e.error()}Te.reportMissingProp=C1;function T0(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=T0;function Lp(e,t,r){return(0,Re._)`${T0(e)}.call(${t}, ${r})`}Te.isOwnProperty=Lp;function R1(e,t,r,n){let i=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${i} && ${Lp(e,t,r)}`:i}Te.propertyInData=R1;function qp(e,t,r,n){let i=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(i,(0,Re.not)(Lp(e,t,r))):i}Te.noPropertyInData=qp;function $0(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Te.allSchemaProperties=$0;function I1(e,t){return $0(t).filter(r=>!(0,Zp.alwaysValidSchema)(e,t[r]))}Te.schemaProperties=I1;function j1({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,u,c){let l=c?(0,Re._)`${e}, ${t}, ${n}${i}`:t,d=[[Un.default.instancePath,(0,Re.strConcat)(Un.default.instancePath,o)],[Un.default.parentData,s.parentData],[Un.default.parentDataProperty,s.parentDataProperty],[Un.default.rootData,Un.default.rootData]];s.opts.dynamicRef&&d.push([Un.default.dynamicAnchors,Un.default.dynamicAnchors]);let h=(0,Re._)`${l}, ${r.object(...d)}`;return u!==Re.nil?(0,Re._)`${a}.call(${u}, ${h})`:(0,Re._)`${a}(${h})`}Te.callValidateCode=j1;var N1=(0,Re._)`new RegExp`;function M1({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:i}=t.code,o=i(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Re._)`${i.code==="new RegExp"?N1:(0,O1.useFunc)(e,i)}(${r}, ${n})`})}Te.usePattern=M1;function D1(e){let{gen:t,data:r,keyword:n,it:i}=e,o=t.name("valid");if(i.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let u=t.const("len",(0,Re._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Zp.Type.Num},o),t.if((0,Re.not)(o),a)})}}Te.validateArray=D1;function Z1(e){let{gen:t,schema:r,keyword:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0,Zp.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Re._)`${s} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,Re.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}Te.validateUnion=Z1});var O0=E(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateKeywordUsage=Gr.validSchemaType=Gr.funcKeywordCode=Gr.macroKeywordCode=void 0;var Nt=ne(),Fi=gn(),L1=fr(),q1=sa();function F1(e,t){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=e,a=t.macro.call(s.self,i,o,s),u=E0(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=r.name("valid");e.subschema({schema:a,schemaPath:Nt.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Gr.macroKeywordCode=F1;function U1(e,t){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:u}=e;G1(u,t);let c=!a&&t.compile?t.compile.call(u.self,o,s,u):t.validate,l=E0(n,i,c),d=n.let("valid");e.block$data(d,h),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function h(){if(t.errors===!1)f(),t.modifying&&z0(e),g(()=>e.error());else{let y=t.async?m():p();t.modifying&&z0(e),g(()=>V1(e,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>f((0,Nt._)`await `),v=>n.assign(d,!1).if((0,Nt._)`${v} instanceof ${u.ValidationError}`,()=>n.assign(y,(0,Nt._)`${v}.errors`),()=>n.throw(v))),y}function p(){let y=(0,Nt._)`${l}.errors`;return n.assign(y,null),f(Nt.nil),y}function f(y=t.async?(0,Nt._)`await `:Nt.nil){let v=u.opts.passContext?Fi.default.this:Fi.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Nt._)`${y}${(0,L1.callValidateCode)(e,l,v,b)}`,t.modifying)}function g(y){var v;n.if((0,Nt.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}Gr.funcKeywordCode=U1;function z0(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Nt._)`${n.parentData}[${n.parentDataProperty}]`))}function V1(e,t){let{gen:r}=e;r.if((0,Nt._)`Array.isArray(${t})`,()=>{r.assign(Fi.default.vErrors,(0,Nt._)`${Fi.default.vErrors} === null ? ${t} : ${Fi.default.vErrors}.concat(${t})`).assign(Fi.default.errors,(0,Nt._)`${Fi.default.vErrors}.length`),(0,q1.extendErrors)(e)},()=>e.error())}function G1({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function E0(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Nt.stringify)(r)})}function B1(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Gr.validSchemaType=B1;function J1({schema:e,opts:t,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}Gr.validateKeywordUsage=J1});var P0=E(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.extendSubschemaMode=Vn.extendSubschemaData=Vn.getSubschema=void 0;var Br=ne(),A0=he();function W1(e,{keyword:t,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Br._)`${e.schemaPath}${(0,Br.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Br._)`${e.schemaPath}${(0,Br.getProperty)(t)}${(0,Br.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,A0.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Vn.getSubschema=W1;function H1(e,t,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:c,dataPathArr:l,opts:d}=t,h=a.let("data",(0,Br._)`${t.data}${(0,Br.getProperty)(r)}`,!0);u(h),e.errorPath=(0,Br.str)`${c}${(0,A0.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Br._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(i!==void 0){let c=i instanceof Br.Name?i:a.let("data",i,!0);u(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Vn.extendSubschemaData=H1;function K1(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(e.compositeRule=n),i!==void 0&&(e.createErrors=i),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Vn.extendSubschemaMode=K1});var Fp=E((K2,C0)=>{"use strict";C0.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r}});var I0=E((Q2,R0)=>{"use strict";var Gn=R0.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};$l(t,n,i,e,"",e)};Gn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Gn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Gn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Gn.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 $l(e,t,r,n,i,o,s,a,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,i,o,s,a,u,c);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Gn.arrayKeywords)for(var h=0;h<d.length;h++)$l(e,t,r,d[h],i+"/"+l+"/"+h,o,i,l,n,h)}else if(l in Gn.propsKeywords){if(d&&typeof d=="object")for(var m in d)$l(e,t,r,d[m],i+"/"+l+"/"+Q1(m),o,i,l,n,m)}else(l in Gn.keywords||e.allKeys&&!(l in Gn.skipKeywords))&&$l(e,t,r,d,i+"/"+l,o,i,l,n)}r(n,i,o,s,a,u,c)}}function Q1(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ca=E(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getSchemaRefs=Gt.resolveUrl=Gt.normalizeId=Gt._getFullPath=Gt.getFullPath=Gt.inlineRef=void 0;var X1=he(),Y1=Fp(),eR=I0(),tR=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function rR(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Up(e):t?j0(e)<=t:!1}Gt.inlineRef=rR;var nR=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Up(e){for(let t in e){if(nR.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Up)||typeof r=="object"&&Up(r))return!0}return!1}function j0(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!tR.has(r)&&(typeof e[r]=="object"&&(0,X1.eachItem)(e[r],n=>t+=j0(n)),t===1/0))return 1/0}return t}function N0(e,t="",r){r!==!1&&(t=Lo(t));let n=e.parse(t);return M0(e,n)}Gt.getFullPath=N0;function M0(e,t){return e.serialize(t).split("#")[0]+"#"}Gt._getFullPath=M0;var iR=/#\/?$/;function Lo(e){return e?e.replace(iR,""):""}Gt.normalizeId=Lo;function oR(e,t,r){return r=Lo(r),e.resolve(t,r)}Gt.resolveUrl=oR;var sR=/^[a-z_][-a-z0-9._]*$/i;function aR(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Lo(e[r]||t),o={"":i},s=N0(n,i,!1),a={},u=new Set;return eR(e,{allKeys:!0},(d,h,m,p)=>{if(p===void 0)return;let f=s+h,g=o[p];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[h]=g;function y(b){let w=this.opts.uriResolver.resolve;if(b=Lo(g?w(g,b):b),u.has(b))throw l(b);u.add(b);let S=this.refs[b];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,b):b!==Lo(f)&&(b[0]==="#"?(c(d,a[b],b),a[b]=d):this.refs[b]=f),b}function v(b){if(typeof b=="string"){if(!sR.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function c(d,h,m){if(h!==void 0&&!Y1(d,h))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Gt.getSchemaRefs=aR});var da=E(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.getData=Bn.KeywordCxt=Bn.validateFunctionCode=void 0;var F0=_0(),D0=aa(),Gp=jp(),zl=aa(),cR=S0(),ua=O0(),Vp=P0(),L=ne(),Q=gn(),lR=ca(),_n=he(),la=sa();function uR(e){if(G0(e)&&(B0(e),V0(e))){mR(e);return}U0(e,()=>(0,F0.topBoolOrEmptySchema)(e))}Bn.validateFunctionCode=uR;function U0({gen:e,validateName:t,schema:r,schemaEnv:n,opts:i},o){i.code.es5?e.func(t,(0,L._)`${Q.default.data}, ${Q.default.valCxt}`,n.$async,()=>{e.code((0,L._)`"use strict"; ${Z0(r,i)}`),fR(e,i),e.code(o)}):e.func(t,(0,L._)`${Q.default.data}, ${dR(i)}`,n.$async,()=>e.code(Z0(r,i)).code(o))}function dR(e){return(0,L._)`{${Q.default.instancePath}="", ${Q.default.parentData}, ${Q.default.parentDataProperty}, ${Q.default.rootData}=${Q.default.data}${e.dynamicRef?(0,L._)`, ${Q.default.dynamicAnchors}={}`:L.nil}}={}`}function fR(e,t){e.if(Q.default.valCxt,()=>{e.var(Q.default.instancePath,(0,L._)`${Q.default.valCxt}.${Q.default.instancePath}`),e.var(Q.default.parentData,(0,L._)`${Q.default.valCxt}.${Q.default.parentData}`),e.var(Q.default.parentDataProperty,(0,L._)`${Q.default.valCxt}.${Q.default.parentDataProperty}`),e.var(Q.default.rootData,(0,L._)`${Q.default.valCxt}.${Q.default.rootData}`),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`${Q.default.valCxt}.${Q.default.dynamicAnchors}`)},()=>{e.var(Q.default.instancePath,(0,L._)`""`),e.var(Q.default.parentData,(0,L._)`undefined`),e.var(Q.default.parentDataProperty,(0,L._)`undefined`),e.var(Q.default.rootData,Q.default.data),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`{}`)})}function mR(e){let{schema:t,opts:r,gen:n}=e;U0(e,()=>{r.$comment&&t.$comment&&W0(e),yR(e),n.let(Q.default.vErrors,null),n.let(Q.default.errors,0),r.unevaluated&&pR(e),J0(e),wR(e)})}function pR(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,L._)`${r}.evaluated`),t.if((0,L._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,L._)`${e.evaluated}.props`,(0,L._)`undefined`)),t.if((0,L._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,L._)`${e.evaluated}.items`,(0,L._)`undefined`))}function Z0(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,L._)`/*# sourceURL=${r} */`:L.nil}function hR(e,t){if(G0(e)&&(B0(e),V0(e))){gR(e,t);return}(0,F0.boolOrEmptySchema)(e,t)}function V0({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function G0(e){return typeof e.schema!="boolean"}function gR(e,t){let{schema:r,gen:n,opts:i}=e;i.$comment&&r.$comment&&W0(e),vR(e),bR(e);let o=n.const("_errs",Q.default.errors);J0(e,o),n.var(t,(0,L._)`${o} === ${Q.default.errors}`)}function B0(e){(0,_n.checkUnknownRules)(e),_R(e)}function J0(e,t){if(e.opts.jtd)return L0(e,[],!1,t);let r=(0,D0.getSchemaTypes)(e.schema),n=(0,D0.coerceAndCheckDataType)(e,r);L0(e,r,!n,t)}function _R(e){let{schema:t,errSchemaPath:r,opts:n,self:i}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,_n.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function yR(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,_n.checkStrictMode)(e,"default is ignored in the schema root")}function vR(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,lR.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function bR(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function W0({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)e.code((0,L._)`${Q.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,L.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,L._)`${Q.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function wR(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=e;r.$async?t.if((0,L._)`${Q.default.errors} === 0`,()=>t.return(Q.default.data),()=>t.throw((0,L._)`new ${i}(${Q.default.vErrors})`)):(t.assign((0,L._)`${n}.errors`,Q.default.vErrors),o.unevaluated&&xR(e),t.return((0,L._)`${Q.default.errors} === 0`))}function xR({gen:e,evaluated:t,props:r,items:n}){r instanceof L.Name&&e.assign((0,L._)`${t}.props`,r),n instanceof L.Name&&e.assign((0,L._)`${t}.items`,n)}function L0(e,t,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0,_n.schemaHasRulesButRef)(o,l))){i.block(()=>K0(e,"$ref",l.all.$ref.definition));return}u.jtd||kR(e,t),i.block(()=>{for(let h of l.rules)d(h);d(l.post)});function d(h){(0,Gp.shouldUseGroup)(o,h)&&(h.type?(i.if((0,zl.checkDataType)(h.type,s,u.strictNumbers)),q0(e,h),t.length===1&&t[0]===h.type&&r&&(i.else(),(0,zl.reportTypeError)(e)),i.endIf()):q0(e,h),a||i.if((0,L._)`${Q.default.errors} === ${n||0}`))}}function q0(e,t){let{gen:r,schema:n,opts:{useDefaults:i}}=e;i&&(0,cR.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0,Gp.shouldUseRule)(n,o)&&K0(e,o.keyword,o.definition,t.type)})}function kR(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(SR(e,t),e.opts.allowUnionTypes||TR(e,t),$R(e,e.dataTypes))}function SR(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{H0(e.dataTypes,r)||Bp(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),ER(e,t)}}function TR(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Bp(e,"use allowUnionTypes to allow union type keyword")}function $R(e,t){let r=e.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Gp.shouldUseRule)(e.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>zR(t,s))&&Bp(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function zR(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function H0(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function ER(e,t){let r=[];for(let n of e.dataTypes)H0(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Bp(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,_n.checkStrictMode)(e,t,e.opts.strictTypes)}var El=class{constructor(t,r,n){if((0,ua.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,_n.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Q0(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ua.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=t.gen.const("_errs",Q.default.errors))}result(t,r,n){this.failResult((0,L.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,L.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,L._)`${r} !== undefined && (${(0,L.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?la.reportExtraError:la.reportError)(this,this.def.error,r)}$dataError(){(0,la.reportError)(this,this.def.$dataError||la.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,la.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=L.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=L.nil,r=L.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,L.or)((0,L._)`${i} === undefined`,r)),t!==L.nil&&n.assign(t,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==L.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,L.or)(s(),a());function s(){if(n.length){if(!(r instanceof L.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return(0,L._)`${(0,zl.checkDataTypes)(u,r,o.opts.strictNumbers,zl.DataType.Wrong)}`}return L.nil}function a(){if(i.validateSchema){let u=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,L._)`!${u}(${r})`}return L.nil}}subschema(t,r){let n=(0,Vp.getSubschema)(this.it,t);(0,Vp.extendSubschemaData)(n,this.it,t),(0,Vp.extendSubschemaMode)(n,t);let i={...this.it,...n,items:void 0,props:void 0};return hR(i,r),i}mergeEvaluated(t,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=_n.mergeEvaluated.props(i,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=_n.mergeEvaluated.items(i,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(t,L.Name)),!0}};Bn.KeywordCxt=El;function K0(e,t,r,n){let i=new El(e,r,t);"code"in r?r.code(i,n):i.$data&&r.validate?(0,ua.funcKeywordCode)(i,r):"macro"in r?(0,ua.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,ua.funcKeywordCode)(i,r)}var OR=/^\/(?:[^~]|~0|~1)*$/,AR=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Q0(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let i,o;if(e==="")return Q.default.rootData;if(e[0]==="/"){if(!OR.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,o=Q.default.rootData}else{let c=AR.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+c[1];if(i=c[2],i==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!i)return o}let s=o,a=i.split("/");for(let c of a)c&&(o=(0,L._)`${o}${(0,L.getProperty)((0,_n.unescapeJsonPointer)(c))}`,s=(0,L._)`${s} && ${o}`);return s;function u(c,l){return`Cannot access ${c} ${l} levels up, current level is ${t}`}}Bn.getData=Q0});var Ol=E(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var Jp=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Wp.default=Jp});var fa=E(Qp=>{"use strict";Object.defineProperty(Qp,"__esModule",{value:!0});var Hp=ca(),Kp=class extends Error{constructor(t,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Hp.resolveUrl)(t,r,n),this.missingSchema=(0,Hp.normalizeId)((0,Hp.getFullPath)(t,this.missingRef))}};Qp.default=Kp});var Pl=E(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.resolveSchema=mr.getCompilingSchema=mr.resolveRef=mr.compileSchema=mr.SchemaEnv=void 0;var $r=ne(),PR=Ol(),Ui=gn(),zr=ca(),X0=he(),CR=da(),qo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,zr.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};mr.SchemaEnv=qo;function Yp(e){let t=Y0.call(this,e);if(t)return t;let r=(0,zr.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new $r.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:PR.default,code:(0,$r._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");e.validateName=u;let c={gen:s,allErrors:this.opts.allErrors,data:Ui.default.data,parentData:Ui.default.parentData,parentDataProperty:Ui.default.parentDataProperty,dataNames:[Ui.default.data],dataPathArr:[$r.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,$r.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:$r.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,$r._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,CR.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();l=`${s.scopeRefs(Ui.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let m=new Function(`${Ui.default.self}`,`${Ui.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:m}),m.errors=null,m.schema=e.schema,m.schemaEnv=e,e.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:u,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:p,items:f}=c;m.evaluated={props:p instanceof $r.Name?void 0:p,items:f instanceof $r.Name?void 0:f,dynamicProps:p instanceof $r.Name,dynamicItems:f instanceof $r.Name},m.source&&(m.source.evaluated=(0,$r.stringify)(m.evaluated))}return e.validate=m,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}mr.compileSchema=Yp;function RR(e,t,r){var n;r=(0,zr.resolveUrl)(this.opts.uriResolver,t,r);let i=e.refs[r];if(i)return i;let o=NR.call(this,e,r);if(o===void 0){let s=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new qo({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=IR.call(this,o)}mr.resolveRef=RR;function IR(e){return(0,zr.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Yp.call(this,e)}function Y0(e){for(let t of this._compilations)if(jR(t,e))return t}mr.getCompilingSchema=Y0;function jR(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function NR(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Al.call(this,e,t)}function Al(e,t){let r=this.opts.uriResolver.parse(t),n=(0,zr._getFullPath)(this.opts.uriResolver,r),i=(0,zr.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===i)return Xp.call(this,r,e);let o=(0,zr.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=Al.call(this,e,s);return typeof a?.schema!="object"?void 0:Xp.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||Yp.call(this,s),o===(0,zr.normalizeId)(t)){let{schema:a}=s,{schemaId:u}=this.opts,c=a[u];return c&&(i=(0,zr.resolveUrl)(this.opts.uriResolver,i,c)),new qo({schema:a,schemaId:u,root:e,baseId:i})}return Xp.call(this,r,s)}}mr.resolveSchema=Al;var MR=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Xp(e,{baseId:t,schema:r,root:n}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0,X0.unescapeFragment)(a)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!MR.has(a)&&c&&(t=(0,zr.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,X0.schemaHasRulesButRef)(r,this.RULES)){let a=(0,zr.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Al.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new qo({schema:r,schemaId:s,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var ex=E((nV,DR)=>{DR.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 th=E((iV,ix)=>{"use strict";var ZR=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),rx=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);function eh(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var LR=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function tx(e){return e.length=0,!0}function qR(e,t,r){if(e.length){let n=eh(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function FR(e){let t=0,r={error:!1,address:"",zone:""},n=[],i=[],o=!1,s=!1,a=qR;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(i,n,r))break;if(++t>7){r.error=!0;break}u>0&&e[u-1]===":"&&(o=!0),n.push(":");continue}else if(c==="%"){if(!a(i,n,r))break;a=tx}else{i.push(c);continue}}return i.length&&(a===tx?r.zone=i.join(""):s?n.push(i.join("")):n.push(eh(i))),r.address=n.join(""),r}function nx(e){if(UR(e,":")<2)return{host:e,isIPV6:!1};let t=FR(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function UR(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function VR(e){let t=e,r=[],n=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(i===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function GR(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function BR(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!rx(r)){let n=nx(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}ix.exports={nonSimpleDomain:LR,recomposeAuthority:BR,normalizeComponentEncoding:GR,removeDotSegments:VR,isIPv4:rx,isUUID:ZR,normalizeIPv6:nx,stringArrayToHexStripped:eh}});var lx=E((oV,cx)=>{"use strict";var{isUUID:JR}=th(),WR=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,HR=["http","https","ws","wss","urn","urn:uuid"];function KR(e){return HR.indexOf(e)!==-1}function rh(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function ox(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function sx(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function QR(e){return e.secure=rh(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function XR(e){if((e.port===(rh(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function YR(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(WR);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let i=`${n}:${t.nid||e.nid}`,o=nh(i);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function eI(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),i=`${r}:${t.nid||n}`,o=nh(i);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s}function tI(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!JR(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function rI(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var ax={scheme:"http",domainHost:!0,parse:ox,serialize:sx},nI={scheme:"https",domainHost:ax.domainHost,parse:ox,serialize:sx},Cl={scheme:"ws",domainHost:!0,parse:QR,serialize:XR},iI={scheme:"wss",domainHost:Cl.domainHost,parse:Cl.parse,serialize:Cl.serialize},oI={scheme:"urn",parse:YR,serialize:eI,skipNormalize:!0},sI={scheme:"urn:uuid",parse:tI,serialize:rI,skipNormalize:!0},Rl={http:ax,https:nI,ws:Cl,wss:iI,urn:oI,"urn:uuid":sI};Object.setPrototypeOf(Rl,null);function nh(e){return e&&(Rl[e]||Rl[e.toLowerCase()])||void 0}cx.exports={wsIsSecure:rh,SCHEMES:Rl,isValidSchemeName:KR,getSchemeHandler:nh}});var fx=E((sV,jl)=>{"use strict";var{normalizeIPv6:aI,removeDotSegments:ma,recomposeAuthority:cI,normalizeComponentEncoding:Il,isIPv4:lI,nonSimpleDomain:uI}=th(),{SCHEMES:dI,getSchemeHandler:ux}=lx();function fI(e,t){return typeof e=="string"?e=Jr(yn(e,t),t):typeof e=="object"&&(e=yn(Jr(e,t),t)),e}function mI(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},i=dx(yn(e,n),yn(t,n),n,!0);return n.skipEscape=!0,Jr(i,n)}function dx(e,t,r,n){let i={};return n||(e=yn(Jr(e,r),r),t=yn(Jr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=ma(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=ma(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=ma(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=ma(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function pI(e,t,r){return typeof e=="string"?(e=unescape(e),e=Jr(Il(yn(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Jr(Il(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=Jr(Il(yn(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Jr(Il(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function Jr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),i=[],o=ux(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let s=cI(r);if(s!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(s),r.path&&r.path[0]!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=ma(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var hI=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function yn(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(hI);if(o){if(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]),n.host)if(lI(n.host)===!1){let u=aI(n.host);n.host=u.host.toLowerCase(),i=u.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 s=ux(r.scheme||n.scheme);if(!r.unicodeSupport&&(!s||!s.unicodeSupport)&&n.host&&(r.domainHost||s&&s.domainHost)&&i===!1&&uI(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!s||s&&!s.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),s&&s.parse&&s.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var ih={SCHEMES:dI,normalize:fI,resolve:mI,resolveComponent:dx,equal:pI,serialize:Jr,parse:yn};jl.exports=ih;jl.exports.default=ih;jl.exports.fastUri=ih});var px=E(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});var mx=fx();mx.code='require("ajv/dist/runtime/uri").default';oh.default=mx});var xx=E(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.CodeGen=_t.Name=_t.nil=_t.stringify=_t.str=_t._=_t.KeywordCxt=void 0;var gI=da();Object.defineProperty(_t,"KeywordCxt",{enumerable:!0,get:function(){return gI.KeywordCxt}});var Fo=ne();Object.defineProperty(_t,"_",{enumerable:!0,get:function(){return Fo._}});Object.defineProperty(_t,"str",{enumerable:!0,get:function(){return Fo.str}});Object.defineProperty(_t,"stringify",{enumerable:!0,get:function(){return Fo.stringify}});Object.defineProperty(_t,"nil",{enumerable:!0,get:function(){return Fo.nil}});Object.defineProperty(_t,"Name",{enumerable:!0,get:function(){return Fo.Name}});Object.defineProperty(_t,"CodeGen",{enumerable:!0,get:function(){return Fo.CodeGen}});var _I=Ol(),vx=fa(),yI=Ip(),pa=Pl(),vI=ne(),ha=ca(),Nl=aa(),ah=he(),hx=ex(),bI=px(),bx=(e,t)=>new RegExp(e,t);bx.code="new RegExp";var wI=["removeAdditional","useDefaults","coerceTypes"],xI=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),kI={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."},SI={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},gx=200;function TI(e){var t,r,n,i,o,s,a,u,c,l,d,h,m,p,f,g,y,v,b,w,S,q,K,ce,C;let V=e.strict,H=(t=e.code)===null||t===void 0?void 0:t.optimize,fe=H===!0||H===void 0?1:H||0,ge=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:bx,j=(i=e.uriResolver)!==null&&i!==void 0?i:bI.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:V)!==null&&s!==void 0?s:!0,strictNumbers:(u=(a=e.strictNumbers)!==null&&a!==void 0?a:V)!==null&&u!==void 0?u:!0,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:V)!==null&&l!==void 0?l:"log",strictTuples:(h=(d=e.strictTuples)!==null&&d!==void 0?d:V)!==null&&h!==void 0?h:"log",strictRequired:(p=(m=e.strictRequired)!==null&&m!==void 0?m:V)!==null&&p!==void 0?p:!1,code:e.code?{...e.code,optimize:fe,regExp:ge}:{optimize:fe,regExp:ge},loopRequired:(f=e.loopRequired)!==null&&f!==void 0?f:gx,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:gx,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(q=e.validateSchema)!==null&&q!==void 0?q:!0,validateFormats:(K=e.validateFormats)!==null&&K!==void 0?K:!0,unicodeRegExp:(ce=e.unicodeRegExp)!==null&&ce!==void 0?ce:!0,int32range:(C=e.int32range)!==null&&C!==void 0?C:!0,uriResolver:j}}var ga=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...TI(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new vI.ValueScope({scope:{},prefixes:xI,es5:r,lines:n}),this.logger=PI(t.logger);let i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,yI.getRules)(),_x.call(this,kI,t,"NOT SUPPORTED"),_x.call(this,SI,t,"DEPRECATED","warn"),this._metaOpts=OI.call(this),t.formats&&zI.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&EI.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),$I.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,i=hx;n==="id"&&(i={...hx},i.id=i.$id,delete i.$id),r&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,t,r);async function i(l,d){await o.call(this,l.$schema);let h=this._addSchema(l,d);return h.validate||s.call(this,h)}async function o(l){l&&!this.getSchema(l)&&await i.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof vx.default))throw d;return a.call(this,d),await u.call(this,d.missingSchema),s.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 u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,n,i);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,ha.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,i,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$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 i=this.validate(n,t);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(t){let r;for(;typeof(r=yx.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,i=new pa.SchemaEnv({schema:{},schemaId:n});if(r=pa.resolveSchema.call(this,i,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=yx.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,ha.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,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(RI.call(this,n,r),!r)return(0,ah.eachItem)(n,o=>sh.call(this,o)),this;jI.call(this,r);let i={...r,type:(0,Nl.getJSONTypes)(r.type),schemaType:(0,Nl.getJSONTypes)(r.schemaType)};return(0,ah.eachItem)(n,i.type.length===0?o=>sh.call(this,o,i):o=>i.type.forEach(s=>sh.call(this,o,i,s))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===t);i>=0&&n.rules.splice(i,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let i of r){let o=i.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in n){let u=n[a];if(typeof u!="object")continue;let{$data:c}=u.definition,l=s[a];c&&l&&(s[a]=wx(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let i=t[n];(!r||r.test(n))&&(typeof i=="string"?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0,ha.normalizeId)(s||n);let c=ha.getSchemaRefs.call(this,t,n);return u=new pa.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),i&&this.validateSchema(t,!0),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):pa.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{pa.compileSchema.call(this,t)}finally{this.opts=r}}};ga.ValidationError=_I.default;ga.MissingRefError=vx.default;_t.default=ga;function _x(e,t,r,n="error"){for(let i in e){let o=i;o in t&&this.logger[n](`${r}: option ${i}. ${e[o]}`)}}function yx(e){return e=(0,ha.normalizeId)(e),this.schemas[e]||this.refs[e]}function $I(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function zI(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function EI(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function OI(){let e={...this.opts};for(let t of wI)delete e[t];return e}var AI={log(){},warn(){},error(){}};function PI(e){if(e===!1)return AI;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var CI=/^[a-z_$][a-z0-9_$:-]*$/i;function RI(e,t){let{RULES:r}=this;if((0,ah.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!CI.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function sh(e,t,r){var n;let i=t?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:u})=>u===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Nl.getJSONTypes)(t.type),schemaType:(0,Nl.getJSONTypes)(t.schemaType)}};t.before?II.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u))}function II(e,t,r){let n=e.rules.findIndex(i=>i.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function jI(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=wx(t)),e.validateSchema=this.compile(t,!0))}var NI={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function wx(e){return{anyOf:[e,NI]}}});var kx=E(ch=>{"use strict";Object.defineProperty(ch,"__esModule",{value:!0});var MI={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ch.default=MI});var zx=E(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.callRef=Vi.getValidate=void 0;var DI=fa(),Sx=fr(),Bt=ne(),Uo=gn(),Tx=Pl(),Ml=he(),ZI={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&i===c.baseId)return d();let l=Tx.resolveRef.call(u,c,i,r);if(l===void 0)throw new DI.default(n.opts.uriResolver,i,r);if(l instanceof Tx.SchemaEnv)return h(l);return m(l);function d(){if(o===c)return Dl(e,s,o,o.$async);let p=t.scopeValue("root",{ref:c});return Dl(e,(0,Bt._)`${p}.validate`,c,c.$async)}function h(p){let f=$x(e,p);Dl(e,f,p,p.$async)}function m(p){let f=t.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,Bt.stringify)(p)}:{ref:p}),g=t.name("valid"),y=e.subschema({schema:p,dataTypes:[],schemaPath:Bt.nil,topSchemaRef:f,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function $x(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Bt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Vi.getValidate=$x;function Dl(e,t,r,n){let{gen:i,it:o}=e,{allErrors:s,schemaEnv:a,opts:u}=o,c=u.passContext?Uo.default.this:Bt.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=i.let("valid");i.try(()=>{i.code((0,Bt._)`await ${(0,Sx.callValidateCode)(e,t,c)}`),m(t),s||i.assign(p,!0)},f=>{i.if((0,Bt._)`!(${f} instanceof ${o.ValidationError})`,()=>i.throw(f)),h(f),s||i.assign(p,!1)}),e.ok(p)}function d(){e.result((0,Sx.callValidateCode)(e,t,c),()=>m(t),()=>h(t))}function h(p){let f=(0,Bt._)`${p}.errors`;i.assign(Uo.default.vErrors,(0,Bt._)`${Uo.default.vErrors} === null ? ${f} : ${Uo.default.vErrors}.concat(${f})`),i.assign(Uo.default.errors,(0,Bt._)`${Uo.default.vErrors}.length`)}function m(p){var f;if(!o.opts.unevaluated)return;let g=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Ml.mergeEvaluated.props(i,g.props,o.props));else{let y=i.var("props",(0,Bt._)`${p}.evaluated.props`);o.props=Ml.mergeEvaluated.props(i,y,o.props,Bt.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Ml.mergeEvaluated.items(i,g.items,o.items));else{let y=i.var("items",(0,Bt._)`${p}.evaluated.items`);o.items=Ml.mergeEvaluated.items(i,y,o.items,Bt.Name)}}}Vi.callRef=Dl;Vi.default=ZI});var Ex=E(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});var LI=kx(),qI=zx(),FI=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",LI.default,qI.default];lh.default=FI});var Ox=E(uh=>{"use strict";Object.defineProperty(uh,"__esModule",{value:!0});var Zl=ne(),Jn=Zl.operators,Ll={maximum:{okStr:"<=",ok:Jn.LTE,fail:Jn.GT},minimum:{okStr:">=",ok:Jn.GTE,fail:Jn.LT},exclusiveMaximum:{okStr:"<",ok:Jn.LT,fail:Jn.GTE},exclusiveMinimum:{okStr:">",ok:Jn.GT,fail:Jn.LTE}},UI={message:({keyword:e,schemaCode:t})=>(0,Zl.str)`must be ${Ll[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Zl._)`{comparison: ${Ll[e].okStr}, limit: ${t}}`},VI={keyword:Object.keys(Ll),type:"number",schemaType:"number",$data:!0,error:UI,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Zl._)`${r} ${Ll[t].fail} ${n} || isNaN(${r})`)}};uh.default=VI});var Ax=E(dh=>{"use strict";Object.defineProperty(dh,"__esModule",{value:!0});var _a=ne(),GI={message:({schemaCode:e})=>(0,_a.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,_a._)`{multipleOf: ${e}}`},BI={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:GI,code(e){let{gen:t,data:r,schemaCode:n,it:i}=e,o=i.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,_a._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,_a._)`${s} !== parseInt(${s})`;e.fail$data((0,_a._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};dh.default=BI});var Cx=E(fh=>{"use strict";Object.defineProperty(fh,"__esModule",{value:!0});function Px(e){let t=e.length,r=0,n=0,i;for(;n<t;)r++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<t&&(i=e.charCodeAt(n),(i&64512)===56320&&n++);return r}fh.default=Px;Px.code='require("ajv/dist/runtime/ucs2length").default'});var Rx=E(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});var Gi=ne(),JI=he(),WI=Cx(),HI={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Gi.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Gi._)`{limit: ${e}}`},KI={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:HI,code(e){let{keyword:t,data:r,schemaCode:n,it:i}=e,o=t==="maxLength"?Gi.operators.GT:Gi.operators.LT,s=i.opts.unicode===!1?(0,Gi._)`${r}.length`:(0,Gi._)`${(0,JI.useFunc)(e.gen,WI.default)}(${r})`;e.fail$data((0,Gi._)`${s} ${o} ${n}`)}};mh.default=KI});var Ix=E(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});var QI=fr(),ql=ne(),XI={message:({schemaCode:e})=>(0,ql.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,ql._)`{pattern: ${e}}`},YI={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:XI,code(e){let{data:t,$data:r,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"",a=r?(0,ql._)`(new RegExp(${i}, ${s}))`:(0,QI.usePattern)(e,n);e.fail$data((0,ql._)`!${a}.test(${t})`)}};ph.default=YI});var jx=E(hh=>{"use strict";Object.defineProperty(hh,"__esModule",{value:!0});var ya=ne(),ej={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,ya.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ya._)`{limit: ${e}}`},tj={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ej,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxProperties"?ya.operators.GT:ya.operators.LT;e.fail$data((0,ya._)`Object.keys(${r}).length ${i} ${n}`)}};hh.default=tj});var Nx=E(gh=>{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});var va=fr(),ba=ne(),rj=he(),nj={message:({params:{missingProperty:e}})=>(0,ba.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,ba._)`{missingProperty: ${e}}`},ij={keyword:"required",type:"object",schemaType:"array",$data:!0,error:nj,code(e){let{gen:t,schema:r,schemaCode:n,data:i,$data:o,it:s}=e,{opts:a}=s;if(!o&&r.length===0)return;let u=r.length>=a.loopRequired;if(s.allErrors?c():l(),a.strictRequired){let m=e.parentSchema.properties,{definedProperties:p}=e.it;for(let f of r)if(m?.[f]===void 0&&!p.has(f)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${f}" is not defined at "${g}" (strictRequired)`;(0,rj.checkStrictMode)(s,y,s.opts.strictRequired)}}function c(){if(u||o)e.block$data(ba.nil,d);else for(let m of r)(0,va.checkReportMissingProp)(e,m)}function l(){let m=t.let("missing");if(u||o){let p=t.let("valid",!0);e.block$data(p,()=>h(m,p)),e.ok(p)}else t.if((0,va.checkMissingProp)(e,r,m)),(0,va.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,va.noPropertyInData)(t,i,m,a.ownProperties),()=>e.error())})}function h(m,p){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(p,(0,va.propertyInData)(t,i,m,a.ownProperties)),t.if((0,ba.not)(p),()=>{e.error(),t.break()})},ba.nil)}}};gh.default=ij});var Mx=E(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});var wa=ne(),oj={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,wa.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,wa._)`{limit: ${e}}`},sj={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:oj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxItems"?wa.operators.GT:wa.operators.LT;e.fail$data((0,wa._)`${r}.length ${i} ${n}`)}};_h.default=sj});var Fl=E(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});var Dx=Fp();Dx.code='require("ajv/dist/runtime/equal").default';yh.default=Dx});var Zx=E(bh=>{"use strict";Object.defineProperty(bh,"__esModule",{value:!0});var vh=aa(),yt=ne(),aj=he(),cj=Fl(),lj={message:({params:{i:e,j:t}})=>(0,yt.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,yt._)`{i: ${e}, j: ${t}}`},uj={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:lj,code(e){let{gen:t,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=e;if(!n&&!i)return;let u=t.let("valid"),c=o.items?(0,vh.getSchemaTypes)(o.items):[];e.block$data(u,l,(0,yt._)`${s} === false`),e.ok(u);function l(){let p=t.let("i",(0,yt._)`${r}.length`),f=t.let("j");e.setParams({i:p,j:f}),t.assign(u,!0),t.if((0,yt._)`${p} > 1`,()=>(d()?h:m)(p,f))}function d(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function h(p,f){let g=t.name("item"),y=(0,vh.checkDataTypes)(c,g,a.opts.strictNumbers,vh.DataType.Wrong),v=t.const("indices",(0,yt._)`{}`);t.for((0,yt._)`;${p}--;`,()=>{t.let(g,(0,yt._)`${r}[${p}]`),t.if(y,(0,yt._)`continue`),c.length>1&&t.if((0,yt._)`typeof ${g} == "string"`,(0,yt._)`${g} += "_"`),t.if((0,yt._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(f,(0,yt._)`${v}[${g}]`),e.error(),t.assign(u,!1).break()}).code((0,yt._)`${v}[${g}] = ${p}`)})}function m(p,f){let g=(0,aj.useFunc)(t,cj.default),y=t.name("outer");t.label(y).for((0,yt._)`;${p}--;`,()=>t.for((0,yt._)`${f} = ${p}; ${f}--;`,()=>t.if((0,yt._)`${g}(${r}[${p}], ${r}[${f}])`,()=>{e.error(),t.assign(u,!1).break(y)})))}}};bh.default=uj});var Lx=E(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});var wh=ne(),dj=he(),fj=Fl(),mj={message:"must be equal to constant",params:({schemaCode:e})=>(0,wh._)`{allowedValue: ${e}}`},pj={keyword:"const",$data:!0,error:mj,code(e){let{gen:t,data:r,$data:n,schemaCode:i,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,wh._)`!${(0,dj.useFunc)(t,fj.default)}(${r}, ${i})`):e.fail((0,wh._)`${o} !== ${r}`)}};xh.default=pj});var qx=E(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var xa=ne(),hj=he(),gj=Fl(),_j={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,xa._)`{allowedValues: ${e}}`},yj={keyword:"enum",schemaType:"array",$data:!0,error:_j,code(e){let{gen:t,data:r,$data:n,schema:i,schemaCode:o,it:s}=e;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,u,c=()=>u??(u=(0,hj.useFunc)(t,gj.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let m=t.const("vSchema",o);l=(0,xa.or)(...i.map((p,f)=>h(m,f)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",o,m=>t.if((0,xa._)`${c()}(${r}, ${m})`,()=>t.assign(l,!0).break()))}function h(m,p){let f=i[p];return typeof f=="object"&&f!==null?(0,xa._)`${c()}(${r}, ${m}[${p}])`:(0,xa._)`${r} === ${f}`}}};kh.default=yj});var Fx=E(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0});var vj=Ox(),bj=Ax(),wj=Rx(),xj=Ix(),kj=jx(),Sj=Nx(),Tj=Mx(),$j=Zx(),zj=Lx(),Ej=qx(),Oj=[vj.default,bj.default,wj.default,xj.default,kj.default,Sj.default,Tj.default,$j.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},zj.default,Ej.default];Sh.default=Oj});var $h=E(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.validateAdditionalItems=void 0;var Bi=ne(),Th=he(),Aj={message:({params:{len:e}})=>(0,Bi.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Bi._)`{limit: ${e}}`},Pj={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Aj,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Th.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ux(e,n)}};function Ux(e,t){let{gen:r,schema:n,data:i,keyword:o,it:s}=e;s.items=!0;let a=r.const("len",(0,Bi._)`${i}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Bi._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Th.alwaysValidSchema)(s,n)){let c=r.var("valid",(0,Bi._)`${a} <= ${t.length}`);r.if((0,Bi.not)(c),()=>u(c)),e.ok(c)}function u(c){r.forRange("i",t.length,a,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:Th.Type.Num},c),s.allErrors||r.if((0,Bi.not)(c),()=>r.break())})}}ka.validateAdditionalItems=Ux;ka.default=Pj});var zh=E(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.validateTuple=void 0;var Vx=ne(),Ul=he(),Cj=fr(),Rj={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Gx(e,"additionalItems",t);r.items=!0,!(0,Ul.alwaysValidSchema)(r,t)&&e.ok((0,Cj.validateArray)(e))}};function Gx(e,t,r=e.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=e;l(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Ul.mergeEvaluated.items(n,r.length,a.items));let u=n.name("valid"),c=n.const("len",(0,Vx._)`${o}.length`);r.forEach((d,h)=>{(0,Ul.alwaysValidSchema)(a,d)||(n.if((0,Vx._)`${c} > ${h}`,()=>e.subschema({keyword:s,schemaProp:h,dataProp:h},u)),e.ok(u))});function l(d){let{opts:h,errSchemaPath:m}=a,p=r.length,f=p===d.minItems&&(p===d.maxItems||d[t]===!1);if(h.strictTuples&&!f){let g=`"${s}" is ${p}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,Ul.checkStrictMode)(a,g,h.strictTuples)}}}Sa.validateTuple=Gx;Sa.default=Rj});var Bx=E(Eh=>{"use strict";Object.defineProperty(Eh,"__esModule",{value:!0});var Ij=zh(),jj={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Ij.validateTuple)(e,"items")};Eh.default=jj});var Wx=E(Oh=>{"use strict";Object.defineProperty(Oh,"__esModule",{value:!0});var Jx=ne(),Nj=he(),Mj=fr(),Dj=$h(),Zj={message:({params:{len:e}})=>(0,Jx.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Jx._)`{limit: ${e}}`},Lj={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Zj,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:i}=r;n.items=!0,!(0,Nj.alwaysValidSchema)(n,t)&&(i?(0,Dj.validateAdditionalItems)(e,i):e.ok((0,Mj.validateArray)(e)))}};Oh.default=Lj});var Hx=E(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0});var pr=ne(),Vl=he(),qj={message:({params:{min:e,max:t}})=>t===void 0?(0,pr.str)`must contain at least ${e} valid item(s)`:(0,pr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,pr._)`{minContains: ${e}}`:(0,pr._)`{minContains: ${e}, maxContains: ${t}}`},Fj={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:qj,code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e,s,a,{minContains:u,maxContains:c}=n;o.opts.next?(s=u===void 0?1:u,a=c):s=1;let l=t.const("len",(0,pr._)`${i}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,Vl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,Vl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Vl.alwaysValidSchema)(o,r)){let f=(0,pr._)`${l} >= ${s}`;a!==void 0&&(f=(0,pr._)`${f} && ${l} <= ${a}`),e.pass(f);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?m(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,pr._)`${i}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset());function h(){let f=t.name("_valid"),g=t.let("count",0);m(f,()=>t.if(f,()=>p(g)))}function m(f,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:Vl.Type.Num,compositeRule:!0},f),g()})}function p(f){t.code((0,pr._)`${f}++`),a===void 0?t.if((0,pr._)`${f} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,pr._)`${f} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,pr._)`${f} >= ${s}`,()=>t.assign(d,!0)))}}};Ah.default=Fj});var Xx=E(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.validateSchemaDeps=Wr.validatePropertyDeps=Wr.error=void 0;var Ph=ne(),Uj=he(),Ta=fr();Wr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Ph.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Ph._)`{property: ${e},
8
+ || ${s} === "boolean" || ${i} === null`).assign(a,(0,te._)`[${i}]`)}}}function O1({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,n))}function Np(e,t,r,n=Do.Correct){let i=n===Do.Correct?te.operators.EQ:te.operators.NEQ,o;switch(e){case"null":return(0,te._)`${t} ${i} null`;case"array":o=(0,te._)`Array.isArray(${t})`;break;case"object":o=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,te._)`typeof ${t} ${i} ${e}`}return n===Do.Correct?o:(0,te.not)(o);function s(a=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,a,r?(0,te._)`isFinite(${t})`:te.nil)}}Et.checkDataType=Np;function Mp(e,t,r,n){if(e.length===1)return Np(e[0],t,r,n);let i,o=(0,k0.toHash)(e);if(o.array&&o.object){let s=(0,te._)`typeof ${t} != "object"`;i=o.null?s:(0,te._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else i=te.nil;o.number&&delete o.integer;for(let s in o)i=(0,te.and)(i,Np(s,t,r,n));return i}Et.checkDataTypes=Mp;var A1={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Dp(e){let t=P1(e);(0,S1.reportError)(t,A1)}Et.reportTypeError=Dp;function P1(e){let{gen:t,data:r,schema:n}=e,i=(0,k0.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:e}}});var E0=z(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.assignDefaults=void 0;var Zo=ne(),C1=he();function R1(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let i in r)$0(e,i,r[i].default);else t==="array"&&Array.isArray(n)&&n.forEach((i,o)=>$0(e,o,i.default))}Tl.assignDefaults=R1;function $0(e,t,r){let{gen:n,compositeRule:i,data:o,opts:s}=e;if(r===void 0)return;let a=(0,Zo._)`${o}${(0,Zo.getProperty)(t)}`;if(i){(0,C1.checkStrictMode)(e,`default is ignored for: ${a}`);return}let u=(0,Zo._)`${a} === undefined`;s.useDefaults==="empty"&&(u=(0,Zo._)`${u} || ${a} === null || ${a} === ""`),n.if(u,(0,Zo._)`${a} = ${(0,Zo.stringify)(r)}`)}});var fr=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var Re=ne(),Zp=he(),Un=gn(),I1=he();function j1(e,t){let{gen:r,data:n,it:i}=e;r.if(qp(r,n,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}Te.checkReportMissingProp=j1;function N1({gen:e,data:t,it:{opts:r}},n,i){return(0,Re.or)(...n.map(o=>(0,Re.and)(qp(e,t,o,r.ownProperties),(0,Re._)`${i} = ${o}`)))}Te.checkMissingProp=N1;function M1(e,t){e.setParams({missingProperty:t},!0),e.error()}Te.reportMissingProp=M1;function z0(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=z0;function Lp(e,t,r){return(0,Re._)`${z0(e)}.call(${t}, ${r})`}Te.isOwnProperty=Lp;function D1(e,t,r,n){let i=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${i} && ${Lp(e,t,r)}`:i}Te.propertyInData=D1;function qp(e,t,r,n){let i=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(i,(0,Re.not)(Lp(e,t,r))):i}Te.noPropertyInData=qp;function O0(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Te.allSchemaProperties=O0;function Z1(e,t){return O0(t).filter(r=>!(0,Zp.alwaysValidSchema)(e,t[r]))}Te.schemaProperties=Z1;function L1({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,u,c){let l=c?(0,Re._)`${e}, ${t}, ${n}${i}`:t,d=[[Un.default.instancePath,(0,Re.strConcat)(Un.default.instancePath,o)],[Un.default.parentData,s.parentData],[Un.default.parentDataProperty,s.parentDataProperty],[Un.default.rootData,Un.default.rootData]];s.opts.dynamicRef&&d.push([Un.default.dynamicAnchors,Un.default.dynamicAnchors]);let h=(0,Re._)`${l}, ${r.object(...d)}`;return u!==Re.nil?(0,Re._)`${a}.call(${u}, ${h})`:(0,Re._)`${a}(${h})`}Te.callValidateCode=L1;var q1=(0,Re._)`new RegExp`;function F1({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:i}=t.code,o=i(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Re._)`${i.code==="new RegExp"?q1:(0,I1.useFunc)(e,i)}(${r}, ${n})`})}Te.usePattern=F1;function U1(e){let{gen:t,data:r,keyword:n,it:i}=e,o=t.name("valid");if(i.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let u=t.const("len",(0,Re._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Zp.Type.Num},o),t.if((0,Re.not)(o),a)})}}Te.validateArray=U1;function V1(e){let{gen:t,schema:r,keyword:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0,Zp.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Re._)`${s} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,Re.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}Te.validateUnion=V1});var C0=z(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateKeywordUsage=Gr.validSchemaType=Gr.funcKeywordCode=Gr.macroKeywordCode=void 0;var Nt=ne(),Fi=gn(),G1=fr(),B1=sa();function J1(e,t){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=e,a=t.macro.call(s.self,i,o,s),u=P0(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=r.name("valid");e.subschema({schema:a,schemaPath:Nt.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Gr.macroKeywordCode=J1;function W1(e,t){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:u}=e;K1(u,t);let c=!a&&t.compile?t.compile.call(u.self,o,s,u):t.validate,l=P0(n,i,c),d=n.let("valid");e.block$data(d,h),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function h(){if(t.errors===!1)f(),t.modifying&&A0(e),g(()=>e.error());else{let y=t.async?m():p();t.modifying&&A0(e),g(()=>H1(e,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>f((0,Nt._)`await `),v=>n.assign(d,!1).if((0,Nt._)`${v} instanceof ${u.ValidationError}`,()=>n.assign(y,(0,Nt._)`${v}.errors`),()=>n.throw(v))),y}function p(){let y=(0,Nt._)`${l}.errors`;return n.assign(y,null),f(Nt.nil),y}function f(y=t.async?(0,Nt._)`await `:Nt.nil){let v=u.opts.passContext?Fi.default.this:Fi.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Nt._)`${y}${(0,G1.callValidateCode)(e,l,v,b)}`,t.modifying)}function g(y){var v;n.if((0,Nt.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}Gr.funcKeywordCode=W1;function A0(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Nt._)`${n.parentData}[${n.parentDataProperty}]`))}function H1(e,t){let{gen:r}=e;r.if((0,Nt._)`Array.isArray(${t})`,()=>{r.assign(Fi.default.vErrors,(0,Nt._)`${Fi.default.vErrors} === null ? ${t} : ${Fi.default.vErrors}.concat(${t})`).assign(Fi.default.errors,(0,Nt._)`${Fi.default.vErrors}.length`),(0,B1.extendErrors)(e)},()=>e.error())}function K1({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function P0(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Nt.stringify)(r)})}function Q1(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Gr.validSchemaType=Q1;function X1({schema:e,opts:t,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}Gr.validateKeywordUsage=X1});var I0=z(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.extendSubschemaMode=Vn.extendSubschemaData=Vn.getSubschema=void 0;var Br=ne(),R0=he();function Y1(e,{keyword:t,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Br._)`${e.schemaPath}${(0,Br.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Br._)`${e.schemaPath}${(0,Br.getProperty)(t)}${(0,Br.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,R0.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Vn.getSubschema=Y1;function eR(e,t,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:c,dataPathArr:l,opts:d}=t,h=a.let("data",(0,Br._)`${t.data}${(0,Br.getProperty)(r)}`,!0);u(h),e.errorPath=(0,Br.str)`${c}${(0,R0.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Br._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(i!==void 0){let c=i instanceof Br.Name?i:a.let("data",i,!0);u(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Vn.extendSubschemaData=eR;function tR(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(e.compositeRule=n),i!==void 0&&(e.createErrors=i),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Vn.extendSubschemaMode=tR});var Fp=z((tV,j0)=>{"use strict";j0.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r}});var M0=z((rV,N0)=>{"use strict";var Gn=N0.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};$l(t,n,i,e,"",e)};Gn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Gn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Gn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Gn.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 $l(e,t,r,n,i,o,s,a,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,i,o,s,a,u,c);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Gn.arrayKeywords)for(var h=0;h<d.length;h++)$l(e,t,r,d[h],i+"/"+l+"/"+h,o,i,l,n,h)}else if(l in Gn.propsKeywords){if(d&&typeof d=="object")for(var m in d)$l(e,t,r,d[m],i+"/"+l+"/"+rR(m),o,i,l,n,m)}else(l in Gn.keywords||e.allKeys&&!(l in Gn.skipKeywords))&&$l(e,t,r,d,i+"/"+l,o,i,l,n)}r(n,i,o,s,a,u,c)}}function rR(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ca=z(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getSchemaRefs=Gt.resolveUrl=Gt.normalizeId=Gt._getFullPath=Gt.getFullPath=Gt.inlineRef=void 0;var nR=he(),iR=Fp(),oR=M0(),sR=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function aR(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Up(e):t?D0(e)<=t:!1}Gt.inlineRef=aR;var cR=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Up(e){for(let t in e){if(cR.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Up)||typeof r=="object"&&Up(r))return!0}return!1}function D0(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!sR.has(r)&&(typeof e[r]=="object"&&(0,nR.eachItem)(e[r],n=>t+=D0(n)),t===1/0))return 1/0}return t}function Z0(e,t="",r){r!==!1&&(t=Lo(t));let n=e.parse(t);return L0(e,n)}Gt.getFullPath=Z0;function L0(e,t){return e.serialize(t).split("#")[0]+"#"}Gt._getFullPath=L0;var lR=/#\/?$/;function Lo(e){return e?e.replace(lR,""):""}Gt.normalizeId=Lo;function uR(e,t,r){return r=Lo(r),e.resolve(t,r)}Gt.resolveUrl=uR;var dR=/^[a-z_][-a-z0-9._]*$/i;function fR(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Lo(e[r]||t),o={"":i},s=Z0(n,i,!1),a={},u=new Set;return oR(e,{allKeys:!0},(d,h,m,p)=>{if(p===void 0)return;let f=s+h,g=o[p];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[h]=g;function y(b){let w=this.opts.uriResolver.resolve;if(b=Lo(g?w(g,b):b),u.has(b))throw l(b);u.add(b);let S=this.refs[b];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,b):b!==Lo(f)&&(b[0]==="#"?(c(d,a[b],b),a[b]=d):this.refs[b]=f),b}function v(b){if(typeof b=="string"){if(!dR.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function c(d,h,m){if(h!==void 0&&!iR(d,h))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Gt.getSchemaRefs=fR});var da=z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.getData=Bn.KeywordCxt=Bn.validateFunctionCode=void 0;var G0=b0(),q0=aa(),Gp=jp(),El=aa(),mR=E0(),ua=C0(),Vp=I0(),L=ne(),Q=gn(),pR=ca(),_n=he(),la=sa();function hR(e){if(W0(e)&&(H0(e),J0(e))){yR(e);return}B0(e,()=>(0,G0.topBoolOrEmptySchema)(e))}Bn.validateFunctionCode=hR;function B0({gen:e,validateName:t,schema:r,schemaEnv:n,opts:i},o){i.code.es5?e.func(t,(0,L._)`${Q.default.data}, ${Q.default.valCxt}`,n.$async,()=>{e.code((0,L._)`"use strict"; ${F0(r,i)}`),_R(e,i),e.code(o)}):e.func(t,(0,L._)`${Q.default.data}, ${gR(i)}`,n.$async,()=>e.code(F0(r,i)).code(o))}function gR(e){return(0,L._)`{${Q.default.instancePath}="", ${Q.default.parentData}, ${Q.default.parentDataProperty}, ${Q.default.rootData}=${Q.default.data}${e.dynamicRef?(0,L._)`, ${Q.default.dynamicAnchors}={}`:L.nil}}={}`}function _R(e,t){e.if(Q.default.valCxt,()=>{e.var(Q.default.instancePath,(0,L._)`${Q.default.valCxt}.${Q.default.instancePath}`),e.var(Q.default.parentData,(0,L._)`${Q.default.valCxt}.${Q.default.parentData}`),e.var(Q.default.parentDataProperty,(0,L._)`${Q.default.valCxt}.${Q.default.parentDataProperty}`),e.var(Q.default.rootData,(0,L._)`${Q.default.valCxt}.${Q.default.rootData}`),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`${Q.default.valCxt}.${Q.default.dynamicAnchors}`)},()=>{e.var(Q.default.instancePath,(0,L._)`""`),e.var(Q.default.parentData,(0,L._)`undefined`),e.var(Q.default.parentDataProperty,(0,L._)`undefined`),e.var(Q.default.rootData,Q.default.data),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`{}`)})}function yR(e){let{schema:t,opts:r,gen:n}=e;B0(e,()=>{r.$comment&&t.$comment&&Q0(e),kR(e),n.let(Q.default.vErrors,null),n.let(Q.default.errors,0),r.unevaluated&&vR(e),K0(e),$R(e)})}function vR(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,L._)`${r}.evaluated`),t.if((0,L._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,L._)`${e.evaluated}.props`,(0,L._)`undefined`)),t.if((0,L._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,L._)`${e.evaluated}.items`,(0,L._)`undefined`))}function F0(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,L._)`/*# sourceURL=${r} */`:L.nil}function bR(e,t){if(W0(e)&&(H0(e),J0(e))){wR(e,t);return}(0,G0.boolOrEmptySchema)(e,t)}function J0({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function W0(e){return typeof e.schema!="boolean"}function wR(e,t){let{schema:r,gen:n,opts:i}=e;i.$comment&&r.$comment&&Q0(e),SR(e),TR(e);let o=n.const("_errs",Q.default.errors);K0(e,o),n.var(t,(0,L._)`${o} === ${Q.default.errors}`)}function H0(e){(0,_n.checkUnknownRules)(e),xR(e)}function K0(e,t){if(e.opts.jtd)return U0(e,[],!1,t);let r=(0,q0.getSchemaTypes)(e.schema),n=(0,q0.coerceAndCheckDataType)(e,r);U0(e,r,!n,t)}function xR(e){let{schema:t,errSchemaPath:r,opts:n,self:i}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,_n.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function kR(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,_n.checkStrictMode)(e,"default is ignored in the schema root")}function SR(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,pR.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function TR(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Q0({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)e.code((0,L._)`${Q.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,L.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,L._)`${Q.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function $R(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=e;r.$async?t.if((0,L._)`${Q.default.errors} === 0`,()=>t.return(Q.default.data),()=>t.throw((0,L._)`new ${i}(${Q.default.vErrors})`)):(t.assign((0,L._)`${n}.errors`,Q.default.vErrors),o.unevaluated&&ER(e),t.return((0,L._)`${Q.default.errors} === 0`))}function ER({gen:e,evaluated:t,props:r,items:n}){r instanceof L.Name&&e.assign((0,L._)`${t}.props`,r),n instanceof L.Name&&e.assign((0,L._)`${t}.items`,n)}function U0(e,t,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0,_n.schemaHasRulesButRef)(o,l))){i.block(()=>Y0(e,"$ref",l.all.$ref.definition));return}u.jtd||zR(e,t),i.block(()=>{for(let h of l.rules)d(h);d(l.post)});function d(h){(0,Gp.shouldUseGroup)(o,h)&&(h.type?(i.if((0,El.checkDataType)(h.type,s,u.strictNumbers)),V0(e,h),t.length===1&&t[0]===h.type&&r&&(i.else(),(0,El.reportTypeError)(e)),i.endIf()):V0(e,h),a||i.if((0,L._)`${Q.default.errors} === ${n||0}`))}}function V0(e,t){let{gen:r,schema:n,opts:{useDefaults:i}}=e;i&&(0,mR.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0,Gp.shouldUseRule)(n,o)&&Y0(e,o.keyword,o.definition,t.type)})}function zR(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(OR(e,t),e.opts.allowUnionTypes||AR(e,t),PR(e,e.dataTypes))}function OR(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{X0(e.dataTypes,r)||Bp(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),RR(e,t)}}function AR(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Bp(e,"use allowUnionTypes to allow union type keyword")}function PR(e,t){let r=e.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Gp.shouldUseRule)(e.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>CR(t,s))&&Bp(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function CR(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function X0(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function RR(e,t){let r=[];for(let n of e.dataTypes)X0(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Bp(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,_n.checkStrictMode)(e,t,e.opts.strictTypes)}var zl=class{constructor(t,r,n){if((0,ua.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,_n.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",ex(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ua.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=t.gen.const("_errs",Q.default.errors))}result(t,r,n){this.failResult((0,L.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,L.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,L._)`${r} !== undefined && (${(0,L.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?la.reportExtraError:la.reportError)(this,this.def.error,r)}$dataError(){(0,la.reportError)(this,this.def.$dataError||la.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,la.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=L.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=L.nil,r=L.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,L.or)((0,L._)`${i} === undefined`,r)),t!==L.nil&&n.assign(t,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==L.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,L.or)(s(),a());function s(){if(n.length){if(!(r instanceof L.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return(0,L._)`${(0,El.checkDataTypes)(u,r,o.opts.strictNumbers,El.DataType.Wrong)}`}return L.nil}function a(){if(i.validateSchema){let u=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,L._)`!${u}(${r})`}return L.nil}}subschema(t,r){let n=(0,Vp.getSubschema)(this.it,t);(0,Vp.extendSubschemaData)(n,this.it,t),(0,Vp.extendSubschemaMode)(n,t);let i={...this.it,...n,items:void 0,props:void 0};return bR(i,r),i}mergeEvaluated(t,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=_n.mergeEvaluated.props(i,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=_n.mergeEvaluated.items(i,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(t,L.Name)),!0}};Bn.KeywordCxt=zl;function Y0(e,t,r,n){let i=new zl(e,r,t);"code"in r?r.code(i,n):i.$data&&r.validate?(0,ua.funcKeywordCode)(i,r):"macro"in r?(0,ua.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,ua.funcKeywordCode)(i,r)}var IR=/^\/(?:[^~]|~0|~1)*$/,jR=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ex(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let i,o;if(e==="")return Q.default.rootData;if(e[0]==="/"){if(!IR.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,o=Q.default.rootData}else{let c=jR.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+c[1];if(i=c[2],i==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!i)return o}let s=o,a=i.split("/");for(let c of a)c&&(o=(0,L._)`${o}${(0,L.getProperty)((0,_n.unescapeJsonPointer)(c))}`,s=(0,L._)`${s} && ${o}`);return s;function u(c,l){return`Cannot access ${c} ${l} levels up, current level is ${t}`}}Bn.getData=ex});var Ol=z(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var Jp=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Wp.default=Jp});var fa=z(Qp=>{"use strict";Object.defineProperty(Qp,"__esModule",{value:!0});var Hp=ca(),Kp=class extends Error{constructor(t,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Hp.resolveUrl)(t,r,n),this.missingSchema=(0,Hp.normalizeId)((0,Hp.getFullPath)(t,this.missingRef))}};Qp.default=Kp});var Pl=z(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.resolveSchema=mr.getCompilingSchema=mr.resolveRef=mr.compileSchema=mr.SchemaEnv=void 0;var $r=ne(),NR=Ol(),Ui=gn(),Er=ca(),tx=he(),MR=da(),qo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,Er.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};mr.SchemaEnv=qo;function Yp(e){let t=rx.call(this,e);if(t)return t;let r=(0,Er.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new $r.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:NR.default,code:(0,$r._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");e.validateName=u;let c={gen:s,allErrors:this.opts.allErrors,data:Ui.default.data,parentData:Ui.default.parentData,parentDataProperty:Ui.default.parentDataProperty,dataNames:[Ui.default.data],dataPathArr:[$r.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,$r.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:$r.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,$r._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,MR.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();l=`${s.scopeRefs(Ui.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let m=new Function(`${Ui.default.self}`,`${Ui.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:m}),m.errors=null,m.schema=e.schema,m.schemaEnv=e,e.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:u,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:p,items:f}=c;m.evaluated={props:p instanceof $r.Name?void 0:p,items:f instanceof $r.Name?void 0:f,dynamicProps:p instanceof $r.Name,dynamicItems:f instanceof $r.Name},m.source&&(m.source.evaluated=(0,$r.stringify)(m.evaluated))}return e.validate=m,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}mr.compileSchema=Yp;function DR(e,t,r){var n;r=(0,Er.resolveUrl)(this.opts.uriResolver,t,r);let i=e.refs[r];if(i)return i;let o=qR.call(this,e,r);if(o===void 0){let s=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new qo({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=ZR.call(this,o)}mr.resolveRef=DR;function ZR(e){return(0,Er.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Yp.call(this,e)}function rx(e){for(let t of this._compilations)if(LR(t,e))return t}mr.getCompilingSchema=rx;function LR(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function qR(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Al.call(this,e,t)}function Al(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Er._getFullPath)(this.opts.uriResolver,r),i=(0,Er.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===i)return Xp.call(this,r,e);let o=(0,Er.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=Al.call(this,e,s);return typeof a?.schema!="object"?void 0:Xp.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||Yp.call(this,s),o===(0,Er.normalizeId)(t)){let{schema:a}=s,{schemaId:u}=this.opts,c=a[u];return c&&(i=(0,Er.resolveUrl)(this.opts.uriResolver,i,c)),new qo({schema:a,schemaId:u,root:e,baseId:i})}return Xp.call(this,r,s)}}mr.resolveSchema=Al;var FR=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Xp(e,{baseId:t,schema:r,root:n}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0,tx.unescapeFragment)(a)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!FR.has(a)&&c&&(t=(0,Er.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,tx.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Er.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Al.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new qo({schema:r,schemaId:s,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var nx=z((cV,UR)=>{UR.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 th=z((lV,ax)=>{"use strict";var VR=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),ox=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);function eh(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var GR=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ix(e){return e.length=0,!0}function BR(e,t,r){if(e.length){let n=eh(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function JR(e){let t=0,r={error:!1,address:"",zone:""},n=[],i=[],o=!1,s=!1,a=BR;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(i,n,r))break;if(++t>7){r.error=!0;break}u>0&&e[u-1]===":"&&(o=!0),n.push(":");continue}else if(c==="%"){if(!a(i,n,r))break;a=ix}else{i.push(c);continue}}return i.length&&(a===ix?r.zone=i.join(""):s?n.push(i.join("")):n.push(eh(i))),r.address=n.join(""),r}function sx(e){if(WR(e,":")<2)return{host:e,isIPV6:!1};let t=JR(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function WR(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function HR(e){let t=e,r=[],n=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(i===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function KR(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function QR(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!ox(r)){let n=sx(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}ax.exports={nonSimpleDomain:GR,recomposeAuthority:QR,normalizeComponentEncoding:KR,removeDotSegments:HR,isIPv4:ox,isUUID:VR,normalizeIPv6:sx,stringArrayToHexStripped:eh}});var fx=z((uV,dx)=>{"use strict";var{isUUID:XR}=th(),YR=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,eI=["http","https","ws","wss","urn","urn:uuid"];function tI(e){return eI.indexOf(e)!==-1}function rh(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function cx(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function lx(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function rI(e){return e.secure=rh(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function nI(e){if((e.port===(rh(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function iI(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(YR);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let i=`${n}:${t.nid||e.nid}`,o=nh(i);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function oI(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),i=`${r}:${t.nid||n}`,o=nh(i);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s}function sI(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!XR(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function aI(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var ux={scheme:"http",domainHost:!0,parse:cx,serialize:lx},cI={scheme:"https",domainHost:ux.domainHost,parse:cx,serialize:lx},Cl={scheme:"ws",domainHost:!0,parse:rI,serialize:nI},lI={scheme:"wss",domainHost:Cl.domainHost,parse:Cl.parse,serialize:Cl.serialize},uI={scheme:"urn",parse:iI,serialize:oI,skipNormalize:!0},dI={scheme:"urn:uuid",parse:sI,serialize:aI,skipNormalize:!0},Rl={http:ux,https:cI,ws:Cl,wss:lI,urn:uI,"urn:uuid":dI};Object.setPrototypeOf(Rl,null);function nh(e){return e&&(Rl[e]||Rl[e.toLowerCase()])||void 0}dx.exports={wsIsSecure:rh,SCHEMES:Rl,isValidSchemeName:tI,getSchemeHandler:nh}});var hx=z((dV,jl)=>{"use strict";var{normalizeIPv6:fI,removeDotSegments:ma,recomposeAuthority:mI,normalizeComponentEncoding:Il,isIPv4:pI,nonSimpleDomain:hI}=th(),{SCHEMES:gI,getSchemeHandler:mx}=fx();function _I(e,t){return typeof e=="string"?e=Jr(yn(e,t),t):typeof e=="object"&&(e=yn(Jr(e,t),t)),e}function yI(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},i=px(yn(e,n),yn(t,n),n,!0);return n.skipEscape=!0,Jr(i,n)}function px(e,t,r,n){let i={};return n||(e=yn(Jr(e,r),r),t=yn(Jr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=ma(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=ma(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=ma(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=ma(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function vI(e,t,r){return typeof e=="string"?(e=unescape(e),e=Jr(Il(yn(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Jr(Il(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=Jr(Il(yn(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Jr(Il(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function Jr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),i=[],o=mx(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let s=mI(r);if(s!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(s),r.path&&r.path[0]!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=ma(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var bI=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function yn(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(bI);if(o){if(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]),n.host)if(pI(n.host)===!1){let u=fI(n.host);n.host=u.host.toLowerCase(),i=u.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 s=mx(r.scheme||n.scheme);if(!r.unicodeSupport&&(!s||!s.unicodeSupport)&&n.host&&(r.domainHost||s&&s.domainHost)&&i===!1&&hI(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!s||s&&!s.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),s&&s.parse&&s.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var ih={SCHEMES:gI,normalize:_I,resolve:yI,resolveComponent:px,equal:vI,serialize:Jr,parse:yn};jl.exports=ih;jl.exports.default=ih;jl.exports.fastUri=ih});var _x=z(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});var gx=hx();gx.code='require("ajv/dist/runtime/uri").default';oh.default=gx});var Tx=z(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.CodeGen=_t.Name=_t.nil=_t.stringify=_t.str=_t._=_t.KeywordCxt=void 0;var wI=da();Object.defineProperty(_t,"KeywordCxt",{enumerable:!0,get:function(){return wI.KeywordCxt}});var Fo=ne();Object.defineProperty(_t,"_",{enumerable:!0,get:function(){return Fo._}});Object.defineProperty(_t,"str",{enumerable:!0,get:function(){return Fo.str}});Object.defineProperty(_t,"stringify",{enumerable:!0,get:function(){return Fo.stringify}});Object.defineProperty(_t,"nil",{enumerable:!0,get:function(){return Fo.nil}});Object.defineProperty(_t,"Name",{enumerable:!0,get:function(){return Fo.Name}});Object.defineProperty(_t,"CodeGen",{enumerable:!0,get:function(){return Fo.CodeGen}});var xI=Ol(),xx=fa(),kI=Ip(),pa=Pl(),SI=ne(),ha=ca(),Nl=aa(),ah=he(),yx=nx(),TI=_x(),kx=(e,t)=>new RegExp(e,t);kx.code="new RegExp";var $I=["removeAdditional","useDefaults","coerceTypes"],EI=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),zI={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."},OI={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},vx=200;function AI(e){var t,r,n,i,o,s,a,u,c,l,d,h,m,p,f,g,y,v,b,w,S,q,K,ce,C;let V=e.strict,H=(t=e.code)===null||t===void 0?void 0:t.optimize,fe=H===!0||H===void 0?1:H||0,ge=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:kx,j=(i=e.uriResolver)!==null&&i!==void 0?i:TI.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:V)!==null&&s!==void 0?s:!0,strictNumbers:(u=(a=e.strictNumbers)!==null&&a!==void 0?a:V)!==null&&u!==void 0?u:!0,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:V)!==null&&l!==void 0?l:"log",strictTuples:(h=(d=e.strictTuples)!==null&&d!==void 0?d:V)!==null&&h!==void 0?h:"log",strictRequired:(p=(m=e.strictRequired)!==null&&m!==void 0?m:V)!==null&&p!==void 0?p:!1,code:e.code?{...e.code,optimize:fe,regExp:ge}:{optimize:fe,regExp:ge},loopRequired:(f=e.loopRequired)!==null&&f!==void 0?f:vx,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:vx,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(q=e.validateSchema)!==null&&q!==void 0?q:!0,validateFormats:(K=e.validateFormats)!==null&&K!==void 0?K:!0,unicodeRegExp:(ce=e.unicodeRegExp)!==null&&ce!==void 0?ce:!0,int32range:(C=e.int32range)!==null&&C!==void 0?C:!0,uriResolver:j}}var ga=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...AI(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new SI.ValueScope({scope:{},prefixes:EI,es5:r,lines:n}),this.logger=NI(t.logger);let i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,kI.getRules)(),bx.call(this,zI,t,"NOT SUPPORTED"),bx.call(this,OI,t,"DEPRECATED","warn"),this._metaOpts=II.call(this),t.formats&&CI.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&RI.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),PI.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,i=yx;n==="id"&&(i={...yx},i.id=i.$id,delete i.$id),r&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,t,r);async function i(l,d){await o.call(this,l.$schema);let h=this._addSchema(l,d);return h.validate||s.call(this,h)}async function o(l){l&&!this.getSchema(l)&&await i.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof xx.default))throw d;return a.call(this,d),await u.call(this,d.missingSchema),s.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 u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,n,i);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,ha.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,i,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$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 i=this.validate(n,t);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(t){let r;for(;typeof(r=wx.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,i=new pa.SchemaEnv({schema:{},schemaId:n});if(r=pa.resolveSchema.call(this,i,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=wx.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,ha.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,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(DI.call(this,n,r),!r)return(0,ah.eachItem)(n,o=>sh.call(this,o)),this;LI.call(this,r);let i={...r,type:(0,Nl.getJSONTypes)(r.type),schemaType:(0,Nl.getJSONTypes)(r.schemaType)};return(0,ah.eachItem)(n,i.type.length===0?o=>sh.call(this,o,i):o=>i.type.forEach(s=>sh.call(this,o,i,s))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===t);i>=0&&n.rules.splice(i,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let i of r){let o=i.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in n){let u=n[a];if(typeof u!="object")continue;let{$data:c}=u.definition,l=s[a];c&&l&&(s[a]=Sx(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let i=t[n];(!r||r.test(n))&&(typeof i=="string"?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0,ha.normalizeId)(s||n);let c=ha.getSchemaRefs.call(this,t,n);return u=new pa.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),i&&this.validateSchema(t,!0),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):pa.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{pa.compileSchema.call(this,t)}finally{this.opts=r}}};ga.ValidationError=xI.default;ga.MissingRefError=xx.default;_t.default=ga;function bx(e,t,r,n="error"){for(let i in e){let o=i;o in t&&this.logger[n](`${r}: option ${i}. ${e[o]}`)}}function wx(e){return e=(0,ha.normalizeId)(e),this.schemas[e]||this.refs[e]}function PI(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function CI(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function RI(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function II(){let e={...this.opts};for(let t of $I)delete e[t];return e}var jI={log(){},warn(){},error(){}};function NI(e){if(e===!1)return jI;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var MI=/^[a-z_$][a-z0-9_$:-]*$/i;function DI(e,t){let{RULES:r}=this;if((0,ah.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!MI.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function sh(e,t,r){var n;let i=t?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:u})=>u===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Nl.getJSONTypes)(t.type),schemaType:(0,Nl.getJSONTypes)(t.schemaType)}};t.before?ZI.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u))}function ZI(e,t,r){let n=e.rules.findIndex(i=>i.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function LI(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Sx(t)),e.validateSchema=this.compile(t,!0))}var qI={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Sx(e){return{anyOf:[e,qI]}}});var $x=z(ch=>{"use strict";Object.defineProperty(ch,"__esModule",{value:!0});var FI={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ch.default=FI});var Ax=z(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.callRef=Vi.getValidate=void 0;var UI=fa(),Ex=fr(),Bt=ne(),Uo=gn(),zx=Pl(),Ml=he(),VI={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&i===c.baseId)return d();let l=zx.resolveRef.call(u,c,i,r);if(l===void 0)throw new UI.default(n.opts.uriResolver,i,r);if(l instanceof zx.SchemaEnv)return h(l);return m(l);function d(){if(o===c)return Dl(e,s,o,o.$async);let p=t.scopeValue("root",{ref:c});return Dl(e,(0,Bt._)`${p}.validate`,c,c.$async)}function h(p){let f=Ox(e,p);Dl(e,f,p,p.$async)}function m(p){let f=t.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,Bt.stringify)(p)}:{ref:p}),g=t.name("valid"),y=e.subschema({schema:p,dataTypes:[],schemaPath:Bt.nil,topSchemaRef:f,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function Ox(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Bt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Vi.getValidate=Ox;function Dl(e,t,r,n){let{gen:i,it:o}=e,{allErrors:s,schemaEnv:a,opts:u}=o,c=u.passContext?Uo.default.this:Bt.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=i.let("valid");i.try(()=>{i.code((0,Bt._)`await ${(0,Ex.callValidateCode)(e,t,c)}`),m(t),s||i.assign(p,!0)},f=>{i.if((0,Bt._)`!(${f} instanceof ${o.ValidationError})`,()=>i.throw(f)),h(f),s||i.assign(p,!1)}),e.ok(p)}function d(){e.result((0,Ex.callValidateCode)(e,t,c),()=>m(t),()=>h(t))}function h(p){let f=(0,Bt._)`${p}.errors`;i.assign(Uo.default.vErrors,(0,Bt._)`${Uo.default.vErrors} === null ? ${f} : ${Uo.default.vErrors}.concat(${f})`),i.assign(Uo.default.errors,(0,Bt._)`${Uo.default.vErrors}.length`)}function m(p){var f;if(!o.opts.unevaluated)return;let g=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Ml.mergeEvaluated.props(i,g.props,o.props));else{let y=i.var("props",(0,Bt._)`${p}.evaluated.props`);o.props=Ml.mergeEvaluated.props(i,y,o.props,Bt.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Ml.mergeEvaluated.items(i,g.items,o.items));else{let y=i.var("items",(0,Bt._)`${p}.evaluated.items`);o.items=Ml.mergeEvaluated.items(i,y,o.items,Bt.Name)}}}Vi.callRef=Dl;Vi.default=VI});var Px=z(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});var GI=$x(),BI=Ax(),JI=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",GI.default,BI.default];lh.default=JI});var Cx=z(uh=>{"use strict";Object.defineProperty(uh,"__esModule",{value:!0});var Zl=ne(),Jn=Zl.operators,Ll={maximum:{okStr:"<=",ok:Jn.LTE,fail:Jn.GT},minimum:{okStr:">=",ok:Jn.GTE,fail:Jn.LT},exclusiveMaximum:{okStr:"<",ok:Jn.LT,fail:Jn.GTE},exclusiveMinimum:{okStr:">",ok:Jn.GT,fail:Jn.LTE}},WI={message:({keyword:e,schemaCode:t})=>(0,Zl.str)`must be ${Ll[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Zl._)`{comparison: ${Ll[e].okStr}, limit: ${t}}`},HI={keyword:Object.keys(Ll),type:"number",schemaType:"number",$data:!0,error:WI,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Zl._)`${r} ${Ll[t].fail} ${n} || isNaN(${r})`)}};uh.default=HI});var Rx=z(dh=>{"use strict";Object.defineProperty(dh,"__esModule",{value:!0});var _a=ne(),KI={message:({schemaCode:e})=>(0,_a.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,_a._)`{multipleOf: ${e}}`},QI={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:KI,code(e){let{gen:t,data:r,schemaCode:n,it:i}=e,o=i.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,_a._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,_a._)`${s} !== parseInt(${s})`;e.fail$data((0,_a._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};dh.default=QI});var jx=z(fh=>{"use strict";Object.defineProperty(fh,"__esModule",{value:!0});function Ix(e){let t=e.length,r=0,n=0,i;for(;n<t;)r++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<t&&(i=e.charCodeAt(n),(i&64512)===56320&&n++);return r}fh.default=Ix;Ix.code='require("ajv/dist/runtime/ucs2length").default'});var Nx=z(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});var Gi=ne(),XI=he(),YI=jx(),ej={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Gi.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Gi._)`{limit: ${e}}`},tj={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ej,code(e){let{keyword:t,data:r,schemaCode:n,it:i}=e,o=t==="maxLength"?Gi.operators.GT:Gi.operators.LT,s=i.opts.unicode===!1?(0,Gi._)`${r}.length`:(0,Gi._)`${(0,XI.useFunc)(e.gen,YI.default)}(${r})`;e.fail$data((0,Gi._)`${s} ${o} ${n}`)}};mh.default=tj});var Mx=z(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});var rj=fr(),ql=ne(),nj={message:({schemaCode:e})=>(0,ql.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,ql._)`{pattern: ${e}}`},ij={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:nj,code(e){let{data:t,$data:r,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"",a=r?(0,ql._)`(new RegExp(${i}, ${s}))`:(0,rj.usePattern)(e,n);e.fail$data((0,ql._)`!${a}.test(${t})`)}};ph.default=ij});var Dx=z(hh=>{"use strict";Object.defineProperty(hh,"__esModule",{value:!0});var ya=ne(),oj={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,ya.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ya._)`{limit: ${e}}`},sj={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:oj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxProperties"?ya.operators.GT:ya.operators.LT;e.fail$data((0,ya._)`Object.keys(${r}).length ${i} ${n}`)}};hh.default=sj});var Zx=z(gh=>{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});var va=fr(),ba=ne(),aj=he(),cj={message:({params:{missingProperty:e}})=>(0,ba.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,ba._)`{missingProperty: ${e}}`},lj={keyword:"required",type:"object",schemaType:"array",$data:!0,error:cj,code(e){let{gen:t,schema:r,schemaCode:n,data:i,$data:o,it:s}=e,{opts:a}=s;if(!o&&r.length===0)return;let u=r.length>=a.loopRequired;if(s.allErrors?c():l(),a.strictRequired){let m=e.parentSchema.properties,{definedProperties:p}=e.it;for(let f of r)if(m?.[f]===void 0&&!p.has(f)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${f}" is not defined at "${g}" (strictRequired)`;(0,aj.checkStrictMode)(s,y,s.opts.strictRequired)}}function c(){if(u||o)e.block$data(ba.nil,d);else for(let m of r)(0,va.checkReportMissingProp)(e,m)}function l(){let m=t.let("missing");if(u||o){let p=t.let("valid",!0);e.block$data(p,()=>h(m,p)),e.ok(p)}else t.if((0,va.checkMissingProp)(e,r,m)),(0,va.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,va.noPropertyInData)(t,i,m,a.ownProperties),()=>e.error())})}function h(m,p){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(p,(0,va.propertyInData)(t,i,m,a.ownProperties)),t.if((0,ba.not)(p),()=>{e.error(),t.break()})},ba.nil)}}};gh.default=lj});var Lx=z(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});var wa=ne(),uj={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,wa.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,wa._)`{limit: ${e}}`},dj={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:uj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxItems"?wa.operators.GT:wa.operators.LT;e.fail$data((0,wa._)`${r}.length ${i} ${n}`)}};_h.default=dj});var Fl=z(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});var qx=Fp();qx.code='require("ajv/dist/runtime/equal").default';yh.default=qx});var Fx=z(bh=>{"use strict";Object.defineProperty(bh,"__esModule",{value:!0});var vh=aa(),yt=ne(),fj=he(),mj=Fl(),pj={message:({params:{i:e,j:t}})=>(0,yt.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,yt._)`{i: ${e}, j: ${t}}`},hj={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:pj,code(e){let{gen:t,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=e;if(!n&&!i)return;let u=t.let("valid"),c=o.items?(0,vh.getSchemaTypes)(o.items):[];e.block$data(u,l,(0,yt._)`${s} === false`),e.ok(u);function l(){let p=t.let("i",(0,yt._)`${r}.length`),f=t.let("j");e.setParams({i:p,j:f}),t.assign(u,!0),t.if((0,yt._)`${p} > 1`,()=>(d()?h:m)(p,f))}function d(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function h(p,f){let g=t.name("item"),y=(0,vh.checkDataTypes)(c,g,a.opts.strictNumbers,vh.DataType.Wrong),v=t.const("indices",(0,yt._)`{}`);t.for((0,yt._)`;${p}--;`,()=>{t.let(g,(0,yt._)`${r}[${p}]`),t.if(y,(0,yt._)`continue`),c.length>1&&t.if((0,yt._)`typeof ${g} == "string"`,(0,yt._)`${g} += "_"`),t.if((0,yt._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(f,(0,yt._)`${v}[${g}]`),e.error(),t.assign(u,!1).break()}).code((0,yt._)`${v}[${g}] = ${p}`)})}function m(p,f){let g=(0,fj.useFunc)(t,mj.default),y=t.name("outer");t.label(y).for((0,yt._)`;${p}--;`,()=>t.for((0,yt._)`${f} = ${p}; ${f}--;`,()=>t.if((0,yt._)`${g}(${r}[${p}], ${r}[${f}])`,()=>{e.error(),t.assign(u,!1).break(y)})))}}};bh.default=hj});var Ux=z(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});var wh=ne(),gj=he(),_j=Fl(),yj={message:"must be equal to constant",params:({schemaCode:e})=>(0,wh._)`{allowedValue: ${e}}`},vj={keyword:"const",$data:!0,error:yj,code(e){let{gen:t,data:r,$data:n,schemaCode:i,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,wh._)`!${(0,gj.useFunc)(t,_j.default)}(${r}, ${i})`):e.fail((0,wh._)`${o} !== ${r}`)}};xh.default=vj});var Vx=z(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var xa=ne(),bj=he(),wj=Fl(),xj={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,xa._)`{allowedValues: ${e}}`},kj={keyword:"enum",schemaType:"array",$data:!0,error:xj,code(e){let{gen:t,data:r,$data:n,schema:i,schemaCode:o,it:s}=e;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,u,c=()=>u??(u=(0,bj.useFunc)(t,wj.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let m=t.const("vSchema",o);l=(0,xa.or)(...i.map((p,f)=>h(m,f)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",o,m=>t.if((0,xa._)`${c()}(${r}, ${m})`,()=>t.assign(l,!0).break()))}function h(m,p){let f=i[p];return typeof f=="object"&&f!==null?(0,xa._)`${c()}(${r}, ${m}[${p}])`:(0,xa._)`${r} === ${f}`}}};kh.default=kj});var Gx=z(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0});var Sj=Cx(),Tj=Rx(),$j=Nx(),Ej=Mx(),zj=Dx(),Oj=Zx(),Aj=Lx(),Pj=Fx(),Cj=Ux(),Rj=Vx(),Ij=[Sj.default,Tj.default,$j.default,Ej.default,zj.default,Oj.default,Aj.default,Pj.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Cj.default,Rj.default];Sh.default=Ij});var $h=z(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.validateAdditionalItems=void 0;var Bi=ne(),Th=he(),jj={message:({params:{len:e}})=>(0,Bi.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Bi._)`{limit: ${e}}`},Nj={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:jj,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Th.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Bx(e,n)}};function Bx(e,t){let{gen:r,schema:n,data:i,keyword:o,it:s}=e;s.items=!0;let a=r.const("len",(0,Bi._)`${i}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Bi._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Th.alwaysValidSchema)(s,n)){let c=r.var("valid",(0,Bi._)`${a} <= ${t.length}`);r.if((0,Bi.not)(c),()=>u(c)),e.ok(c)}function u(c){r.forRange("i",t.length,a,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:Th.Type.Num},c),s.allErrors||r.if((0,Bi.not)(c),()=>r.break())})}}ka.validateAdditionalItems=Bx;ka.default=Nj});var Eh=z(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.validateTuple=void 0;var Jx=ne(),Ul=he(),Mj=fr(),Dj={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Wx(e,"additionalItems",t);r.items=!0,!(0,Ul.alwaysValidSchema)(r,t)&&e.ok((0,Mj.validateArray)(e))}};function Wx(e,t,r=e.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=e;l(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Ul.mergeEvaluated.items(n,r.length,a.items));let u=n.name("valid"),c=n.const("len",(0,Jx._)`${o}.length`);r.forEach((d,h)=>{(0,Ul.alwaysValidSchema)(a,d)||(n.if((0,Jx._)`${c} > ${h}`,()=>e.subschema({keyword:s,schemaProp:h,dataProp:h},u)),e.ok(u))});function l(d){let{opts:h,errSchemaPath:m}=a,p=r.length,f=p===d.minItems&&(p===d.maxItems||d[t]===!1);if(h.strictTuples&&!f){let g=`"${s}" is ${p}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,Ul.checkStrictMode)(a,g,h.strictTuples)}}}Sa.validateTuple=Wx;Sa.default=Dj});var Hx=z(zh=>{"use strict";Object.defineProperty(zh,"__esModule",{value:!0});var Zj=Eh(),Lj={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Zj.validateTuple)(e,"items")};zh.default=Lj});var Qx=z(Oh=>{"use strict";Object.defineProperty(Oh,"__esModule",{value:!0});var Kx=ne(),qj=he(),Fj=fr(),Uj=$h(),Vj={message:({params:{len:e}})=>(0,Kx.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Kx._)`{limit: ${e}}`},Gj={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Vj,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:i}=r;n.items=!0,!(0,qj.alwaysValidSchema)(n,t)&&(i?(0,Uj.validateAdditionalItems)(e,i):e.ok((0,Fj.validateArray)(e)))}};Oh.default=Gj});var Xx=z(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0});var pr=ne(),Vl=he(),Bj={message:({params:{min:e,max:t}})=>t===void 0?(0,pr.str)`must contain at least ${e} valid item(s)`:(0,pr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,pr._)`{minContains: ${e}}`:(0,pr._)`{minContains: ${e}, maxContains: ${t}}`},Jj={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Bj,code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e,s,a,{minContains:u,maxContains:c}=n;o.opts.next?(s=u===void 0?1:u,a=c):s=1;let l=t.const("len",(0,pr._)`${i}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,Vl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,Vl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Vl.alwaysValidSchema)(o,r)){let f=(0,pr._)`${l} >= ${s}`;a!==void 0&&(f=(0,pr._)`${f} && ${l} <= ${a}`),e.pass(f);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?m(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,pr._)`${i}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset());function h(){let f=t.name("_valid"),g=t.let("count",0);m(f,()=>t.if(f,()=>p(g)))}function m(f,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:Vl.Type.Num,compositeRule:!0},f),g()})}function p(f){t.code((0,pr._)`${f}++`),a===void 0?t.if((0,pr._)`${f} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,pr._)`${f} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,pr._)`${f} >= ${s}`,()=>t.assign(d,!0)))}}};Ah.default=Jj});var tk=z(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.validateSchemaDeps=Wr.validatePropertyDeps=Wr.error=void 0;var Ph=ne(),Wj=he(),Ta=fr();Wr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Ph.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Ph._)`{property: ${e},
9
9
  missingProperty: ${n},
10
10
  depsCount: ${t},
11
- deps: ${r}}`};var Vj={keyword:"dependencies",type:"object",schemaType:"object",error:Wr.error,code(e){let[t,r]=Gj(e);Kx(e,t),Qx(e,r)}};function Gj({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let i=Array.isArray(e[n])?t:r;i[n]=e[n]}return[t,r]}function Kx(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let u=(0,Ta.propertyInData)(r,n,s,i.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(u,()=>{for(let c of a)(0,Ta.checkReportMissingProp)(e,c)}):(r.if((0,Ph._)`${u} && (${(0,Ta.checkMissingProp)(e,a,o)})`),(0,Ta.reportMissingProp)(e,o),r.else())}}Wr.validatePropertyDeps=Kx;function Qx(e,t=e.schema){let{gen:r,data:n,keyword:i,it:o}=e,s=r.name("valid");for(let a in t)(0,Uj.alwaysValidSchema)(o,t[a])||(r.if((0,Ta.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let u=e.subschema({keyword:i,schemaProp:a},s);e.mergeValidEvaluated(u,s)},()=>r.var(s,!0)),e.ok(s))}Wr.validateSchemaDeps=Qx;Wr.default=Vj});var ek=E(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});var Yx=ne(),Bj=he(),Jj={message:"property name must be valid",params:({params:e})=>(0,Yx._)`{propertyName: ${e.propertyName}}`},Wj={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Jj,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,Bj.alwaysValidSchema)(i,r))return;let o=t.name("valid");t.forIn("key",n,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,Yx.not)(o),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(o)}};Ch.default=Wj});var Ih=E(Rh=>{"use strict";Object.defineProperty(Rh,"__esModule",{value:!0});var Gl=fr(),Er=ne(),Hj=gn(),Bl=he(),Kj={message:"must NOT have additional properties",params:({params:e})=>(0,Er._)`{additionalProperty: ${e.additionalProperty}}`},Qj={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Kj,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:u}=s;if(s.props=!0,u.removeAdditional!=="all"&&(0,Bl.alwaysValidSchema)(s,r))return;let c=(0,Gl.allSchemaProperties)(n.properties),l=(0,Gl.allSchemaProperties)(n.patternProperties);d(),e.ok((0,Er._)`${o} === ${Hj.default.errors}`);function d(){t.forIn("key",i,g=>{!c.length&&!l.length?p(g):t.if(h(g),()=>p(g))})}function h(g){let y;if(c.length>8){let v=(0,Bl.schemaRefOrVal)(s,n.properties,"properties");y=(0,Gl.isOwnProperty)(t,v,g)}else c.length?y=(0,Er.or)(...c.map(v=>(0,Er._)`${g} === ${v}`)):y=Er.nil;return l.length&&(y=(0,Er.or)(y,...l.map(v=>(0,Er._)`${(0,Gl.usePattern)(e,v)}.test(${g})`))),(0,Er.not)(y)}function m(g){t.code((0,Er._)`delete ${i}[${g}]`)}function p(g){if(u.removeAdditional==="all"||u.removeAdditional&&r===!1){m(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,Bl.alwaysValidSchema)(s,r)){let y=t.name("valid");u.removeAdditional==="failing"?(f(g,y,!1),t.if((0,Er.not)(y),()=>{e.reset(),m(g)})):(f(g,y),a||t.if((0,Er.not)(y),()=>t.break()))}}function f(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Bl.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,y)}}};Rh.default=Qj});var nk=E(Nh=>{"use strict";Object.defineProperty(Nh,"__esModule",{value:!0});var Xj=da(),tk=fr(),jh=he(),rk=Ih(),Yj={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&rk.default.code(new Xj.KeywordCxt(o,rk.default,"additionalProperties"));let s=(0,tk.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=jh.mergeEvaluated.props(t,(0,jh.toHash)(s),o.props));let a=s.filter(d=>!(0,jh.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let u=t.name("valid");for(let d of a)c(d)?l(d):(t.if((0,tk.propertyInData)(t,i,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u)}}};Nh.default=Yj});var ak=E(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});var ik=fr(),Jl=ne(),ok=he(),sk=he(),eN={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:o}=e,{opts:s}=o,a=(0,ik.allSchemaProperties)(r),u=a.filter(f=>(0,ok.alwaysValidSchema)(o,r[f]));if(a.length===0||u.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=t.name("valid");o.props!==!0&&!(o.props instanceof Jl.Name)&&(o.props=(0,sk.evaluatedPropsToName)(t,o.props));let{props:d}=o;h();function h(){for(let f of a)c&&m(f),o.allErrors?p(f):(t.var(l,!0),p(f),t.if(l))}function m(f){for(let g in c)new RegExp(f).test(g)&&(0,ok.checkStrictMode)(o,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function p(f){t.forIn("key",n,g=>{t.if((0,Jl._)`${(0,ik.usePattern)(e,f)}.test(${g})`,()=>{let y=u.includes(f);y||e.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:sk.Type.Str},l),o.opts.unevaluated&&d!==!0?t.assign((0,Jl._)`${d}[${g}]`,!0):!y&&!o.allErrors&&t.if((0,Jl.not)(l),()=>t.break())})})}}};Mh.default=eN});var ck=E(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var tN=he(),rN={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,tN.alwaysValidSchema)(n,r)){e.fail();return}let i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Dh.default=rN});var lk=E(Zh=>{"use strict";Object.defineProperty(Zh,"__esModule",{value:!0});var nN=fr(),iN={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:nN.validateUnion,error:{message:"must match a schema in anyOf"}};Zh.default=iN});var uk=E(Lh=>{"use strict";Object.defineProperty(Lh,"__esModule",{value:!0});var Wl=ne(),oN=he(),sN={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Wl._)`{passingSchemas: ${e.passing}}`},aN={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:sN,code(e){let{gen:t,schema:r,parentSchema:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=t.let("valid",!1),a=t.let("passing",null),u=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((l,d)=>{let h;(0,oN.alwaysValidSchema)(i,l)?t.var(u,!0):h=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},u),d>0&&t.if((0,Wl._)`${u} && ${s}`).assign(s,!1).assign(a,(0,Wl._)`[${a}, ${d}]`).else(),t.if(u,()=>{t.assign(s,!0),t.assign(a,d),h&&e.mergeEvaluated(h,Wl.Name)})})}}};Lh.default=aN});var dk=E(qh=>{"use strict";Object.defineProperty(qh,"__esModule",{value:!0});var cN=he(),lN={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=t.name("valid");r.forEach((o,s)=>{if((0,cN.alwaysValidSchema)(n,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},i);e.ok(i),e.mergeEvaluated(a)})}};qh.default=lN});var pk=E(Fh=>{"use strict";Object.defineProperty(Fh,"__esModule",{value:!0});var Hl=ne(),mk=he(),uN={message:({params:e})=>(0,Hl.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Hl._)`{failingKeyword: ${e.ifClause}}`},dN={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:uN,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,mk.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=fk(n,"then"),o=fk(n,"else");if(!i&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(u(),e.reset(),i&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,c("then",l),c("else",l))}else i?t.if(a,c("then")):t.if((0,Hl.not)(a),c("else"));e.pass(s,()=>e.error(!0));function u(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function c(l,d){return()=>{let h=e.subschema({keyword:l},a);t.assign(s,a),e.mergeValidEvaluated(h,s),d?t.assign(d,(0,Hl._)`${l}`):e.setParams({ifClause:l})}}}};function fk(e,t){let r=e.schema[t];return r!==void 0&&!(0,mk.alwaysValidSchema)(e,r)}Fh.default=dN});var hk=E(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});var fN=he(),mN={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,fN.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Uh.default=mN});var gk=E(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});var pN=$h(),hN=Bx(),gN=zh(),_N=Wx(),yN=Hx(),vN=Xx(),bN=ek(),wN=Ih(),xN=nk(),kN=ak(),SN=ck(),TN=lk(),$N=uk(),zN=dk(),EN=pk(),ON=hk();function AN(e=!1){let t=[SN.default,TN.default,$N.default,zN.default,EN.default,ON.default,bN.default,wN.default,vN.default,xN.default,kN.default];return e?t.push(hN.default,_N.default):t.push(pN.default,gN.default),t.push(yN.default),t}Vh.default=AN});var _k=E(Gh=>{"use strict";Object.defineProperty(Gh,"__esModule",{value:!0});var Xe=ne(),PN={message:({schemaCode:e})=>(0,Xe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Xe._)`{format: ${e}}`},CN={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:PN,code(e,t){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=a;if(!u.validateFormats)return;i?h():m();function h(){let p=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),f=r.const("fDef",(0,Xe._)`${p}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,Xe._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,Xe._)`${f}.type || "string"`).assign(y,(0,Xe._)`${f}.validate`),()=>r.assign(g,(0,Xe._)`"string"`).assign(y,f)),e.fail$data((0,Xe.or)(v(),b()));function v(){return u.strictSchema===!1?Xe.nil:(0,Xe._)`${s} && !${y}`}function b(){let w=l.$async?(0,Xe._)`(${f}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Xe._)`${y}(${n})`,S=(0,Xe._)`(typeof ${y} == "function" ? ${w} : ${y}.test(${n}))`;return(0,Xe._)`${y} && ${y} !== true && ${g} === ${t} && !${S}`}}function m(){let p=d.formats[o];if(!p){v();return}if(p===!0)return;let[f,g,y]=b(p);f===t&&e.pass(w());function v(){if(u.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function b(S){let q=S instanceof RegExp?(0,Xe.regexpCode)(S):u.code.formats?(0,Xe._)`${u.code.formats}${(0,Xe.getProperty)(o)}`:void 0,K=r.scopeValue("formats",{key:o,ref:S,code:q});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,Xe._)`${K}.validate`]:["string",S,K]}function w(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Xe._)`await ${y}(${n})`}return typeof g=="function"?(0,Xe._)`${y}(${n})`:(0,Xe._)`${y}.test(${n})`}}}};Gh.default=CN});var yk=E(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var RN=_k(),IN=[RN.default];Bh.default=IN});var vk=E(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.contentVocabulary=Vo.metadataVocabulary=void 0;Vo.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vo.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var wk=E(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});var jN=Ex(),NN=Fx(),MN=gk(),DN=yk(),bk=vk(),ZN=[jN.default,NN.default,(0,MN.default)(),DN.default,bk.metadataVocabulary,bk.contentVocabulary];Jh.default=ZN});var kk=E(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.DiscrError=void 0;var xk;(function(e){e.Tag="tag",e.Mapping="mapping"})(xk||(Kl.DiscrError=xk={}))});var Tk=E(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});var Go=ne(),Wh=kk(),Sk=Pl(),LN=fa(),qN=he(),FN={message:({params:{discrError:e,tagName:t}})=>e===Wh.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Go._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},UN={keyword:"discriminator",type:"object",schemaType:"object",error:FN,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:o}=e,{oneOf:s}=i;if(!o.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(!s)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",!1),c=t.const("tag",(0,Go._)`${r}${(0,Go.getProperty)(a)}`);t.if((0,Go._)`typeof ${c} == "string"`,()=>l(),()=>e.error(!1,{discrError:Wh.DiscrError.Tag,tag:c,tagName:a})),e.ok(u);function l(){let m=h();t.if(!1);for(let p in m)t.elseIf((0,Go._)`${c} === ${p}`),t.assign(u,d(m[p]));t.else(),e.error(!1,{discrError:Wh.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(m){let p=t.name("valid"),f=e.subschema({keyword:"oneOf",schemaProp:m},p);return e.mergeEvaluated(f,Go.Name),p}function h(){var m;let p={},f=y(i),g=!0;for(let w=0;w<s.length;w++){let S=s[w];if(S?.$ref&&!(0,qN.schemaHasRulesButRef)(S,o.self.RULES)){let K=S.$ref;if(S=Sk.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,K),S instanceof Sk.SchemaEnv&&(S=S.schema),S===void 0)throw new LN.default(o.opts.uriResolver,o.baseId,K)}let q=(m=S?.properties)===null||m===void 0?void 0:m[a];if(typeof q!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||y(S)),v(q,w)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return p;function y({required:w}){return Array.isArray(w)&&w.includes(a)}function v(w,S){if(w.const)b(w.const,S);else if(w.enum)for(let q of w.enum)b(q,S);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(w,S){if(typeof w!="string"||w in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[w]=S}}}};Hh.default=UN});var $k=E((WV,VN)=>{VN.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 Qh=E((Ie,Kh)=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.MissingRefError=Ie.ValidationError=Ie.CodeGen=Ie.Name=Ie.nil=Ie.stringify=Ie.str=Ie._=Ie.KeywordCxt=Ie.Ajv=void 0;var GN=xx(),BN=wk(),JN=Tk(),zk=$k(),WN=["/properties"],Ql="http://json-schema.org/draft-07/schema",Bo=class extends GN.default{_addVocabularies(){super._addVocabularies(),BN.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(JN.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(zk,WN):zk;this.addMetaSchema(t,Ql,!1),this.refs["http://json-schema.org/schema"]=Ql}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ql)?Ql:void 0)}};Ie.Ajv=Bo;Kh.exports=Ie=Bo;Kh.exports.Ajv=Bo;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.default=Bo;var HN=da();Object.defineProperty(Ie,"KeywordCxt",{enumerable:!0,get:function(){return HN.KeywordCxt}});var Jo=ne();Object.defineProperty(Ie,"_",{enumerable:!0,get:function(){return Jo._}});Object.defineProperty(Ie,"str",{enumerable:!0,get:function(){return Jo.str}});Object.defineProperty(Ie,"stringify",{enumerable:!0,get:function(){return Jo.stringify}});Object.defineProperty(Ie,"nil",{enumerable:!0,get:function(){return Jo.nil}});Object.defineProperty(Ie,"Name",{enumerable:!0,get:function(){return Jo.Name}});Object.defineProperty(Ie,"CodeGen",{enumerable:!0,get:function(){return Jo.CodeGen}});var KN=Ol();Object.defineProperty(Ie,"ValidationError",{enumerable:!0,get:function(){return KN.default}});var QN=fa();Object.defineProperty(Ie,"MissingRefError",{enumerable:!0,get:function(){return QN.default}})});var jk=E(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.formatNames=Kr.fastFormats=Kr.fullFormats=void 0;function Hr(e,t){return{validate:e,compare:t}}Kr.fullFormats={date:Hr(Pk,tg),time:Hr(Yh(!0),rg),"date-time":Hr(Ek(!0),Rk),"iso-time":Hr(Yh(),Ck),"iso-date-time":Hr(Ek(),Ik),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:nM,"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:uM,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:iM,int32:{type:"number",validate:aM},int64:{type:"number",validate:cM},float:{type:"number",validate:Ak},double:{type:"number",validate:Ak},password:!0,binary:!0};Kr.fastFormats={...Kr.fullFormats,date:Hr(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,tg),time:Hr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,rg),"date-time":Hr(/^\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,Rk),"iso-time":Hr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Ck),"iso-date-time":Hr(/^\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,Ik),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};Kr.formatNames=Object.keys(Kr.fullFormats);function XN(e){return e%4===0&&(e%100!==0||e%400===0)}var YN=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,eM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Pk(e){let t=YN.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n===2&&XN(r)?29:eM[n])}function tg(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Xh=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Yh(e){return function(r){let n=Xh.exec(r);if(!n)return!1;let i=+n[1],o=+n[2],s=+n[3],a=n[4],u=n[5]==="-"?-1:1,c=+(n[6]||0),l=+(n[7]||0);if(c>23||l>59||e&&!a)return!1;if(i<=23&&o<=59&&s<60)return!0;let d=o-l*u,h=i-c*u-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&s<61}}function rg(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Ck(e,t){if(!(e&&t))return;let r=Xh.exec(e),n=Xh.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var eg=/t|\s/i;function Ek(e){let t=Yh(e);return function(n){let i=n.split(eg);return i.length===2&&Pk(i[0])&&t(i[1])}}function Rk(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Ik(e,t){if(!(e&&t))return;let[r,n]=e.split(eg),[i,o]=t.split(eg),s=tg(r,i);if(s!==void 0)return s||rg(n,o)}var tM=/\/|:/,rM=/^(?:[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 nM(e){return tM.test(e)&&rM.test(e)}var Ok=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function iM(e){return Ok.lastIndex=0,Ok.test(e)}var oM=-(2**31),sM=2**31-1;function aM(e){return Number.isInteger(e)&&e<=sM&&e>=oM}function cM(e){return Number.isInteger(e)}function Ak(){return!0}var lM=/[^\\]\\Z/;function uM(e){if(lM.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Nk=E(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.formatLimitDefinition=void 0;var dM=Qh(),Or=ne(),Wn=Or.operators,Xl={formatMaximum:{okStr:"<=",ok:Wn.LTE,fail:Wn.GT},formatMinimum:{okStr:">=",ok:Wn.GTE,fail:Wn.LT},formatExclusiveMaximum:{okStr:"<",ok:Wn.LT,fail:Wn.GTE},formatExclusiveMinimum:{okStr:">",ok:Wn.GT,fail:Wn.LTE}},fM={message:({keyword:e,schemaCode:t})=>(0,Or.str)`should be ${Xl[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Or._)`{comparison: ${Xl[e].okStr}, limit: ${t}}`};Wo.formatLimitDefinition={keyword:Object.keys(Xl),type:"string",schemaType:"string",$data:!0,error:fM,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:o}=e,{opts:s,self:a}=o;if(!s.validateFormats)return;let u=new dM.KeywordCxt(o,a.RULES.all.format.definition,"format");u.$data?c():l();function c(){let h=t.scopeValue("formats",{ref:a.formats,code:s.code.formats}),m=t.const("fmt",(0,Or._)`${h}[${u.schemaCode}]`);e.fail$data((0,Or.or)((0,Or._)`typeof ${m} != "object"`,(0,Or._)`${m} instanceof RegExp`,(0,Or._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let h=u.schema,m=a.formats[h];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${i}": format "${h}" does not define "compare" function`);let p=t.scopeValue("formats",{key:h,ref:m,code:s.code.formats?(0,Or._)`${s.code.formats}${(0,Or.getProperty)(h)}`:void 0});e.fail$data(d(p))}function d(h){return(0,Or._)`${h}.compare(${r}, ${n}) ${Xl[i].fail} 0`}},dependencies:["format"]};var mM=e=>(e.addKeyword(Wo.formatLimitDefinition),e);Wo.default=mM});var Lk=E(($a,Zk)=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});var Ho=jk(),pM=Nk(),ng=ne(),Mk=new ng.Name("fullFormats"),hM=new ng.Name("fastFormats"),ig=(e,t={keywords:!0})=>{if(Array.isArray(t))return Dk(e,t,Ho.fullFormats,Mk),e;let[r,n]=t.mode==="fast"?[Ho.fastFormats,hM]:[Ho.fullFormats,Mk],i=t.formats||Ho.formatNames;return Dk(e,i,r,n),t.keywords&&(0,pM.default)(e),e};ig.get=(e,t="full")=>{let n=(t==="fast"?Ho.fastFormats:Ho.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function Dk(e,t,r,n){var i,o;(i=(o=e.opts.code).formats)!==null&&i!==void 0||(o.formats=(0,ng._)`require("ajv-formats/dist/formats").${n}`);for(let s of t)e.addFormat(s,r[s])}Zk.exports=$a=ig;Object.defineProperty($a,"__esModule",{value:!0});$a.default=ig});import*as rS from"node:url";import*as be from"node:fs";import*as Aa from"node:crypto";function gr(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Wi(e){if(e!=null)return gr(e)}function ve(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function Cr(e){if(e.RE_EXN_ID==="JsExn")return gr(e._1)}var Oa=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),NM=Oa("stack"),Rr=Oa("message"),MM=Oa("name"),DM=Oa("fileName");function wt(e,t){if(e!==void 0)return gr(t(ve(e)))}function it(e,t){if(e!==void 0)return t(ve(e))}function lt(e,t){return e!==void 0?ve(e):t}var mg=(function(e,t){for(var r in e)t(r)});function Ot(e,t){if(e===t)return!0;let r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;let n=typeof t;if(r==="function"||n==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(n==="number"||n==="bigint"||n==="undefined"||t===null)return!1;let i=e.TAG,o=t.TAG;if(i!==o)return!1;let s=e.length|0,a=t.length|0;if(s===a)if(Array.isArray(e)){let u=0;for(;;){let c=u;if(c===s)return!0;if(!Ot(e[c],t[c]))return!1;u=c+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let u={contents:!0},c=d=>{if(!Object.prototype.hasOwnProperty.call(t,d)){u.contents=!1;return}},l=d=>{if(!Object.prototype.hasOwnProperty.call(e,d)||!Ot(t[d],e[d])){u.contents=!1;return}};return mg(e,c),u.contents&&mg(t,l),u.contents}}else return!1}import*as hg from"node:child_process";function gS(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function X(e){return gS(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var uu={};function pg(e){let t=uu[e];if(t!==void 0){let r=t+1|0;return uu[e]=r,e+("/"+r)}return uu[e]=1,e}function Ve(e){let t=Cr(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=ve(t);return{code:Wi(r.code),message:lt(Rr(r),"unknown error")}}function gg(e,t){return Ot(e.code,t)}function yr(e){try{return{TAG:"Ok",_0:be.readFileSync(e,"utf8")}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function _g(e,t){try{return{TAG:"Ok",_0:(be.writeFileSync(e,t,"utf8"),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Yo(e,t,r){try{return{TAG:"Ok",_0:(be.writeFileSync(e,t,r),void 0)}}catch(n){let i=X(n);return{TAG:"Error",_0:Ve(i)}}}function vr(e){try{return{TAG:"Ok",_0:(be.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Pa(e,t){try{return{TAG:"Ok",_0:(be.chmodSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function yg(e,t){try{return{TAG:"Ok",_0:(be.linkSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function vg(e){try{return{TAG:"Ok",_0:(be.unlinkSync(e),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Ca(e,t){try{return{TAG:"Ok",_0:(be.renameSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Qn(e){try{return{TAG:"Ok",_0:(be.rmSync(e,{force:!0}),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Ra(e){return Aa.createHash("sha256").update(e).digest("hex")}function bg(e){try{return Aa.randomBytes(e).toString("hex")}catch{return""}}function wg(e){try{return{TAG:"Ok",_0:be.readdirSync(e)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function xg(e,t,r,n){try{return{TAG:"Ok",_0:hg.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=X(i);return{TAG:"Error",_0:Ve(o)}}}function es(e){try{return process.stderr.write(e)}catch{return!1}}function du(e,t){return e[t]}function fu(e,t){try{return process.kill(e,t),{TAG:"Ok",_0:void 0}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Hi(e){try{return gr(new URL(e))}catch{return}}function Xr(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=X(r),i=Cr(n);return{TAG:"Error",_0:i!==void 0?lt(Rr(ve(i)),"unknown error"):"unknown error"}}}var et={};et["api-url"]="ValueKind";et.token="ValueKind";et["auth-file"]="ValueKind";et["delegation-auth-file"]="ValueKind";et.workspace="ValueKind";et.channel="ValueKind";et["owner-username"]="ValueKind";et.mode="ValueKind";et.cwd="ValueKind";et["thread-id"]="ValueKind";et.format="ValueKind";et.command="ValueKind";et["tool-scope"]="ValueKind";et["agent-session"]="BooleanKind";et["ask-user-question-tool"]="BooleanKind";et["multi-agent-jobs"]="BooleanKind";et["include-token"]="BooleanKind";et.help="BooleanKind";function Ia(e){let t={},r,n=0;for(;r===void 0&&n<e.length;){let o=e[n];if(o!==void 0)if(o.startsWith("--")){let s=o.slice(2),a=et[s];if(a!==void 0)if(a==="ValueKind"){let u=e[n+1|0];u!==void 0?u.startsWith("--")?r="--"+s+" requires a value":(t[s]={TAG:"ValueFlag",_0:u},n=n+2|0):r="--"+s+" requires a value"}else t[s]="BoolFlag",n=n+1|0;else r="unsupported option --"+s}else r="unexpected argument "+o;else n=n+1|0}let i=r;return i!==void 0?{TAG:"Error",_0:i}:{TAG:"Ok",_0:t}}function We(e,t){let r=e[t];if(r===void 0||typeof r!="object")return;let n=r._0;if(n.trim()!=="")return n}function Ki(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function ja(e,t){let r=We(e,t);return r!==void 0?{TAG:"Ok",_0:r}:{TAG:"Error",_0:"--"+t+" is required"}}function Na(e){if(e===void 0)return{TAG:"Ok",_0:"Text"};switch(e){case"text":return{TAG:"Ok",_0:"Text"};case"voice":return{TAG:"Ok",_0:"Voice"};default:return{TAG:"Error",_0:"--mode must be voice or text"}}}function mu(e){if(e===void 0)return{TAG:"Ok",_0:"All"};switch(e){case"all":return{TAG:"Ok",_0:"All"};case"coding":return{TAG:"Ok",_0:"Coding"};case"onboarding-discovery":return{TAG:"Ok",_0:"OnboardingDiscovery"};default:return{TAG:"Error",_0:"--tool-scope must be all, coding, or onboarding-discovery"}}}function kg(e){return e[0]==="mcp"?e.slice(1):e}function Ma(){return`Linzumi MCP
11
+ deps: ${r}}`};var Hj={keyword:"dependencies",type:"object",schemaType:"object",error:Wr.error,code(e){let[t,r]=Kj(e);Yx(e,t),ek(e,r)}};function Kj({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let i=Array.isArray(e[n])?t:r;i[n]=e[n]}return[t,r]}function Yx(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let u=(0,Ta.propertyInData)(r,n,s,i.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(u,()=>{for(let c of a)(0,Ta.checkReportMissingProp)(e,c)}):(r.if((0,Ph._)`${u} && (${(0,Ta.checkMissingProp)(e,a,o)})`),(0,Ta.reportMissingProp)(e,o),r.else())}}Wr.validatePropertyDeps=Yx;function ek(e,t=e.schema){let{gen:r,data:n,keyword:i,it:o}=e,s=r.name("valid");for(let a in t)(0,Wj.alwaysValidSchema)(o,t[a])||(r.if((0,Ta.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let u=e.subschema({keyword:i,schemaProp:a},s);e.mergeValidEvaluated(u,s)},()=>r.var(s,!0)),e.ok(s))}Wr.validateSchemaDeps=ek;Wr.default=Hj});var nk=z(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});var rk=ne(),Qj=he(),Xj={message:"property name must be valid",params:({params:e})=>(0,rk._)`{propertyName: ${e.propertyName}}`},Yj={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Xj,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,Qj.alwaysValidSchema)(i,r))return;let o=t.name("valid");t.forIn("key",n,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,rk.not)(o),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(o)}};Ch.default=Yj});var Ih=z(Rh=>{"use strict";Object.defineProperty(Rh,"__esModule",{value:!0});var Gl=fr(),zr=ne(),eN=gn(),Bl=he(),tN={message:"must NOT have additional properties",params:({params:e})=>(0,zr._)`{additionalProperty: ${e.additionalProperty}}`},rN={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:tN,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:u}=s;if(s.props=!0,u.removeAdditional!=="all"&&(0,Bl.alwaysValidSchema)(s,r))return;let c=(0,Gl.allSchemaProperties)(n.properties),l=(0,Gl.allSchemaProperties)(n.patternProperties);d(),e.ok((0,zr._)`${o} === ${eN.default.errors}`);function d(){t.forIn("key",i,g=>{!c.length&&!l.length?p(g):t.if(h(g),()=>p(g))})}function h(g){let y;if(c.length>8){let v=(0,Bl.schemaRefOrVal)(s,n.properties,"properties");y=(0,Gl.isOwnProperty)(t,v,g)}else c.length?y=(0,zr.or)(...c.map(v=>(0,zr._)`${g} === ${v}`)):y=zr.nil;return l.length&&(y=(0,zr.or)(y,...l.map(v=>(0,zr._)`${(0,Gl.usePattern)(e,v)}.test(${g})`))),(0,zr.not)(y)}function m(g){t.code((0,zr._)`delete ${i}[${g}]`)}function p(g){if(u.removeAdditional==="all"||u.removeAdditional&&r===!1){m(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,Bl.alwaysValidSchema)(s,r)){let y=t.name("valid");u.removeAdditional==="failing"?(f(g,y,!1),t.if((0,zr.not)(y),()=>{e.reset(),m(g)})):(f(g,y),a||t.if((0,zr.not)(y),()=>t.break()))}}function f(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Bl.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,y)}}};Rh.default=rN});var sk=z(Nh=>{"use strict";Object.defineProperty(Nh,"__esModule",{value:!0});var nN=da(),ik=fr(),jh=he(),ok=Ih(),iN={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ok.default.code(new nN.KeywordCxt(o,ok.default,"additionalProperties"));let s=(0,ik.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=jh.mergeEvaluated.props(t,(0,jh.toHash)(s),o.props));let a=s.filter(d=>!(0,jh.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let u=t.name("valid");for(let d of a)c(d)?l(d):(t.if((0,ik.propertyInData)(t,i,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u)}}};Nh.default=iN});var uk=z(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});var ak=fr(),Jl=ne(),ck=he(),lk=he(),oN={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:o}=e,{opts:s}=o,a=(0,ak.allSchemaProperties)(r),u=a.filter(f=>(0,ck.alwaysValidSchema)(o,r[f]));if(a.length===0||u.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=t.name("valid");o.props!==!0&&!(o.props instanceof Jl.Name)&&(o.props=(0,lk.evaluatedPropsToName)(t,o.props));let{props:d}=o;h();function h(){for(let f of a)c&&m(f),o.allErrors?p(f):(t.var(l,!0),p(f),t.if(l))}function m(f){for(let g in c)new RegExp(f).test(g)&&(0,ck.checkStrictMode)(o,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function p(f){t.forIn("key",n,g=>{t.if((0,Jl._)`${(0,ak.usePattern)(e,f)}.test(${g})`,()=>{let y=u.includes(f);y||e.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:lk.Type.Str},l),o.opts.unevaluated&&d!==!0?t.assign((0,Jl._)`${d}[${g}]`,!0):!y&&!o.allErrors&&t.if((0,Jl.not)(l),()=>t.break())})})}}};Mh.default=oN});var dk=z(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var sN=he(),aN={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,sN.alwaysValidSchema)(n,r)){e.fail();return}let i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Dh.default=aN});var fk=z(Zh=>{"use strict";Object.defineProperty(Zh,"__esModule",{value:!0});var cN=fr(),lN={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:cN.validateUnion,error:{message:"must match a schema in anyOf"}};Zh.default=lN});var mk=z(Lh=>{"use strict";Object.defineProperty(Lh,"__esModule",{value:!0});var Wl=ne(),uN=he(),dN={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Wl._)`{passingSchemas: ${e.passing}}`},fN={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:dN,code(e){let{gen:t,schema:r,parentSchema:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=t.let("valid",!1),a=t.let("passing",null),u=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((l,d)=>{let h;(0,uN.alwaysValidSchema)(i,l)?t.var(u,!0):h=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},u),d>0&&t.if((0,Wl._)`${u} && ${s}`).assign(s,!1).assign(a,(0,Wl._)`[${a}, ${d}]`).else(),t.if(u,()=>{t.assign(s,!0),t.assign(a,d),h&&e.mergeEvaluated(h,Wl.Name)})})}}};Lh.default=fN});var pk=z(qh=>{"use strict";Object.defineProperty(qh,"__esModule",{value:!0});var mN=he(),pN={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=t.name("valid");r.forEach((o,s)=>{if((0,mN.alwaysValidSchema)(n,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},i);e.ok(i),e.mergeEvaluated(a)})}};qh.default=pN});var _k=z(Fh=>{"use strict";Object.defineProperty(Fh,"__esModule",{value:!0});var Hl=ne(),gk=he(),hN={message:({params:e})=>(0,Hl.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Hl._)`{failingKeyword: ${e.ifClause}}`},gN={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:hN,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,gk.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=hk(n,"then"),o=hk(n,"else");if(!i&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(u(),e.reset(),i&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,c("then",l),c("else",l))}else i?t.if(a,c("then")):t.if((0,Hl.not)(a),c("else"));e.pass(s,()=>e.error(!0));function u(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function c(l,d){return()=>{let h=e.subschema({keyword:l},a);t.assign(s,a),e.mergeValidEvaluated(h,s),d?t.assign(d,(0,Hl._)`${l}`):e.setParams({ifClause:l})}}}};function hk(e,t){let r=e.schema[t];return r!==void 0&&!(0,gk.alwaysValidSchema)(e,r)}Fh.default=gN});var yk=z(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});var _N=he(),yN={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,_N.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Uh.default=yN});var vk=z(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});var vN=$h(),bN=Hx(),wN=Eh(),xN=Qx(),kN=Xx(),SN=tk(),TN=nk(),$N=Ih(),EN=sk(),zN=uk(),ON=dk(),AN=fk(),PN=mk(),CN=pk(),RN=_k(),IN=yk();function jN(e=!1){let t=[ON.default,AN.default,PN.default,CN.default,RN.default,IN.default,TN.default,$N.default,SN.default,EN.default,zN.default];return e?t.push(bN.default,xN.default):t.push(vN.default,wN.default),t.push(kN.default),t}Vh.default=jN});var bk=z(Gh=>{"use strict";Object.defineProperty(Gh,"__esModule",{value:!0});var Xe=ne(),NN={message:({schemaCode:e})=>(0,Xe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Xe._)`{format: ${e}}`},MN={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:NN,code(e,t){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=a;if(!u.validateFormats)return;i?h():m();function h(){let p=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),f=r.const("fDef",(0,Xe._)`${p}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,Xe._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,Xe._)`${f}.type || "string"`).assign(y,(0,Xe._)`${f}.validate`),()=>r.assign(g,(0,Xe._)`"string"`).assign(y,f)),e.fail$data((0,Xe.or)(v(),b()));function v(){return u.strictSchema===!1?Xe.nil:(0,Xe._)`${s} && !${y}`}function b(){let w=l.$async?(0,Xe._)`(${f}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Xe._)`${y}(${n})`,S=(0,Xe._)`(typeof ${y} == "function" ? ${w} : ${y}.test(${n}))`;return(0,Xe._)`${y} && ${y} !== true && ${g} === ${t} && !${S}`}}function m(){let p=d.formats[o];if(!p){v();return}if(p===!0)return;let[f,g,y]=b(p);f===t&&e.pass(w());function v(){if(u.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function b(S){let q=S instanceof RegExp?(0,Xe.regexpCode)(S):u.code.formats?(0,Xe._)`${u.code.formats}${(0,Xe.getProperty)(o)}`:void 0,K=r.scopeValue("formats",{key:o,ref:S,code:q});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,Xe._)`${K}.validate`]:["string",S,K]}function w(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Xe._)`await ${y}(${n})`}return typeof g=="function"?(0,Xe._)`${y}(${n})`:(0,Xe._)`${y}.test(${n})`}}}};Gh.default=MN});var wk=z(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var DN=bk(),ZN=[DN.default];Bh.default=ZN});var xk=z(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.contentVocabulary=Vo.metadataVocabulary=void 0;Vo.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vo.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Sk=z(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});var LN=Px(),qN=Gx(),FN=vk(),UN=wk(),kk=xk(),VN=[LN.default,qN.default,(0,FN.default)(),UN.default,kk.metadataVocabulary,kk.contentVocabulary];Jh.default=VN});var $k=z(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.DiscrError=void 0;var Tk;(function(e){e.Tag="tag",e.Mapping="mapping"})(Tk||(Kl.DiscrError=Tk={}))});var zk=z(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});var Go=ne(),Wh=$k(),Ek=Pl(),GN=fa(),BN=he(),JN={message:({params:{discrError:e,tagName:t}})=>e===Wh.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Go._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},WN={keyword:"discriminator",type:"object",schemaType:"object",error:JN,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:o}=e,{oneOf:s}=i;if(!o.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(!s)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",!1),c=t.const("tag",(0,Go._)`${r}${(0,Go.getProperty)(a)}`);t.if((0,Go._)`typeof ${c} == "string"`,()=>l(),()=>e.error(!1,{discrError:Wh.DiscrError.Tag,tag:c,tagName:a})),e.ok(u);function l(){let m=h();t.if(!1);for(let p in m)t.elseIf((0,Go._)`${c} === ${p}`),t.assign(u,d(m[p]));t.else(),e.error(!1,{discrError:Wh.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(m){let p=t.name("valid"),f=e.subschema({keyword:"oneOf",schemaProp:m},p);return e.mergeEvaluated(f,Go.Name),p}function h(){var m;let p={},f=y(i),g=!0;for(let w=0;w<s.length;w++){let S=s[w];if(S?.$ref&&!(0,BN.schemaHasRulesButRef)(S,o.self.RULES)){let K=S.$ref;if(S=Ek.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,K),S instanceof Ek.SchemaEnv&&(S=S.schema),S===void 0)throw new GN.default(o.opts.uriResolver,o.baseId,K)}let q=(m=S?.properties)===null||m===void 0?void 0:m[a];if(typeof q!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||y(S)),v(q,w)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return p;function y({required:w}){return Array.isArray(w)&&w.includes(a)}function v(w,S){if(w.const)b(w.const,S);else if(w.enum)for(let q of w.enum)b(q,S);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(w,S){if(typeof w!="string"||w in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[w]=S}}}};Hh.default=WN});var Ok=z((YV,HN)=>{HN.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 Qh=z((Ie,Kh)=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.MissingRefError=Ie.ValidationError=Ie.CodeGen=Ie.Name=Ie.nil=Ie.stringify=Ie.str=Ie._=Ie.KeywordCxt=Ie.Ajv=void 0;var KN=Tx(),QN=Sk(),XN=zk(),Ak=Ok(),YN=["/properties"],Ql="http://json-schema.org/draft-07/schema",Bo=class extends KN.default{_addVocabularies(){super._addVocabularies(),QN.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(XN.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Ak,YN):Ak;this.addMetaSchema(t,Ql,!1),this.refs["http://json-schema.org/schema"]=Ql}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ql)?Ql:void 0)}};Ie.Ajv=Bo;Kh.exports=Ie=Bo;Kh.exports.Ajv=Bo;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.default=Bo;var eM=da();Object.defineProperty(Ie,"KeywordCxt",{enumerable:!0,get:function(){return eM.KeywordCxt}});var Jo=ne();Object.defineProperty(Ie,"_",{enumerable:!0,get:function(){return Jo._}});Object.defineProperty(Ie,"str",{enumerable:!0,get:function(){return Jo.str}});Object.defineProperty(Ie,"stringify",{enumerable:!0,get:function(){return Jo.stringify}});Object.defineProperty(Ie,"nil",{enumerable:!0,get:function(){return Jo.nil}});Object.defineProperty(Ie,"Name",{enumerable:!0,get:function(){return Jo.Name}});Object.defineProperty(Ie,"CodeGen",{enumerable:!0,get:function(){return Jo.CodeGen}});var tM=Ol();Object.defineProperty(Ie,"ValidationError",{enumerable:!0,get:function(){return tM.default}});var rM=fa();Object.defineProperty(Ie,"MissingRefError",{enumerable:!0,get:function(){return rM.default}})});var Dk=z(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.formatNames=Kr.fastFormats=Kr.fullFormats=void 0;function Hr(e,t){return{validate:e,compare:t}}Kr.fullFormats={date:Hr(Ik,tg),time:Hr(Yh(!0),rg),"date-time":Hr(Pk(!0),Nk),"iso-time":Hr(Yh(),jk),"iso-date-time":Hr(Pk(),Mk),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:cM,"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:hM,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:lM,int32:{type:"number",validate:fM},int64:{type:"number",validate:mM},float:{type:"number",validate:Rk},double:{type:"number",validate:Rk},password:!0,binary:!0};Kr.fastFormats={...Kr.fullFormats,date:Hr(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,tg),time:Hr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,rg),"date-time":Hr(/^\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,Nk),"iso-time":Hr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,jk),"iso-date-time":Hr(/^\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,Mk),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};Kr.formatNames=Object.keys(Kr.fullFormats);function nM(e){return e%4===0&&(e%100!==0||e%400===0)}var iM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,oM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Ik(e){let t=iM.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n===2&&nM(r)?29:oM[n])}function tg(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Xh=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Yh(e){return function(r){let n=Xh.exec(r);if(!n)return!1;let i=+n[1],o=+n[2],s=+n[3],a=n[4],u=n[5]==="-"?-1:1,c=+(n[6]||0),l=+(n[7]||0);if(c>23||l>59||e&&!a)return!1;if(i<=23&&o<=59&&s<60)return!0;let d=o-l*u,h=i-c*u-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&s<61}}function rg(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function jk(e,t){if(!(e&&t))return;let r=Xh.exec(e),n=Xh.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var eg=/t|\s/i;function Pk(e){let t=Yh(e);return function(n){let i=n.split(eg);return i.length===2&&Ik(i[0])&&t(i[1])}}function Nk(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Mk(e,t){if(!(e&&t))return;let[r,n]=e.split(eg),[i,o]=t.split(eg),s=tg(r,i);if(s!==void 0)return s||rg(n,o)}var sM=/\/|:/,aM=/^(?:[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 cM(e){return sM.test(e)&&aM.test(e)}var Ck=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function lM(e){return Ck.lastIndex=0,Ck.test(e)}var uM=-(2**31),dM=2**31-1;function fM(e){return Number.isInteger(e)&&e<=dM&&e>=uM}function mM(e){return Number.isInteger(e)}function Rk(){return!0}var pM=/[^\\]\\Z/;function hM(e){if(pM.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Zk=z(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.formatLimitDefinition=void 0;var gM=Qh(),Or=ne(),Wn=Or.operators,Xl={formatMaximum:{okStr:"<=",ok:Wn.LTE,fail:Wn.GT},formatMinimum:{okStr:">=",ok:Wn.GTE,fail:Wn.LT},formatExclusiveMaximum:{okStr:"<",ok:Wn.LT,fail:Wn.GTE},formatExclusiveMinimum:{okStr:">",ok:Wn.GT,fail:Wn.LTE}},_M={message:({keyword:e,schemaCode:t})=>(0,Or.str)`should be ${Xl[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Or._)`{comparison: ${Xl[e].okStr}, limit: ${t}}`};Wo.formatLimitDefinition={keyword:Object.keys(Xl),type:"string",schemaType:"string",$data:!0,error:_M,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:o}=e,{opts:s,self:a}=o;if(!s.validateFormats)return;let u=new gM.KeywordCxt(o,a.RULES.all.format.definition,"format");u.$data?c():l();function c(){let h=t.scopeValue("formats",{ref:a.formats,code:s.code.formats}),m=t.const("fmt",(0,Or._)`${h}[${u.schemaCode}]`);e.fail$data((0,Or.or)((0,Or._)`typeof ${m} != "object"`,(0,Or._)`${m} instanceof RegExp`,(0,Or._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let h=u.schema,m=a.formats[h];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${i}": format "${h}" does not define "compare" function`);let p=t.scopeValue("formats",{key:h,ref:m,code:s.code.formats?(0,Or._)`${s.code.formats}${(0,Or.getProperty)(h)}`:void 0});e.fail$data(d(p))}function d(h){return(0,Or._)`${h}.compare(${r}, ${n}) ${Xl[i].fail} 0`}},dependencies:["format"]};var yM=e=>(e.addKeyword(Wo.formatLimitDefinition),e);Wo.default=yM});var Uk=z(($a,Fk)=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});var Ho=Dk(),vM=Zk(),ng=ne(),Lk=new ng.Name("fullFormats"),bM=new ng.Name("fastFormats"),ig=(e,t={keywords:!0})=>{if(Array.isArray(t))return qk(e,t,Ho.fullFormats,Lk),e;let[r,n]=t.mode==="fast"?[Ho.fastFormats,bM]:[Ho.fullFormats,Lk],i=t.formats||Ho.formatNames;return qk(e,i,r,n),t.keywords&&(0,vM.default)(e),e};ig.get=(e,t="full")=>{let n=(t==="fast"?Ho.fastFormats:Ho.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function qk(e,t,r,n){var i,o;(i=(o=e.opts.code).formats)!==null&&i!==void 0||(o.formats=(0,ng._)`require("ajv-formats/dist/formats").${n}`);for(let s of t)e.addFormat(s,r[s])}Fk.exports=$a=ig;Object.defineProperty($a,"__esModule",{value:!0});$a.default=ig});import*as oS from"node:url";import*as be from"node:fs";import*as Aa from"node:crypto";function gr(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Wi(e){if(e!=null)return gr(e)}function ve(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function Cr(e){if(e.RE_EXN_ID==="JsExn")return gr(e._1)}var Oa=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),qM=Oa("stack"),Rr=Oa("message"),FM=Oa("name"),UM=Oa("fileName");function wt(e,t){if(e!==void 0)return gr(t(ve(e)))}function it(e,t){if(e!==void 0)return t(ve(e))}function lt(e,t){return e!==void 0?ve(e):t}var mg=(function(e,t){for(var r in e)t(r)});function Ot(e,t){if(e===t)return!0;let r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;let n=typeof t;if(r==="function"||n==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(n==="number"||n==="bigint"||n==="undefined"||t===null)return!1;let i=e.TAG,o=t.TAG;if(i!==o)return!1;let s=e.length|0,a=t.length|0;if(s===a)if(Array.isArray(e)){let u=0;for(;;){let c=u;if(c===s)return!0;if(!Ot(e[c],t[c]))return!1;u=c+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let u={contents:!0},c=d=>{if(!Object.prototype.hasOwnProperty.call(t,d)){u.contents=!1;return}},l=d=>{if(!Object.prototype.hasOwnProperty.call(e,d)||!Ot(t[d],e[d])){u.contents=!1;return}};return mg(e,c),u.contents&&mg(t,l),u.contents}}else return!1}import*as hg from"node:child_process";function vS(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function X(e){return vS(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var uu={};function pg(e){let t=uu[e];if(t!==void 0){let r=t+1|0;return uu[e]=r,e+("/"+r)}return uu[e]=1,e}function Ve(e){let t=Cr(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=ve(t);return{code:Wi(r.code),message:lt(Rr(r),"unknown error")}}function gg(e,t){return Ot(e.code,t)}function yr(e){try{return{TAG:"Ok",_0:be.readFileSync(e,"utf8")}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function _g(e,t){try{return{TAG:"Ok",_0:(be.writeFileSync(e,t,"utf8"),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Yo(e,t,r){try{return{TAG:"Ok",_0:(be.writeFileSync(e,t,r),void 0)}}catch(n){let i=X(n);return{TAG:"Error",_0:Ve(i)}}}function vr(e){try{return{TAG:"Ok",_0:(be.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Pa(e,t){try{return{TAG:"Ok",_0:(be.chmodSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function yg(e,t){try{return{TAG:"Ok",_0:(be.linkSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function vg(e){try{return{TAG:"Ok",_0:(be.unlinkSync(e),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Ca(e,t){try{return{TAG:"Ok",_0:(be.renameSync(e,t),void 0)}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Qn(e){try{return{TAG:"Ok",_0:(be.rmSync(e,{force:!0}),void 0)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function Ra(e){return Aa.createHash("sha256").update(e).digest("hex")}function bg(e){try{return Aa.randomBytes(e).toString("hex")}catch{return""}}function wg(e){try{return{TAG:"Ok",_0:be.readdirSync(e)}}catch(t){let r=X(t);return{TAG:"Error",_0:Ve(r)}}}function xg(e,t,r,n){try{return{TAG:"Ok",_0:hg.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=X(i);return{TAG:"Error",_0:Ve(o)}}}function es(e){try{return process.stderr.write(e)}catch{return!1}}function du(e,t){return e[t]}function fu(e,t){try{return process.kill(e,t),{TAG:"Ok",_0:void 0}}catch(r){let n=X(r);return{TAG:"Error",_0:Ve(n)}}}function Hi(e){try{return gr(new URL(e))}catch{return}}function Xr(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=X(r),i=Cr(n);return{TAG:"Error",_0:i!==void 0?lt(Rr(ve(i)),"unknown error"):"unknown error"}}}var et={};et["api-url"]="ValueKind";et.token="ValueKind";et["auth-file"]="ValueKind";et["delegation-auth-file"]="ValueKind";et.workspace="ValueKind";et.channel="ValueKind";et["owner-username"]="ValueKind";et.mode="ValueKind";et.cwd="ValueKind";et["thread-id"]="ValueKind";et.format="ValueKind";et.command="ValueKind";et["tool-scope"]="ValueKind";et["agent-session"]="BooleanKind";et["ask-user-question-tool"]="BooleanKind";et["multi-agent-jobs"]="BooleanKind";et["include-token"]="BooleanKind";et.help="BooleanKind";function Ia(e){let t={},r,n=0;for(;r===void 0&&n<e.length;){let o=e[n];if(o!==void 0)if(o.startsWith("--")){let s=o.slice(2),a=et[s];if(a!==void 0)if(a==="ValueKind"){let u=e[n+1|0];u!==void 0?u.startsWith("--")?r="--"+s+" requires a value":(t[s]={TAG:"ValueFlag",_0:u},n=n+2|0):r="--"+s+" requires a value"}else t[s]="BoolFlag",n=n+1|0;else r="unsupported option --"+s}else r="unexpected argument "+o;else n=n+1|0}let i=r;return i!==void 0?{TAG:"Error",_0:i}:{TAG:"Ok",_0:t}}function We(e,t){let r=e[t];if(r===void 0||typeof r!="object")return;let n=r._0;if(n.trim()!=="")return n}function Ki(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function ja(e,t){let r=We(e,t);return r!==void 0?{TAG:"Ok",_0:r}:{TAG:"Error",_0:"--"+t+" is required"}}function Na(e){if(e===void 0)return{TAG:"Ok",_0:"Text"};switch(e){case"text":return{TAG:"Ok",_0:"Text"};case"voice":return{TAG:"Ok",_0:"Voice"};default:return{TAG:"Error",_0:"--mode must be voice or text"}}}function mu(e){if(e===void 0)return{TAG:"Ok",_0:"All"};switch(e){case"all":return{TAG:"Ok",_0:"All"};case"coding":return{TAG:"Ok",_0:"Coding"};case"onboarding-discovery":return{TAG:"Ok",_0:"OnboardingDiscovery"};default:return{TAG:"Error",_0:"--tool-scope must be all, coding, or onboarding-discovery"}}}function kg(e){return e[0]==="mcp"?e.slice(1):e}function Ma(){return`Linzumi MCP
12
12
 
13
13
  Usage:
14
14
  linzumi mcp server --api-url <url> [--mode voice|text] [--workspace <slug> --channel <slug>]
@@ -102,14 +102,14 @@ Tools:
102
102
  Auth:
103
103
  Uses --token, LINZUMI_MCP_ACCESS_TOKEN, or cached local runner OAuth from linzumi auth.
104
104
  Hosted personal agents use --delegation-auth-file with a signed delegation grant.
105
- `}function Tg(e){throw e}function $g(e){throw e}function pu(e){throw e}function Ge(e){throw new Error(e)}function Yr(e){let t=Cr(e);if(t===void 0)return"unknown error";let r=ve(t);return lt(Rr(r),String(r))}function _S(e,t){return fetch(e,t)}function yS(e,t){return fetch(e,t)}var Da={json:_S,binary:yS};function zg(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength|0)}function Za(e){return new Promise((t,r)=>{setTimeout(()=>t(),e)})}function hu(e){process.exitCode=e}function Xn(e){process.stdout.write(e)}function tt(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function Y(e,t){return e.TAG==="Ok"?t(e._0):e}function ke(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}function Og(e,t,r){return e.reduce(r,t)}function Ht(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let s=e[o],a=t(s);a!==void 0&&(n[i]=ve(a),i=i+1|0)}return n.length=i,n}var Rg={},Qa=[],xS=(e=>({...e}));function no(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
106
- `:return JSON.stringify(e);default:t=r+1|0;continue}}}function kS(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function SS(e){return"["+no(e)+"]"}function TS(e){let t=e.length;return t!==1?t!==0?e.map(SS).join(""):"":"["+no(e[0])+"]"}var xu="sury",ku=Symbol(xu),Su=Symbol(xu+":item"),Yi="string",Sn="number",$S="bigint",zS="boolean",ES="symbol",eo="null",Mr="undefined",vu="nan";var Tu="instance",ti="array",st="object",Tn="union",bu="never",cs="unknown",OS="ref",$u=pg("Sury.Exn"),Dr="const";function AS(e){return e.type===Mr?!0:e.type===Tn?Mr in e.has:!1}function PS(e,t){return(e&t)!==0}var Ke={[cs]:1,[Yi]:2,[Sn]:4,[zS]:8,[Mr]:16,[eo]:32,[st]:64,[ti]:128,[Tn]:256,[OS]:512,[$S]:1024,[vu]:2048,function:4096,[Tu]:8192,[bu]:32768,[ES]:16384};function Fa(e){let t=Ke[typeof e];if(t&16)return Mr;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return eo;if(Array.isArray(e)){let i="[";for(let o=0,s=e.length;o<s;++o)o!==0&&(i=i+", "),i=i+Fa(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let r=Object.keys(e),n="{ ";for(let i=0,o=r.length;i<o;++i){let s=r[i],a=e[s];n=n+s+": "+Fa(a)+"; "}return n+"}"}function He(e){let t=e.type,r=e.to,n=e.const,i=e.name;if(i!==void 0)return i;if(n!==void 0)return Fa(n);let o=e.format,s=e.anyOf;if(s!==void 0)return s.map(He).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let a=e.additionalItems;if(r===void 0)return a!==void 0&&a!=="strip"&&a!=="strict"?He(a)+"[]":"unknown[][]";let u=r.properties;return u===void 0?"unknown[][]":"["+Object.keys(u).map(l=>{let d=u[l];return He(d)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,u=e.properties,c=Object.keys(u);return c.length===0?typeof a===st?"{ [key: string]: "+He(a)+"; }":"{}":"{ "+c.map(l=>l+": "+He(u[l])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let l=e.additionalItems,d=e.items;if(typeof l!==st)return"["+d.map(He).join(", ")+"]";let h=He(l);return(l.type===Tn?"("+h+")":h)+"[]";default:return t}}}var ri=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},br=Object.defineProperty,ls=ri.prototype;br(ls,"message",{get(){return jg(this)}});br(ls,"name",{value:"SuryError"});br(ls,"s",{value:ku});br(ls,"_1",{get(){return this}});br(ls,"RE_EXN_ID",{value:$u});var Ig=1,zu=function(){},Eu=Object.create(null);br(Eu,"with",{get(){return(e,...t)=>e(this,...t)}});zu.prototype=Eu;function Xa(e){if(e&&e.s===ku)return e;throw e}function jg(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var ts={m:jg,d:void 0,a:"strip",f:0},xn={};var Ua="value",Qi="r";function At(e,t){let r=new zu;return r.type=e,r.seq=Ig++,t&&(xn[Ua]=r,br(r,Qi,xn)),r}function Ng(e){return e}var gu={};function io(e,t,r){if(gu[e])return gu[e];let n=At(t,!0);return r(n),gu[e]=n,n}var ot=At(cs,!0);ot.decoder=Ng;var to=(e=>{let t=new zu;for(let r in e)t[r]=e[r];return t.seq=Ig++,t});function $n(e,t){let r=to(e),n=r;for(;n.to;){let i=to(n.to);n.to=i,n=i}return t(n),r}function ni(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function us(e,t){let r=Ke[t.type],n=t.const;return r&16?"void 0":r&2?no(n):r&1024?n+"n":r&28672?ni(e,t.const):n}function ii(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=no(t);return e[r]=i,i}function Mt(){return this.i}function CS(){return this.b.v()}function RS(){return this.prev.v()}function rr(e){let t=e.v+1;return e.v=t,"v"+t}function Va(e,t){e.hd=e.hd===""?t:e.hd+","+t}function IS(){let e=this,t=rr(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=Mt,t}function wu(){let e=this,t=e.p;if(t.fz)return e.v=Mt,e.i;let r=rr(e.g);return Va(t,r+"="+e.i),e.v=Mt,e.i=r,r}function Ga(){let e=this;if(e.fz)return e.v=Mt,e.i="("+e.i+")",e.i;let t=rr(e.g);if(e.prev!==void 0){let n=e.i;n===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+n+";")}else{let n=e.i;n===""?Va(e,t):Va(e,t+"="+n)}return e.v=Mt,e.i=t,t}function jS(e,t,r,n){return{v:Mt,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function ds(e,t,r){let n=e.path,i="Can't decode "+He(t)+" to "+He(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new ri(o)}function rs(e,t,r){return ni(e,n=>{let i=t(n);throw new ri(i)})+"("+r+")"}function Mg(e,t,r,n,i,o,s){let a=s!==void 0?s:"Expected "+He(e)+", received "+(i?Fa(n):He(t));if(o!==void 0){let c={};for(let l=0,d=o.length;l<d;++l){let h=o[l],m=h.reason.split(`
105
+ `}function Tg(e){throw e}function $g(e){throw e}function pu(e){throw e}function Ge(e){throw new Error(e)}function Yr(e){let t=Cr(e);if(t===void 0)return"unknown error";let r=ve(t);return lt(Rr(r),String(r))}function bS(e,t){return fetch(e,t)}function wS(e,t){return fetch(e,t)}var Da={json:bS,binary:wS};function Eg(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength|0)}function Za(e){return new Promise((t,r)=>{setTimeout(()=>t(),e)})}function hu(e){process.exitCode=e}function Xn(e){process.stdout.write(e)}function tt(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function Y(e,t){return e.TAG==="Ok"?t(e._0):e}function ke(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}function Og(e,t,r){return e.reduce(r,t)}function Ht(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let s=e[o],a=t(s);a!==void 0&&(n[i]=ve(a),i=i+1|0)}return n.length=i,n}var Rg={},Qa=[],TS=(e=>({...e}));function no(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
106
+ `:return JSON.stringify(e);default:t=r+1|0;continue}}}function $S(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function ES(e){return"["+no(e)+"]"}function zS(e){let t=e.length;return t!==1?t!==0?e.map(ES).join(""):"":"["+no(e[0])+"]"}var xu="sury",ku=Symbol(xu),Su=Symbol(xu+":item"),Yi="string",Sn="number",OS="bigint",AS="boolean",PS="symbol",eo="null",Mr="undefined",vu="nan";var Tu="instance",ti="array",st="object",Tn="union",bu="never",cs="unknown",CS="ref",$u=pg("Sury.Exn"),Dr="const";function RS(e){return e.type===Mr?!0:e.type===Tn?Mr in e.has:!1}function IS(e,t){return(e&t)!==0}var Ke={[cs]:1,[Yi]:2,[Sn]:4,[AS]:8,[Mr]:16,[eo]:32,[st]:64,[ti]:128,[Tn]:256,[CS]:512,[OS]:1024,[vu]:2048,function:4096,[Tu]:8192,[bu]:32768,[PS]:16384};function Fa(e){let t=Ke[typeof e];if(t&16)return Mr;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return eo;if(Array.isArray(e)){let i="[";for(let o=0,s=e.length;o<s;++o)o!==0&&(i=i+", "),i=i+Fa(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let r=Object.keys(e),n="{ ";for(let i=0,o=r.length;i<o;++i){let s=r[i],a=e[s];n=n+s+": "+Fa(a)+"; "}return n+"}"}function He(e){let t=e.type,r=e.to,n=e.const,i=e.name;if(i!==void 0)return i;if(n!==void 0)return Fa(n);let o=e.format,s=e.anyOf;if(s!==void 0)return s.map(He).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let a=e.additionalItems;if(r===void 0)return a!==void 0&&a!=="strip"&&a!=="strict"?He(a)+"[]":"unknown[][]";let u=r.properties;return u===void 0?"unknown[][]":"["+Object.keys(u).map(l=>{let d=u[l];return He(d)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,u=e.properties,c=Object.keys(u);return c.length===0?typeof a===st?"{ [key: string]: "+He(a)+"; }":"{}":"{ "+c.map(l=>l+": "+He(u[l])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let l=e.additionalItems,d=e.items;if(typeof l!==st)return"["+d.map(He).join(", ")+"]";let h=He(l);return(l.type===Tn?"("+h+")":h)+"[]";default:return t}}}var ri=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},br=Object.defineProperty,ls=ri.prototype;br(ls,"message",{get(){return jg(this)}});br(ls,"name",{value:"SuryError"});br(ls,"s",{value:ku});br(ls,"_1",{get(){return this}});br(ls,"RE_EXN_ID",{value:$u});var Ig=1,Eu=function(){},zu=Object.create(null);br(zu,"with",{get(){return(e,...t)=>e(this,...t)}});Eu.prototype=zu;function Xa(e){if(e&&e.s===ku)return e;throw e}function jg(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var ts={m:jg,d:void 0,a:"strip",f:0},xn={};var Ua="value",Qi="r";function At(e,t){let r=new Eu;return r.type=e,r.seq=Ig++,t&&(xn[Ua]=r,br(r,Qi,xn)),r}function Ng(e){return e}var gu={};function io(e,t,r){if(gu[e])return gu[e];let n=At(t,!0);return r(n),gu[e]=n,n}var ot=At(cs,!0);ot.decoder=Ng;var to=(e=>{let t=new Eu;for(let r in e)t[r]=e[r];return t.seq=Ig++,t});function $n(e,t){let r=to(e),n=r;for(;n.to;){let i=to(n.to);n.to=i,n=i}return t(n),r}function ni(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function us(e,t){let r=Ke[t.type],n=t.const;return r&16?"void 0":r&2?no(n):r&1024?n+"n":r&28672?ni(e,t.const):n}function ii(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=no(t);return e[r]=i,i}function Mt(){return this.i}function jS(){return this.b.v()}function NS(){return this.prev.v()}function rr(e){let t=e.v+1;return e.v=t,"v"+t}function Va(e,t){e.hd=e.hd===""?t:e.hd+","+t}function MS(){let e=this,t=rr(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=Mt,t}function wu(){let e=this,t=e.p;if(t.fz)return e.v=Mt,e.i;let r=rr(e.g);return Va(t,r+"="+e.i),e.v=Mt,e.i=r,r}function Ga(){let e=this;if(e.fz)return e.v=Mt,e.i="("+e.i+")",e.i;let t=rr(e.g);if(e.prev!==void 0){let n=e.i;n===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+n+";")}else{let n=e.i;n===""?Va(e,t):Va(e,t+"="+n)}return e.v=Mt,e.i=t,t}function DS(e,t,r,n){return{v:Mt,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function ds(e,t,r){let n=e.path,i="Can't decode "+He(t)+" to "+He(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new ri(o)}function rs(e,t,r){return ni(e,n=>{let i=t(n);throw new ri(i)})+"("+r+")"}function Mg(e,t,r,n,i,o,s){let a=s!==void 0?s:"Expected "+He(e)+", received "+(i?Fa(n):He(t));if(o!==void 0){let c={};for(let l=0,d=o.length;l<d;++l){let h=o[l],m=h.reason.split(`
107
107
  `).join(`
108
108
  `),p=h.path,g=`
109
- - `+(p===""?"":"At "+p+": ")+m;c[g]||(c[g]=1,a=a+g)}}let u={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(u.input=n),u}function Ou(e,t,r,n){return i=>{let o=t!==void 0?t:"",s=n!==void 0?n:!0,a=e!==void 0?e:i.e,u=i.prev,c=u!==void 0?u.s:i.s,l=o===""?i.path:i.path+o;return d=>Mg(a,c,l,d,s,void 0,r)}}function ut(e){let t=e.e.errorMessage,r;if(t!==void 0){let n=t.type;r=n!==void 0?n:t._}else r=void 0;return Ou(void 0,void 0,r,void 0)(e)}function NS(e,t){let r=t!==void 0?t:e.e;return rs(e,Ou(r,void 0,void 0,void 0)(e),e.v())}function MS(e,t){let r=e.vc,n=r.length;if(n===1){let s=r[0];return s.c(t)+"||"+rs(e,s.f(e),t)+";"}let i="",o=0;for(;o<n;){let s=r[o],a=s.f,u=s.c(t);for(o=o+1|0;o<n&&r[o].f===a;)u=u+"&&"+r[o].c(t),o=o+1|0;i=i+(u+"||"+rs(e,a(e),t)+";")}return i}function Dg(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Nr(e,t){let r=e,n="";for(;r!==void 0;){let i=r;r=i.prev;let o="";if(i.vc)if(t!==void 0&&Dg(i)){let a=r.v(),u=i.vc,c="";for(let l=0,d=u.length;l<d;++l){let h=u[l],m=h.c(a);h.f===ut?c=c?c+"&&"+m:m:i.e.noValidation!==!0&&(o=o+(m+"||"+rs(i,h.f(i),a)+";"))}c&&(t.contents?t.contents=c+"&&"+t.contents:t.contents=c)}else i.e.noValidation!==!0&&(o=MS(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Zr(e,t,r,n){let i=n!==void 0?n:e.e;return{v:Ga,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function je(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,s=e.v!==Mt,a={v:s?RS:Mt,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:r,t:e.t,path:e.path,g:e.g};if(s){let u=e.v.bind(e);e.v=()=>{let c=u();return a.i=c,a.v=Mt,c}}return a}function Au(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function ns(e,t){let r=t.e.inputRefiner,n;if(r!==void 0){let a=r(t);if(a.length!==0)if(t.prev!==void 0){for(let c=0,l=a.length;c<l;++c)Au(t,a[c]);n=void 0}else n=a;else n=void 0}else n=void 0;let i=e.e.refiner,o;if(i!==void 0){let a=i(e);o=a.length!==0?a:void 0}else o=void 0;let s=n!==void 0?o!==void 0?je(e,void 0,n.concat(o),void 0):je(e,void 0,n,void 0):o!==void 0?je(e,void 0,o,void 0):e;return s.io=!0,s}function Zg(e,t,r){if(!t.vc)return;let i="["+ii(e.g,r)+"]";t.vc.forEach(o=>Au(e,{c:s=>o.c(s+i),f:o.f})),t.vc=void 0}function Lg(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:ot;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:ot,{p:e,v:IS,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function ei(e,t,r){return Zr(e,us(e,t),t,r)}function qg(e,t){let r=Zr(e,t,e.s,void 0);return r.f=1,r}function kn(e,t,r){e.s.type===ti?e.s.items.push(r.s):(r.o||e.s.required.push(t),e.s.properties[t]=r.s),r.f&1&&r.v(),e.cp=e.cp+Nr(r,void 0),e.d[t]=r}function Fg(e,t,r){return e.v()+"["+t+"]="+r.i}function tn(e){let t=e.v!==Mt,r={b:e,v:t?CS:Mt,i:e.i,s:e.s,io:e.io,e:e.e,f:0,d:e.d,cp:"",hd:"",u:!1,t:!1,path:e.path,g:e.g};if(t){let n=e.v.bind(e);e.v=()=>{let i=n();return r.i=i,r.v=Mt,i}}return r}function DS(e,t){throw new ri({code:"invalid_operation",path:e.path,reason:t})}function Ug(e,t,r,n){if(e.path===""&&r===void 0)return Nr(e,void 0);{let i=u=>{let c=t.path,l=c===""?"":no(c)+"+";return u+".path="+l+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+u+".path"},o=Nr(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let s=rr(e.g),a=i(s)+";throw "+s;return e.f&1&&(e.i=e.i+".catch("+s+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+s+"){"+a+"}"}}function Vg(e){return e}Vg.embedded=Qa;function _u(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function is(e){return t=>"typeof "+t+'==="'+e+'"'}function Xi(e){return"Number.isNaN("+e+")"}function Ba(e){return"Array.isArray("+e+")"}function Gg(e){return is(st)(e)+"&&"+e}function ZS(e,t){return r=>r+" instanceof "+ni(e,t)}function LS(e){let t=Ke[e.s.type];if(t&1){let i=[{c:is(Sn),f:ut}],o=e.e.format,s=0;return o==="int32"?i.push({c:_u,f:ut}):s=1,s===1&&(e.g.o&2||i.push({c:a=>"!"+Xi(a),f:ut})),je(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?je(e,e.e,[{c:_u,f:ut}],void 0):e:ds(e,e.s,e.e);let r=rr(e.g),n=Zr(e,r,e.e,void 0);return n.v=Mt,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?_u(r):"!"+Xi(r)},f:ut}],n}function Bg(){return io(Sn,Sn,e=>{e.decoder=LS})}function qS(e){return Zr(e,'""+'+e.i,Pu(),void 0)}function FS(e){let t=Ke[e.s.type];if(t&1)return je(e,e.e,[{c:is(Yi),f:ut}],void 0);if(!(t&3132&&Dr in e.s))return t&1036?qS(e):t&2?e:ds(e,e.s,e.e);let r=""+e.s.const,n=At(Yi,!1);return n.const=r,Zr(e,'"'+r+'"',n,void 0)}function Pu(){return io(Yi,Yi,e=>{e.decoder=FS})}function Jg(e,t){e[Ke[t]&768?cs:t]=!0}var US="JSON";function ro(e){let t=e.e;if(t.noValidation&&!e.u)return ei(e,t,void 0);if(Dr in e.s)return e.s.const===t.const?e:ei(e,t,void 0);let r=Ke[t.type];if(!(Ke[e.s.type]&2&&r&3132))return r&2048?je(e,t,[{c:Xi,f:ut}],void 0):je(e,t,[{c:o=>o+"==="+us(e,t),f:ut}],void 0);let n=At(Yi,!1);n.const=""+t.const;let i=ei(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:ut}],ei(i,t,t)}function Ya(){return io(Mr,Mr,e=>{e.const=void 0,e.decoder=ro})}function VS(){return io(eo,eo,e=>{e.const=null,e.decoder=ro})}function Wg(){return io(vu,vu,e=>{e.const=NaN,e.decoder=ro})}function Cu(e){if(e===null)return VS();let t=typeof e;if(t===Mr)return Ya();if(t===Sn&&Number.isNaN(e))return Wg();if(t===st){let n=At(Tu,!0);return n.class=e.constructor,n.const=e,n.decoder=ro,n}let r=At(t,!0);return r.const=e,r.decoder=ro,r}function nr(e){let t=e,r,n=0;for(;!t.io||t.e.to;){let i=r;r=void 0;let o=t;if(n=n+1|0,n>50)throw new Error("Loop count exceeded 100");if(o.e.$defs&&(o.g.d?Object.assign(o.g.d,o.e.$defs):o.g.d=o.e.$defs),o.f&1){let s=o.v(),a=tn(o),u=nr(a),c=Nr(u,void 0);t=a.i!==u.i||c!==""?Zr(o,s+".then("+s+"=>{"+c+"return "+u.i+"})",u.s,u.e):je(o,u.s,void 0,u.e),t.f=t.f|1,t.io=!0}else if(o.io){let s=o.e.to,u=o.e.parser;t=u!==void 0?u(o):je(t,void 0,void 0,s)}else{let s=o.s.encoder;s&&s!==i&&o.s!==o.e&&o.e.type!==cs&&(t=s(o,o.e)),o!==t?r=s:(t=o.e.decoder(o),t.io||(t=ns(t,t)))}}return t}function zn(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function en(e){if(Qi in e)return e[Qi];let t,r=e;for(;r;){let i=to(r),o=i.to,s=t;s!==void 0?i.to=s:delete i.to;let a=i.parser,u=i.serializer;u!==void 0?i.parser=u:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let c=i.refiner,l=i.inputRefiner;l!==void 0?i.refiner=l:delete i.refiner,c!==void 0?i.inputRefiner=c:delete i.inputRefiner;let d=i.fromDefault,h=i.default;h!==void 0?i.fromDefault=h:delete i.fromDefault,d!==void 0?i.default=d:delete i.default;let m=i.items;m!==void 0&&(i.items=m.map(en));let p=i.properties;if(p!==void 0){let y={},v=Object.keys(p);for(let b=0,w=v.length;b<w;++b){let S=v[b];y[S]=en(p[S])}i.properties=y}typeof i.additionalItems===st&&(i.additionalItems=en(i.additionalItems));let f=i.anyOf;if(f!==void 0){let y={},v=[];for(let b=0,w=f.length;b<w;++b){let S=f[b],q=en(S);v.push(q),Jg(y,q.type)}i.has=y,i.anyOf=v}let g=i.$defs;if(g!==void 0){let y={};for(let v=0,b=Object.keys(g).length;v<b;++v){let w=Object.keys(g)[v];y[w]=en(g[w])}i.$defs=y}t=i,r=o}let n=t;return xn[Ua]=n,br(e,Qi,xn),xn[Ua]=e,br(n,Qi,xn),n}function Hg(e){try{return nr(e)}catch(t){let r=Xa(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function GS(e,t,r,n){let i=jS(Dr in e?ot:e,t,r,n),o=nr(i),s=Nr(o,void 0),a=PS(o.f,1);t.isAsync=a;let u=o.t===!0;if(t.hasTransform=u,s===""&&(o===i||o.i===i.i)&&!(r&1))return Vg;let c=o.i;r&1&&!a&&!n&&(c="Promise.resolve("+c+")");let l="i=>{"+s+"return "+c+"}",d=i.g.e,h=new Function("e","s","return "+l)(d,ku);return h.embedded=i.g.e,h}function Ja(e,t){let r=arguments,n=0,i,o="",s=0,a;for(;i===void 0;){let c=r[n];if(c)if(typeof c===Sn){let l=c|ts.f;i=l,o=o+"-"+l}else{let l=c.seq;l>s&&(s=l,a=c),o=o+l+"-",n=n+1|0}else{let l=ts.f;i=l,o=o+"-"+l}}let u=a;if(u!==void 0){let c=o;if(c in u)return u[c];let l=r[n-1|0];for(let h=n-2|0;h>=0;--h){let m=l;l=$n(r[h],p=>{p.to=m})}let d=GS(l,l,i,0);return xn[Ua]=d,br(u,c,xn),d}throw new Error("[Sury] No schema provided for decoder.")}var oi="BS_PRIVATE_NESTED_SOME_NONE";function BS(e){let t=je(e,void 0,void 0,Ru());return t.cp=NS(e,void 0)+";",t}function Ru(){return io(bu,bu,e=>{e.decoder=BS})}function JS(e){let t=e.e.to;return Zr(e,"{"+oi+":"+zn(e.e).properties[oi].const+"}",t,t)}function os(e,t){return{v:Ga,i:"",s:t.type===ti?{type:ti,decoder:ju,additionalItems:"strict",items:[]}:{type:st,decoder:fs,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Iu(e){return Mu(e,Ya())}function fs(e){let t=e.u,r=e.e,n=Ke[e.s.type],i;if(n&65){let l=n&64,d;if(l)d=e.s;else{let m=At(st,!1);m.properties=Rg,m.additionalItems=ot,d=m}let h=[];l||(h.push({c:Gg,f:ut}),r.additionalItems!=="strip"&&h.push({c:m=>"!"+Ba(m),f:ut})),i=h.length!==0?je(e,d,h,void 0):je(e,d,void 0,void 0)}else i=ds(e,e.s,r);let o=r.additionalItems,s;s=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,u;u=a!=="strip"&&a!=="strict";let c;if(s!==void 0)if(s===ot)c=i;else if(u){let l=i.v(),d=rr(i.g),h=Lg(i,d),m=Hg(h),p=m.t,f=p?Zr(i,"{}",r,void 0):je(i,r,void 0,void 0),g=Ug(m,i,d,p?()=>Fg(f,d,m):void 0);if((p||g!=="")&&(f.cp=f.cp+("for(let "+d+" in "+l+"){"+g+"}")),m.f&1){let y=rr(f.g),v=rr(f.g),b=rr(f.g),w=rr(f.g),S=f.v();c=qg(f,"new Promise(("+y+","+v+")=>{let "+w+"=Object.keys("+S+").length;for(let "+d+" in "+S+"){"+S+"["+d+"].then("+b+"=>{"+S+"["+d+"]="+b+";if("+w+"--===1){"+y+"("+S+")}},"+v+")}})")}else c=f}else{let l=os(i,r),d=Object.keys(i.s.properties);for(let h=0,m=d.length;h<m;++h){let p=d[h],f=Wa(i,p);f.e=s,f.io=!1,f.u=t,kn(l,p,nr(f))}c=ss(l)}else{let l=r.properties,d=Object.keys(l),h=d.length,m=os(i,r),p=r.additionalItems,f;f=p==="strip"||p==="strict"?p==="strip"?u||Object.keys(i.s.properties).length!==h:!1:!0;let g=i.s.additionalItems,y;y=g==="strip"||g==="strict"?!1:g.name===US;for(let b=0;b<h;++b){let w=d[b],S=l[w],q=Wa(i,w);q.e=S,q.io=!1,q.u=t,y&&S.type===Tn&&S.has[Mr]&&(q.i="("+q.i+"??null)");let K=nr(q);t&&Dr in S&&Zg(i,K,w),kn(m,w,K),f||(f=K.t)}let v=!1;if(r.additionalItems==="strict"){let b=i.s.additionalItems,w;w=b!=="strip"&&b!=="strict",v=w}if(v){let b=rr(m.g);if(Va(i,b),m.cp=m.cp+("for("+b+" in "+i.v()+"){if("),d.length!==0)for(let w=0,S=d.length;w<S;++w){let q=d[w];w!==0&&(m.cp=m.cp+"&&"),m.cp=m.cp+(b+"!=="+ii(i.g,q))}else m.cp=m.cp+"true";m.cp=m.cp+("){"+rs(i,w=>({code:"unrecognized_keys",path:m.path,reason:'Unrecognized key "'+w+'"',keys:[w]}),b)+"}}")}if(f)c=ss(m);else{let b=je(i,void 0,void 0,void 0);b.cp=m.cp,b.d=m.d,c=b}}return ns(c,i)}function WS(){let e=Cu(0),t={};return t[oi]=e,{type:st,serializer:r=>{let n=r.e.to;return ei(r,n,n)},decoder:fs,additionalItems:"strip",required:[oi],properties:t}}function ju(e){let t=e.u,r=e.e,n=Ke[e.s.type],i=r.items,o=i.length,s;if(n&129){let l=n&128,d=l?e.s:Nu(ot),h=[];l||h.push({c:Ba,f:ut});let m=d.additionalItems,p;if(p=m==="strip"||m==="strict"?d.items.length===o:!1,!p){let f=r.additionalItems;(f==="strip"||f==="strict")&&(f==="strip"?h.push({c:g=>g+".length>="+o,f:ut}):h.push({c:g=>g+".length==="+o,f:ut}))}s=h.length!==0?je(e,d,h,void 0):je(e,d,void 0,void 0)}else s=ds(e,e.s,r);let a=r.additionalItems,u,c=0;if(a==="strip"||a==="strict")c=1;else if(a===ot)u=s;else{let l=s.v(),d=rr(s.g),h=Lg(s,d),m=Hg(h),p=m.t,f=p?Zr(s,"new Array("+l+".length)",r,void 0):je(s,r,void 0,void 0),g=Ug(m,s,d,p?()=>Fg(f,d,m):void 0);(p||g!=="")&&(f.cp=f.cp+("for(let "+d+"="+o+";"+d+"<"+l+".length;++"+d+"){"+g+"}")),u=m.f&1?qg(f,"Promise.all("+f.i+")"):f}if(c===1){let l=os(s,r),d=r.additionalItems,h;if(d==="strip"||d==="strict")if(d==="strip"){let m=s.s.additionalItems;h=m==="strip"||m==="strict"?s.s.items.length!==o:!0}else h=!1;else h=!0;for(let m=0;m<o;++m){let p=i[m],f=m.toString(),g=Wa(s,f);g.e=p,g.io=!1,g.u=t;let y=nr(g);t&&Dr in p&&Zg(s,y,f),kn(l,f,y),h||(h=y.t)}if(h)u=ss(l);else{let m=je(s,void 0,void 0,void 0);m.cp=l.cp,m.d=l.d,u=m}}return ns(u,s)}function HS(e,t){let r=e.s.anyOf;return t.type===Tn&&Qg(t)===void 0&&Kg(t.anyOf,r)||!XS(r,t)?e:QS(e,t)}function KS(e){let t=e.e,r=t.anyOf,n=Ke[e.s.type],i=Qg(t);if(e.s===t&&i===void 0&&r.every(La)||n&256&&Kg(r,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(n&256||e.s.encoder===void 0&&n&512)&&(e.s=ot);let o="";if(!(n&769)){let j=yu(e.s),$=!1,R=!1,N=r.length,I=0;for(;o===""&&I<N;){let G=r[I];yu(G)===j?o=j:G.type===eo?$=!0:G.type===Mr&&(R=!0),I=I+1|0}o===""&&(n&16&&$?o=eo:n&32&&R&&(o=Mr))}let s=o,a=e.i,u=j=>ni(e,function(){let $=arguments,R=Mg(t,ot,e.path,$[0],!0,$.length>1?Array.from($).slice(1):void 0,void 0);throw new ri(R)})+"("+e.v()+j+")",c=je(e,void 0,void 0,void 0),l=[],d={contents:""},h=(j,$)=>{let R=j[0],N=j[1],I="",G="",ye=!1,qe={contents:""},Ye="",Et={},vt=2,xe=j.length-1|0;for(;vt<=xe;){let Fe=tn(N);Fe.u=!0,Fe.t=N.t,Fe.io=!1,Fe.e=j[vt];let Ue=vt===xe,_e=vt===2,hr=_e&&Ue,Ji=!hr,Ar=!1,Qr="",vn={contents:""};try{let Pe=nr(Fe);if(l.push(Pe.s),Qr=Nr(Pe,vn),Pe.t){c.t=!0,Pe.f&1&&(c.f=c.f|1);let Pr=R.v();Pe.i!==Pr&&(Qr=Qr+(Pr+"="+Pe.i))}}catch(Pe){let Pr=ni(Fe,Xa(Pe));Ye=Ye+","+Pr,$&&hr?(d.contents=Pr,Ar=!0):Ue?(Ji=!1,Qr=$?"throw "+Pr:u(Ye)):Ar=!0}let bn=vn.contents,Kn=Qr;if(!Ar&&bn)if(Kn){let Pe=Et[bn];Pe!==void 0?typeof Pe=="string"?Et[bn]=[Pe,Kn]:Pe.push(Kn):Et[bn]=Kn}else qe.contents=qe.contents?qe.contents+"||"+bn:bn;if(!Ar&&(!bn||Ue)){let Pe=Object.keys(Et);for(let Pr=0,nS=Pe.length;Pr<nS;++Pr){let ug=Pe[Pr];I=I+(ye?"else if":"if")+("("+ug+"){");let Ko=Et[ug];if(typeof Ko=="string")I=I+Ko+"}";else{let su="";for(let Ea=0,iS=Ko.length;Ea<iS;++Ea){let oS=Ko[Ea],dg="e"+Ea;I=I+("try{"+oS+"}catch("+dg+"){"),su=su+","+dg}I=I+u(su)+"}".repeat(Ko.length)+"}"}ye=!0}Et={}}if(!Ar&&!bn)if(Kn)if(qe.contents&&(I=I+(ye?"else if":"if")+("(!("+qe.contents+")){"),G="}"+G,qe.contents="",ye=!1),Ue&&($||!Ji||_e))I=I+((ye?"else{":"")+Kn),G=(ye?"}":"")+G;else{let Pe="e"+(vt-2|0);I=I+((ye?"else{":"")+"try{"+Kn+"}catch("+Pe+"){"),G=(ye?"}":"")+"}"+G,Ye=Ye+","+Pe,ye=!1}else qe.contents="",vt=xe,Ji=!1;if(Ue){if(qe.contents)I||Ye?I=I+(ye?"else if":"if")+("(!("+qe.contents+")){"+u(Ye)+"}"):Au(N,{c:Pe=>"("+qe.contents+")",f:ut});else if(Ji){let Pe=u(Ye);I=I+(ye?"else{"+Pe+"}":Pe)}}vt=vt+1}return I+G},m="",p="",f="",g=!1,y=r.length-1|0,v={},b=[],w=t.refiner,S=t.inputRefiner,q={contents:void 0},K={contents:void 0},ce=(j,$,R)=>{if($===void 0)return j;let N=I=>{let G=R.contents;if(G!==void 0)return G;let ye=$(I);return R.contents=ye,ye};return j!==void 0?I=>{let G=j(I),ye=N(I);for(let qe=0,Ye=ye.length;qe<Ye;++qe)G.push(ye[qe]);return G}:N},C=j=>{let $=ce(j.refiner,w,q);$!==void 0&&(j.refiner=$);let R=ce(j.inputRefiner,S,K);if(R!==void 0){j.inputRefiner=R;return}},V;if(Dr in e.s){let j=[],$=[];for(let R=0;R<=y;++R){let N=r[R];Dr in N&&N.const===e.s.const?j.push(N):$.push(N)}V=j.concat($)}else V=r;for(let j=0;j<=y;++j){let $=i!==void 0?$n(V[j],G=>{C(G),G.to=i}):V[j],R=$.type,N=Ke[R],I=yu($);if((s===""||s===I)&&!(N&16&&"fromDefault"in t)){let G=v[I];if(G!==void 0)N&64&&oi in $.properties?G.splice(G.length-1|0,0,$):N&2096||G.push($);else{let ye=tn(e),qe;if(N&37633)qe=ot;else{let xe=At($.type,!1);xe.encoder=$.encoder,N&8192?xe.class=$.class:N&64?(xe.properties=Rg,xe.additionalItems=ot):N&128?(xe.additionalItems=ot,xe.items=Qa):N&2096&&(xe.const=$.const),xe.decoder=Fe=>Ke[Fe.s.type]&1?je(Fe,Fe.e,[{c:Ue=>{let _e=Ke[$.type];if(_e&64)return Gg(Ue)+"&&!"+Ba(Ue);if(_e&128)return Ba(Ue);if(_e&8192)return ZS(Fe,$.class)(Ue);if(!(_e&4))return _e&2048?Xi(Ue):_e&48?Ue+"==="+us(Fe,$):_e&17418?is($.type)(Ue):"";let hr=is(Sn)(Ue);return Fe.g.o&2?hr:hr+"&&!"+Xi(Ue)},f:ut}],void 0):$.decoder(Fe),qe=xe}ye.e=qe;let Ye;try{Ye=nr(ye)}catch{ye.vc=void 0,Ye=ye}Ag(N,v)?b.unshift(I):b.push(I),v[I]=[ye,Ye,$];let Et=!0,vt=Ye;for(;vt!==void 0&&Et;){let xe=vt;vt=xe.prev,Et=!(xe.vc&&Dg(xe))}if(Et){for(let xe=0,Fe=b.length;xe<Fe;++xe){let Ue=b[xe];if(!g){let _e=v[Ue],hr=_e[1],Ji=h(_e,!0),Ar=Nr(hr,void 0)+Ji,Qr=d.contents;if(Qr)if(d.contents="",Ar){let vn="e"+(j+xe|0);m=m+("try{"+Ar+"throw "+Qr+"}catch("+vn+"){"),p="}"+p,f=f+","+vn}else f=f+","+Qr;else if(Ar){let vn="e"+(j+xe|0);m=m+("try{"+Ar+"}catch("+vn+"){"),p="}"+p,f=f+","+vn}else g=!0}}v={},b=[]}}}}let H=v,fe=b;if(!g){let j=!1,$="";for(let I=0,G=fe.length;I<G;++I){let ye=H[fe[I]],qe=ye[1],Ye=ye[2],Et=h(ye,!1),vt={contents:""},xe=Nr(qe,vt)+Et,Fe=vt.contents;xe||Ag(Ke[Ye.type],H)?(m=m+(j?"else if":"if")+("("+Fe+"){"+xe+"}"),j=!0):$=$?$+"||"+Fe:Fe}let R=u(f),N;$?N=(j?"else if":"if")+("(!("+$+")){"+R+"}"):N=j?"else{"+R+"}":p===""?R+";":R,m=m+N}c.cp=c.cp+m+p,e.i!==c.i&&(c.i=e.i);let ge=c.f&1?(c.i="Promise.resolve("+c.i+")",c.v=Ga,c):c.v===Mt&&e.cp===""&&c.cp===""&&a==="i"?(e.hd="",e.v=Ga,e.i=a,e):c;return ge.s=l.length?as(l):Ru(),ge.e=i!==void 0?(ge.io=!0,zn(i)):t,ge}function Kg(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Ke[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function QS(e,t){return je(e,ot,void 0,$n(e.s,r=>{r.to=t}))}function XS(e,t){return!(Ke[zn(t).type]&512)&&!(t.type===Tn&&t.anyOf.some(r=>Ke[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Ke[r.type]&512):!1}function Qg(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function Wa(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let l={};e.d=l,n=l}let i=n[t];if(i!==void 0)return tn(i);let o=e.s.type===st?e.s.properties[t]:e.s.items[t],s;if(o!==void 0)s=o;else{let l=e.s.additionalItems;s=l==="strip"||l==="strict"?ds(e,e.s,e.e):e.s.type===st&&l.type!==cs&&!(Ke[l.type]&512)&&!AS(l)?Iu(l):l}let u="["+ii(e.g,t)+"]",c={p:e,v:wu,i:Dr in s?us(e,s):e.v()+u,s,e:s,f:0,cp:"",hd:"",path:e.path+u,g:e.g};return n[t]=c,c}function ss(e){let t=e.s.type===ti,r="",n="",i,o=Object.keys(e.d);for(let c=0,l=o.length;c<l;++c){let d=o[c],h=e.d[d];if(h.f&1&&(n=n+h.i+","),h.o){let m=i;i=p=>(m!==void 0?m(p):"")+("if("+h.v()+"!==void 0){"+p+"["+ii(e.g,d)+"]="+h.i+"}")}else r=r+(t?h.i:ii(e.g,d)+":"+h.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let c=tn(e);c.io=!0;let l=nr(c),d=Nr(l,void 0);return d===""&&n===l.i+","?e.i=l.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+d+"return "+l.i+"})",e.f=e.f|1,e.s=l.s,e.e=l.e,e.io=!0,e}let s=i;if(s===void 0)return e;let a=s(e.v()),u=je(e,void 0,void 0,void 0);return u.cp=u.cp+a,u}function as(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,s=e.length;o<s;++o){let a=e[o];a.type===Tn&&a.to===void 0?(a.anyOf.forEach(u=>{n.add(u)}),Object.assign(r,a.has)):(n.add(a),Jg(r,a.type))}let i=At(Tn,!1);return i.anyOf=Array.from(n),i.decoder=KS,i.encoder=HS,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function Ag(e,t){return e&8320&&st in t?!0:e&2048?Sn in t:!1}function yu(e){return Ke[e.type]&8192?e.class.name:e.type}function La(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Ke[t.type]&512)){let s=t.anyOf;i=s!==void 0?s.every(La):!0}if(i){let s=t.items;n=s!==void 0?s.every(La):!0}if(n){let s=t.properties;r=s!==void 0?Object.values(s).every(La):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function Nu(e){let t=At(ti,e[Qi]===e);return t.additionalItems=e,t.items=Qa,t.decoder=ju,t}function Mu(e,t){let r=t!==void 0?t:Ya(),n=zn(e);switch(n.type){case"undefined":return as([r,Pg(e)]);case"union":let o=n.has,s=n.anyOf;return $n(e,a=>{let u=xS(o),c=[];for(let l=0,d=s.length;l<d;++l){let h=s[l],m=zn(h),p=m.type,f;if(p==="undefined")u[r.type]=!0,c.push(r),f=Pg(h);else{let g=m.properties;if(g!==void 0){let y=g[oi];f=y!==void 0?$n(h,v=>{let b={},w={...y};w.const=y.const+1,b[oi]=w,v.properties=b}):h}else f=h}c.push(f)}c.length===s.length&&(u[r.type]=!0,c.push(r)),a.anyOf=c,a.has=u});default:return as([e,r])}}function Pg(e){return $n(e,t=>{t.to=WS(),t.parser=JS})}br(Eu,"~standard",{get:function(){let e=this;return{version:1,vendor:xu,validate:t=>{try{return{value:Ja(ot,e)(t)}}catch(r){let n=Xa(r);return{issues:[{message:n.reason,path:n.path===""?void 0:kS(n.path)}]}}}}}});function Xg(e,t){return Ja(ot,t)(e)}function YS(e,t){return $n(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let s=i(o),a=n(o);for(let u=0,c=a.length;u<c;++u)s.push(a[u]);return s}:r.refiner=n})}function Yg(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?TS(n):"";return YS(e,s=>(a=>{let u=ni(a,t);return[{c:c=>u+"("+c+")",f:Ou(void 0,o,i,void 0)}]}))}function e_(e,t){return $n(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],s=[];for(let h=0,m=n.length;h<m;++h){let p=n[h],f=zn(p);f.type!=="undefined"&&(o.push(f),s.push(p))}let a=o.length,u;if(a!==1)if(a!==0)u=as(o);else{let h="Can't set default for "+He(r);throw new Error("[Sury] "+h)}else u=o[0];let c=s.length!==1?as(s):s[0];if(t.TAG==="Value"){let h=t._0;try{Ja(ot,u)(h)}catch(m){let p=Xa(m),f="Invalid default for "+He(r)+": "+p.message;throw new Error("[Sury] "+f)}try{r.default=Ja(en(c),void 0)(h)}catch{}}r.parser=h=>{let m=h.e.to,p=h.v(),f;return f=t.TAG==="Value"?us(h,Cu(t._0)):ni(h,t._0)+"()",Zr(h,p+"===void 0?"+f+":"+p,m,m)};let l=to(u),d=l.decoder;l.serializer=h=>{let m=en(c);return je(d(h),m,void 0,m)},l.decoder=Ng,r.to=l;return}let i="Can't set default for "+He(r);throw new Error("[Sury] "+i)})}function eT(e){return e[Su]}function Ha(e,t,r){let n=to(zn(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===Su)return i;let s=i.items,a=i.properties,u=a!==void 0?a[o]:s!==void 0?s[o]:void 0;if(u===void 0){let c='Cannot read property "'+o+'" of '+He(i);throw new Error("[Sury] "+c)}return Ha(u,i.from.concat(o),i.fromFlattened)}})}function t_(e,t,r){let n=os(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,s=i.length;o<s;++o){let a=o.toString();kn(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let s=Object.keys(o);for(let a=0,u=s.length;a<u;++a){let c=s[a];kn(n,c,r(c,o[c]))}}else{let s="Don't know where the value is coming from: "+He(t);throw new Error("[Sury] "+s)}}return ss(n)}function r_(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?tn(Cg(e.fv[n],t.from,0)):r!==void 0?tn(Cg(e,r,0)):Dr in t?ei(e,t,void 0):t_(e,t,(o,s)=>r_(e,s));return i.prev=void 0,i.e=t,i}function n_(e,t){let r=t.e,n=r.from;if(n!==void 0){let s=r.fromFlattened,a;if(s!==void 0){e.flattened===void 0&&(e.flattened=[]);let u=e.flattened[s];if(u!==void 0)a=u;else{let c={};e.flattened[s]=c,a=c}}else a=e;for(let u=0,c=n.length;u<c;++u){let l=n[u],d=a.properties,h;if(d!==void 0)h=d;else{let f={};a.properties=f,h=f}let m=h[l],p;if(m!==void 0)p=m;else{let f={};h[l]=f,p=f}a=p}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let s=0,a=o.length;s<a;++s)n_(e,i[o[s]])}function qa(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let s=tn(o);return s.t=!0,s.s=r,s.e=r,nr(s)}i=1}else i=1;if(i===1){if(Dr in r){let d=ei(e,r,r);return d.prev=void 0,d.p=e,d.v=wu,d.io=!0,nr(d)}let o=t===void 0?zn(r):r,s=os(e,o);s.e=o,s.io=!0,s.prev=void 0,s.p=e,s.v=wu;let a=o.flattened,u=o.items,c=0,l=0;if(u!==void 0&&(t!==void 0||typeof o.additionalItems!==st))for(let d=0,h=u.length;d<h;++d){let m=d.toString(),p;if(t!==void 0){let g=t.properties;p=g!==void 0?g[m]:void 0}else p=void 0;let f=ii(e.g,m);kn(s,m,qa(e,p,u[d],n+("["+f+"]")))}else l=3;if(l===3){let d=o.properties;if(d!==void 0&&(t!==void 0||typeof o.additionalItems!==st)){if(a!==void 0&&t!==void 0){let m=t.flattened;m!==void 0&&m.forEach((p,f)=>{let y=qa(e,p,en(a[f]),n).d,v=Object.keys(y);for(let b=0,w=v.length;b<w;++b){let S=v[b];kn(s,S,y[S])}})}let h=Object.keys(d);for(let m=0,p=h.length;m<p;++m){let f=h[m];if(!(f in s.d)){let g;if(t!==void 0){let v=t.properties;g=v!==void 0?v[f]:void 0}else g=void 0;let y=ii(e.g,f);kn(s,f,qa(e,g,d[f],n+("["+y+"]")))}}}else c=2}if(c===2){let d=r.from,h=d!==void 0?n+d.map(p=>'["'+p+'"]').join(""):n,m=h===""?"":" at "+h;DS(e,"Missing input for "+He(r)+m)}return ss(s)}}function Cg(e,t,r){for(;;){let n=r,i=e,o=t[n];if(o===void 0)return i;r=n+1|0,e=i.d[o]}}function Ka(e,t){if(typeof e!==st||e===null)return Cu(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let u=0,c=e.length;u<c;++u){let l=Ka(e[u],t);e[u]=l}let a=At(ti,!1);return a.items=e,a.additionalItems="strict",a.decoder=ju,a}let n=e.constructor;if(n&&n!==Object){let a=At(Tu,!0);return a.class=n,a.const=e,a.decoder=ro,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let u=i[a],c=Ka(e[u],t);e[u]=c}let s=At(st,!1);return s.required=i,s.properties=e,s.additionalItems=ts.a,s.decoder=fs,s}function tT(e){let t={};n_(t,e);let r=e.e.to,n=qa(e,t,r,"");return n.t=!0,n.prev=e,n}function i_(e){return Ka(e,t=>{if(t["~standard"])return t})}function o_(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return ve(n);let i={},o=[],s=At(st,!1);s.required=o,s.properties=i,s.additionalItems=ts.a,s.decoder=fs;let a=t.f(e,s)[Su],u=(m,p)=>{let f=no(m);if(m in i)throw new Error("[Sury] "+("The field "+f+" defined twice"));return o.push(m),i[m]=p,Ha(p,a.from.concat(m),a.fromFlattened)},h={field:u,f:u,fieldOr:(m,p,f)=>{let g=Mu(p,void 0);return u(m,e_(g,{TAG:"Value",_0:f}))},tag:(m,p)=>{u(m,i_(p))},nested:o_,flatten:m=>{if(m.type==="object"){let g=m.to,y=m.properties;if(g){let w="Unsupported nested flatten for transformed object schema "+He(m);throw new Error("[Sury] "+w)}let v=Object.keys(y),b={};for(let w=0,S=v.length;w<S;++w){let q=v[w];b[q]=u(q,y[q])}return b}let f="Can't flatten "+He(m)+" schema";throw new Error("[Sury] "+f)}};return t[r]=h,h}function rT(e){let t=to(Ka(e,eT));return t.serializer=tT,t}function nT(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,s=t.length;o<s;++o){let a=t[o],u=a.to,c;if(u!==void 0){let l=tn(e);l.e=a,l.io=!0,c=nr(l)}else{let l=t_(e,a,(d,h)=>Wa(e,d));l.e=a,l.prev=void 0,c=ns(l,l)}i.push(c),e.cp=e.cp+Nr(c,void 0)}e.fv=i}let r=e.e.to,n=r_(e,r);return n.t=!0,n.prev=e,ns(n,e)}function s_(e){let t,r={},n=l=>{if(l.type==="object"){let m=l.properties,p=Object.keys(m);for(let g=0,y=p.length;g<y;++g){let v=p[g],b=m[v],w=r[v];if(w!==void 0){if(w!==b)throw new Error("[Sury] "+('The field "'+v+'" defined twice with incompatible schemas'))}else r[v]=b}let f=t||(t=[]);return Ha(l,Qa,f.push(l)-1|0)}let h="The '"+He(l)+"' schema can't be flattened";throw new Error("[Sury] "+h)},i=(l,d)=>{if(l in r)throw new Error("[Sury] "+('The field "'+l+'" defined twice with incompatible schemas'));return r[l]=d,Ha(d,[l],void 0)},u=e({field:i,f:i,fieldOr:(l,d,h)=>{let m=Mu(d,void 0);return i(l,e_(m,{TAG:"Value",_0:h}))},tag:(l,d)=>{i(l,i_(d))},nested:o_,flatten:n}),c=At(st,!1);return c.required=Object.keys(r),c.properties=r,c.additionalItems=ts.a,c.decoder=fs,c.parser=nT,c.to=rT(u),t!==void 0&&(c.flattened=t),c}var En=Pu();var a_=Bg();var c_=$u;var l_=Nu;var ms=Iu;var rn=Yg;var u_=Xg;var ec=s_;function oT(e){return{path:e.path,summary:e.message}}function F(e){return{path:"",summary:e}}function Du(e,t){try{return{TAG:"Ok",_0:u_(e,t)}}catch(r){let n=X(r);if(n.RE_EXN_ID===c_)return{TAG:"Error",_0:oT(n._1)};throw n}}import*as ps from"node:fs";import*as g_ from"node:os";import*as tc from"node:path";var sT="--api-url must be ws://, wss://, http://, or https://";function Pt(e){let t=Hi(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=ve(t),n=r.protocol,i;switch(n){case"http:":case"https:":i={TAG:"Ok",_0:void 0};break;case"ws:":r.protocol="http:",i={TAG:"Ok",_0:void 0};break;case"wss:":r.protocol="https:",i={TAG:"Ok",_0:void 0};break;default:i={TAG:"Error",_0:sT}}return tt(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var f_="wss://serve.linzumi.com";function hs(){return tc.join(g_.homedir(),".linzumi","auth.json")}var m_="Kandan auth cache must contain a JSON object",aT="Kandan auth cache local_codex_runner must be an object",cT="Kandan auth cache personal_agent_delegation must be an object";function p_(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,r=e.issued_at;if(t===void 0||typeof t!="string"||r===void 0||typeof r!="string")return;let n=e.expires_at,i;return i=typeof n=="string"?n:void 0,{accessToken:t,issuedAt:r,expiresAt:i}}function __(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:F(m_)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:F(m_)};let r=t.local_codex_runner,n=t.personal_agent_delegation,i=r!==void 0?typeof r=="object"&&r!==null&&!Array.isArray(r):!0,o=n!==void 0?typeof n=="object"&&n!==null&&!Array.isArray(n):!0;if(!i)return{TAG:"Error",_0:F(aT)};if(!o)return{TAG:"Error",_0:F(cT)};let s;return s=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(Ht(Object.entries(r),a=>{let u=a[0];return wt(p_(a[1]),c=>[u,c])})):void 0,{TAG:"Ok",_0:{serverTokens:s,personalAgentDelegation:it(n,p_)}}}function y_(e){return ps.existsSync(e)?Y(ke(yr(e),t=>F(t.message)),t=>tt(__(t),r=>r)):{TAG:"Ok",_0:void 0}}function v_(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function rc(e,t,r){return ps.existsSync(t)?Y(y_(t),n=>tt(ke(Pt(e),F),i=>it(it(it(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||v_(o.expiresAt,r)))return{accessToken:o.accessToken,serverBaseUrl:i,issuedAt:o.issuedAt,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function lT(e){return"missing personal-agent delegation auth file: "+e}var uT="personal-agent delegation auth file is missing access_token",dT="personal-agent delegation auth file token is expired";function b_(e,t){return ps.existsSync(e)?Y(y_(e),r=>{let n=it(r,i=>i.personalAgentDelegation);return n!==void 0&&n.accessToken.trim()!==""?v_(n.expiresAt,t)?{TAG:"Error",_0:F(dT)}:{TAG:"Ok",_0:n}:{TAG:"Error",_0:F(uT)}}):{TAG:"Error",_0:F(lT(e))}}function h_(e){let t={};t.access_token=e.accessToken,t.issued_at=e.issuedAt;let r=e.expiresAt;return r!==void 0&&(t.expires_at=r),t}function fT(e){let t={};t.version=1;let r=e.serverTokens;r!==void 0&&(t.local_codex_runner=Object.fromEntries(Object.entries(r).map(i=>[i[0],h_(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=h_(n)),t}function Zu(e,t,r,n,i){return Y(ke(Pt(e),F),o=>{let s=ps.existsSync(n)?Y(ke(yr(n),a=>F(a.message)),__):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return Y(s,a=>{let u=i.toISOString(),c=wt(r,y=>new Date(i.getTime()+y*1e3).toISOString()),l={accessToken:t,issuedAt:u,expiresAt:c},d=a.serverTokens,h=d!==void 0?Object.fromEntries(Object.entries(d)):{};h[o]=l;let m=fT({serverTokens:h,personalAgentDelegation:a.personalAgentDelegation}),p=JSON.stringify(m,void 0,2)+`
110
- `,f=n+".tmp."+process.pid.toString()+"."+bg(6),g=y=>F(y.message);return Y(ke(vr(tc.dirname(n)),g),()=>{let y=Y(Yo(f,p,{encoding:"utf8",mode:384}),()=>Ca(f,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,serverBaseUrl:o,issuedAt:u,expiresAt:c}}:(Qn(f),{TAG:"Error",_0:F(y._0.message)})})})})}function qu(e){let t=Cr(e);return t!==void 0?lt(Rr(ve(t)),"unknown error"):"unknown error"}async function gs(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=X(r);return{TAG:"Error",_0:{message:qu(n)}}}}async function mT(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=X(t);return{TAG:"Error",_0:{message:qu(r)}}}}async function _s(e){let t=await mT(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=X(r);return{TAG:"Error",_0:{message:qu(n)}}}}function pT(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function oo(e,t,r,n,i){let o=i!==void 0?i:[],s=ke(Pt(e),F);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=Xr("/api/v2/local-codex-runner/oauth/validate",s._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:F(a._0)};let u=a._0,c=u.searchParams;r!==void 0&&c.set("workspace",r),n!==void 0&&c.set("channel",n),o.forEach(p=>{c.append("required_scope",p)});let l={};l.authorization="Bearer "+t;let d=await gs(u.toString(),{method:"GET",headers:l});if(d.TAG!=="Ok")return{TAG:"Error",_0:F(d._0.message)};let h=d._0,m=h.status;if(m>404||m<401){if(m===200){let p=await _s(h);return p.TAG!=="Ok"?{TAG:"Error",_0:F(p._0.message)}:it(pT(p._0),g=>g.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(m<402)return{TAG:"Ok",_0:"Rejected"};switch(m){case 402:break;case 403:return{TAG:"Ok",_0:"Rejected"};case 404:return{TAG:"Ok",_0:"NotFound"}}}return{TAG:"Error",_0:F("local runner auth validation failed with HTTP "+m.toString())}}import*as F_ from"node:os";import*as oc from"node:fs";import*as Ju from"node:os";import*as xt from"node:path";import*as Wu from"node:crypto";function Uu(e){return isFinite(e)?Math.trunc(e)===e:!1}var hT=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),gT=new RegExp("^[a-zA-Z0-9_.-]+$");function Vu(e){return hT.test(e)}function ic(e){return gT.test(e)}var _T=rn(En,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function T_(e){return{version:1,machineId:e.f("machineId",ms(rn(En,Vu,"invalid machine id",void 0))),runnerId:e.f("runnerId",ms(rn(En,ic,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",l_(_T))}}var yT=ec(T_),vT=ec(e=>(e.tag("version",1),T_(e)));function Gu(e){let t=new Set;return Ht(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function $_(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:Gu(e.allowedCwds)}}function Bu(e){return tt(Du(e,vT),$_)}function z_(e){return tt(Du(e,yT),$_)}var nc=ms(rn(En,e=>e.trim()!=="","must be a non-empty string",void 0)),k_=ms(rn(a_,e=>Uu(e)?e>0:!1,"must be a positive integer",void 0));function bT(e){return!Number.isNaN(new Date(e).getTime())}var S_=rn(En,bT,"must be a parseable date",void 0),mZ=ec(e=>({email:e.f("email",rn(En,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",rn(En,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",nc),refreshToken:e.f("refresh_token",nc),expiresInSeconds:e.f("expires_in_seconds",k_),userId:e.f("user_id",k_),workspaceSlug:e.f("workspace_slug",nc),launchUrl:e.f("launch_url",nc),createdAt:e.f("created_at",S_),updatedAt:e.f("updated_at",S_)}));var Lr="prod";function E_(e){let t=e!==void 0?e:process.env,r=du(t,"HOME");return r!==void 0&&r.trim()!==""?r:Ju.homedir()}function xT(e,t){let r=e!==void 0?e:process.env;return t==="~"?E_(r):t.startsWith("~/")?xt.resolve(E_(r),t.slice(2)):t}function P_(e){let t=du(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?xt.resolve(xT(e,t)):xt.resolve(Ju.homedir(),".linzumi","config.json")}function ys(e){let t=Pt(e),r=Pt(f_);if(t.TAG!=="Ok")return{TAG:"Error",_0:F(t._0)};let n=t._0;return r.TAG==="Ok"?{TAG:"Ok",_0:n===r._0?Lr:n}:{TAG:"Error",_0:F(r._0)}}function kT(e){return tt(ys(e),t=>t===Lr?Lr:Buffer.from(t).toString("base64url"))}function ST(e,t,r){let n=xt.dirname(e),i=xt.basename(e);return t!==void 0?Y(ys(t),o=>o===Lr?{TAG:"Ok",_0:xt.join(n,i+"."+r)}:tt(kT(t),s=>xt.join(n,i+"."+s+"."+r))):{TAG:"Ok",_0:xt.join(n,i+"."+r)}}function C_(e){if(oc.existsSync(e))return Y(ke(yr(e),r=>F(r.message)),r=>{let n;try{n=JSON.parse(r)}catch{n=void 0}return typeof n=="object"&&n!==null&&!Array.isArray(n)?Bu(n).TAG==="Ok"?{TAG:"Ok",_0:n}:{TAG:"Error",_0:F("invalid Linzumi config: "+e)}:{TAG:"Error",_0:F("invalid Linzumi config: "+e)}});let t={};return t.version=1,t.allowedCwds=[],{TAG:"Ok",_0:t}}function TT(){let e={};return e.allowedCwds=[],e}function O_(e,t){return Y(C_(e),r=>{let n=t!==void 0?ys(t):{TAG:"Ok",_0:Lr};return Y(n,i=>{let o=i===Lr?r:lt(r[i],TT()),s=i===Lr?Bu(o):z_(o);return ke(s,a=>F("invalid Linzumi config section "+i+": "+e))})})}function $T(e,t){let r=i=>F(i.message),n=oc.existsSync(e)?ke(Pa(e,384),r):{TAG:"Ok",_0:void 0};return Y(Y(n,()=>ke(Yo(e,JSON.stringify(t,void 0,2)+`
111
- `,{encoding:"utf8",mode:384}),r)),()=>ke(Pa(e,384),r))}function zT(e){let t={},r=e.machineId;r!==void 0&&(t.machineId=r);let n=e.runnerId;return n!==void 0&&(t.runnerId=n),t.allowedCwds=Gu(e.allowedCwds).map(i=>i),t}function ET(e){let t=e.version===1,r=e.machineId,n=r!==void 0?Vu(r):!0,i=e.runnerId,o=i!==void 0?ic(i):!0,s=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&s?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:F("invalid Linzumi config")}}function OT(e,t,r){return Y(ET(e),()=>{let n=r!==void 0?ys(r):{TAG:"Ok",_0:Lr};return Y(n,i=>Y(C_(t),o=>{let s=Object.fromEntries(Object.entries(o)),a=zT(e);return i===Lr?(Object.entries(a).forEach(u=>{s[u[0]]=u[1]}),s.version=1):(s.version=1,s[i]=a),Y(ke(vr(xt.dirname(t)),u=>F(u.message)),()=>$T(t,s))}))})}function A_(e,t,r){return Y(ke(yr(e),n=>F(n.message)),n=>{let i=n.trim();return t(i)?{TAG:"Ok",_0:i}:{TAG:"Error",_0:F("invalid Linzumi "+r+" seed: "+e)}})}function AT(e,t,r,n){if(oc.existsSync(e))return A_(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:F("invalid generated Linzumi "+n+": "+i)};let o=xt.dirname(e),s=xt.basename(e),a=xt.join(o,"."+s+"."+process.pid.toString()+"."+Wu.randomUUID()+".tmp"),u=c=>F(c.message);return Y(Y(ke(vr(o),u),()=>ke(Yo(a,i+`
112
- `,{encoding:"utf8",flag:"wx"}),u)),()=>{let c=yg(a,e),l;if(c.TAG==="Ok")l={TAG:"Ok",_0:i};else{let d=c._0;l=gg(d,"EEXIST")?A_(e,r,n):{TAG:"Error",_0:F(d.message)}}return vg(a),l})}function PT(){return"runner-"+Wu.randomUUID()}function CT(e,t,r,n,i,o,s,a){let u=t!==void 0?tt(ys(t),c=>{if(c!==Lr)return t}):{TAG:"Ok",_0:void 0};return Y(u,c=>Y(O_(e,c),l=>{let d=s(l);return d!==void 0?{TAG:"Ok",_0:d}:Y(ST(e,c,r),h=>Y(AT(h,n,i,o),m=>Y(O_(e,c),p=>{let f=s(p);return f!==void 0?{TAG:"Ok",_0:f}:tt(OT(a(p,m),e,c),()=>m)})))}))}function R_(e,t,r){return CT(e,t,"runner-id",r!==void 0?r:PT,ic,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}function I_(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function j_(e,t){if(e===void 0)return t!==void 0?"local runner device authorization failed (HTTP "+t.toString()+", no reason returned by the server)":"local runner device authorization failed (no reason returned by the server)";switch(e){case"access_denied":return"local runner device authorization was denied";case"approving_user_not_found":return"local runner device authorization failed: the approving Linzumi account could not be found";case"device_session_consumed":return"local runner device authorization was already used";case"device_session_expired":return"local runner device authorization expired";case"device_session_not_pending":return"local runner device authorization was already decided (approved or denied) on the server";case"invalid_device_code":return"local runner device authorization code was rejected";case"invalid_user_code":return"local runner device authorization code was not recognized by the server";case"rate_limited":return"local runner device authorization was rate limited by the server; wait a minute and retry";default:return"local runner device authorization failed (server said: "+e+")"}}function so(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function N_(e,t,r,n,i){let o=Xr("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:F(o._0)};let s={},a=(g,y)=>{if(y!==void 0){s[g]=y;return}};a("workspace",t),a("channel",r),a("onboarding",n),i!==void 0&&(a("runner_id",i.commanderId),a("machine_fingerprint",i.machineFingerprint),a("hostname",i.hostname));let u={};u["content-type"]="application/json";let c=await gs(o._0.toString(),{method:"POST",headers:u,body:JSON.stringify(s)});if(c.TAG!=="Ok")return{TAG:"Error",_0:F(c._0.message)};let l=c._0,d=l.status,h=await _s(l);if(h.TAG!=="Ok")return{TAG:"Error",_0:F(h._0.message)};let m=h._0;if(d>=200&&d<300){if(Array.isArray(m))return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(m!==null)switch(typeof m){case"object":let g=so(m,"device_code"),y=so(m,"user_code"),v=so(m,"verification_uri");if(g===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(y===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(v===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};let b=m.expires_in,w;return w=typeof b=="number"?b:void 0,{TAG:"Ok",_0:{deviceCode:g,userCode:y,verificationUri:v,expiresInSeconds:w}}}}let f=I_(m);return{TAG:"Error",_0:F(f!==void 0?"local runner device authorization failed to start (server said: "+f+")":"local runner device authorization failed to start (HTTP "+d.toString()+")")}}async function IT(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let s={};s["content-type"]="application/json";let a=Xr("/api/v2/local-codex-runner/device/token",e),u;if(u=a.TAG==="Ok"?await gs(a._0.toString(),{method:"POST",headers:s,body:JSON.stringify(o),signal:gr(n.signal)}):{TAG:"Error",_0:{message:a._0}},u.TAG==="Ok"){let c=u._0,l=c.status,d=await _s(c);if(clearTimeout(i),d.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+d._0.message+")",httpStatus:l}};let h=d._0,m=l>=200&&l<300,p=I_(h),f=0;if(l!==202||p===void 0)f=1;else{if(p==="authorization_pending")return"Continue";f=1}if(f===1){let g=0;if(m){if(Array.isArray(h))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};if(h===null)g=2;else switch(typeof h){case"object":let y=so(h,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};let v=h.expires_in,b;return b=typeof v=="number"?v:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:b,workspaceSlug:so(h,"workspace"),channelSlug:so(h,"channel")}}};default:g=2}}else g=2;if(g===2){let y=0;if(p!==void 0)switch(p){case"access_denied":return{TAG:"Done",_0:"Denied"};case"device_session_consumed":return{TAG:"Done",_0:"Consumed"};case"device_session_expired":return{TAG:"Done",_0:"CodeExpired"};default:y=3}else y=3;if(y===3)return l>=500||l===429?{TAG:"Done",_0:{TAG:"Transient",reason:p!==void 0?p:"HTTP "+l.toString(),httpStatus:l}}:{TAG:"Done",_0:{TAG:"Rejected",reason:p,httpStatus:l}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:u._0.message,httpStatus:void 0}}}async function M_(e,t,r,n){let i=n!==void 0?n:()=>Date.now(),o=r!==void 0&&r>=0?r:600,s=i()+o*1e3,a=async()=>{if(i()>=s)return"CodeExpired";let u=Math.max(0,Math.min(3e4,s-i())),c=await IT(e,t,u);return typeof c!="object"?await a():c._0};return await a()}var NT=3600*1e3;function MT(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<NT?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function D_(e){let t=Math.floor(e/6e4),r=Math.floor(t/60),n=t-r*60;return r>0?r.toString()+"h "+n.toString()+"m":n.toString()+"m"}function DT(e){switch(e.TAG){case"Prompt":return(e.cycle===1?"":`The previous code expired; here is a fresh one (no restart needed - this prompt stays alive).
109
+ - `+(p===""?"":"At "+p+": ")+m;c[g]||(c[g]=1,a=a+g)}}let u={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(u.input=n),u}function Ou(e,t,r,n){return i=>{let o=t!==void 0?t:"",s=n!==void 0?n:!0,a=e!==void 0?e:i.e,u=i.prev,c=u!==void 0?u.s:i.s,l=o===""?i.path:i.path+o;return d=>Mg(a,c,l,d,s,void 0,r)}}function ut(e){let t=e.e.errorMessage,r;if(t!==void 0){let n=t.type;r=n!==void 0?n:t._}else r=void 0;return Ou(void 0,void 0,r,void 0)(e)}function ZS(e,t){let r=t!==void 0?t:e.e;return rs(e,Ou(r,void 0,void 0,void 0)(e),e.v())}function LS(e,t){let r=e.vc,n=r.length;if(n===1){let s=r[0];return s.c(t)+"||"+rs(e,s.f(e),t)+";"}let i="",o=0;for(;o<n;){let s=r[o],a=s.f,u=s.c(t);for(o=o+1|0;o<n&&r[o].f===a;)u=u+"&&"+r[o].c(t),o=o+1|0;i=i+(u+"||"+rs(e,a(e),t)+";")}return i}function Dg(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Nr(e,t){let r=e,n="";for(;r!==void 0;){let i=r;r=i.prev;let o="";if(i.vc)if(t!==void 0&&Dg(i)){let a=r.v(),u=i.vc,c="";for(let l=0,d=u.length;l<d;++l){let h=u[l],m=h.c(a);h.f===ut?c=c?c+"&&"+m:m:i.e.noValidation!==!0&&(o=o+(m+"||"+rs(i,h.f(i),a)+";"))}c&&(t.contents?t.contents=c+"&&"+t.contents:t.contents=c)}else i.e.noValidation!==!0&&(o=LS(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Zr(e,t,r,n){let i=n!==void 0?n:e.e;return{v:Ga,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function je(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,s=e.v!==Mt,a={v:s?NS:Mt,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:r,t:e.t,path:e.path,g:e.g};if(s){let u=e.v.bind(e);e.v=()=>{let c=u();return a.i=c,a.v=Mt,c}}return a}function Au(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function ns(e,t){let r=t.e.inputRefiner,n;if(r!==void 0){let a=r(t);if(a.length!==0)if(t.prev!==void 0){for(let c=0,l=a.length;c<l;++c)Au(t,a[c]);n=void 0}else n=a;else n=void 0}else n=void 0;let i=e.e.refiner,o;if(i!==void 0){let a=i(e);o=a.length!==0?a:void 0}else o=void 0;let s=n!==void 0?o!==void 0?je(e,void 0,n.concat(o),void 0):je(e,void 0,n,void 0):o!==void 0?je(e,void 0,o,void 0):e;return s.io=!0,s}function Zg(e,t,r){if(!t.vc)return;let i="["+ii(e.g,r)+"]";t.vc.forEach(o=>Au(e,{c:s=>o.c(s+i),f:o.f})),t.vc=void 0}function Lg(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:ot;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:ot,{p:e,v:MS,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function ei(e,t,r){return Zr(e,us(e,t),t,r)}function qg(e,t){let r=Zr(e,t,e.s,void 0);return r.f=1,r}function kn(e,t,r){e.s.type===ti?e.s.items.push(r.s):(r.o||e.s.required.push(t),e.s.properties[t]=r.s),r.f&1&&r.v(),e.cp=e.cp+Nr(r,void 0),e.d[t]=r}function Fg(e,t,r){return e.v()+"["+t+"]="+r.i}function tn(e){let t=e.v!==Mt,r={b:e,v:t?jS:Mt,i:e.i,s:e.s,io:e.io,e:e.e,f:0,d:e.d,cp:"",hd:"",u:!1,t:!1,path:e.path,g:e.g};if(t){let n=e.v.bind(e);e.v=()=>{let i=n();return r.i=i,r.v=Mt,i}}return r}function qS(e,t){throw new ri({code:"invalid_operation",path:e.path,reason:t})}function Ug(e,t,r,n){if(e.path===""&&r===void 0)return Nr(e,void 0);{let i=u=>{let c=t.path,l=c===""?"":no(c)+"+";return u+".path="+l+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+u+".path"},o=Nr(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let s=rr(e.g),a=i(s)+";throw "+s;return e.f&1&&(e.i=e.i+".catch("+s+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+s+"){"+a+"}"}}function Vg(e){return e}Vg.embedded=Qa;function _u(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function is(e){return t=>"typeof "+t+'==="'+e+'"'}function Xi(e){return"Number.isNaN("+e+")"}function Ba(e){return"Array.isArray("+e+")"}function Gg(e){return is(st)(e)+"&&"+e}function FS(e,t){return r=>r+" instanceof "+ni(e,t)}function US(e){let t=Ke[e.s.type];if(t&1){let i=[{c:is(Sn),f:ut}],o=e.e.format,s=0;return o==="int32"?i.push({c:_u,f:ut}):s=1,s===1&&(e.g.o&2||i.push({c:a=>"!"+Xi(a),f:ut})),je(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?je(e,e.e,[{c:_u,f:ut}],void 0):e:ds(e,e.s,e.e);let r=rr(e.g),n=Zr(e,r,e.e,void 0);return n.v=Mt,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?_u(r):"!"+Xi(r)},f:ut}],n}function Bg(){return io(Sn,Sn,e=>{e.decoder=US})}function VS(e){return Zr(e,'""+'+e.i,Pu(),void 0)}function GS(e){let t=Ke[e.s.type];if(t&1)return je(e,e.e,[{c:is(Yi),f:ut}],void 0);if(!(t&3132&&Dr in e.s))return t&1036?VS(e):t&2?e:ds(e,e.s,e.e);let r=""+e.s.const,n=At(Yi,!1);return n.const=r,Zr(e,'"'+r+'"',n,void 0)}function Pu(){return io(Yi,Yi,e=>{e.decoder=GS})}function Jg(e,t){e[Ke[t]&768?cs:t]=!0}var BS="JSON";function ro(e){let t=e.e;if(t.noValidation&&!e.u)return ei(e,t,void 0);if(Dr in e.s)return e.s.const===t.const?e:ei(e,t,void 0);let r=Ke[t.type];if(!(Ke[e.s.type]&2&&r&3132))return r&2048?je(e,t,[{c:Xi,f:ut}],void 0):je(e,t,[{c:o=>o+"==="+us(e,t),f:ut}],void 0);let n=At(Yi,!1);n.const=""+t.const;let i=ei(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:ut}],ei(i,t,t)}function Ya(){return io(Mr,Mr,e=>{e.const=void 0,e.decoder=ro})}function JS(){return io(eo,eo,e=>{e.const=null,e.decoder=ro})}function Wg(){return io(vu,vu,e=>{e.const=NaN,e.decoder=ro})}function Cu(e){if(e===null)return JS();let t=typeof e;if(t===Mr)return Ya();if(t===Sn&&Number.isNaN(e))return Wg();if(t===st){let n=At(Tu,!0);return n.class=e.constructor,n.const=e,n.decoder=ro,n}let r=At(t,!0);return r.const=e,r.decoder=ro,r}function nr(e){let t=e,r,n=0;for(;!t.io||t.e.to;){let i=r;r=void 0;let o=t;if(n=n+1|0,n>50)throw new Error("Loop count exceeded 100");if(o.e.$defs&&(o.g.d?Object.assign(o.g.d,o.e.$defs):o.g.d=o.e.$defs),o.f&1){let s=o.v(),a=tn(o),u=nr(a),c=Nr(u,void 0);t=a.i!==u.i||c!==""?Zr(o,s+".then("+s+"=>{"+c+"return "+u.i+"})",u.s,u.e):je(o,u.s,void 0,u.e),t.f=t.f|1,t.io=!0}else if(o.io){let s=o.e.to,u=o.e.parser;t=u!==void 0?u(o):je(t,void 0,void 0,s)}else{let s=o.s.encoder;s&&s!==i&&o.s!==o.e&&o.e.type!==cs&&(t=s(o,o.e)),o!==t?r=s:(t=o.e.decoder(o),t.io||(t=ns(t,t)))}}return t}function En(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function en(e){if(Qi in e)return e[Qi];let t,r=e;for(;r;){let i=to(r),o=i.to,s=t;s!==void 0?i.to=s:delete i.to;let a=i.parser,u=i.serializer;u!==void 0?i.parser=u:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let c=i.refiner,l=i.inputRefiner;l!==void 0?i.refiner=l:delete i.refiner,c!==void 0?i.inputRefiner=c:delete i.inputRefiner;let d=i.fromDefault,h=i.default;h!==void 0?i.fromDefault=h:delete i.fromDefault,d!==void 0?i.default=d:delete i.default;let m=i.items;m!==void 0&&(i.items=m.map(en));let p=i.properties;if(p!==void 0){let y={},v=Object.keys(p);for(let b=0,w=v.length;b<w;++b){let S=v[b];y[S]=en(p[S])}i.properties=y}typeof i.additionalItems===st&&(i.additionalItems=en(i.additionalItems));let f=i.anyOf;if(f!==void 0){let y={},v=[];for(let b=0,w=f.length;b<w;++b){let S=f[b],q=en(S);v.push(q),Jg(y,q.type)}i.has=y,i.anyOf=v}let g=i.$defs;if(g!==void 0){let y={};for(let v=0,b=Object.keys(g).length;v<b;++v){let w=Object.keys(g)[v];y[w]=en(g[w])}i.$defs=y}t=i,r=o}let n=t;return xn[Ua]=n,br(e,Qi,xn),xn[Ua]=e,br(n,Qi,xn),n}function Hg(e){try{return nr(e)}catch(t){let r=Xa(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function WS(e,t,r,n){let i=DS(Dr in e?ot:e,t,r,n),o=nr(i),s=Nr(o,void 0),a=IS(o.f,1);t.isAsync=a;let u=o.t===!0;if(t.hasTransform=u,s===""&&(o===i||o.i===i.i)&&!(r&1))return Vg;let c=o.i;r&1&&!a&&!n&&(c="Promise.resolve("+c+")");let l="i=>{"+s+"return "+c+"}",d=i.g.e,h=new Function("e","s","return "+l)(d,ku);return h.embedded=i.g.e,h}function Ja(e,t){let r=arguments,n=0,i,o="",s=0,a;for(;i===void 0;){let c=r[n];if(c)if(typeof c===Sn){let l=c|ts.f;i=l,o=o+"-"+l}else{let l=c.seq;l>s&&(s=l,a=c),o=o+l+"-",n=n+1|0}else{let l=ts.f;i=l,o=o+"-"+l}}let u=a;if(u!==void 0){let c=o;if(c in u)return u[c];let l=r[n-1|0];for(let h=n-2|0;h>=0;--h){let m=l;l=$n(r[h],p=>{p.to=m})}let d=WS(l,l,i,0);return xn[Ua]=d,br(u,c,xn),d}throw new Error("[Sury] No schema provided for decoder.")}var oi="BS_PRIVATE_NESTED_SOME_NONE";function HS(e){let t=je(e,void 0,void 0,Ru());return t.cp=ZS(e,void 0)+";",t}function Ru(){return io(bu,bu,e=>{e.decoder=HS})}function KS(e){let t=e.e.to;return Zr(e,"{"+oi+":"+En(e.e).properties[oi].const+"}",t,t)}function os(e,t){return{v:Ga,i:"",s:t.type===ti?{type:ti,decoder:ju,additionalItems:"strict",items:[]}:{type:st,decoder:fs,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Iu(e){return Mu(e,Ya())}function fs(e){let t=e.u,r=e.e,n=Ke[e.s.type],i;if(n&65){let l=n&64,d;if(l)d=e.s;else{let m=At(st,!1);m.properties=Rg,m.additionalItems=ot,d=m}let h=[];l||(h.push({c:Gg,f:ut}),r.additionalItems!=="strip"&&h.push({c:m=>"!"+Ba(m),f:ut})),i=h.length!==0?je(e,d,h,void 0):je(e,d,void 0,void 0)}else i=ds(e,e.s,r);let o=r.additionalItems,s;s=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,u;u=a!=="strip"&&a!=="strict";let c;if(s!==void 0)if(s===ot)c=i;else if(u){let l=i.v(),d=rr(i.g),h=Lg(i,d),m=Hg(h),p=m.t,f=p?Zr(i,"{}",r,void 0):je(i,r,void 0,void 0),g=Ug(m,i,d,p?()=>Fg(f,d,m):void 0);if((p||g!=="")&&(f.cp=f.cp+("for(let "+d+" in "+l+"){"+g+"}")),m.f&1){let y=rr(f.g),v=rr(f.g),b=rr(f.g),w=rr(f.g),S=f.v();c=qg(f,"new Promise(("+y+","+v+")=>{let "+w+"=Object.keys("+S+").length;for(let "+d+" in "+S+"){"+S+"["+d+"].then("+b+"=>{"+S+"["+d+"]="+b+";if("+w+"--===1){"+y+"("+S+")}},"+v+")}})")}else c=f}else{let l=os(i,r),d=Object.keys(i.s.properties);for(let h=0,m=d.length;h<m;++h){let p=d[h],f=Wa(i,p);f.e=s,f.io=!1,f.u=t,kn(l,p,nr(f))}c=ss(l)}else{let l=r.properties,d=Object.keys(l),h=d.length,m=os(i,r),p=r.additionalItems,f;f=p==="strip"||p==="strict"?p==="strip"?u||Object.keys(i.s.properties).length!==h:!1:!0;let g=i.s.additionalItems,y;y=g==="strip"||g==="strict"?!1:g.name===BS;for(let b=0;b<h;++b){let w=d[b],S=l[w],q=Wa(i,w);q.e=S,q.io=!1,q.u=t,y&&S.type===Tn&&S.has[Mr]&&(q.i="("+q.i+"??null)");let K=nr(q);t&&Dr in S&&Zg(i,K,w),kn(m,w,K),f||(f=K.t)}let v=!1;if(r.additionalItems==="strict"){let b=i.s.additionalItems,w;w=b!=="strip"&&b!=="strict",v=w}if(v){let b=rr(m.g);if(Va(i,b),m.cp=m.cp+("for("+b+" in "+i.v()+"){if("),d.length!==0)for(let w=0,S=d.length;w<S;++w){let q=d[w];w!==0&&(m.cp=m.cp+"&&"),m.cp=m.cp+(b+"!=="+ii(i.g,q))}else m.cp=m.cp+"true";m.cp=m.cp+("){"+rs(i,w=>({code:"unrecognized_keys",path:m.path,reason:'Unrecognized key "'+w+'"',keys:[w]}),b)+"}}")}if(f)c=ss(m);else{let b=je(i,void 0,void 0,void 0);b.cp=m.cp,b.d=m.d,c=b}}return ns(c,i)}function QS(){let e=Cu(0),t={};return t[oi]=e,{type:st,serializer:r=>{let n=r.e.to;return ei(r,n,n)},decoder:fs,additionalItems:"strip",required:[oi],properties:t}}function ju(e){let t=e.u,r=e.e,n=Ke[e.s.type],i=r.items,o=i.length,s;if(n&129){let l=n&128,d=l?e.s:Nu(ot),h=[];l||h.push({c:Ba,f:ut});let m=d.additionalItems,p;if(p=m==="strip"||m==="strict"?d.items.length===o:!1,!p){let f=r.additionalItems;(f==="strip"||f==="strict")&&(f==="strip"?h.push({c:g=>g+".length>="+o,f:ut}):h.push({c:g=>g+".length==="+o,f:ut}))}s=h.length!==0?je(e,d,h,void 0):je(e,d,void 0,void 0)}else s=ds(e,e.s,r);let a=r.additionalItems,u,c=0;if(a==="strip"||a==="strict")c=1;else if(a===ot)u=s;else{let l=s.v(),d=rr(s.g),h=Lg(s,d),m=Hg(h),p=m.t,f=p?Zr(s,"new Array("+l+".length)",r,void 0):je(s,r,void 0,void 0),g=Ug(m,s,d,p?()=>Fg(f,d,m):void 0);(p||g!=="")&&(f.cp=f.cp+("for(let "+d+"="+o+";"+d+"<"+l+".length;++"+d+"){"+g+"}")),u=m.f&1?qg(f,"Promise.all("+f.i+")"):f}if(c===1){let l=os(s,r),d=r.additionalItems,h;if(d==="strip"||d==="strict")if(d==="strip"){let m=s.s.additionalItems;h=m==="strip"||m==="strict"?s.s.items.length!==o:!0}else h=!1;else h=!0;for(let m=0;m<o;++m){let p=i[m],f=m.toString(),g=Wa(s,f);g.e=p,g.io=!1,g.u=t;let y=nr(g);t&&Dr in p&&Zg(s,y,f),kn(l,f,y),h||(h=y.t)}if(h)u=ss(l);else{let m=je(s,void 0,void 0,void 0);m.cp=l.cp,m.d=l.d,u=m}}return ns(u,s)}function XS(e,t){let r=e.s.anyOf;return t.type===Tn&&Qg(t)===void 0&&Kg(t.anyOf,r)||!tT(r,t)?e:eT(e,t)}function YS(e){let t=e.e,r=t.anyOf,n=Ke[e.s.type],i=Qg(t);if(e.s===t&&i===void 0&&r.every(La)||n&256&&Kg(r,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(n&256||e.s.encoder===void 0&&n&512)&&(e.s=ot);let o="";if(!(n&769)){let j=yu(e.s),$=!1,R=!1,N=r.length,I=0;for(;o===""&&I<N;){let G=r[I];yu(G)===j?o=j:G.type===eo?$=!0:G.type===Mr&&(R=!0),I=I+1|0}o===""&&(n&16&&$?o=eo:n&32&&R&&(o=Mr))}let s=o,a=e.i,u=j=>ni(e,function(){let $=arguments,R=Mg(t,ot,e.path,$[0],!0,$.length>1?Array.from($).slice(1):void 0,void 0);throw new ri(R)})+"("+e.v()+j+")",c=je(e,void 0,void 0,void 0),l=[],d={contents:""},h=(j,$)=>{let R=j[0],N=j[1],I="",G="",ye=!1,qe={contents:""},Ye="",zt={},vt=2,xe=j.length-1|0;for(;vt<=xe;){let Fe=tn(N);Fe.u=!0,Fe.t=N.t,Fe.io=!1,Fe.e=j[vt];let Ue=vt===xe,_e=vt===2,hr=_e&&Ue,Ji=!hr,Ar=!1,Qr="",vn={contents:""};try{let Pe=nr(Fe);if(l.push(Pe.s),Qr=Nr(Pe,vn),Pe.t){c.t=!0,Pe.f&1&&(c.f=c.f|1);let Pr=R.v();Pe.i!==Pr&&(Qr=Qr+(Pr+"="+Pe.i))}}catch(Pe){let Pr=ni(Fe,Xa(Pe));Ye=Ye+","+Pr,$&&hr?(d.contents=Pr,Ar=!0):Ue?(Ji=!1,Qr=$?"throw "+Pr:u(Ye)):Ar=!0}let bn=vn.contents,Kn=Qr;if(!Ar&&bn)if(Kn){let Pe=zt[bn];Pe!==void 0?typeof Pe=="string"?zt[bn]=[Pe,Kn]:Pe.push(Kn):zt[bn]=Kn}else qe.contents=qe.contents?qe.contents+"||"+bn:bn;if(!Ar&&(!bn||Ue)){let Pe=Object.keys(zt);for(let Pr=0,sS=Pe.length;Pr<sS;++Pr){let ug=Pe[Pr];I=I+(ye?"else if":"if")+("("+ug+"){");let Ko=zt[ug];if(typeof Ko=="string")I=I+Ko+"}";else{let su="";for(let za=0,aS=Ko.length;za<aS;++za){let cS=Ko[za],dg="e"+za;I=I+("try{"+cS+"}catch("+dg+"){"),su=su+","+dg}I=I+u(su)+"}".repeat(Ko.length)+"}"}ye=!0}zt={}}if(!Ar&&!bn)if(Kn)if(qe.contents&&(I=I+(ye?"else if":"if")+("(!("+qe.contents+")){"),G="}"+G,qe.contents="",ye=!1),Ue&&($||!Ji||_e))I=I+((ye?"else{":"")+Kn),G=(ye?"}":"")+G;else{let Pe="e"+(vt-2|0);I=I+((ye?"else{":"")+"try{"+Kn+"}catch("+Pe+"){"),G=(ye?"}":"")+"}"+G,Ye=Ye+","+Pe,ye=!1}else qe.contents="",vt=xe,Ji=!1;if(Ue){if(qe.contents)I||Ye?I=I+(ye?"else if":"if")+("(!("+qe.contents+")){"+u(Ye)+"}"):Au(N,{c:Pe=>"("+qe.contents+")",f:ut});else if(Ji){let Pe=u(Ye);I=I+(ye?"else{"+Pe+"}":Pe)}}vt=vt+1}return I+G},m="",p="",f="",g=!1,y=r.length-1|0,v={},b=[],w=t.refiner,S=t.inputRefiner,q={contents:void 0},K={contents:void 0},ce=(j,$,R)=>{if($===void 0)return j;let N=I=>{let G=R.contents;if(G!==void 0)return G;let ye=$(I);return R.contents=ye,ye};return j!==void 0?I=>{let G=j(I),ye=N(I);for(let qe=0,Ye=ye.length;qe<Ye;++qe)G.push(ye[qe]);return G}:N},C=j=>{let $=ce(j.refiner,w,q);$!==void 0&&(j.refiner=$);let R=ce(j.inputRefiner,S,K);if(R!==void 0){j.inputRefiner=R;return}},V;if(Dr in e.s){let j=[],$=[];for(let R=0;R<=y;++R){let N=r[R];Dr in N&&N.const===e.s.const?j.push(N):$.push(N)}V=j.concat($)}else V=r;for(let j=0;j<=y;++j){let $=i!==void 0?$n(V[j],G=>{C(G),G.to=i}):V[j],R=$.type,N=Ke[R],I=yu($);if((s===""||s===I)&&!(N&16&&"fromDefault"in t)){let G=v[I];if(G!==void 0)N&64&&oi in $.properties?G.splice(G.length-1|0,0,$):N&2096||G.push($);else{let ye=tn(e),qe;if(N&37633)qe=ot;else{let xe=At($.type,!1);xe.encoder=$.encoder,N&8192?xe.class=$.class:N&64?(xe.properties=Rg,xe.additionalItems=ot):N&128?(xe.additionalItems=ot,xe.items=Qa):N&2096&&(xe.const=$.const),xe.decoder=Fe=>Ke[Fe.s.type]&1?je(Fe,Fe.e,[{c:Ue=>{let _e=Ke[$.type];if(_e&64)return Gg(Ue)+"&&!"+Ba(Ue);if(_e&128)return Ba(Ue);if(_e&8192)return FS(Fe,$.class)(Ue);if(!(_e&4))return _e&2048?Xi(Ue):_e&48?Ue+"==="+us(Fe,$):_e&17418?is($.type)(Ue):"";let hr=is(Sn)(Ue);return Fe.g.o&2?hr:hr+"&&!"+Xi(Ue)},f:ut}],void 0):$.decoder(Fe),qe=xe}ye.e=qe;let Ye;try{Ye=nr(ye)}catch{ye.vc=void 0,Ye=ye}Ag(N,v)?b.unshift(I):b.push(I),v[I]=[ye,Ye,$];let zt=!0,vt=Ye;for(;vt!==void 0&&zt;){let xe=vt;vt=xe.prev,zt=!(xe.vc&&Dg(xe))}if(zt){for(let xe=0,Fe=b.length;xe<Fe;++xe){let Ue=b[xe];if(!g){let _e=v[Ue],hr=_e[1],Ji=h(_e,!0),Ar=Nr(hr,void 0)+Ji,Qr=d.contents;if(Qr)if(d.contents="",Ar){let vn="e"+(j+xe|0);m=m+("try{"+Ar+"throw "+Qr+"}catch("+vn+"){"),p="}"+p,f=f+","+vn}else f=f+","+Qr;else if(Ar){let vn="e"+(j+xe|0);m=m+("try{"+Ar+"}catch("+vn+"){"),p="}"+p,f=f+","+vn}else g=!0}}v={},b=[]}}}}let H=v,fe=b;if(!g){let j=!1,$="";for(let I=0,G=fe.length;I<G;++I){let ye=H[fe[I]],qe=ye[1],Ye=ye[2],zt=h(ye,!1),vt={contents:""},xe=Nr(qe,vt)+zt,Fe=vt.contents;xe||Ag(Ke[Ye.type],H)?(m=m+(j?"else if":"if")+("("+Fe+"){"+xe+"}"),j=!0):$=$?$+"||"+Fe:Fe}let R=u(f),N;$?N=(j?"else if":"if")+("(!("+$+")){"+R+"}"):N=j?"else{"+R+"}":p===""?R+";":R,m=m+N}c.cp=c.cp+m+p,e.i!==c.i&&(c.i=e.i);let ge=c.f&1?(c.i="Promise.resolve("+c.i+")",c.v=Ga,c):c.v===Mt&&e.cp===""&&c.cp===""&&a==="i"?(e.hd="",e.v=Ga,e.i=a,e):c;return ge.s=l.length?as(l):Ru(),ge.e=i!==void 0?(ge.io=!0,En(i)):t,ge}function Kg(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Ke[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function eT(e,t){return je(e,ot,void 0,$n(e.s,r=>{r.to=t}))}function tT(e,t){return!(Ke[En(t).type]&512)&&!(t.type===Tn&&t.anyOf.some(r=>Ke[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Ke[r.type]&512):!1}function Qg(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function Wa(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let l={};e.d=l,n=l}let i=n[t];if(i!==void 0)return tn(i);let o=e.s.type===st?e.s.properties[t]:e.s.items[t],s;if(o!==void 0)s=o;else{let l=e.s.additionalItems;s=l==="strip"||l==="strict"?ds(e,e.s,e.e):e.s.type===st&&l.type!==cs&&!(Ke[l.type]&512)&&!RS(l)?Iu(l):l}let u="["+ii(e.g,t)+"]",c={p:e,v:wu,i:Dr in s?us(e,s):e.v()+u,s,e:s,f:0,cp:"",hd:"",path:e.path+u,g:e.g};return n[t]=c,c}function ss(e){let t=e.s.type===ti,r="",n="",i,o=Object.keys(e.d);for(let c=0,l=o.length;c<l;++c){let d=o[c],h=e.d[d];if(h.f&1&&(n=n+h.i+","),h.o){let m=i;i=p=>(m!==void 0?m(p):"")+("if("+h.v()+"!==void 0){"+p+"["+ii(e.g,d)+"]="+h.i+"}")}else r=r+(t?h.i:ii(e.g,d)+":"+h.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let c=tn(e);c.io=!0;let l=nr(c),d=Nr(l,void 0);return d===""&&n===l.i+","?e.i=l.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+d+"return "+l.i+"})",e.f=e.f|1,e.s=l.s,e.e=l.e,e.io=!0,e}let s=i;if(s===void 0)return e;let a=s(e.v()),u=je(e,void 0,void 0,void 0);return u.cp=u.cp+a,u}function as(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,s=e.length;o<s;++o){let a=e[o];a.type===Tn&&a.to===void 0?(a.anyOf.forEach(u=>{n.add(u)}),Object.assign(r,a.has)):(n.add(a),Jg(r,a.type))}let i=At(Tn,!1);return i.anyOf=Array.from(n),i.decoder=YS,i.encoder=XS,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function Ag(e,t){return e&8320&&st in t?!0:e&2048?Sn in t:!1}function yu(e){return Ke[e.type]&8192?e.class.name:e.type}function La(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Ke[t.type]&512)){let s=t.anyOf;i=s!==void 0?s.every(La):!0}if(i){let s=t.items;n=s!==void 0?s.every(La):!0}if(n){let s=t.properties;r=s!==void 0?Object.values(s).every(La):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function Nu(e){let t=At(ti,e[Qi]===e);return t.additionalItems=e,t.items=Qa,t.decoder=ju,t}function Mu(e,t){let r=t!==void 0?t:Ya(),n=En(e);switch(n.type){case"undefined":return as([r,Pg(e)]);case"union":let o=n.has,s=n.anyOf;return $n(e,a=>{let u=TS(o),c=[];for(let l=0,d=s.length;l<d;++l){let h=s[l],m=En(h),p=m.type,f;if(p==="undefined")u[r.type]=!0,c.push(r),f=Pg(h);else{let g=m.properties;if(g!==void 0){let y=g[oi];f=y!==void 0?$n(h,v=>{let b={},w={...y};w.const=y.const+1,b[oi]=w,v.properties=b}):h}else f=h}c.push(f)}c.length===s.length&&(u[r.type]=!0,c.push(r)),a.anyOf=c,a.has=u});default:return as([e,r])}}function Pg(e){return $n(e,t=>{t.to=QS(),t.parser=KS})}br(zu,"~standard",{get:function(){let e=this;return{version:1,vendor:xu,validate:t=>{try{return{value:Ja(ot,e)(t)}}catch(r){let n=Xa(r);return{issues:[{message:n.reason,path:n.path===""?void 0:$S(n.path)}]}}}}}});function Xg(e,t){return Ja(ot,t)(e)}function rT(e,t){return $n(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let s=i(o),a=n(o);for(let u=0,c=a.length;u<c;++u)s.push(a[u]);return s}:r.refiner=n})}function Yg(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?zS(n):"";return rT(e,s=>(a=>{let u=ni(a,t);return[{c:c=>u+"("+c+")",f:Ou(void 0,o,i,void 0)}]}))}function e_(e,t){return $n(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],s=[];for(let h=0,m=n.length;h<m;++h){let p=n[h],f=En(p);f.type!=="undefined"&&(o.push(f),s.push(p))}let a=o.length,u;if(a!==1)if(a!==0)u=as(o);else{let h="Can't set default for "+He(r);throw new Error("[Sury] "+h)}else u=o[0];let c=s.length!==1?as(s):s[0];if(t.TAG==="Value"){let h=t._0;try{Ja(ot,u)(h)}catch(m){let p=Xa(m),f="Invalid default for "+He(r)+": "+p.message;throw new Error("[Sury] "+f)}try{r.default=Ja(en(c),void 0)(h)}catch{}}r.parser=h=>{let m=h.e.to,p=h.v(),f;return f=t.TAG==="Value"?us(h,Cu(t._0)):ni(h,t._0)+"()",Zr(h,p+"===void 0?"+f+":"+p,m,m)};let l=to(u),d=l.decoder;l.serializer=h=>{let m=en(c);return je(d(h),m,void 0,m)},l.decoder=Ng,r.to=l;return}let i="Can't set default for "+He(r);throw new Error("[Sury] "+i)})}function nT(e){return e[Su]}function Ha(e,t,r){let n=to(En(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===Su)return i;let s=i.items,a=i.properties,u=a!==void 0?a[o]:s!==void 0?s[o]:void 0;if(u===void 0){let c='Cannot read property "'+o+'" of '+He(i);throw new Error("[Sury] "+c)}return Ha(u,i.from.concat(o),i.fromFlattened)}})}function t_(e,t,r){let n=os(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,s=i.length;o<s;++o){let a=o.toString();kn(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let s=Object.keys(o);for(let a=0,u=s.length;a<u;++a){let c=s[a];kn(n,c,r(c,o[c]))}}else{let s="Don't know where the value is coming from: "+He(t);throw new Error("[Sury] "+s)}}return ss(n)}function r_(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?tn(Cg(e.fv[n],t.from,0)):r!==void 0?tn(Cg(e,r,0)):Dr in t?ei(e,t,void 0):t_(e,t,(o,s)=>r_(e,s));return i.prev=void 0,i.e=t,i}function n_(e,t){let r=t.e,n=r.from;if(n!==void 0){let s=r.fromFlattened,a;if(s!==void 0){e.flattened===void 0&&(e.flattened=[]);let u=e.flattened[s];if(u!==void 0)a=u;else{let c={};e.flattened[s]=c,a=c}}else a=e;for(let u=0,c=n.length;u<c;++u){let l=n[u],d=a.properties,h;if(d!==void 0)h=d;else{let f={};a.properties=f,h=f}let m=h[l],p;if(m!==void 0)p=m;else{let f={};h[l]=f,p=f}a=p}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let s=0,a=o.length;s<a;++s)n_(e,i[o[s]])}function qa(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let s=tn(o);return s.t=!0,s.s=r,s.e=r,nr(s)}i=1}else i=1;if(i===1){if(Dr in r){let d=ei(e,r,r);return d.prev=void 0,d.p=e,d.v=wu,d.io=!0,nr(d)}let o=t===void 0?En(r):r,s=os(e,o);s.e=o,s.io=!0,s.prev=void 0,s.p=e,s.v=wu;let a=o.flattened,u=o.items,c=0,l=0;if(u!==void 0&&(t!==void 0||typeof o.additionalItems!==st))for(let d=0,h=u.length;d<h;++d){let m=d.toString(),p;if(t!==void 0){let g=t.properties;p=g!==void 0?g[m]:void 0}else p=void 0;let f=ii(e.g,m);kn(s,m,qa(e,p,u[d],n+("["+f+"]")))}else l=3;if(l===3){let d=o.properties;if(d!==void 0&&(t!==void 0||typeof o.additionalItems!==st)){if(a!==void 0&&t!==void 0){let m=t.flattened;m!==void 0&&m.forEach((p,f)=>{let y=qa(e,p,en(a[f]),n).d,v=Object.keys(y);for(let b=0,w=v.length;b<w;++b){let S=v[b];kn(s,S,y[S])}})}let h=Object.keys(d);for(let m=0,p=h.length;m<p;++m){let f=h[m];if(!(f in s.d)){let g;if(t!==void 0){let v=t.properties;g=v!==void 0?v[f]:void 0}else g=void 0;let y=ii(e.g,f);kn(s,f,qa(e,g,d[f],n+("["+y+"]")))}}}else c=2}if(c===2){let d=r.from,h=d!==void 0?n+d.map(p=>'["'+p+'"]').join(""):n,m=h===""?"":" at "+h;qS(e,"Missing input for "+He(r)+m)}return ss(s)}}function Cg(e,t,r){for(;;){let n=r,i=e,o=t[n];if(o===void 0)return i;r=n+1|0,e=i.d[o]}}function Ka(e,t){if(typeof e!==st||e===null)return Cu(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let u=0,c=e.length;u<c;++u){let l=Ka(e[u],t);e[u]=l}let a=At(ti,!1);return a.items=e,a.additionalItems="strict",a.decoder=ju,a}let n=e.constructor;if(n&&n!==Object){let a=At(Tu,!0);return a.class=n,a.const=e,a.decoder=ro,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let u=i[a],c=Ka(e[u],t);e[u]=c}let s=At(st,!1);return s.required=i,s.properties=e,s.additionalItems=ts.a,s.decoder=fs,s}function iT(e){let t={};n_(t,e);let r=e.e.to,n=qa(e,t,r,"");return n.t=!0,n.prev=e,n}function i_(e){return Ka(e,t=>{if(t["~standard"])return t})}function o_(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return ve(n);let i={},o=[],s=At(st,!1);s.required=o,s.properties=i,s.additionalItems=ts.a,s.decoder=fs;let a=t.f(e,s)[Su],u=(m,p)=>{let f=no(m);if(m in i)throw new Error("[Sury] "+("The field "+f+" defined twice"));return o.push(m),i[m]=p,Ha(p,a.from.concat(m),a.fromFlattened)},h={field:u,f:u,fieldOr:(m,p,f)=>{let g=Mu(p,void 0);return u(m,e_(g,{TAG:"Value",_0:f}))},tag:(m,p)=>{u(m,i_(p))},nested:o_,flatten:m=>{if(m.type==="object"){let g=m.to,y=m.properties;if(g){let w="Unsupported nested flatten for transformed object schema "+He(m);throw new Error("[Sury] "+w)}let v=Object.keys(y),b={};for(let w=0,S=v.length;w<S;++w){let q=v[w];b[q]=u(q,y[q])}return b}let f="Can't flatten "+He(m)+" schema";throw new Error("[Sury] "+f)}};return t[r]=h,h}function oT(e){let t=to(Ka(e,nT));return t.serializer=iT,t}function sT(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,s=t.length;o<s;++o){let a=t[o],u=a.to,c;if(u!==void 0){let l=tn(e);l.e=a,l.io=!0,c=nr(l)}else{let l=t_(e,a,(d,h)=>Wa(e,d));l.e=a,l.prev=void 0,c=ns(l,l)}i.push(c),e.cp=e.cp+Nr(c,void 0)}e.fv=i}let r=e.e.to,n=r_(e,r);return n.t=!0,n.prev=e,ns(n,e)}function s_(e){let t,r={},n=l=>{if(l.type==="object"){let m=l.properties,p=Object.keys(m);for(let g=0,y=p.length;g<y;++g){let v=p[g],b=m[v],w=r[v];if(w!==void 0){if(w!==b)throw new Error("[Sury] "+('The field "'+v+'" defined twice with incompatible schemas'))}else r[v]=b}let f=t||(t=[]);return Ha(l,Qa,f.push(l)-1|0)}let h="The '"+He(l)+"' schema can't be flattened";throw new Error("[Sury] "+h)},i=(l,d)=>{if(l in r)throw new Error("[Sury] "+('The field "'+l+'" defined twice with incompatible schemas'));return r[l]=d,Ha(d,[l],void 0)},u=e({field:i,f:i,fieldOr:(l,d,h)=>{let m=Mu(d,void 0);return i(l,e_(m,{TAG:"Value",_0:h}))},tag:(l,d)=>{i(l,i_(d))},nested:o_,flatten:n}),c=At(st,!1);return c.required=Object.keys(r),c.properties=r,c.additionalItems=ts.a,c.decoder=fs,c.parser=sT,c.to=oT(u),t!==void 0&&(c.flattened=t),c}var zn=Pu();var a_=Bg();var c_=$u;var l_=Nu;var ms=Iu;var rn=Yg;var u_=Xg;var ec=s_;function cT(e){return{path:e.path,summary:e.message}}function F(e){return{path:"",summary:e}}function Du(e,t){try{return{TAG:"Ok",_0:u_(e,t)}}catch(r){let n=X(r);if(n.RE_EXN_ID===c_)return{TAG:"Error",_0:cT(n._1)};throw n}}import*as ps from"node:fs";import*as g_ from"node:os";import*as tc from"node:path";var lT="--api-url must be ws://, wss://, http://, or https://";function Pt(e){let t=Hi(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=ve(t),n=r.protocol,i;switch(n){case"http:":case"https:":i={TAG:"Ok",_0:void 0};break;case"ws:":r.protocol="http:",i={TAG:"Ok",_0:void 0};break;case"wss:":r.protocol="https:",i={TAG:"Ok",_0:void 0};break;default:i={TAG:"Error",_0:lT}}return tt(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var f_="wss://serve.linzumi.com";function hs(){return tc.join(g_.homedir(),".linzumi","auth.json")}var m_="Kandan auth cache must contain a JSON object",uT="Kandan auth cache local_codex_runner must be an object",dT="Kandan auth cache personal_agent_delegation must be an object";function p_(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,r=e.issued_at;if(t===void 0||typeof t!="string"||r===void 0||typeof r!="string")return;let n=e.expires_at,i;return i=typeof n=="string"?n:void 0,{accessToken:t,issuedAt:r,expiresAt:i}}function __(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:F(m_)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:F(m_)};let r=t.local_codex_runner,n=t.personal_agent_delegation,i=r!==void 0?typeof r=="object"&&r!==null&&!Array.isArray(r):!0,o=n!==void 0?typeof n=="object"&&n!==null&&!Array.isArray(n):!0;if(!i)return{TAG:"Error",_0:F(uT)};if(!o)return{TAG:"Error",_0:F(dT)};let s;return s=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(Ht(Object.entries(r),a=>{let u=a[0];return wt(p_(a[1]),c=>[u,c])})):void 0,{TAG:"Ok",_0:{serverTokens:s,personalAgentDelegation:it(n,p_)}}}function y_(e){return ps.existsSync(e)?Y(ke(yr(e),t=>F(t.message)),t=>tt(__(t),r=>r)):{TAG:"Ok",_0:void 0}}function v_(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function rc(e,t,r){return ps.existsSync(t)?Y(y_(t),n=>tt(ke(Pt(e),F),i=>it(it(it(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||v_(o.expiresAt,r)))return{accessToken:o.accessToken,serverBaseUrl:i,issuedAt:o.issuedAt,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function fT(e){return"missing personal-agent delegation auth file: "+e}var mT="personal-agent delegation auth file is missing access_token",pT="personal-agent delegation auth file token is expired";function b_(e,t){return ps.existsSync(e)?Y(y_(e),r=>{let n=it(r,i=>i.personalAgentDelegation);return n!==void 0&&n.accessToken.trim()!==""?v_(n.expiresAt,t)?{TAG:"Error",_0:F(pT)}:{TAG:"Ok",_0:n}:{TAG:"Error",_0:F(mT)}}):{TAG:"Error",_0:F(fT(e))}}function h_(e){let t={};t.access_token=e.accessToken,t.issued_at=e.issuedAt;let r=e.expiresAt;return r!==void 0&&(t.expires_at=r),t}function hT(e){let t={};t.version=1;let r=e.serverTokens;r!==void 0&&(t.local_codex_runner=Object.fromEntries(Object.entries(r).map(i=>[i[0],h_(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=h_(n)),t}function Zu(e,t,r,n,i){return Y(ke(Pt(e),F),o=>{let s=ps.existsSync(n)?Y(ke(yr(n),a=>F(a.message)),__):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return Y(s,a=>{let u=i.toISOString(),c=wt(r,y=>new Date(i.getTime()+y*1e3).toISOString()),l={accessToken:t,issuedAt:u,expiresAt:c},d=a.serverTokens,h=d!==void 0?Object.fromEntries(Object.entries(d)):{};h[o]=l;let m=hT({serverTokens:h,personalAgentDelegation:a.personalAgentDelegation}),p=JSON.stringify(m,void 0,2)+`
110
+ `,f=n+".tmp."+process.pid.toString()+"."+bg(6),g=y=>F(y.message);return Y(ke(vr(tc.dirname(n)),g),()=>{let y=Y(Yo(f,p,{encoding:"utf8",mode:384}),()=>Ca(f,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,serverBaseUrl:o,issuedAt:u,expiresAt:c}}:(Qn(f),{TAG:"Error",_0:F(y._0.message)})})})})}function qu(e){let t=Cr(e);return t!==void 0?lt(Rr(ve(t)),"unknown error"):"unknown error"}async function gs(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=X(r);return{TAG:"Error",_0:{message:qu(n)}}}}async function gT(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=X(t);return{TAG:"Error",_0:{message:qu(r)}}}}async function _s(e){let t=await gT(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=X(r);return{TAG:"Error",_0:{message:qu(n)}}}}function _T(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function oo(e,t,r,n,i){let o=i!==void 0?i:[],s=ke(Pt(e),F);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=Xr("/api/v2/local-codex-runner/oauth/validate",s._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:F(a._0)};let u=a._0,c=u.searchParams;r!==void 0&&c.set("workspace",r),n!==void 0&&c.set("channel",n),o.forEach(p=>{c.append("required_scope",p)});let l={};l.authorization="Bearer "+t;let d=await gs(u.toString(),{method:"GET",headers:l});if(d.TAG!=="Ok")return{TAG:"Error",_0:F(d._0.message)};let h=d._0,m=h.status;if(m>404||m<401){if(m===200){let p=await _s(h);return p.TAG!=="Ok"?{TAG:"Error",_0:F(p._0.message)}:it(_T(p._0),g=>g.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(m<402)return{TAG:"Ok",_0:"Rejected"};switch(m){case 402:break;case 403:return{TAG:"Ok",_0:"Rejected"};case 404:return{TAG:"Ok",_0:"NotFound"}}}return{TAG:"Error",_0:F("local runner auth validation failed with HTTP "+m.toString())}}import*as F_ from"node:os";import*as oc from"node:fs";import*as Ju from"node:os";import*as xt from"node:path";import*as Wu from"node:crypto";function Uu(e){return isFinite(e)?Math.trunc(e)===e:!1}var yT=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),vT=new RegExp("^[a-zA-Z0-9_.-]+$");function Vu(e){return yT.test(e)}function ic(e){return vT.test(e)}var bT=rn(zn,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function T_(e){return{version:1,machineId:e.f("machineId",ms(rn(zn,Vu,"invalid machine id",void 0))),runnerId:e.f("runnerId",ms(rn(zn,ic,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",l_(bT))}}var wT=ec(T_),xT=ec(e=>(e.tag("version",1),T_(e)));function Gu(e){let t=new Set;return Ht(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function $_(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:Gu(e.allowedCwds)}}function Bu(e){return tt(Du(e,xT),$_)}function E_(e){return tt(Du(e,wT),$_)}var nc=ms(rn(zn,e=>e.trim()!=="","must be a non-empty string",void 0)),k_=ms(rn(a_,e=>Uu(e)?e>0:!1,"must be a positive integer",void 0));function kT(e){return!Number.isNaN(new Date(e).getTime())}var S_=rn(zn,kT,"must be a parseable date",void 0),yZ=ec(e=>({email:e.f("email",rn(zn,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",rn(zn,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",nc),refreshToken:e.f("refresh_token",nc),expiresInSeconds:e.f("expires_in_seconds",k_),userId:e.f("user_id",k_),workspaceSlug:e.f("workspace_slug",nc),launchUrl:e.f("launch_url",nc),createdAt:e.f("created_at",S_),updatedAt:e.f("updated_at",S_)}));var Lr="prod";function z_(e){let t=e!==void 0?e:process.env,r=du(t,"HOME");return r!==void 0&&r.trim()!==""?r:Ju.homedir()}function TT(e,t){let r=e!==void 0?e:process.env;return t==="~"?z_(r):t.startsWith("~/")?xt.resolve(z_(r),t.slice(2)):t}function P_(e){let t=du(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?xt.resolve(TT(e,t)):xt.resolve(Ju.homedir(),".linzumi","config.json")}function ys(e){let t=Pt(e),r=Pt(f_);if(t.TAG!=="Ok")return{TAG:"Error",_0:F(t._0)};let n=t._0;return r.TAG==="Ok"?{TAG:"Ok",_0:n===r._0?Lr:n}:{TAG:"Error",_0:F(r._0)}}function $T(e){return tt(ys(e),t=>t===Lr?Lr:Buffer.from(t).toString("base64url"))}function ET(e,t,r){let n=xt.dirname(e),i=xt.basename(e);return t!==void 0?Y(ys(t),o=>o===Lr?{TAG:"Ok",_0:xt.join(n,i+"."+r)}:tt($T(t),s=>xt.join(n,i+"."+s+"."+r))):{TAG:"Ok",_0:xt.join(n,i+"."+r)}}function C_(e){if(oc.existsSync(e))return Y(ke(yr(e),r=>F(r.message)),r=>{let n;try{n=JSON.parse(r)}catch{n=void 0}return typeof n=="object"&&n!==null&&!Array.isArray(n)?Bu(n).TAG==="Ok"?{TAG:"Ok",_0:n}:{TAG:"Error",_0:F("invalid Linzumi config: "+e)}:{TAG:"Error",_0:F("invalid Linzumi config: "+e)}});let t={};return t.version=1,t.allowedCwds=[],{TAG:"Ok",_0:t}}function zT(){let e={};return e.allowedCwds=[],e}function O_(e,t){return Y(C_(e),r=>{let n=t!==void 0?ys(t):{TAG:"Ok",_0:Lr};return Y(n,i=>{let o=i===Lr?r:lt(r[i],zT()),s=i===Lr?Bu(o):E_(o);return ke(s,a=>F("invalid Linzumi config section "+i+": "+e))})})}function OT(e,t){let r=i=>F(i.message),n=oc.existsSync(e)?ke(Pa(e,384),r):{TAG:"Ok",_0:void 0};return Y(Y(n,()=>ke(Yo(e,JSON.stringify(t,void 0,2)+`
111
+ `,{encoding:"utf8",mode:384}),r)),()=>ke(Pa(e,384),r))}function AT(e){let t={},r=e.machineId;r!==void 0&&(t.machineId=r);let n=e.runnerId;return n!==void 0&&(t.runnerId=n),t.allowedCwds=Gu(e.allowedCwds).map(i=>i),t}function PT(e){let t=e.version===1,r=e.machineId,n=r!==void 0?Vu(r):!0,i=e.runnerId,o=i!==void 0?ic(i):!0,s=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&s?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:F("invalid Linzumi config")}}function CT(e,t,r){return Y(PT(e),()=>{let n=r!==void 0?ys(r):{TAG:"Ok",_0:Lr};return Y(n,i=>Y(C_(t),o=>{let s=Object.fromEntries(Object.entries(o)),a=AT(e);return i===Lr?(Object.entries(a).forEach(u=>{s[u[0]]=u[1]}),s.version=1):(s.version=1,s[i]=a),Y(ke(vr(xt.dirname(t)),u=>F(u.message)),()=>OT(t,s))}))})}function A_(e,t,r){return Y(ke(yr(e),n=>F(n.message)),n=>{let i=n.trim();return t(i)?{TAG:"Ok",_0:i}:{TAG:"Error",_0:F("invalid Linzumi "+r+" seed: "+e)}})}function RT(e,t,r,n){if(oc.existsSync(e))return A_(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:F("invalid generated Linzumi "+n+": "+i)};let o=xt.dirname(e),s=xt.basename(e),a=xt.join(o,"."+s+"."+process.pid.toString()+"."+Wu.randomUUID()+".tmp"),u=c=>F(c.message);return Y(Y(ke(vr(o),u),()=>ke(Yo(a,i+`
112
+ `,{encoding:"utf8",flag:"wx"}),u)),()=>{let c=yg(a,e),l;if(c.TAG==="Ok")l={TAG:"Ok",_0:i};else{let d=c._0;l=gg(d,"EEXIST")?A_(e,r,n):{TAG:"Error",_0:F(d.message)}}return vg(a),l})}function IT(){return"runner-"+Wu.randomUUID()}function jT(e,t,r,n,i,o,s,a){let u=t!==void 0?tt(ys(t),c=>{if(c!==Lr)return t}):{TAG:"Ok",_0:void 0};return Y(u,c=>Y(O_(e,c),l=>{let d=s(l);return d!==void 0?{TAG:"Ok",_0:d}:Y(ET(e,c,r),h=>Y(RT(h,n,i,o),m=>Y(O_(e,c),p=>{let f=s(p);return f!==void 0?{TAG:"Ok",_0:f}:tt(CT(a(p,m),e,c),()=>m)})))}))}function R_(e,t,r){return jT(e,t,"runner-id",r!==void 0?r:IT,ic,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}function I_(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function j_(e,t){if(e===void 0)return t!==void 0?"local runner device authorization failed (HTTP "+t.toString()+", no reason returned by the server)":"local runner device authorization failed (no reason returned by the server)";switch(e){case"access_denied":return"local runner device authorization was denied";case"approving_user_not_found":return"local runner device authorization failed: the approving Linzumi account could not be found";case"device_session_consumed":return"local runner device authorization was already used";case"device_session_expired":return"local runner device authorization expired";case"device_session_not_pending":return"local runner device authorization was already decided (approved or denied) on the server";case"invalid_device_code":return"local runner device authorization code was rejected";case"invalid_user_code":return"local runner device authorization code was not recognized by the server";case"rate_limited":return"local runner device authorization was rate limited by the server; wait a minute and retry";default:return"local runner device authorization failed (server said: "+e+")"}}function so(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function N_(e,t,r,n,i){let o=Xr("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:F(o._0)};let s={},a=(g,y)=>{if(y!==void 0){s[g]=y;return}};a("workspace",t),a("channel",r),a("onboarding",n),i!==void 0&&(a("runner_id",i.commanderId),a("machine_fingerprint",i.machineFingerprint),a("hostname",i.hostname));let u={};u["content-type"]="application/json";let c=await gs(o._0.toString(),{method:"POST",headers:u,body:JSON.stringify(s)});if(c.TAG!=="Ok")return{TAG:"Error",_0:F(c._0.message)};let l=c._0,d=l.status,h=await _s(l);if(h.TAG!=="Ok")return{TAG:"Error",_0:F(h._0.message)};let m=h._0;if(d>=200&&d<300){if(Array.isArray(m))return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(m!==null)switch(typeof m){case"object":let g=so(m,"device_code"),y=so(m,"user_code"),v=so(m,"verification_uri");if(g===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(y===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};if(v===void 0)return{TAG:"Error",_0:F("local runner device authorization response was incomplete")};let b=m.expires_in,w;return w=typeof b=="number"?b:void 0,{TAG:"Ok",_0:{deviceCode:g,userCode:y,verificationUri:v,expiresInSeconds:w}}}}let f=I_(m);return{TAG:"Error",_0:F(f!==void 0?"local runner device authorization failed to start (server said: "+f+")":"local runner device authorization failed to start (HTTP "+d.toString()+")")}}async function MT(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let s={};s["content-type"]="application/json";let a=Xr("/api/v2/local-codex-runner/device/token",e),u;if(u=a.TAG==="Ok"?await gs(a._0.toString(),{method:"POST",headers:s,body:JSON.stringify(o),signal:gr(n.signal)}):{TAG:"Error",_0:{message:a._0}},u.TAG==="Ok"){let c=u._0,l=c.status,d=await _s(c);if(clearTimeout(i),d.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+d._0.message+")",httpStatus:l}};let h=d._0,m=l>=200&&l<300,p=I_(h),f=0;if(l!==202||p===void 0)f=1;else{if(p==="authorization_pending")return"Continue";f=1}if(f===1){let g=0;if(m){if(Array.isArray(h))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};if(h===null)g=2;else switch(typeof h){case"object":let y=so(h,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};let v=h.expires_in,b;return b=typeof v=="number"?v:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:b,workspaceSlug:so(h,"workspace"),channelSlug:so(h,"channel")}}};default:g=2}}else g=2;if(g===2){let y=0;if(p!==void 0)switch(p){case"access_denied":return{TAG:"Done",_0:"Denied"};case"device_session_consumed":return{TAG:"Done",_0:"Consumed"};case"device_session_expired":return{TAG:"Done",_0:"CodeExpired"};default:y=3}else y=3;if(y===3)return l>=500||l===429?{TAG:"Done",_0:{TAG:"Transient",reason:p!==void 0?p:"HTTP "+l.toString(),httpStatus:l}}:{TAG:"Done",_0:{TAG:"Rejected",reason:p,httpStatus:l}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:u._0.message,httpStatus:void 0}}}async function M_(e,t,r,n){let i=n!==void 0?n:()=>Date.now(),o=r!==void 0&&r>=0?r:600,s=i()+o*1e3,a=async()=>{if(i()>=s)return"CodeExpired";let u=Math.max(0,Math.min(3e4,s-i())),c=await MT(e,t,u);return typeof c!="object"?await a():c._0};return await a()}var ZT=3600*1e3;function LT(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<ZT?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function D_(e){let t=Math.floor(e/6e4),r=Math.floor(t/60),n=t-r*60;return r>0?r.toString()+"h "+n.toString()+"m":n.toString()+"m"}function qT(e){switch(e.TAG){case"Prompt":return(e.cycle===1?"":`The previous code expired; here is a fresh one (no restart needed - this prompt stays alive).
113
113
  `)+`Authorize this computer:
114
114
  Code: `+e.userCode+`
115
115
  Open: `+e.verificationUri+`
@@ -119,8 +119,8 @@ Code: `+e.userCode+`
119
119
  Open: `+e.verificationUri+`
120
120
  `);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+D_(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e.reason+`); retrying with the same code.
121
121
  `;case"StartFailed":return"Could not mint a device authorization code ("+e.reason+"); retrying in "+Math.round(e.retryInMs/1e3).toString()+`s.
122
- `}}function ZT(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function LT(e){return{startDeviceAuthorization:t=>N_(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>M_(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds,void 0),now:()=>Date.now(),sleep:ZT,report:e,log:(t,r)=>{}}}var qT="local runner device authorization was denied - a signed-in user rejected this computer";async function Z_(e,t,r,n,i,o,s,a){let u=o!==void 0?o:y=>{es(y)},c=a!==void 0?a:LT(y=>u(DT(y))),l=s!==void 0?s:Ot(Wi(process.stderr.isTTY),!0),d=ke(Pt(e),F);if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let h=d._0,m=c.now(),p={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},f=async y=>{let v=await c.pollDeviceCodeForToken({httpBaseUrl:h,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof v!="object"||v.TAG!=="Transient")return v;let b=v.httpStatus,w=v.reason;c.report({TAG:"TransientFailure",reason:w,waitedMs:c.now()-m});let S={};return S.cycle=p.cycle,S.reason=w,S.httpStatus=b!==void 0?b:null,c.log("device_wait.transient_poll_failure",S),await c.sleep(5e3),await f(y)},g=async()=>{let y=await c.startDeviceAuthorization({httpBaseUrl:h,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let v=y._0;p.startFailures=0,p.cycle=p.cycle+1|0;let b=MT(p.cycle,c.now(),p.lastLoudPromptAtMs,l),w=0;switch(b){case"DecidePrompt":case"DecideSummary":w=1;break;case"DecideRefreshLine":c.report({TAG:"RefreshLine",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:c.now()-m});break;case"DecideSilent":break}if(w===1){p.lastLoudPromptAtMs=c.now();let K=c.now()-m,ce;ce=b==="DecidePrompt"?{TAG:"Prompt",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:K}:{TAG:"Summary",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:K},c.report(ce)}let S={};S.cycle=p.cycle,S.verificationUri=v.verificationUri,c.log("device_wait.code_issued",S);let q=await f(v);if(typeof q!="object")switch(q){case"CodeExpired":let K={};return K.cycle=p.cycle,K.outcome="code_expired",c.log("device_wait.code_retired",K),await g();case"Denied":return{TAG:"Error",_0:F(qT)};case"Consumed":let ce={};return ce.cycle=p.cycle,ce.outcome="consumed",c.log("device_wait.code_retired",ce),await g()}else switch(q.TAG){case"Token":let K={};return K.cycle=p.cycle,K.waitedMs=c.now()-m,c.log("device_wait.authorized",K),{TAG:"Ok",_0:q._0};case"Rejected":let ce=q.httpStatus,C=q.reason;c.report({TAG:"TransientFailure",reason:j_(C,ce),waitedMs:c.now()-m});let V={};return V.cycle=p.cycle,V.reason=C!==void 0?C:null,V.httpStatus=ce,c.log("device_wait.code_rejected",V),await g();case"Transient":return await g()}}else{let v=y._0;p.startFailures=p.startFailures+1|0;let b=Math.min(6e4,5e3*Math.pow(2,p.startFailures-1|0));c.report({TAG:"StartFailed",reason:v.summary,retryInMs:b});let w={};return w.reason=v.summary,w.retryInMs=b,w.attempt=p.startFailures,c.log("device_wait.start_failed",w),await c.sleep(b),await g()}};return await g()}var VT="linzumi-machine-fingerprint:v1:";var L_={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function GT(e,t){return xg(e,t,5e3,1024*1024)}var BT=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),JT=new RegExp("^[0-9a-f]{32}$"),WT=["/etc/machine-id","/var/lib/dbus/machine-id"];function HT(e){let t=e!==void 0?e:L_,r=lt(t.platform,process.platform),n=lt(t.execFile,GT),i=lt(t.readFile,yr);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let s=BT.exec(o._0);if(s==null)return;let a=s.slice(1)[0];if(a===void 0)return;let u=ve(a);return u!==void 0?u.toLowerCase():void 0;case"linux":return Og(WT,void 0,(c,l)=>{if(c!==void 0)return c;let d=i(l);if(d.TAG!=="Ok")return;let h=d._0.trim().toLowerCase();if(JT.test(h))return h});default:return}}function q_(e){return wt(HT(e!==void 0?e:L_),r=>"mfp-"+Ra(VT+r).slice(0,32))}function QT(e,t){return Y(ke(Pt(e),F),r=>{let n=Hi(r);return n===void 0?{TAG:"Error",_0:F("invalid URL: "+r)}:{TAG:"Ok",_0:"Workspace '"+(t!==void 0?t:"undefined")+"' was not found on "+ve(n).host+". Sign in to the web app to create it, then re-run connect."}})}var XT="local runner browser OAuth is not available in this implementation yet; use --auth-mode device or supply --token";async function YT(e){let t=P_(process.env),r=R_(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=q_(void 0),o=F_.hostname(),s={commanderId:n,machineFingerprint:i,hostname:o},a=await Z_(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,s,void 0,void 0,void 0);if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u=a._0,c=e.authFilePath,l=c!==void 0?c:hs();return tt(Zu(e.serviceUrl,u.accessToken,u.expiresInSeconds,l,new Date),d=>u.accessToken)}async function e$(e){let t=e.authMode;return typeof(t!==void 0?t:{TAG:"BrowserMode",callbackHost:e.callbackHost})!="object"?await YT(e):{TAG:"Error",_0:F(XT)}}function t$(){return{readCachedToken:(e,t)=>rc(e,t,Date.now()),validateToken:(e,t,r,n,i)=>oo(e,t,r,n,i),acquireAndCacheToken:e$}}async function r$(e,t,r){let n=await t.validateToken(e.serviceUrl,r,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(n.TAG!=="Ok")return{TAG:"Ok",_0:void 0};switch(n._0){case"Usable":case"Rejected":return{TAG:"Ok",_0:void 0};case"NotFound":return Y(QT(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:F(i)}))}}async function U_(e,t){let r=t!==void 0?t:t$(),n=e.explicitToken;if(n!==void 0)return{TAG:"Ok",_0:n};let i=e.authFilePath,o=i!==void 0?i:hs(),s=r.readCachedToken(e.serviceUrl,o);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=s._0,u;if(a!==void 0){let p=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(p.TAG==="Ok")switch(p._0){case"Usable":u={TAG:"Ok",_0:a.accessToken};break;case"Rejected":let f=e.reportRejectedCachedToken;f!==void 0&&f("UnusableRejected"),u={TAG:"Ok",_0:void 0};break;case"NotFound":let g=e.reportRejectedCachedToken;g!==void 0&&g("UnusableNotFound"),u={TAG:"Ok",_0:void 0};break}else u={TAG:"Error",_0:p._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c!==void 0)return{TAG:"Ok",_0:c};let l=await r.acquireAndCacheToken(e);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:d};let m=await r$(e,r,d);return m.TAG==="Ok"?{TAG:"Ok",_0:d}:{TAG:"Error",_0:m._0}}function i$(){return{readCachedToken:(e,t)=>rc(e,t,Date.now()),validateTokenOutcome:(e,t,r,n)=>oo(e,t,r,n,void 0),resolveToken:e=>U_(e,void 0)}}var o$="missing Linzumi MCP token; run linzumi auth or pass --token";function s$(e){return"Linzumi MCP token was rejected by the server and re-mint failed: "+e}async function V_(e,t,r,n,i,o){let s=o!==void 0?o:i$(),a=r!==void 0?r:hs(),u=t!==void 0?{TAG:"Ok",_0:t}:tt(s.readCachedToken(e,a),h=>wt(h,m=>m.accessToken));if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c===void 0)return{TAG:"Error",_0:F(o$)};let l=await s.validateTokenOutcome(e,c,n,i);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};switch(l._0){case"Usable":return{TAG:"Ok",_0:c};case"Rejected":case"NotFound":break}let d=await s.resolveToken({serviceUrl:e,explicitToken:void 0,workspaceSlug:n,channelSlug:i,requiredScopes:[],onboarding:void 0,authFilePath:r,callbackHost:void 0,authMode:void 0,reportRejectedCachedToken:void 0});return d.TAG==="Ok"?{TAG:"Ok",_0:d._0}:{TAG:"Error",_0:F(s$(d._0.summary))}}var _={};cu(_,{BRAND:()=>R$,DIRTY:()=>ai,EMPTY_PATH:()=>d$,INVALID:()=>B,NEVER:()=>gz,OK:()=>kt,ParseStatus:()=>dt,Schema:()=>re,ZodAny:()=>Pn,ZodArray:()=>cn,ZodBigInt:()=>li,ZodBoolean:()=>ui,ZodBranded:()=>bs,ZodCatch:()=>wi,ZodDate:()=>di,ZodDefault:()=>bi,ZodDiscriminatedUnion:()=>cc,ZodEffects:()=>or,ZodEnum:()=>yi,ZodError:()=>Dt,ZodFirstPartyTypeKind:()=>z,ZodFunction:()=>uc,ZodIntersection:()=>hi,ZodIssueCode:()=>T,ZodLazy:()=>gi,ZodLiteral:()=>_i,ZodMap:()=>mo,ZodNaN:()=>ho,ZodNativeEnum:()=>vi,ZodNever:()=>wr,ZodNull:()=>mi,ZodNullable:()=>Ur,ZodNumber:()=>ci,ZodObject:()=>Lt,ZodOptional:()=>Zt,ZodParsedType:()=>A,ZodPipeline:()=>ws,ZodPromise:()=>Cn,ZodReadonly:()=>xi,ZodRecord:()=>lc,ZodSchema:()=>re,ZodSet:()=>po,ZodString:()=>An,ZodSymbol:()=>uo,ZodTransformer:()=>or,ZodTuple:()=>Fr,ZodType:()=>re,ZodUndefined:()=>fi,ZodUnion:()=>pi,ZodUnknown:()=>an,ZodVoid:()=>fo,addIssueToContext:()=>O,any:()=>F$,array:()=>B$,bigint:()=>M$,boolean:()=>ty,coerce:()=>hz,custom:()=>X_,date:()=>D$,datetimeRegex:()=>K_,defaultErrorMap:()=>on,discriminatedUnion:()=>H$,effect:()=>az,enum:()=>iz,function:()=>tz,getErrorMap:()=>ao,getParsedType:()=>qr,instanceof:()=>j$,intersection:()=>K$,isAborted:()=>sc,isAsync:()=>co,isDirty:()=>ac,isValid:()=>On,late:()=>I$,lazy:()=>rz,literal:()=>nz,makeIssue:()=>vs,map:()=>Y$,nan:()=>N$,nativeEnum:()=>oz,never:()=>V$,null:()=>q$,nullable:()=>lz,number:()=>ey,object:()=>Xu,objectUtil:()=>Hu,oboolean:()=>pz,onumber:()=>mz,optional:()=>cz,ostring:()=>fz,pipeline:()=>dz,preprocess:()=>uz,promise:()=>sz,quotelessJson:()=>c$,record:()=>X$,set:()=>ez,setErrorMap:()=>u$,strictObject:()=>J$,string:()=>Y_,symbol:()=>Z$,transformer:()=>az,tuple:()=>Q$,undefined:()=>L$,union:()=>W$,unknown:()=>U$,util:()=>se,void:()=>G$});var se;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},e.find=(i,o)=>{for(let s of i)if(o(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(se||(se={}));var Hu;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Hu||(Hu={}));var A=se.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qr=e=>{switch(typeof e){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(e)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":return Array.isArray(e)?A.array:e===null?A.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?A.promise:typeof Map<"u"&&e instanceof Map?A.map:typeof Set<"u"&&e instanceof Set?A.set:typeof Date<"u"&&e instanceof Date?A.date:A.object;default:return A.unknown}};var 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"]),c$=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Dt=class e extends Error{get errors(){return this.issues}constructor(t){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=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,se.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Dt.create=e=>new Dt(e);var l$=(e,t)=>{let r;switch(e.code){case T.invalid_type:e.received===A.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,se.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${se.joinValues(e.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${se.joinValues(e.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${se.joinValues(e.options)}, received '${e.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 e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:se.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case T.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case T.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case 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 ${e.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=t.defaultError,se.assertNever(e)}return{message:r}},on=l$;var G_=on;function u$(e){G_=e}function ao(){return G_}var vs=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(s,{data:t,defaultError:a}).message;return{...i,path:o,message:a}},d$=[];function O(e,t){let r=ao(),n=vs({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===on?void 0:on].filter(i=>!!i)});e.common.issues.push(n)}var dt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return B;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return B;o.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:t.value,value:n}}},B=Object.freeze({status:"aborted"}),ai=e=>({status:"dirty",value:e}),kt=e=>({status:"valid",value:e}),sc=e=>e.status==="aborted",ac=e=>e.status==="dirty",On=e=>e.status==="valid",co=e=>typeof Promise<"u"&&e instanceof Promise;var M;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(M||(M={}));var ir=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},B_=(e,t)=>{if(On(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Dt(e.common.issues);return this._error=r,this._error}}};function ee(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(s,a)=>{let{message:u}=e;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:i}}var re=class{get description(){return this._def.description}_getType(t){return qr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:qr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new dt,ctx:{common:t.parent.common,data:t.data,parsedType:qr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(co(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)},i=this._parseSync({data:t,path:n.path,parent:n});return B_(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return On(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:t,path:[],parent:r}).then(n=>On(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(co(i)?i:Promise.resolve(i));return B_(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=t(i),a=()=>o.addIssue({code:T.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new or({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Zt.create(this,this._def)}nullable(){return Ur.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cn.create(this)}promise(){return Cn.create(this,this._def)}or(t){return pi.create([this,t],this._def)}and(t){return hi.create(this,t,this._def)}transform(t){return new or({...ee(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new bi({...ee(this._def),innerType:this,defaultValue:r,typeName:z.ZodDefault})}brand(){return new bs({typeName:z.ZodBranded,type:this,...ee(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new wi({...ee(this._def),innerType:this,catchValue:r,typeName:z.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return ws.create(this,t)}readonly(){return xi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},f$=/^c[^\s-]{8,}$/i,m$=/^[0-9a-z]+$/,p$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,h$=/^[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,g$=/^[a-z0-9_-]{21}$/i,_$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y$=/^[-+]?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)?)??$/,v$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,b$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ku,w$=/^(?:(?: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])$/,x$=/^(?:(?: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])$/,k$=/^(([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]))$/,S$=/^(([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])$/,T$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,W_="((\\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])))",z$=new RegExp(`^${W_}$`);function H_(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function E$(e){return new RegExp(`^${H_(e)}$`)}function K_(e){let t=`${W_}T${H_(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function O$(e,t){return!!((t==="v4"||!t)&&w$.test(e)||(t==="v6"||!t)&&k$.test(e))}function A$(e,t){if(!_$.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function P$(e,t){return!!((t==="v4"||!t)&&x$.test(e)||(t==="v6"||!t)&&S$.test(e))}var An=class e extends re{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==A.string){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.string,received:o.parsedType}),B}let n=new dt,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=t.data.length>o.value,a=t.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(t,i),s?O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")v$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"email",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Ku||(Ku=new RegExp(b$,"u")),Ku.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"emoji",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")h$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"uuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")g$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"nanoid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")f$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")m$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid2",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")p$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ulid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),O(i,{validation:"url",code:T.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"regex",code:T.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?K_(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?E$(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?y$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"duration",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?O$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ip",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?A$(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"jwt",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?P$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cidr",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?T$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?$$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64url",code:T.invalid_string,message:o.message}),n.dirty()):se.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:T.invalid_string,...M.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...M.errToObj(t)})}url(t){return this._addCheck({kind:"url",...M.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...M.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...M.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...M.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...M.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...M.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...M.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...M.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...M.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...M.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...M.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...M.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...M.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...M.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...M.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...M.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...M.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...M.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...M.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...M.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...M.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...M.errToObj(r)})}nonempty(t){return this.min(1,M.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};An.create=e=>new An({checks:[],typeName:z.ZodString,coerce:e?.coerce??!1,...ee(e)});function C$(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}var ci=class e extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==A.number){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.number,received:o.parsedType}),B}let n,i=new dt;for(let o of this._def.checks)o.kind==="int"?se.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?C$(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_finite,message:o.message}),i.dirty()):se.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:M.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:M.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:M.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&se.isInteger(t.value))}get isFinite(){let t=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"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ci.create=e=>new ci({checks:[],typeName:z.ZodNumber,coerce:e?.coerce||!1,...ee(e)});var li=class e extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==A.bigint)return this._getInvalidInput(t);let n,i=new dt;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):se.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:A.bigint,received:r.parsedType}),B}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:M.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};li.create=e=>new li({checks:[],typeName:z.ZodBigInt,coerce:e?.coerce??!1,...ee(e)});var ui=class extends re{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==A.boolean){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.boolean,received:n.parsedType}),B}return kt(t.data)}};ui.create=e=>new ui({typeName:z.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});var di=class e extends re{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==A.date){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.date,received:o.parsedType}),B}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_date}),B}let n=new dt,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):se.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:M.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:M.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};di.create=e=>new di({checks:[],coerce:e?.coerce||!1,typeName:z.ZodDate,...ee(e)});var uo=class extends re{_parse(t){if(this._getType(t)!==A.symbol){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.symbol,received:n.parsedType}),B}return kt(t.data)}};uo.create=e=>new uo({typeName:z.ZodSymbol,...ee(e)});var fi=class extends re{_parse(t){if(this._getType(t)!==A.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.undefined,received:n.parsedType}),B}return kt(t.data)}};fi.create=e=>new fi({typeName:z.ZodUndefined,...ee(e)});var mi=class extends re{_parse(t){if(this._getType(t)!==A.null){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.null,received:n.parsedType}),B}return kt(t.data)}};mi.create=e=>new mi({typeName:z.ZodNull,...ee(e)});var Pn=class extends re{constructor(){super(...arguments),this._any=!0}_parse(t){return kt(t.data)}};Pn.create=e=>new Pn({typeName:z.ZodAny,...ee(e)});var an=class extends re{constructor(){super(...arguments),this._unknown=!0}_parse(t){return kt(t.data)}};an.create=e=>new an({typeName:z.ZodUnknown,...ee(e)});var wr=class extends re{_parse(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:A.never,received:r.parsedType}),B}};wr.create=e=>new wr({typeName:z.ZodNever,...ee(e)});var fo=class extends re{_parse(t){if(this._getType(t)!==A.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.void,received:n.parsedType}),B}return kt(t.data)}};fo.create=e=>new fo({typeName:z.ZodVoid,...ee(e)});var cn=class e extends re{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==A.array)return O(r,{code:T.invalid_type,expected:A.array,received:r.parsedType}),B;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(O(r,{code:s?T.too_big:T.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(O(r,{code:T.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(O(r,{code:T.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new ir(r,s,r.path,a)))).then(s=>dt.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new ir(r,s,r.path,a)));return dt.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:M.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:M.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:M.toString(r)}})}nonempty(t){return this.min(1,t)}};cn.create=(e,t)=>new cn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...ee(t)});function lo(e){if(e instanceof Lt){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Zt.create(lo(n))}return new Lt({...e._def,shape:()=>t})}else return e instanceof cn?new cn({...e._def,type:lo(e.element)}):e instanceof Zt?Zt.create(lo(e.unwrap())):e instanceof Ur?Ur.create(lo(e.unwrap())):e instanceof Fr?Fr.create(e.items.map(t=>lo(t))):e}var Lt=class e extends re{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=se.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==A.object){let c=this._getOrReturnCtx(t);return O(c,{code:T.invalid_type,expected:A.object,received:c.parsedType}),B}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof wr&&this._def.unknownKeys==="strip"))for(let c in i.data)s.includes(c)||a.push(c);let u=[];for(let c of s){let l=o[c],d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new ir(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof wr){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(O(i,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new ir(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,h=await l.value;c.push({key:d,value:h,alwaysSet:l.alwaysSet})}return c}).then(c=>dt.mergeObjectSync(n,c)):dt.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return M.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:M.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:z.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of se.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of se.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return lo(this)}partial(t){let r={};for(let n of se.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of se.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Zt;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return Q_(se.objectKeys(this.shape))}};Lt.create=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strip",catchall:wr.create(),typeName:z.ZodObject,...ee(t)});Lt.strictCreate=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strict",catchall:wr.create(),typeName:z.ZodObject,...ee(t)});Lt.lazycreate=(e,t)=>new Lt({shape:e,unknownKeys:"strip",catchall:wr.create(),typeName:z.ZodObject,...ee(t)});var pi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Dt(a.ctx.common.issues));return O(r,{code:T.invalid_union,unionErrors:s}),B}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(u=>new Dt(u));return O(r,{code:T.invalid_union,unionErrors:a}),B}}get options(){return this._def.options}};pi.create=(e,t)=>new pi({options:e,typeName:z.ZodUnion,...ee(t)});var sn=e=>e instanceof gi?sn(e.schema):e instanceof or?sn(e.innerType()):e instanceof _i?[e.value]:e instanceof yi?e.options:e instanceof vi?se.objectValues(e.enum):e instanceof bi?sn(e._def.innerType):e instanceof fi?[void 0]:e instanceof mi?[null]:e instanceof Zt?[void 0,...sn(e.unwrap())]:e instanceof Ur?[null,...sn(e.unwrap())]:e instanceof bs||e instanceof xi?sn(e.unwrap()):e instanceof wi?sn(e._def.innerType):[],cc=class e extends re{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.object)return O(r,{code:T.invalid_type,expected:A.object,received:r.parsedType}),B;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(O(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),B)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let s=sn(o.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,o)}}return new e({typeName:z.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ee(n)})}};function Qu(e,t){let r=qr(e),n=qr(t);if(e===t)return{valid:!0,data:e};if(r===A.object&&n===A.object){let i=se.objectKeys(t),o=se.objectKeys(e).filter(a=>i.indexOf(a)!==-1),s={...e,...t};for(let a of o){let u=Qu(e[a],t[a]);if(!u.valid)return{valid:!1};s[a]=u.data}return{valid:!0,data:s}}else if(r===A.array&&n===A.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let s=e[o],a=t[o],u=Qu(s,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===A.date&&n===A.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var hi=class extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,s)=>{if(sc(o)||sc(s))return B;let a=Qu(o.value,s.value);return a.valid?((ac(o)||ac(s))&&r.dirty(),{status:r.value,value:a.data}):(O(n,{code:T.invalid_intersection_types}),B)};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(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};hi.create=(e,t,r)=>new hi({left:e,right:t,typeName:z.ZodIntersection,...ee(r)});var Fr=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.array)return O(n,{code:T.invalid_type,expected:A.array,received:n.parsedType}),B;if(n.data.length<this._def.items.length)return O(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&n.data.length>this._def.items.length&&(O(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new ir(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>dt.mergeArray(r,s)):dt.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Fr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fr({items:e,typeName:z.ZodTuple,rest:null,...ee(t)})};var lc=class e extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.object)return O(n,{code:T.invalid_type,expected:A.object,received:n.parsedType}),B;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new ir(n,a,n.path,a)),value:s._parse(new ir(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?dt.mergeObjectAsync(r,i):dt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof re?new e({keyType:t,valueType:r,typeName:z.ZodRecord,...ee(n)}):new e({keyType:An.create(),valueType:t,typeName:z.ZodRecord,...ee(r)})}},mo=class extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.map)return O(n,{code:T.invalid_type,expected:A.map,received:n.parsedType}),B;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,u],c)=>({key:i._parse(new ir(n,a,n.path,[c,"key"])),value:o._parse(new ir(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of s){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return B;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of s){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return B;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};mo.create=(e,t,r)=>new mo({valueType:t,keyType:e,typeName:z.ZodMap,...ee(r)});var po=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.set)return O(n,{code:T.invalid_type,expected:A.set,received:n.parsedType}),B;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(O(n,{code:T.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(O(n,{code:T.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(u){let c=new Set;for(let l of u){if(l.status==="aborted")return B;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>o._parse(new ir(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>s(u)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:M.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:M.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};po.create=(e,t)=>new po({valueType:e,minSize:null,maxSize:null,typeName:z.ZodSet,...ee(t)});var uc=class e extends re{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.function)return O(r,{code:T.invalid_type,expected:A.function,received:r.parsedType}),B;function n(a,u){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ao(),on].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:u}})}function i(a,u){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ao(),on].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Cn){let a=this;return kt(async function(...u){let c=new Dt([]),l=await a._def.args.parseAsync(u,o).catch(m=>{throw c.addIssue(n(u,m)),c}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(m=>{throw c.addIssue(i(d,m)),c})})}else{let a=this;return kt(function(...u){let c=a._def.args.safeParse(u,o);if(!c.success)throw new Dt([n(u,c.error)]);let l=Reflect.apply(s,this,c.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new Dt([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Fr.create(t).rest(an.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Fr.create([]).rest(an.create()),returns:r||an.create(),typeName:z.ZodFunction,...ee(n)})}},gi=class extends re{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};gi.create=(e,t)=>new gi({getter:e,typeName:z.ZodLazy,...ee(t)});var _i=class extends re{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return O(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:t.data}}get value(){return this._def.value}};_i.create=(e,t)=>new _i({value:e,typeName:z.ZodLiteral,...ee(t)});function Q_(e,t){return new yi({values:e,typeName:z.ZodEnum,...ee(t)})}var yi=class e extends re{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{expected:se.joinValues(n),received:r.parsedType,code:T.invalid_type}),B}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{received:r.data,code:T.invalid_enum_value,options:n}),B}return kt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};yi.create=Q_;var vi=class extends re{_parse(t){let r=se.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==A.string&&n.parsedType!==A.number){let i=se.objectValues(r);return O(n,{expected:se.joinValues(i),received:n.parsedType,code:T.invalid_type}),B}if(this._cache||(this._cache=new Set(se.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=se.objectValues(r);return O(n,{received:n.data,code:T.invalid_enum_value,options:i}),B}return kt(t.data)}get enum(){return this._def.values}};vi.create=(e,t)=>new vi({values:e,typeName:z.ZodNativeEnum,...ee(t)});var Cn=class extends re{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.promise&&r.common.async===!1)return O(r,{code:T.invalid_type,expected:A.promise,received:r.parsedType}),B;let n=r.parsedType===A.promise?r.data:Promise.resolve(r.data);return kt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Cn.create=(e,t)=>new Cn({type:e,typeName:z.ZodPromise,...ee(t)});var or=class extends re{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:s=>{O(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return B;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?B:u.status==="dirty"?ai(u.value):r.value==="dirty"?ai(u.value):u});{if(r.value==="aborted")return B;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?B:a.status==="dirty"?ai(a.value):r.value==="dirty"?ai(a.value):a}}if(i.type==="refinement"){let s=a=>{let u=i.refinement(a,o);if(n.common.async)return Promise.resolve(u);if(u 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"?B:(a.status==="dirty"&&r.dirty(),s(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"?B:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!On(s))return B;let a=i.transform(s.value,o);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(s=>On(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):B);se.assertNever(i)}};or.create=(e,t,r)=>new or({schema:e,typeName:z.ZodEffects,effect:t,...ee(r)});or.createWithPreprocess=(e,t,r)=>new or({schema:t,effect:{type:"preprocess",transform:e},typeName:z.ZodEffects,...ee(r)});var Zt=class extends re{_parse(t){return this._getType(t)===A.undefined?kt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zt.create=(e,t)=>new Zt({innerType:e,typeName:z.ZodOptional,...ee(t)});var Ur=class extends re{_parse(t){return this._getType(t)===A.null?kt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ur.create=(e,t)=>new Ur({innerType:e,typeName:z.ZodNullable,...ee(t)});var bi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===A.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};bi.create=(e,t)=>new bi({innerType:e,typeName:z.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ee(t)});var wi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return co(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};wi.create=(e,t)=>new wi({innerType:e,typeName:z.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ee(t)});var ho=class extends re{_parse(t){if(this._getType(t)!==A.nan){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.nan,received:n.parsedType}),B}return{status:"valid",value:t.data}}};ho.create=e=>new ho({typeName:z.ZodNaN,...ee(e)});var R$=Symbol("zod_brand"),bs=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},ws=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?B:o.status==="dirty"?(r.dirty(),ai(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?B:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:z.ZodPipeline})}},xi=class extends re{_parse(t){let r=this._def.innerType._parse(t),n=i=>(On(i)&&(i.value=Object.freeze(i.value)),i);return co(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};xi.create=(e,t)=>new xi({innerType:e,typeName:z.ZodReadonly,...ee(t)});function J_(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function X_(e,t={},r){return e?Pn.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=J_(t,n),u=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:u})}});if(!o){let s=J_(t,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Pn.create()}var I$={object:Lt.lazycreate},z;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(z||(z={}));var j$=(e,t={message:`Input not instance of ${e.name}`})=>X_(r=>r instanceof e,t),Y_=An.create,ey=ci.create,N$=ho.create,M$=li.create,ty=ui.create,D$=di.create,Z$=uo.create,L$=fi.create,q$=mi.create,F$=Pn.create,U$=an.create,V$=wr.create,G$=fo.create,B$=cn.create,Xu=Lt.create,J$=Lt.strictCreate,W$=pi.create,H$=cc.create,K$=hi.create,Q$=Fr.create,X$=lc.create,Y$=mo.create,ez=po.create,tz=uc.create,rz=gi.create,nz=_i.create,iz=yi.create,oz=vi.create,sz=Cn.create,az=or.create,cz=Zt.create,lz=Ur.create,uz=or.createWithPreprocess,dz=ws.create,fz=()=>Y_().optional(),mz=()=>ey().optional(),pz=()=>ty().optional(),hz={string:(e=>An.create({...e,coerce:!0})),number:(e=>ci.create({...e,coerce:!0})),boolean:(e=>ui.create({...e,coerce:!0})),bigint:(e=>li.create({...e,coerce:!0})),date:(e=>di.create({...e,coerce:!0}))};var gz=B;import*as ed from"node:fs";import*as ly from"node:os";import*as qt from"node:path";import*as go from"node:fs/promises";function ny(e,t){return"Kandan attachment path must resolve inside an allowed upload root ("+e+"): "+t}function iy(e){return"Kandan attachment upload path must not include hidden path segments: "+e}function Yu(e){return"Kandan attachment upload requires a known media/document type or text content (binary content is not allowed): "+e}var oy="LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID";var sy="Kandan attachment path must not be empty";function ft(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function xs(e){if(Array.isArray(e))return e}function Qe(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function _z(e){if(e!==void 0&&typeof e=="number"&&Number.isInteger(e))return e}function td(e){if(e!==void 0)return e}function St(e){let t={};t.type="text",t.text=JSON.stringify(e,void 0,2);let r={};return r.content=[t],r.structuredContent=e,r}var yz="failed: ([a-z0-9_]+)(?: detail=(.+))?$";async function rd(e){let t;try{t=await e}catch(r){let n=X(r),i=Yr(n),o=new RegExp(yz).exec(i);if(o==null){let d={};return d.error=i,St(d)}let s=o.slice(1),a=s[0],u;if(a!==void 0){let d=ve(a);u=d!==void 0?d:i}else u=i;let c={};c.error=u;let l=s[1];if(l!==void 0){let d=ve(l);d!==void 0&&(c.detail=d)}return St(c)}return St(t)}function uy(e){let t=Cr(e);if(t===void 0)return pu(e);let r=ve(t),n=Rr(r);return n!==void 0&&n.includes("channel_required")?Tg(new Error(n+". Remediation: pass the channel slug in the `channel` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.",{cause:r})):$g(r)}function ln(e){let t={};return Object.entries(e).forEach(r=>{t[r[0]]=r[1]}),t}function nd(e,t){if(Qe(e.thread_id)!==void 0||t===void 0)return e;let n=()=>{let s=ln(e);return s.thread_id=t,s},i=e.message_seq;if(i!==void 0&&typeof i<"u")return n();let o=Qe(e.kind);if(o===void 0)return e;switch(o){case"latest_assistant_message":case"message_seq":case"new_message":return n();default:return e}}function sr(e,t){if(Qe(e.thread_id)!==void 0||t===void 0)return e;let n=ln(e);return n.thread_id=t,n}function dc(e,t){let r=Hi(t);if(r!==void 0)return ve(r).toString();let n=e.replace(new RegExp("^wss://"),"https://").replace(new RegExp("^ws://"),"http://"),i=Xr(t,n);return i.TAG==="Ok"?i._0.toString():Ge(i._0)}function vz(e,t){let r=Qe(t.inline_url),n=Qe(t.carousel_url),i=ln(t);return r!==void 0&&(i.inline_url=dc(e,r)),n!==void 0&&(i.carousel_url=dc(e,n)),i}function bz(e,t){if(typeof t!="object"||t===null||Array.isArray(t))return t;let r=Qe(t.url),n=ft(t.image_variants),i=ln(t);return r!==void 0&&(i.url=dc(e,r)),n!==void 0&&(i.image_variants=vz(e,n)),i}function cy(e,t){let r=xs(t.attachments);if(r===void 0)return t;let n=ln(t);return n.attachments=r.map(i=>bz(e,i)),n}function id(e,t){let r=ft(t.message),n=ft(t.target_message);if(r===void 0&&n===void 0)return t;let i=ln(t);return r!==void 0&&(i.message=cy(e,r)),n!==void 0&&(i.target_message=cy(e,n)),i}var wz=[".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"];async function xz(e){let t=[{path:e,label:"runner cwd"}],r=wt(process.env.HOME,o=>o.trim()),n=qt.resolve(r!==void 0&&r!==""?r:ly.homedir(),"Downloads"),i;try{i=await go.realpath(n)}catch{return t}return t.some(o=>o.path===i)||t.push({path:i,label:"~/Downloads"}),t}function kz(e,t){let r=qt.relative(e,t);return r===""?!0:r.startsWith("..")?!1:!qt.isAbsolute(r)}async function Sz(e,t){if(t==="")return Ge(sy);let r=qt.isAbsolute(t)?qt.resolve(t):qt.resolve(e,t);return await go.realpath(r)}async function Tz(e,t){if(!(await e.stat()).isFile())return Ge("Kandan attachment path is not a file: "+t);let n=qt.extname(t).toLowerCase();if(wz.includes(n))return{classification:"KnownType",bytes:await e.readFile()};let i=Buffer.alloc(8192),s=(await e.read(i,0,8192,0)).bytesRead;if(i.subarray(0,s).includes(0))return Ge(Yu(t));let a=await e.readFile();return a.subarray(0,8192).includes(0)?Ge(Yu(t)):{classification:"TextContent",bytes:a}}async function $z(e,t){let r=e.find(i=>kz(i.path,t));if(r!==void 0){if(qt.relative(r.path,t).split(new RegExp("[\\\\/]+","g")).find(l=>l!==void 0?l.startsWith("."):!1)!==void 0)return Ge(iy(t));let s=await go.open(t,ed.constants.O_RDONLY|ed.constants.O_NONBLOCK),a,u=0,c;try{c=await Tz(s,t),u=1}catch(l){a={TAG:"Error",_0:X(l)}}return u===1&&(a={TAG:"Ok",_0:c}),await s.close(),a.TAG==="Ok"?a._0:pu(a._0)}let n=e.map(i=>i.label).join(", ");return Ge(ny(n,t))}function zz(e){let t=e.toLowerCase();return t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".gif")?"image/gif":t.endsWith(".webp")?"image/webp":t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".md")||t.endsWith(".txt")||t.endsWith(".log")?"text/plain":"application/octet-stream"}function Ez(e,t){if(e.toLowerCase().endsWith(".py"))return"text/x-python";let n=zz(e);return t==="KnownType"||n!=="application/octet-stream"?n:"text/plain"}async function dy(e,t){let r=await go.realpath(e),n=await xz(r),i=await Sz(r,t),o=await $z(n,i);return{fileName:qt.basename(i),contentType:Ez(i,o.classification),sizeBytes:o.bytes.byteLength,bytes:o.bytes}}async function fy(e,t,r,n,i){let o={};return o["content-type"]=n,await Da.binary(dc(e,t),{method:r,headers:o,body:zg(i)})}async function my(e){let t=await Promise.all(e.files.map(p=>dy(e.cwd,p))),r=Qe(e.target.thread_id),n={},i=e.workspace;i!==void 0&&(n.workspace=i);let o=e.channel;o!==void 0&&(n.channel=o),r!==void 0&&(n.thread_id=r),n.files=t.map(p=>{let f={};return f.file_name=p.fileName,f.content_type=p.contentType,f.size_bytes=p.sizeBytes,f});let s=await e.client.prepareMessageUploads(n),a=xs(s.uploads),u=a!==void 0?a:[];u.length===t.length||Ge("Linzumi upload prepare response count mismatch"),await Promise.all(t.map(async(p,f)=>{let g=ft(u[f]),y=Qe(it(g,S=>S.upload_url)),v=Qe(it(g,S=>S.upload_method)),b=v!==void 0?v:"PUT";if(y===void 0)return Ge("Linzumi upload prepare response missing upload_url");let w=await fy(e.serviceUrl,y,b,p.contentType,p.bytes);if(!w.ok)return Ge("Linzumi upload failed for "+p.fileName+": "+w.status.toString()+" "+w.statusText)}));let c=u.map(p=>{let f=Qe(it(ft(p),g=>g.file_id));return f!==void 0?f:Ge("Linzumi upload prepare response missing file_id")}),l={},d=e.workspace;d!==void 0&&(l.workspace=d);let h=e.channel;h!==void 0&&(l.channel=h),r!==void 0&&(l.thread_id=r),l.target=e.target;let m=e.body;return m!==void 0&&(l.body=m),l.uploaded_file_ids=c,await e.client.attachMessageFiles(l)}async function py(e){let t=await dy(e.cwd,e.file),r={},n=e.workspace;n!==void 0&&(r.workspace=n),r.name=e.name,r.file_name=t.fileName,r.content_type=t.contentType,r.size_bytes=t.sizeBytes;let i=await e.client.prepareCustomEmoji(r),o=ft(i.upload),s=Qe(it(o,p=>p.upload_url)),a=Qe(it(o,p=>p.upload_method)),u=a!==void 0?a:"PUT";if(s===void 0)return Ge("Linzumi custom emoji prepare response missing upload_url");let c=await fy(e.serviceUrl,s,u,t.contentType,t.bytes);if(c.ok){let p=await c.json();if(typeof p!="object"||p===null||Array.isArray(p))return Ge("Linzumi custom emoji upload returned non-object JSON");let f=ft(p.custom_emoji);if(f===void 0)return Ge("Linzumi custom emoji upload response missing custom_emoji");let g={};g.ok=!0;let y=i.workspace;g.workspace=y!==void 0?y:void 0,g.emoji=f;let v=Qe(p.asset_id);g.asset_id=v!==void 0?v:void 0;let b=_z(f.id);g.id=b!==void 0?b:void 0;let w=Qe(f.name);g.name=w!==void 0?w:void 0;let S=Qe(f.shortcode);g.shortcode=S!==void 0?S:void 0;let q=Qe(f.image_url);return g.image_url=q!==void 0?q:void 0,g}let l=c.status.toString()+" "+c.statusText,h=(await c.text()).trim(),m;if(h==="")m=l;else{let p=0,f;try{f=JSON.parse(h),p=1}catch{m=h}if(p===1)if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let g=f.error;m=typeof g=="string"?g:h}else m=h}return Ge("Linzumi custom emoji upload failed: "+m)}import*as Ct from"node:fs";import*as By from"node:os";import*as Jy from"node:net";import*as Kt from"node:path";var Wy=lu(Gy(),1);import*as Hy from"node:child_process";function xc(e,t){}function bd(e){return e==="DesiredRunning"?"running":"stopped"}function Ky(e){switch(e){case"Running":return"running";case"Unhealthy":return"unhealthy";case"Exited":return"exited";case"Failed":return"failed";case"Stopped":return"stopped"}}function rE(){let e=wt(process.env.LINZUMI_DEV_SERVICES_DIR,t=>t.trim());return e!==void 0&&e!==""?e:Kt.join(By.homedir(),".linzumi","dev-services")}function nE(e){let t=e.replace(new RegExp("[^A-Za-z0-9._-]+","g"),"-").replace(new RegExp("^[-.]+|[-.]+$","g"),"").slice(0,80),r=Ra(e).slice(0,8),n=t===""?"runner":t;return Kt.join(rE(),n+"."+r)}function kc(e){let t=e.trim().toLowerCase();if(new RegExp("^[a-z0-9][a-z0-9._-]{0,63}$").test(t)&&!t.includes(".."))return t}function Ts(e,t){return Kt.join(e,"services",t+".json")}function wd(e,t){return Kt.join(e,"exits",t+".json")}function Qy(e,t){return Kt.join(e,"logs",t+".log")}function Ei(e){if(typeof e=="string"&&e!=="")return e}function dn(e){if(e!==void 0&&typeof e=="number"&&isFinite(e))return e}function iE(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=65535)return t}):[]:[]}function oE(e,t,r){if(r!==void 0&&r!==null){if(typeof r=="object"&&!Array.isArray(r)){let n=Ei(r.reason),i=dn(r.atMs);if(n!==void 0&&i!==void 0)return{reason:n,atMs:i};let o=[];n!==void 0||o.push("reason"),i!==void 0||o.push("atMs");let s=o.join(", ");return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields="+o.join(",")),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid '+s,atMs:t}}return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields=reason,atMs"),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid reason, atMs',atMs:t}}}function sE(e){if(typeof e!="object"||e===null||Array.isArray(e)||!Ot(e.version,1))return;let t=Ei(e.name),r=it(t,kc),n=Ei(e.command),i=Ei(e.cwd),o=e.desiredState,s;if(typeof o=="string")switch(o){case"running":s="DesiredRunning";break;case"stopped":s="DesiredStopped";break;default:s=void 0}else s=void 0;let a=dn(e.updatedAtMs),u=Ei(e.logPath),c=Ot(r,t);if(r!==void 0&&c&&n!==void 0&&i!==void 0&&s!==void 0&&a!==void 0&&u!==void 0)return{watchdogVersion:dn(e.watchdogVersion),name:r,command:n,cwd:i,ports:iE(e.ports),restartOnBranchChange:Ot(e.restartOnBranchChange,!0),desiredState:s,pid:dn(e.pid),ownerPid:dn(e.ownerPid),startedAtMs:dn(e.startedAtMs),updatedAtMs:a,lastBranch:Ei(e.lastBranch),logPath:u,automaticRestartAttempts:lt(dn(e.automaticRestartAttempts),0),automaticRestartWindowStartedAtMs:dn(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ei(e.automaticRestartCause),failure:oE(r,a,e.failure)}}function zi(e){return e!==void 0?ve(e):null}function aE(e){let t=e.failure,r=t!==void 0?{reason:t.reason,atMs:t.atMs}:null,n={version:1,watchdogVersion:zi(e.watchdogVersion),name:e.name,command:e.command,cwd:e.cwd,ports:e.ports,restartOnBranchChange:e.restartOnBranchChange,desiredState:bd(e.desiredState),pid:zi(e.pid),ownerPid:zi(e.ownerPid),startedAtMs:zi(e.startedAtMs),updatedAtMs:e.updatedAtMs,lastBranch:zi(e.lastBranch),logPath:e.logPath,automaticRestartAttempts:e.automaticRestartAttempts,automaticRestartWindowStartedAtMs:zi(e.automaticRestartWindowStartedAtMs),automaticRestartCause:zi(e.automaticRestartCause),failure:r},i=JSON.stringify(n);if(i!==void 0)return i+`
123
- `;throw{RE_EXN_ID:"Failure",_1:"dev-service record could not be encoded",Error:new Error}}function cE(e,t,r){let n=Ts(e,t.name),i=Y(Y(ke(vr(Kt.dirname(n)),a=>a.message),()=>{try{return{TAG:"Ok",_0:aE(t)}}catch(a){let u=X(a);return{TAG:"Error",_0:"record encoding failed: "+Ve(u).message}}}),a=>{let u=n+".tmp";return Y(ke(_g(u,a),c=>c.message),()=>ke(Ca(u,n),c=>c.message))});if(i.TAG==="Ok")return{TAG:"Ok",_0:void 0};let o=i._0,s={};return s.path=n,s.message=o,r("dev_services.record_write_failed",s),{TAG:"Error",_0:"could not persist dev-service state at "+n+": "+o}}function _d(e,t,r){let n=Ts(e,t.name),i=n+".lock",o=Y(vr(Kt.dirname(n)),()=>{let u;try{let c=Ct.statSync(i),l=c.isFile(),d=c.isDirectory(),h=Date.now()-c.mtimeMs>=5e3;u=l?h?tt(Qn(i),()=>{let m={};m.name=t.name,m.path=i,r("dev_services.legacy_record_lock_recovered",m)}):{TAG:"Ok",_0:void 0}:d&&h?{TAG:"Ok",_0:Date.now()-c.mtimeMs}:{TAG:"Ok",_0:void 0}}catch(c){let l=X(c),d=Ve(l);u=d.code==="ENOENT"?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:d}}return Y(u,c=>{try{let l=Wy.lockSync(n,{lockfilePath:i,realpath:!1,retries:0,stale:5e3,update:1e3,onCompromised:d=>{let h=Ve(d),m={};throw m.name=t.name,m.path=i,m.message=h.message,r("dev_services.record_lock_compromised",m),d}});if(c!==void 0){let d={};d.name=t.name,d.path=i,d.age_ms=c,r("dev_services.record_lease_recovered",d)}return{TAG:"Ok",_0:l}}catch(l){let d=X(l);return{TAG:"Error",_0:Ve(d)}}})});if(o.TAG==="Ok"){let u=cE(e,t,r),c;try{o._0(),c={TAG:"Ok",_0:void 0}}catch(h){let m=X(h);c={TAG:"Error",_0:Ve(m)}}if(u.TAG!=="Ok")return{TAG:"PersistUnwritten",_0:u._0};if(c.TAG==="Ok")return"PersistOk";let l=c._0,d={};return d.name=t.name,d.path=i,d.message=l.message,r("dev_services.record_unlock_failed",d),{TAG:"PersistCommittedUnlockFailed",_0:"could not unlock dev-service state at "+i+": "+l.message}}let s=o._0,a={};return a.name=t.name,a.path=i,a.message=s.message,r("dev_services.record_lock_failed",a),{TAG:"PersistUnwritten",_0:"could not lock dev-service state at "+i+": "+s.message}}function xd(e,t){let r=kc(t);if(r===void 0)return;let n=yr(Ts(e,r));if(n.TAG!=="Ok")return;let i;try{i=JSON.parse(n._0)}catch{return}return sE(i)}function lE(e){let t=wg(Kt.join(e,"services"));return t.TAG==="Ok"?Ht(t._0,r=>{if(r.endsWith(".json"))return xd(e,r.slice(0,r.length-5|0))}).toSorted((r,n)=>r.name.localeCompare(n.name)):[]}function Xy(e,t){let r=yr(wd(e,t));if(r.TAG!=="Ok")return;let n;try{n=JSON.parse(r._0)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let i=dn(n.atMs);if(i===void 0)return;let o=n.code,s;s=typeof o=="number"?o:void 0;let a=n.signal,u;return u=typeof a=="string"?a:void 0,{code:s,signal:u,atMs:i}}function uE(e){let t={};return t.command=e.command,t.args=e.args.map(r=>r),t.cwd=e.cwd,t.pollIntervalMs=e.pollIntervalMs,t.recordPath=e.recordPath,t.exitStatusPath=e.exitStatusPath,JSON.stringify(t)}function dE(e,t){return{command:e,args:["-e",`
122
+ `}}function FT(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function UT(e){return{startDeviceAuthorization:t=>N_(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>M_(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds,void 0),now:()=>Date.now(),sleep:FT,report:e,log:(t,r)=>{}}}var VT="local runner device authorization was denied - a signed-in user rejected this computer";async function Z_(e,t,r,n,i,o,s,a){let u=o!==void 0?o:y=>{es(y)},c=a!==void 0?a:UT(y=>u(qT(y))),l=s!==void 0?s:Ot(Wi(process.stderr.isTTY),!0),d=ke(Pt(e),F);if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let h=d._0,m=c.now(),p={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},f=async y=>{let v=await c.pollDeviceCodeForToken({httpBaseUrl:h,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof v!="object"||v.TAG!=="Transient")return v;let b=v.httpStatus,w=v.reason;c.report({TAG:"TransientFailure",reason:w,waitedMs:c.now()-m});let S={};return S.cycle=p.cycle,S.reason=w,S.httpStatus=b!==void 0?b:null,c.log("device_wait.transient_poll_failure",S),await c.sleep(5e3),await f(y)},g=async()=>{let y=await c.startDeviceAuthorization({httpBaseUrl:h,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let v=y._0;p.startFailures=0,p.cycle=p.cycle+1|0;let b=LT(p.cycle,c.now(),p.lastLoudPromptAtMs,l),w=0;switch(b){case"DecidePrompt":case"DecideSummary":w=1;break;case"DecideRefreshLine":c.report({TAG:"RefreshLine",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:c.now()-m});break;case"DecideSilent":break}if(w===1){p.lastLoudPromptAtMs=c.now();let K=c.now()-m,ce;ce=b==="DecidePrompt"?{TAG:"Prompt",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:K}:{TAG:"Summary",cycle:p.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:K},c.report(ce)}let S={};S.cycle=p.cycle,S.verificationUri=v.verificationUri,c.log("device_wait.code_issued",S);let q=await f(v);if(typeof q!="object")switch(q){case"CodeExpired":let K={};return K.cycle=p.cycle,K.outcome="code_expired",c.log("device_wait.code_retired",K),await g();case"Denied":return{TAG:"Error",_0:F(VT)};case"Consumed":let ce={};return ce.cycle=p.cycle,ce.outcome="consumed",c.log("device_wait.code_retired",ce),await g()}else switch(q.TAG){case"Token":let K={};return K.cycle=p.cycle,K.waitedMs=c.now()-m,c.log("device_wait.authorized",K),{TAG:"Ok",_0:q._0};case"Rejected":let ce=q.httpStatus,C=q.reason;c.report({TAG:"TransientFailure",reason:j_(C,ce),waitedMs:c.now()-m});let V={};return V.cycle=p.cycle,V.reason=C!==void 0?C:null,V.httpStatus=ce,c.log("device_wait.code_rejected",V),await g();case"Transient":return await g()}}else{let v=y._0;p.startFailures=p.startFailures+1|0;let b=Math.min(6e4,5e3*Math.pow(2,p.startFailures-1|0));c.report({TAG:"StartFailed",reason:v.summary,retryInMs:b});let w={};return w.reason=v.summary,w.retryInMs=b,w.attempt=p.startFailures,c.log("device_wait.start_failed",w),await c.sleep(b),await g()}};return await g()}var JT="linzumi-machine-fingerprint:v1:";var L_={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function WT(e,t){return xg(e,t,5e3,1024*1024)}var HT=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),KT=new RegExp("^[0-9a-f]{32}$"),QT=["/etc/machine-id","/var/lib/dbus/machine-id"];function XT(e){let t=e!==void 0?e:L_,r=lt(t.platform,process.platform),n=lt(t.execFile,WT),i=lt(t.readFile,yr);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let s=HT.exec(o._0);if(s==null)return;let a=s.slice(1)[0];if(a===void 0)return;let u=ve(a);return u!==void 0?u.toLowerCase():void 0;case"linux":return Og(QT,void 0,(c,l)=>{if(c!==void 0)return c;let d=i(l);if(d.TAG!=="Ok")return;let h=d._0.trim().toLowerCase();if(KT.test(h))return h});default:return}}function q_(e){return wt(XT(e!==void 0?e:L_),r=>"mfp-"+Ra(JT+r).slice(0,32))}function e$(e,t){return Y(ke(Pt(e),F),r=>{let n=Hi(r);return n===void 0?{TAG:"Error",_0:F("invalid URL: "+r)}:{TAG:"Ok",_0:"Workspace '"+(t!==void 0?t:"undefined")+"' was not found on "+ve(n).host+". Sign in to the web app to create it, then re-run connect."}})}var t$="local runner browser OAuth is not available in this implementation yet; use --auth-mode device or supply --token";async function r$(e){let t=P_(process.env),r=R_(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=q_(void 0),o=F_.hostname(),s={commanderId:n,machineFingerprint:i,hostname:o},a=await Z_(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,s,void 0,void 0,void 0);if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u=a._0,c=e.authFilePath,l=c!==void 0?c:hs();return tt(Zu(e.serviceUrl,u.accessToken,u.expiresInSeconds,l,new Date),d=>u.accessToken)}async function n$(e){let t=e.authMode;return typeof(t!==void 0?t:{TAG:"BrowserMode",callbackHost:e.callbackHost})!="object"?await r$(e):{TAG:"Error",_0:F(t$)}}function i$(){return{readCachedToken:(e,t)=>rc(e,t,Date.now()),validateToken:(e,t,r,n,i)=>oo(e,t,r,n,i),acquireAndCacheToken:n$}}async function o$(e,t,r){let n=await t.validateToken(e.serviceUrl,r,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(n.TAG!=="Ok")return{TAG:"Ok",_0:void 0};switch(n._0){case"Usable":case"Rejected":return{TAG:"Ok",_0:void 0};case"NotFound":return Y(e$(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:F(i)}))}}async function U_(e,t){let r=t!==void 0?t:i$(),n=e.explicitToken;if(n!==void 0)return{TAG:"Ok",_0:n};let i=e.authFilePath,o=i!==void 0?i:hs(),s=r.readCachedToken(e.serviceUrl,o);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=s._0,u;if(a!==void 0){let p=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(p.TAG==="Ok")switch(p._0){case"Usable":u={TAG:"Ok",_0:a.accessToken};break;case"Rejected":let f=e.reportRejectedCachedToken;f!==void 0&&f("UnusableRejected"),u={TAG:"Ok",_0:void 0};break;case"NotFound":let g=e.reportRejectedCachedToken;g!==void 0&&g("UnusableNotFound"),u={TAG:"Ok",_0:void 0};break}else u={TAG:"Error",_0:p._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c!==void 0)return{TAG:"Ok",_0:c};let l=await r.acquireAndCacheToken(e);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:d};let m=await o$(e,r,d);return m.TAG==="Ok"?{TAG:"Ok",_0:d}:{TAG:"Error",_0:m._0}}function a$(){return{readCachedToken:(e,t)=>rc(e,t,Date.now()),validateTokenOutcome:(e,t,r,n)=>oo(e,t,r,n,void 0),resolveToken:e=>U_(e,void 0)}}var c$="missing Linzumi MCP token; run linzumi auth or pass --token";function l$(e){return"Linzumi MCP token was rejected by the server and re-mint failed: "+e}async function V_(e,t,r,n,i,o){let s=o!==void 0?o:a$(),a=r!==void 0?r:hs(),u=t!==void 0?{TAG:"Ok",_0:t}:tt(s.readCachedToken(e,a),h=>wt(h,m=>m.accessToken));if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c===void 0)return{TAG:"Error",_0:F(c$)};let l=await s.validateTokenOutcome(e,c,n,i);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};switch(l._0){case"Usable":return{TAG:"Ok",_0:c};case"Rejected":case"NotFound":break}let d=await s.resolveToken({serviceUrl:e,explicitToken:void 0,workspaceSlug:n,channelSlug:i,requiredScopes:[],onboarding:void 0,authFilePath:r,callbackHost:void 0,authMode:void 0,reportRejectedCachedToken:void 0});return d.TAG==="Ok"?{TAG:"Ok",_0:d._0}:{TAG:"Error",_0:F(l$(d._0.summary))}}var _={};cu(_,{BRAND:()=>N$,DIRTY:()=>ai,EMPTY_PATH:()=>p$,INVALID:()=>B,NEVER:()=>vE,OK:()=>kt,ParseStatus:()=>dt,Schema:()=>re,ZodAny:()=>Pn,ZodArray:()=>cn,ZodBigInt:()=>li,ZodBoolean:()=>ui,ZodBranded:()=>bs,ZodCatch:()=>wi,ZodDate:()=>di,ZodDefault:()=>bi,ZodDiscriminatedUnion:()=>cc,ZodEffects:()=>or,ZodEnum:()=>yi,ZodError:()=>Dt,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>uc,ZodIntersection:()=>hi,ZodIssueCode:()=>T,ZodLazy:()=>gi,ZodLiteral:()=>_i,ZodMap:()=>mo,ZodNaN:()=>ho,ZodNativeEnum:()=>vi,ZodNever:()=>wr,ZodNull:()=>mi,ZodNullable:()=>Ur,ZodNumber:()=>ci,ZodObject:()=>Lt,ZodOptional:()=>Zt,ZodParsedType:()=>A,ZodPipeline:()=>ws,ZodPromise:()=>Cn,ZodReadonly:()=>xi,ZodRecord:()=>lc,ZodSchema:()=>re,ZodSet:()=>po,ZodString:()=>An,ZodSymbol:()=>uo,ZodTransformer:()=>or,ZodTuple:()=>Fr,ZodType:()=>re,ZodUndefined:()=>fi,ZodUnion:()=>pi,ZodUnknown:()=>an,ZodVoid:()=>fo,addIssueToContext:()=>O,any:()=>G$,array:()=>H$,bigint:()=>L$,boolean:()=>ty,coerce:()=>yE,custom:()=>X_,date:()=>q$,datetimeRegex:()=>K_,defaultErrorMap:()=>on,discriminatedUnion:()=>X$,effect:()=>uE,enum:()=>aE,function:()=>iE,getErrorMap:()=>ao,getParsedType:()=>qr,instanceof:()=>D$,intersection:()=>Y$,isAborted:()=>sc,isAsync:()=>co,isDirty:()=>ac,isValid:()=>On,late:()=>M$,lazy:()=>oE,literal:()=>sE,makeIssue:()=>vs,map:()=>rE,nan:()=>Z$,nativeEnum:()=>cE,never:()=>J$,null:()=>V$,nullable:()=>fE,number:()=>ey,object:()=>Xu,objectUtil:()=>Hu,oboolean:()=>_E,onumber:()=>gE,optional:()=>dE,ostring:()=>hE,pipeline:()=>pE,preprocess:()=>mE,promise:()=>lE,quotelessJson:()=>d$,record:()=>tE,set:()=>nE,setErrorMap:()=>m$,strictObject:()=>K$,string:()=>Y_,symbol:()=>F$,transformer:()=>uE,tuple:()=>eE,undefined:()=>U$,union:()=>Q$,unknown:()=>B$,util:()=>se,void:()=>W$});var se;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},e.find=(i,o)=>{for(let s of i)if(o(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(se||(se={}));var Hu;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Hu||(Hu={}));var A=se.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qr=e=>{switch(typeof e){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(e)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":return Array.isArray(e)?A.array:e===null?A.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?A.promise:typeof Map<"u"&&e instanceof Map?A.map:typeof Set<"u"&&e instanceof Set?A.set:typeof Date<"u"&&e instanceof Date?A.date:A.object;default:return A.unknown}};var 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"]),d$=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Dt=class e extends Error{get errors(){return this.issues}constructor(t){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=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,se.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Dt.create=e=>new Dt(e);var f$=(e,t)=>{let r;switch(e.code){case T.invalid_type:e.received===A.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,se.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${se.joinValues(e.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${se.joinValues(e.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${se.joinValues(e.options)}, received '${e.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 e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:se.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case T.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case T.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case 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 ${e.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=t.defaultError,se.assertNever(e)}return{message:r}},on=f$;var G_=on;function m$(e){G_=e}function ao(){return G_}var vs=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(s,{data:t,defaultError:a}).message;return{...i,path:o,message:a}},p$=[];function O(e,t){let r=ao(),n=vs({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===on?void 0:on].filter(i=>!!i)});e.common.issues.push(n)}var dt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return B;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return B;o.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:t.value,value:n}}},B=Object.freeze({status:"aborted"}),ai=e=>({status:"dirty",value:e}),kt=e=>({status:"valid",value:e}),sc=e=>e.status==="aborted",ac=e=>e.status==="dirty",On=e=>e.status==="valid",co=e=>typeof Promise<"u"&&e instanceof Promise;var M;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(M||(M={}));var ir=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},B_=(e,t)=>{if(On(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Dt(e.common.issues);return this._error=r,this._error}}};function ee(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(s,a)=>{let{message:u}=e;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:i}}var re=class{get description(){return this._def.description}_getType(t){return qr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:qr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new dt,ctx:{common:t.parent.common,data:t.data,parsedType:qr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(co(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)},i=this._parseSync({data:t,path:n.path,parent:n});return B_(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return On(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:t,path:[],parent:r}).then(n=>On(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qr(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(co(i)?i:Promise.resolve(i));return B_(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=t(i),a=()=>o.addIssue({code:T.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new or({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Zt.create(this,this._def)}nullable(){return Ur.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cn.create(this)}promise(){return Cn.create(this,this._def)}or(t){return pi.create([this,t],this._def)}and(t){return hi.create(this,t,this._def)}transform(t){return new or({...ee(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new bi({...ee(this._def),innerType:this,defaultValue:r,typeName:E.ZodDefault})}brand(){return new bs({typeName:E.ZodBranded,type:this,...ee(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new wi({...ee(this._def),innerType:this,catchValue:r,typeName:E.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return ws.create(this,t)}readonly(){return xi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},h$=/^c[^\s-]{8,}$/i,g$=/^[0-9a-z]+$/,_$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,y$=/^[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,v$=/^[a-z0-9_-]{21}$/i,b$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,w$=/^[-+]?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)?)??$/,x$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,k$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ku,S$=/^(?:(?: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])$/,T$=/^(?:(?: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])$/,$$=/^(([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]))$/,E$=/^(([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])$/,z$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,W_="((\\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])))",A$=new RegExp(`^${W_}$`);function H_(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function P$(e){return new RegExp(`^${H_(e)}$`)}function K_(e){let t=`${W_}T${H_(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function C$(e,t){return!!((t==="v4"||!t)&&S$.test(e)||(t==="v6"||!t)&&$$.test(e))}function R$(e,t){if(!b$.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function I$(e,t){return!!((t==="v4"||!t)&&T$.test(e)||(t==="v6"||!t)&&E$.test(e))}var An=class e extends re{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==A.string){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.string,received:o.parsedType}),B}let n=new dt,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=t.data.length>o.value,a=t.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(t,i),s?O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")x$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"email",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Ku||(Ku=new RegExp(k$,"u")),Ku.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"emoji",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")y$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"uuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")v$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"nanoid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")h$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")g$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid2",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")_$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ulid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),O(i,{validation:"url",code:T.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"regex",code:T.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?K_(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?A$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?P$(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?w$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"duration",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?C$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ip",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?R$(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"jwt",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?I$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cidr",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?O$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64url",code:T.invalid_string,message:o.message}),n.dirty()):se.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:T.invalid_string,...M.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...M.errToObj(t)})}url(t){return this._addCheck({kind:"url",...M.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...M.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...M.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...M.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...M.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...M.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...M.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...M.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...M.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...M.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...M.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...M.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...M.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...M.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...M.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...M.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...M.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...M.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...M.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...M.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...M.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...M.errToObj(r)})}nonempty(t){return this.min(1,M.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};An.create=e=>new An({checks:[],typeName:E.ZodString,coerce:e?.coerce??!1,...ee(e)});function j$(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}var ci=class e extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==A.number){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.number,received:o.parsedType}),B}let n,i=new dt;for(let o of this._def.checks)o.kind==="int"?se.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?j$(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_finite,message:o.message}),i.dirty()):se.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:M.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:M.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:M.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&se.isInteger(t.value))}get isFinite(){let t=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"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};ci.create=e=>new ci({checks:[],typeName:E.ZodNumber,coerce:e?.coerce||!1,...ee(e)});var li=class e extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==A.bigint)return this._getInvalidInput(t);let n,i=new dt;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):se.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:A.bigint,received:r.parsedType}),B}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:M.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};li.create=e=>new li({checks:[],typeName:E.ZodBigInt,coerce:e?.coerce??!1,...ee(e)});var ui=class extends re{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==A.boolean){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.boolean,received:n.parsedType}),B}return kt(t.data)}};ui.create=e=>new ui({typeName:E.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});var di=class e extends re{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==A.date){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:A.date,received:o.parsedType}),B}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_date}),B}let n=new dt,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):se.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:M.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:M.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};di.create=e=>new di({checks:[],coerce:e?.coerce||!1,typeName:E.ZodDate,...ee(e)});var uo=class extends re{_parse(t){if(this._getType(t)!==A.symbol){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.symbol,received:n.parsedType}),B}return kt(t.data)}};uo.create=e=>new uo({typeName:E.ZodSymbol,...ee(e)});var fi=class extends re{_parse(t){if(this._getType(t)!==A.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.undefined,received:n.parsedType}),B}return kt(t.data)}};fi.create=e=>new fi({typeName:E.ZodUndefined,...ee(e)});var mi=class extends re{_parse(t){if(this._getType(t)!==A.null){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.null,received:n.parsedType}),B}return kt(t.data)}};mi.create=e=>new mi({typeName:E.ZodNull,...ee(e)});var Pn=class extends re{constructor(){super(...arguments),this._any=!0}_parse(t){return kt(t.data)}};Pn.create=e=>new Pn({typeName:E.ZodAny,...ee(e)});var an=class extends re{constructor(){super(...arguments),this._unknown=!0}_parse(t){return kt(t.data)}};an.create=e=>new an({typeName:E.ZodUnknown,...ee(e)});var wr=class extends re{_parse(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:A.never,received:r.parsedType}),B}};wr.create=e=>new wr({typeName:E.ZodNever,...ee(e)});var fo=class extends re{_parse(t){if(this._getType(t)!==A.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.void,received:n.parsedType}),B}return kt(t.data)}};fo.create=e=>new fo({typeName:E.ZodVoid,...ee(e)});var cn=class e extends re{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==A.array)return O(r,{code:T.invalid_type,expected:A.array,received:r.parsedType}),B;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(O(r,{code:s?T.too_big:T.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(O(r,{code:T.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(O(r,{code:T.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new ir(r,s,r.path,a)))).then(s=>dt.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new ir(r,s,r.path,a)));return dt.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:M.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:M.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:M.toString(r)}})}nonempty(t){return this.min(1,t)}};cn.create=(e,t)=>new cn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...ee(t)});function lo(e){if(e instanceof Lt){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Zt.create(lo(n))}return new Lt({...e._def,shape:()=>t})}else return e instanceof cn?new cn({...e._def,type:lo(e.element)}):e instanceof Zt?Zt.create(lo(e.unwrap())):e instanceof Ur?Ur.create(lo(e.unwrap())):e instanceof Fr?Fr.create(e.items.map(t=>lo(t))):e}var Lt=class e extends re{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=se.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==A.object){let c=this._getOrReturnCtx(t);return O(c,{code:T.invalid_type,expected:A.object,received:c.parsedType}),B}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof wr&&this._def.unknownKeys==="strip"))for(let c in i.data)s.includes(c)||a.push(c);let u=[];for(let c of s){let l=o[c],d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new ir(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof wr){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(O(i,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new ir(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,h=await l.value;c.push({key:d,value:h,alwaysSet:l.alwaysSet})}return c}).then(c=>dt.mergeObjectSync(n,c)):dt.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return M.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:M.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:E.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of se.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of se.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return lo(this)}partial(t){let r={};for(let n of se.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of se.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Zt;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return Q_(se.objectKeys(this.shape))}};Lt.create=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strip",catchall:wr.create(),typeName:E.ZodObject,...ee(t)});Lt.strictCreate=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strict",catchall:wr.create(),typeName:E.ZodObject,...ee(t)});Lt.lazycreate=(e,t)=>new Lt({shape:e,unknownKeys:"strip",catchall:wr.create(),typeName:E.ZodObject,...ee(t)});var pi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Dt(a.ctx.common.issues));return O(r,{code:T.invalid_union,unionErrors:s}),B}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(u=>new Dt(u));return O(r,{code:T.invalid_union,unionErrors:a}),B}}get options(){return this._def.options}};pi.create=(e,t)=>new pi({options:e,typeName:E.ZodUnion,...ee(t)});var sn=e=>e instanceof gi?sn(e.schema):e instanceof or?sn(e.innerType()):e instanceof _i?[e.value]:e instanceof yi?e.options:e instanceof vi?se.objectValues(e.enum):e instanceof bi?sn(e._def.innerType):e instanceof fi?[void 0]:e instanceof mi?[null]:e instanceof Zt?[void 0,...sn(e.unwrap())]:e instanceof Ur?[null,...sn(e.unwrap())]:e instanceof bs||e instanceof xi?sn(e.unwrap()):e instanceof wi?sn(e._def.innerType):[],cc=class e extends re{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.object)return O(r,{code:T.invalid_type,expected:A.object,received:r.parsedType}),B;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(O(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),B)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let s=sn(o.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,o)}}return new e({typeName:E.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ee(n)})}};function Qu(e,t){let r=qr(e),n=qr(t);if(e===t)return{valid:!0,data:e};if(r===A.object&&n===A.object){let i=se.objectKeys(t),o=se.objectKeys(e).filter(a=>i.indexOf(a)!==-1),s={...e,...t};for(let a of o){let u=Qu(e[a],t[a]);if(!u.valid)return{valid:!1};s[a]=u.data}return{valid:!0,data:s}}else if(r===A.array&&n===A.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let s=e[o],a=t[o],u=Qu(s,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===A.date&&n===A.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var hi=class extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,s)=>{if(sc(o)||sc(s))return B;let a=Qu(o.value,s.value);return a.valid?((ac(o)||ac(s))&&r.dirty(),{status:r.value,value:a.data}):(O(n,{code:T.invalid_intersection_types}),B)};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(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};hi.create=(e,t,r)=>new hi({left:e,right:t,typeName:E.ZodIntersection,...ee(r)});var Fr=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.array)return O(n,{code:T.invalid_type,expected:A.array,received:n.parsedType}),B;if(n.data.length<this._def.items.length)return O(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&n.data.length>this._def.items.length&&(O(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new ir(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>dt.mergeArray(r,s)):dt.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Fr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fr({items:e,typeName:E.ZodTuple,rest:null,...ee(t)})};var lc=class e extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.object)return O(n,{code:T.invalid_type,expected:A.object,received:n.parsedType}),B;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new ir(n,a,n.path,a)),value:s._parse(new ir(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?dt.mergeObjectAsync(r,i):dt.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof re?new e({keyType:t,valueType:r,typeName:E.ZodRecord,...ee(n)}):new e({keyType:An.create(),valueType:t,typeName:E.ZodRecord,...ee(r)})}},mo=class extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.map)return O(n,{code:T.invalid_type,expected:A.map,received:n.parsedType}),B;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,u],c)=>({key:i._parse(new ir(n,a,n.path,[c,"key"])),value:o._parse(new ir(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of s){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return B;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of s){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return B;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};mo.create=(e,t,r)=>new mo({valueType:t,keyType:e,typeName:E.ZodMap,...ee(r)});var po=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==A.set)return O(n,{code:T.invalid_type,expected:A.set,received:n.parsedType}),B;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(O(n,{code:T.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(O(n,{code:T.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(u){let c=new Set;for(let l of u){if(l.status==="aborted")return B;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>o._parse(new ir(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>s(u)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:M.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:M.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};po.create=(e,t)=>new po({valueType:e,minSize:null,maxSize:null,typeName:E.ZodSet,...ee(t)});var uc=class e extends re{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.function)return O(r,{code:T.invalid_type,expected:A.function,received:r.parsedType}),B;function n(a,u){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ao(),on].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:u}})}function i(a,u){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ao(),on].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Cn){let a=this;return kt(async function(...u){let c=new Dt([]),l=await a._def.args.parseAsync(u,o).catch(m=>{throw c.addIssue(n(u,m)),c}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(m=>{throw c.addIssue(i(d,m)),c})})}else{let a=this;return kt(function(...u){let c=a._def.args.safeParse(u,o);if(!c.success)throw new Dt([n(u,c.error)]);let l=Reflect.apply(s,this,c.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new Dt([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Fr.create(t).rest(an.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Fr.create([]).rest(an.create()),returns:r||an.create(),typeName:E.ZodFunction,...ee(n)})}},gi=class extends re{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};gi.create=(e,t)=>new gi({getter:e,typeName:E.ZodLazy,...ee(t)});var _i=class extends re{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return O(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:t.data}}get value(){return this._def.value}};_i.create=(e,t)=>new _i({value:e,typeName:E.ZodLiteral,...ee(t)});function Q_(e,t){return new yi({values:e,typeName:E.ZodEnum,...ee(t)})}var yi=class e extends re{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{expected:se.joinValues(n),received:r.parsedType,code:T.invalid_type}),B}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{received:r.data,code:T.invalid_enum_value,options:n}),B}return kt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};yi.create=Q_;var vi=class extends re{_parse(t){let r=se.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==A.string&&n.parsedType!==A.number){let i=se.objectValues(r);return O(n,{expected:se.joinValues(i),received:n.parsedType,code:T.invalid_type}),B}if(this._cache||(this._cache=new Set(se.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=se.objectValues(r);return O(n,{received:n.data,code:T.invalid_enum_value,options:i}),B}return kt(t.data)}get enum(){return this._def.values}};vi.create=(e,t)=>new vi({values:e,typeName:E.ZodNativeEnum,...ee(t)});var Cn=class extends re{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==A.promise&&r.common.async===!1)return O(r,{code:T.invalid_type,expected:A.promise,received:r.parsedType}),B;let n=r.parsedType===A.promise?r.data:Promise.resolve(r.data);return kt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Cn.create=(e,t)=>new Cn({type:e,typeName:E.ZodPromise,...ee(t)});var or=class extends re{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:s=>{O(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return B;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?B:u.status==="dirty"?ai(u.value):r.value==="dirty"?ai(u.value):u});{if(r.value==="aborted")return B;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?B:a.status==="dirty"?ai(a.value):r.value==="dirty"?ai(a.value):a}}if(i.type==="refinement"){let s=a=>{let u=i.refinement(a,o);if(n.common.async)return Promise.resolve(u);if(u 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"?B:(a.status==="dirty"&&r.dirty(),s(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"?B:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!On(s))return B;let a=i.transform(s.value,o);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(s=>On(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):B);se.assertNever(i)}};or.create=(e,t,r)=>new or({schema:e,typeName:E.ZodEffects,effect:t,...ee(r)});or.createWithPreprocess=(e,t,r)=>new or({schema:t,effect:{type:"preprocess",transform:e},typeName:E.ZodEffects,...ee(r)});var Zt=class extends re{_parse(t){return this._getType(t)===A.undefined?kt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zt.create=(e,t)=>new Zt({innerType:e,typeName:E.ZodOptional,...ee(t)});var Ur=class extends re{_parse(t){return this._getType(t)===A.null?kt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ur.create=(e,t)=>new Ur({innerType:e,typeName:E.ZodNullable,...ee(t)});var bi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===A.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};bi.create=(e,t)=>new bi({innerType:e,typeName:E.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ee(t)});var wi=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return co(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};wi.create=(e,t)=>new wi({innerType:e,typeName:E.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ee(t)});var ho=class extends re{_parse(t){if(this._getType(t)!==A.nan){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:A.nan,received:n.parsedType}),B}return{status:"valid",value:t.data}}};ho.create=e=>new ho({typeName:E.ZodNaN,...ee(e)});var N$=Symbol("zod_brand"),bs=class extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},ws=class e extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?B:o.status==="dirty"?(r.dirty(),ai(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?B:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:E.ZodPipeline})}},xi=class extends re{_parse(t){let r=this._def.innerType._parse(t),n=i=>(On(i)&&(i.value=Object.freeze(i.value)),i);return co(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};xi.create=(e,t)=>new xi({innerType:e,typeName:E.ZodReadonly,...ee(t)});function J_(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function X_(e,t={},r){return e?Pn.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=J_(t,n),u=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:u})}});if(!o){let s=J_(t,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Pn.create()}var M$={object:Lt.lazycreate},E;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(E||(E={}));var D$=(e,t={message:`Input not instance of ${e.name}`})=>X_(r=>r instanceof e,t),Y_=An.create,ey=ci.create,Z$=ho.create,L$=li.create,ty=ui.create,q$=di.create,F$=uo.create,U$=fi.create,V$=mi.create,G$=Pn.create,B$=an.create,J$=wr.create,W$=fo.create,H$=cn.create,Xu=Lt.create,K$=Lt.strictCreate,Q$=pi.create,X$=cc.create,Y$=hi.create,eE=Fr.create,tE=lc.create,rE=mo.create,nE=po.create,iE=uc.create,oE=gi.create,sE=_i.create,aE=yi.create,cE=vi.create,lE=Cn.create,uE=or.create,dE=Zt.create,fE=Ur.create,mE=or.createWithPreprocess,pE=ws.create,hE=()=>Y_().optional(),gE=()=>ey().optional(),_E=()=>ty().optional(),yE={string:(e=>An.create({...e,coerce:!0})),number:(e=>ci.create({...e,coerce:!0})),boolean:(e=>ui.create({...e,coerce:!0})),bigint:(e=>li.create({...e,coerce:!0})),date:(e=>di.create({...e,coerce:!0}))};var vE=B;var bE=new Intl.Segmenter("en",{granularity:"grapheme"});function ny(e){return Array.from(bE.segment(e)).length}import*as ed from"node:fs";import*as uy from"node:os";import*as qt from"node:path";import*as go from"node:fs/promises";function iy(e,t){return"Kandan attachment path must resolve inside an allowed upload root ("+e+"): "+t}function oy(e){return"Kandan attachment upload path must not include hidden path segments: "+e}function Yu(e){return"Kandan attachment upload requires a known media/document type or text content (binary content is not allowed): "+e}var sy="LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID";var ay="Kandan attachment path must not be empty";function ft(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function xs(e){if(Array.isArray(e))return e}function Qe(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function xE(e){if(e!==void 0&&typeof e=="number"&&Number.isInteger(e))return e}function td(e){if(e!==void 0)return e}function St(e){let t={};t.type="text",t.text=JSON.stringify(e,void 0,2);let r={};return r.content=[t],r.structuredContent=e,r}var kE="failed: ([a-z0-9_]+)(?: detail=(.+))?$";async function rd(e){let t;try{t=await e}catch(r){let n=X(r),i=Yr(n),o=new RegExp(kE).exec(i);if(o==null){let d={};return d.error=i,St(d)}let s=o.slice(1),a=s[0],u;if(a!==void 0){let d=ve(a);u=d!==void 0?d:i}else u=i;let c={};c.error=u;let l=s[1];if(l!==void 0){let d=ve(l);d!==void 0&&(c.detail=d)}return St(c)}return St(t)}function dy(e){let t=Cr(e);if(t===void 0)return pu(e);let r=ve(t),n=Rr(r);return n!==void 0&&n.includes("channel_required")?Tg(new Error(n+". Remediation: pass the channel slug in the `channel` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.",{cause:r})):$g(r)}function ln(e){let t={};return Object.entries(e).forEach(r=>{t[r[0]]=r[1]}),t}function nd(e,t){if(Qe(e.thread_id)!==void 0||t===void 0)return e;let n=()=>{let s=ln(e);return s.thread_id=t,s},i=e.message_seq;if(i!==void 0&&typeof i<"u")return n();let o=Qe(e.kind);if(o===void 0)return e;switch(o){case"latest_assistant_message":case"message_seq":case"new_message":return n();default:return e}}function sr(e,t){if(Qe(e.thread_id)!==void 0||t===void 0)return e;let n=ln(e);return n.thread_id=t,n}function dc(e,t){let r=Hi(t);if(r!==void 0)return ve(r).toString();let n=e.replace(new RegExp("^wss://"),"https://").replace(new RegExp("^ws://"),"http://"),i=Xr(t,n);return i.TAG==="Ok"?i._0.toString():Ge(i._0)}function SE(e,t){let r=Qe(t.inline_url),n=Qe(t.carousel_url),i=ln(t);return r!==void 0&&(i.inline_url=dc(e,r)),n!==void 0&&(i.carousel_url=dc(e,n)),i}function TE(e,t){if(typeof t!="object"||t===null||Array.isArray(t))return t;let r=Qe(t.url),n=ft(t.image_variants),i=ln(t);return r!==void 0&&(i.url=dc(e,r)),n!==void 0&&(i.image_variants=SE(e,n)),i}function ly(e,t){let r=xs(t.attachments);if(r===void 0)return t;let n=ln(t);return n.attachments=r.map(i=>TE(e,i)),n}function id(e,t){let r=ft(t.message),n=ft(t.target_message);if(r===void 0&&n===void 0)return t;let i=ln(t);return r!==void 0&&(i.message=ly(e,r)),n!==void 0&&(i.target_message=ly(e,n)),i}var $E=[".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"];async function EE(e){let t=[{path:e,label:"runner cwd"}],r=wt(process.env.HOME,o=>o.trim()),n=qt.resolve(r!==void 0&&r!==""?r:uy.homedir(),"Downloads"),i;try{i=await go.realpath(n)}catch{return t}return t.some(o=>o.path===i)||t.push({path:i,label:"~/Downloads"}),t}function zE(e,t){let r=qt.relative(e,t);return r===""?!0:r.startsWith("..")?!1:!qt.isAbsolute(r)}async function OE(e,t){if(t==="")return Ge(ay);let r=qt.isAbsolute(t)?qt.resolve(t):qt.resolve(e,t);return await go.realpath(r)}async function AE(e,t){if(!(await e.stat()).isFile())return Ge("Kandan attachment path is not a file: "+t);let n=qt.extname(t).toLowerCase();if($E.includes(n))return{classification:"KnownType",bytes:await e.readFile()};let i=Buffer.alloc(8192),s=(await e.read(i,0,8192,0)).bytesRead;if(i.subarray(0,s).includes(0))return Ge(Yu(t));let a=await e.readFile();return a.subarray(0,8192).includes(0)?Ge(Yu(t)):{classification:"TextContent",bytes:a}}async function PE(e,t){let r=e.find(i=>zE(i.path,t));if(r!==void 0){if(qt.relative(r.path,t).split(new RegExp("[\\\\/]+","g")).find(l=>l!==void 0?l.startsWith("."):!1)!==void 0)return Ge(oy(t));let s=await go.open(t,ed.constants.O_RDONLY|ed.constants.O_NONBLOCK),a,u=0,c;try{c=await AE(s,t),u=1}catch(l){a={TAG:"Error",_0:X(l)}}return u===1&&(a={TAG:"Ok",_0:c}),await s.close(),a.TAG==="Ok"?a._0:pu(a._0)}let n=e.map(i=>i.label).join(", ");return Ge(iy(n,t))}function CE(e){let t=e.toLowerCase();return t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".gif")?"image/gif":t.endsWith(".webp")?"image/webp":t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".md")||t.endsWith(".txt")||t.endsWith(".log")?"text/plain":"application/octet-stream"}function RE(e,t){if(e.toLowerCase().endsWith(".py"))return"text/x-python";let n=CE(e);return t==="KnownType"||n!=="application/octet-stream"?n:"text/plain"}async function fy(e,t){let r=await go.realpath(e),n=await EE(r),i=await OE(r,t),o=await PE(n,i);return{fileName:qt.basename(i),contentType:RE(i,o.classification),sizeBytes:o.bytes.byteLength,bytes:o.bytes}}async function my(e,t,r,n,i){let o={};return o["content-type"]=n,await Da.binary(dc(e,t),{method:r,headers:o,body:Eg(i)})}async function py(e){let t=await Promise.all(e.files.map(p=>fy(e.cwd,p))),r=Qe(e.target.thread_id),n={},i=e.workspace;i!==void 0&&(n.workspace=i);let o=e.channel;o!==void 0&&(n.channel=o),r!==void 0&&(n.thread_id=r),n.files=t.map(p=>{let f={};return f.file_name=p.fileName,f.content_type=p.contentType,f.size_bytes=p.sizeBytes,f});let s=await e.client.prepareMessageUploads(n),a=xs(s.uploads),u=a!==void 0?a:[];u.length===t.length||Ge("Linzumi upload prepare response count mismatch"),await Promise.all(t.map(async(p,f)=>{let g=ft(u[f]),y=Qe(it(g,S=>S.upload_url)),v=Qe(it(g,S=>S.upload_method)),b=v!==void 0?v:"PUT";if(y===void 0)return Ge("Linzumi upload prepare response missing upload_url");let w=await my(e.serviceUrl,y,b,p.contentType,p.bytes);if(!w.ok)return Ge("Linzumi upload failed for "+p.fileName+": "+w.status.toString()+" "+w.statusText)}));let c=u.map(p=>{let f=Qe(it(ft(p),g=>g.file_id));return f!==void 0?f:Ge("Linzumi upload prepare response missing file_id")}),l={},d=e.workspace;d!==void 0&&(l.workspace=d);let h=e.channel;h!==void 0&&(l.channel=h),r!==void 0&&(l.thread_id=r),l.target=e.target;let m=e.body;return m!==void 0&&(l.body=m),l.uploaded_file_ids=c,await e.client.attachMessageFiles(l)}async function hy(e){let t=await fy(e.cwd,e.file),r={},n=e.workspace;n!==void 0&&(r.workspace=n),r.name=e.name,r.file_name=t.fileName,r.content_type=t.contentType,r.size_bytes=t.sizeBytes;let i=await e.client.prepareCustomEmoji(r),o=ft(i.upload),s=Qe(it(o,p=>p.upload_url)),a=Qe(it(o,p=>p.upload_method)),u=a!==void 0?a:"PUT";if(s===void 0)return Ge("Linzumi custom emoji prepare response missing upload_url");let c=await my(e.serviceUrl,s,u,t.contentType,t.bytes);if(c.ok){let p=await c.json();if(typeof p!="object"||p===null||Array.isArray(p))return Ge("Linzumi custom emoji upload returned non-object JSON");let f=ft(p.custom_emoji);if(f===void 0)return Ge("Linzumi custom emoji upload response missing custom_emoji");let g={};g.ok=!0;let y=i.workspace;g.workspace=y!==void 0?y:void 0,g.emoji=f;let v=Qe(p.asset_id);g.asset_id=v!==void 0?v:void 0;let b=xE(f.id);g.id=b!==void 0?b:void 0;let w=Qe(f.name);g.name=w!==void 0?w:void 0;let S=Qe(f.shortcode);g.shortcode=S!==void 0?S:void 0;let q=Qe(f.image_url);return g.image_url=q!==void 0?q:void 0,g}let l=c.status.toString()+" "+c.statusText,h=(await c.text()).trim(),m;if(h==="")m=l;else{let p=0,f;try{f=JSON.parse(h),p=1}catch{m=h}if(p===1)if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let g=f.error;m=typeof g=="string"?g:h}else m=h}return Ge("Linzumi custom emoji upload failed: "+m)}import*as Ct from"node:fs";import*as Jy from"node:os";import*as Wy from"node:net";import*as Kt from"node:path";var Hy=lu(By(),1);import*as Ky from"node:child_process";function xc(e,t){}function bd(e){return e==="DesiredRunning"?"running":"stopped"}function Qy(e){switch(e){case"Running":return"running";case"Unhealthy":return"unhealthy";case"Exited":return"exited";case"Failed":return"failed";case"Stopped":return"stopped"}}function az(){let e=wt(process.env.LINZUMI_DEV_SERVICES_DIR,t=>t.trim());return e!==void 0&&e!==""?e:Kt.join(Jy.homedir(),".linzumi","dev-services")}function cz(e){let t=e.replace(new RegExp("[^A-Za-z0-9._-]+","g"),"-").replace(new RegExp("^[-.]+|[-.]+$","g"),"").slice(0,80),r=Ra(e).slice(0,8),n=t===""?"runner":t;return Kt.join(az(),n+"."+r)}function kc(e){let t=e.trim().toLowerCase();if(new RegExp("^[a-z0-9][a-z0-9._-]{0,63}$").test(t)&&!t.includes(".."))return t}function Ts(e,t){return Kt.join(e,"services",t+".json")}function wd(e,t){return Kt.join(e,"exits",t+".json")}function Xy(e,t){return Kt.join(e,"logs",t+".log")}function zi(e){if(typeof e=="string"&&e!=="")return e}function dn(e){if(e!==void 0&&typeof e=="number"&&isFinite(e))return e}function lz(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=65535)return t}):[]:[]}function uz(e,t,r){if(r!==void 0&&r!==null){if(typeof r=="object"&&!Array.isArray(r)){let n=zi(r.reason),i=dn(r.atMs);if(n!==void 0&&i!==void 0)return{reason:n,atMs:i};let o=[];n!==void 0||o.push("reason"),i!==void 0||o.push("atMs");let s=o.join(", ");return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields="+o.join(",")),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid '+s,atMs:t}}return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields=reason,atMs"),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid reason, atMs',atMs:t}}}function dz(e){if(typeof e!="object"||e===null||Array.isArray(e)||!Ot(e.version,1))return;let t=zi(e.name),r=it(t,kc),n=zi(e.command),i=zi(e.cwd),o=e.desiredState,s;if(typeof o=="string")switch(o){case"running":s="DesiredRunning";break;case"stopped":s="DesiredStopped";break;default:s=void 0}else s=void 0;let a=dn(e.updatedAtMs),u=zi(e.logPath),c=Ot(r,t);if(r!==void 0&&c&&n!==void 0&&i!==void 0&&s!==void 0&&a!==void 0&&u!==void 0)return{watchdogVersion:dn(e.watchdogVersion),name:r,command:n,cwd:i,ports:lz(e.ports),restartOnBranchChange:Ot(e.restartOnBranchChange,!0),desiredState:s,pid:dn(e.pid),ownerPid:dn(e.ownerPid),startedAtMs:dn(e.startedAtMs),updatedAtMs:a,lastBranch:zi(e.lastBranch),logPath:u,automaticRestartAttempts:lt(dn(e.automaticRestartAttempts),0),automaticRestartWindowStartedAtMs:dn(e.automaticRestartWindowStartedAtMs),automaticRestartCause:zi(e.automaticRestartCause),failure:uz(r,a,e.failure)}}function Ei(e){return e!==void 0?ve(e):null}function fz(e){let t=e.failure,r=t!==void 0?{reason:t.reason,atMs:t.atMs}:null,n={version:1,watchdogVersion:Ei(e.watchdogVersion),name:e.name,command:e.command,cwd:e.cwd,ports:e.ports,restartOnBranchChange:e.restartOnBranchChange,desiredState:bd(e.desiredState),pid:Ei(e.pid),ownerPid:Ei(e.ownerPid),startedAtMs:Ei(e.startedAtMs),updatedAtMs:e.updatedAtMs,lastBranch:Ei(e.lastBranch),logPath:e.logPath,automaticRestartAttempts:e.automaticRestartAttempts,automaticRestartWindowStartedAtMs:Ei(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ei(e.automaticRestartCause),failure:r},i=JSON.stringify(n);if(i!==void 0)return i+`
123
+ `;throw{RE_EXN_ID:"Failure",_1:"dev-service record could not be encoded",Error:new Error}}function mz(e,t,r){let n=Ts(e,t.name),i=Y(Y(ke(vr(Kt.dirname(n)),a=>a.message),()=>{try{return{TAG:"Ok",_0:fz(t)}}catch(a){let u=X(a);return{TAG:"Error",_0:"record encoding failed: "+Ve(u).message}}}),a=>{let u=n+".tmp";return Y(ke(_g(u,a),c=>c.message),()=>ke(Ca(u,n),c=>c.message))});if(i.TAG==="Ok")return{TAG:"Ok",_0:void 0};let o=i._0,s={};return s.path=n,s.message=o,r("dev_services.record_write_failed",s),{TAG:"Error",_0:"could not persist dev-service state at "+n+": "+o}}function _d(e,t,r){let n=Ts(e,t.name),i=n+".lock",o=Y(vr(Kt.dirname(n)),()=>{let u;try{let c=Ct.statSync(i),l=c.isFile(),d=c.isDirectory(),h=Date.now()-c.mtimeMs>=5e3;u=l?h?tt(Qn(i),()=>{let m={};m.name=t.name,m.path=i,r("dev_services.legacy_record_lock_recovered",m)}):{TAG:"Ok",_0:void 0}:d&&h?{TAG:"Ok",_0:Date.now()-c.mtimeMs}:{TAG:"Ok",_0:void 0}}catch(c){let l=X(c),d=Ve(l);u=d.code==="ENOENT"?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:d}}return Y(u,c=>{try{let l=Hy.lockSync(n,{lockfilePath:i,realpath:!1,retries:0,stale:5e3,update:1e3,onCompromised:d=>{let h=Ve(d),m={};throw m.name=t.name,m.path=i,m.message=h.message,r("dev_services.record_lock_compromised",m),d}});if(c!==void 0){let d={};d.name=t.name,d.path=i,d.age_ms=c,r("dev_services.record_lease_recovered",d)}return{TAG:"Ok",_0:l}}catch(l){let d=X(l);return{TAG:"Error",_0:Ve(d)}}})});if(o.TAG==="Ok"){let u=mz(e,t,r),c;try{o._0(),c={TAG:"Ok",_0:void 0}}catch(h){let m=X(h);c={TAG:"Error",_0:Ve(m)}}if(u.TAG!=="Ok")return{TAG:"PersistUnwritten",_0:u._0};if(c.TAG==="Ok")return"PersistOk";let l=c._0,d={};return d.name=t.name,d.path=i,d.message=l.message,r("dev_services.record_unlock_failed",d),{TAG:"PersistCommittedUnlockFailed",_0:"could not unlock dev-service state at "+i+": "+l.message}}let s=o._0,a={};return a.name=t.name,a.path=i,a.message=s.message,r("dev_services.record_lock_failed",a),{TAG:"PersistUnwritten",_0:"could not lock dev-service state at "+i+": "+s.message}}function xd(e,t){let r=kc(t);if(r===void 0)return;let n=yr(Ts(e,r));if(n.TAG!=="Ok")return;let i;try{i=JSON.parse(n._0)}catch{return}return dz(i)}function pz(e){let t=wg(Kt.join(e,"services"));return t.TAG==="Ok"?Ht(t._0,r=>{if(r.endsWith(".json"))return xd(e,r.slice(0,r.length-5|0))}).toSorted((r,n)=>r.name.localeCompare(n.name)):[]}function Yy(e,t){let r=yr(wd(e,t));if(r.TAG!=="Ok")return;let n;try{n=JSON.parse(r._0)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let i=dn(n.atMs);if(i===void 0)return;let o=n.code,s;s=typeof o=="number"?o:void 0;let a=n.signal,u;return u=typeof a=="string"?a:void 0,{code:s,signal:u,atMs:i}}function hz(e){let t={};return t.command=e.command,t.args=e.args.map(r=>r),t.cwd=e.cwd,t.pollIntervalMs=e.pollIntervalMs,t.recordPath=e.recordPath,t.exitStatusPath=e.exitStatusPath,JSON.stringify(t)}function gz(e,t){return{command:e,args:["-e",`
124
124
  const { spawn } = require('node:child_process');
125
125
  const fs = require('node:fs');
126
126
  const config = JSON.parse(process.argv[process.argv.length - 1]);
@@ -206,10 +206,10 @@ const watchdog = setInterval(() => {
206
206
  }
207
207
  }
208
208
  }, config.pollIntervalMs);
209
- `.trim(),uE(t)]}}function yd(e){if(e===void 0||e<=1)return!1;try{return process.kill(-e,0),!0}catch(t){let r=X(t);return Ot(Ve(r).code,"EPERM")}}function kd(e,t){let r=t.pid;if(r===void 0||r<=1)return!1;let n=Xy(e,t.name),i=t.startedAtMs;return n!==void 0&&i!==void 0&&n.atMs>=i?!1:yd(t.pid)}function Sd(e){return new Promise((t,r)=>{let n=Jy.createConnection({port:e,host:"127.0.0.1"}),i=o=>{n.removeAllListeners(),n.destroy(),t(o)};n.setTimeout(750),n.once("connect",()=>i(!0)),n.once("timeout",()=>i(!1)),n.once("error",()=>i(!1))})}async function fE(e,t){let r=kd(e,t),n=[];for(let s=0,a=t.ports.length;s<a;++s){let u=t.ports[s];if(u!==void 0){let c=r?await Sd(u|0):!1;n.push({port:u,listening:c})}}let i=t.desiredState,o;if(i==="DesiredRunning"){let s=t.failure;o=r?n.every(a=>a.listening)?"Running":"Unhealthy":s!==void 0?"Failed":"Exited"}else o="Stopped";return{record:t,liveness:o,portProbes:n,lastExit:Xy(e,t.name),failure:t.failure}}async function Td(e){let t=[],r=lE(e);for(let n=0,i=r.length;n<i;++n){let o=r[n];o!==void 0&&t.push(await fE(e,o))}return t}function mE(e){let t=wt(e.SHELL,r=>r.trim());return t!==void 0&&t!==""?t:"/bin/sh"}async function vd(e,t,r,n){let i=n!==void 0?n:3e3;if(e===void 0||e<=1||fu(-e|0,"SIGTERM").TAG!=="Ok")return;let s=Date.now()+i,a=yd(e);for(;a&&Date.now()<s;)await Za(100),a=yd(e);if(!a||fu(-e|0,"SIGKILL").TAG!=="Ok")return;let c={};return c.name=r,c.pgid=e,t("dev_services.stop_escalated",c)}async function Yy(e){let t=e.log,r=t!==void 0?t:xc,n=kc(e.definition.name);if(n===void 0)return{TAG:"Error",_0:"invalid service name: use 1-64 lowercase letters, digits, ., _ or -"};let i=e.definition.command.trim();if(i==="")return{TAG:"Error",_0:"service command must not be empty"};let o;try{o={TAG:"Ok",_0:Ct.statSync(e.definition.cwd).isDirectory()}}catch{o={TAG:"Error",_0:"cwd does not exist: "+e.definition.cwd}}if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};if(!o._0)return{TAG:"Error",_0:"cwd is not a directory: "+e.definition.cwd};let s=xd(e.scopeDir,n);s!==void 0&&kd(e.scopeDir,s)&&await vd(s.pid,r,n,void 0);let a=e.nowMs,u=a!==void 0?a:Date.now(),c=Qy(e.scopeDir,n),l=wd(e.scopeDir,n),d=Y(Y(Y(vr(Kt.dirname(c)),()=>vr(Kt.join(e.scopeDir,"services"))),()=>vr(Kt.dirname(l))),()=>{try{return{TAG:"Ok",_0:Ct.openSync(c,"a")}}catch($){let R=X($);return{TAG:"Error",_0:Ve(R)}}});if(d.TAG!=="Ok")return{TAG:"Error",_0:"cannot open service log: "+d._0.message};let h=d._0,m=Qn(l);if(m.TAG!=="Ok"){let $={};$.name=n,$.path=l,$.message=m._0.message,r("dev_services.exit_marker_remove_failed",$)}let p=e.shellPathOverride,f=p!==void 0?p:mE(process.env),g=e.nodeExecPath,y=e.watchdogPollIntervalMs,v=dE(g!==void 0?g:process.execPath,{command:f,args:["-lc",i],cwd:e.definition.cwd,pollIntervalMs:y!==void 0?y:500,recordPath:Ts(e.scopeDir,n),exitStatusPath:l});try{Ct.writeFileSync(h,`
209
+ `.trim(),hz(t)]}}function yd(e){if(e===void 0||e<=1)return!1;try{return process.kill(-e,0),!0}catch(t){let r=X(t);return Ot(Ve(r).code,"EPERM")}}function kd(e,t){let r=t.pid;if(r===void 0||r<=1)return!1;let n=Yy(e,t.name),i=t.startedAtMs;return n!==void 0&&i!==void 0&&n.atMs>=i?!1:yd(t.pid)}function Sd(e){return new Promise((t,r)=>{let n=Wy.createConnection({port:e,host:"127.0.0.1"}),i=o=>{n.removeAllListeners(),n.destroy(),t(o)};n.setTimeout(750),n.once("connect",()=>i(!0)),n.once("timeout",()=>i(!1)),n.once("error",()=>i(!1))})}async function _z(e,t){let r=kd(e,t),n=[];for(let s=0,a=t.ports.length;s<a;++s){let u=t.ports[s];if(u!==void 0){let c=r?await Sd(u|0):!1;n.push({port:u,listening:c})}}let i=t.desiredState,o;if(i==="DesiredRunning"){let s=t.failure;o=r?n.every(a=>a.listening)?"Running":"Unhealthy":s!==void 0?"Failed":"Exited"}else o="Stopped";return{record:t,liveness:o,portProbes:n,lastExit:Yy(e,t.name),failure:t.failure}}async function Td(e){let t=[],r=pz(e);for(let n=0,i=r.length;n<i;++n){let o=r[n];o!==void 0&&t.push(await _z(e,o))}return t}function yz(e){let t=wt(e.SHELL,r=>r.trim());return t!==void 0&&t!==""?t:"/bin/sh"}async function vd(e,t,r,n){let i=n!==void 0?n:3e3;if(e===void 0||e<=1||fu(-e|0,"SIGTERM").TAG!=="Ok")return;let s=Date.now()+i,a=yd(e);for(;a&&Date.now()<s;)await Za(100),a=yd(e);if(!a||fu(-e|0,"SIGKILL").TAG!=="Ok")return;let c={};return c.name=r,c.pgid=e,t("dev_services.stop_escalated",c)}async function ev(e){let t=e.log,r=t!==void 0?t:xc,n=kc(e.definition.name);if(n===void 0)return{TAG:"Error",_0:"invalid service name: use 1-64 lowercase letters, digits, ., _ or -"};let i=e.definition.command.trim();if(i==="")return{TAG:"Error",_0:"service command must not be empty"};let o;try{o={TAG:"Ok",_0:Ct.statSync(e.definition.cwd).isDirectory()}}catch{o={TAG:"Error",_0:"cwd does not exist: "+e.definition.cwd}}if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};if(!o._0)return{TAG:"Error",_0:"cwd is not a directory: "+e.definition.cwd};let s=xd(e.scopeDir,n);s!==void 0&&kd(e.scopeDir,s)&&await vd(s.pid,r,n,void 0);let a=e.nowMs,u=a!==void 0?a:Date.now(),c=Xy(e.scopeDir,n),l=wd(e.scopeDir,n),d=Y(Y(Y(vr(Kt.dirname(c)),()=>vr(Kt.join(e.scopeDir,"services"))),()=>vr(Kt.dirname(l))),()=>{try{return{TAG:"Ok",_0:Ct.openSync(c,"a")}}catch($){let R=X($);return{TAG:"Error",_0:Ve(R)}}});if(d.TAG!=="Ok")return{TAG:"Error",_0:"cannot open service log: "+d._0.message};let h=d._0,m=Qn(l);if(m.TAG!=="Ok"){let $={};$.name=n,$.path=l,$.message=m._0.message,r("dev_services.exit_marker_remove_failed",$)}let p=e.shellPathOverride,f=p!==void 0?p:yz(process.env),g=e.nodeExecPath,y=e.watchdogPollIntervalMs,v=gz(g!==void 0?g:process.execPath,{command:f,args:["-lc",i],cwd:e.definition.cwd,pollIntervalMs:y!==void 0?y:500,recordPath:Ts(e.scopeDir,n),exitStatusPath:l});try{Ct.writeFileSync(h,`
210
210
  --- linzumi dev-service "`+n+'" starting at '+new Date(u).toISOString()+" (owner pid "+e.ownerPid.toString()+`) ---
211
211
  $ `+i+`
212
- `)}catch($){let R=X($),N={};N.name=n,N.message=Ve(R).message,r("dev_services.start_banner_write_failed",N)}let b=[];e.definition.ports.forEach($=>{if(!b.includes($)){b.push($);return}});let w=1,S=e.definition.cwd,q=b.toSorted(($,R)=>$-R),K=e.definition.restartOnBranchChange,ce=e.ownerPid,C=u,V={reason:'dev service "'+n+'" start did not complete',atMs:u},H={watchdogVersion:w,name:n,command:i,cwd:S,ports:q,restartOnBranchChange:K,desiredState:"DesiredStopped",pid:void 0,ownerPid:ce,startedAtMs:C,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:V},fe=()=>{try{return Ct.closeSync(h),{TAG:"Ok",_0:void 0}}catch($){let R=X($);return{TAG:"Error",_0:Ve(R).message}}},ge=_d(e.scopeDir,H,r);if(typeof ge!="object"){let $={};Object.entries(process.env).forEach(_e=>{$[_e[0]]=_e[1]}),$.ELECTRON_RUN_AS_NODE="1";let R;try{let _e=Hy.spawn(v.command,v.args,{cwd:e.definition.cwd,detached:!0,stdio:["ignore",Number(h),Number(h)],env:$});_e.unref(),R={TAG:"Ok",_0:Wi(_e.pid)}}catch(_e){let hr=X(_e);R={TAG:"Error",_0:"spawn failed: "+Ve(hr).message}}let N=fe();if(N.TAG!=="Ok"){let _e={};_e.name=n,_e.message=N._0,r("dev_services.log_close_failed",_e)}if(R.TAG!=="Ok")return{TAG:"Error",_0:R._0};let I=R._0;if(I===void 0)return{TAG:"Error",_0:"spawn failed: no pid"};let G=w,ye=S,qe=q,Ye=K,Et=I,Fe={watchdogVersion:G,name:n,command:i,cwd:ye,ports:qe,restartOnBranchChange:Ye,desiredState:"DesiredRunning",pid:Et,ownerPid:ce,startedAtMs:C,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:void 0},Ue=_d(e.scopeDir,Fe,r);if(typeof Ue!="object"){let _e={};return _e.name=n,_e.pid=I,_e.owner_pid=e.ownerPid,_e.cwd=e.definition.cwd,_e.ports=qe.map(hr=>hr),r("dev_services.started",_e),{TAG:"Ok",_0:Fe}}return Ue.TAG!=="PersistUnwritten"?{TAG:"Error",_0:Ue._0}:(await vd(Et,r,n,0),{TAG:"Error",_0:Ue._0})}else ge.TAG;let j=fe();if(j.TAG!=="Ok"){let $={};$.name=n,$.message=j._0,r("dev_services.log_close_failed",$)}return{TAG:"Error",_0:ge._0}}async function $d(e,t,r){let n=r!==void 0?r:xc,i=xd(e,t);if(i===void 0)return{TAG:"Error",_0:"unknown service: "+t};kd(e,i)&&await vd(i.pid,n,i.name,void 0);let o=i.watchdogVersion,s=i.name,a=i.command,u=i.cwd,c=i.ports,l=i.restartOnBranchChange,d=i.startedAtMs,h=Date.now(),m=i.lastBranch,p=i.logPath,f=i.automaticRestartAttempts,g=i.automaticRestartWindowStartedAtMs,y=i.automaticRestartCause,v={watchdogVersion:o,name:s,command:a,cwd:u,ports:c,restartOnBranchChange:l,desiredState:"DesiredStopped",pid:void 0,ownerPid:void 0,startedAtMs:d,updatedAtMs:h,lastBranch:m,logPath:p,automaticRestartAttempts:f,automaticRestartWindowStartedAtMs:g,automaticRestartCause:y,failure:void 0},b=_d(e,v,n);if(typeof b=="object")return{TAG:"Error",_0:b._0};let w={};return w.name=i.name,n("dev_services.stopped",w),{TAG:"Ok",_0:v}}async function ev(e,t,r){let n=await $d(e,t,r);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Y(Qn(Ts(e,i.name)),()=>Qn(wd(e,i.name)));if(o.TAG==="Ok")return{TAG:"Ok",_0:i};let s=o._0,a={};return a.name=i.name,a.message=s.message,r("dev_services.remove_failed",a),{TAG:"Error",_0:'could not remove dev service "'+i.name+'": '+s.message}}function tv(e,t,r){let n=kc(t);if(n===void 0)return;let i=Qy(e,n),o;try{o=Ct.openSync(i,"r")}catch{return}let s;try{let a=Ct.fstatSync(o).size,u=Math.min(a,r),c=Buffer.alloc(u|0);Ct.readSync(o,c,0,u|0,a-u),s=c.toString("utf8")}catch{s=void 0}try{Ct.closeSync(o)}catch{}return s}function rv(e){let t=wt(e.LINZUMI_DEV_SERVICES_SCOPE,i=>i.trim()),r=e.LINZUMI_DEV_SERVICES_OWNER_PID,n=Number.parseInt(r!==void 0?r:"",10);if(t!==void 0&&t!==""&&Number.isInteger(n)&&n>0)return{scopeDir:nE(t),ownerPid:n}}var iv=`<linzumi_markdown_media_guidance>
212
+ `)}catch($){let R=X($),N={};N.name=n,N.message=Ve(R).message,r("dev_services.start_banner_write_failed",N)}let b=[];e.definition.ports.forEach($=>{if(!b.includes($)){b.push($);return}});let w=1,S=e.definition.cwd,q=b.toSorted(($,R)=>$-R),K=e.definition.restartOnBranchChange,ce=e.ownerPid,C=u,V={reason:'dev service "'+n+'" start did not complete',atMs:u},H={watchdogVersion:w,name:n,command:i,cwd:S,ports:q,restartOnBranchChange:K,desiredState:"DesiredStopped",pid:void 0,ownerPid:ce,startedAtMs:C,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:V},fe=()=>{try{return Ct.closeSync(h),{TAG:"Ok",_0:void 0}}catch($){let R=X($);return{TAG:"Error",_0:Ve(R).message}}},ge=_d(e.scopeDir,H,r);if(typeof ge!="object"){let $={};Object.entries(process.env).forEach(_e=>{$[_e[0]]=_e[1]}),$.ELECTRON_RUN_AS_NODE="1";let R;try{let _e=Ky.spawn(v.command,v.args,{cwd:e.definition.cwd,detached:!0,stdio:["ignore",Number(h),Number(h)],env:$});_e.unref(),R={TAG:"Ok",_0:Wi(_e.pid)}}catch(_e){let hr=X(_e);R={TAG:"Error",_0:"spawn failed: "+Ve(hr).message}}let N=fe();if(N.TAG!=="Ok"){let _e={};_e.name=n,_e.message=N._0,r("dev_services.log_close_failed",_e)}if(R.TAG!=="Ok")return{TAG:"Error",_0:R._0};let I=R._0;if(I===void 0)return{TAG:"Error",_0:"spawn failed: no pid"};let G=w,ye=S,qe=q,Ye=K,zt=I,Fe={watchdogVersion:G,name:n,command:i,cwd:ye,ports:qe,restartOnBranchChange:Ye,desiredState:"DesiredRunning",pid:zt,ownerPid:ce,startedAtMs:C,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:void 0},Ue=_d(e.scopeDir,Fe,r);if(typeof Ue!="object"){let _e={};return _e.name=n,_e.pid=I,_e.owner_pid=e.ownerPid,_e.cwd=e.definition.cwd,_e.ports=qe.map(hr=>hr),r("dev_services.started",_e),{TAG:"Ok",_0:Fe}}return Ue.TAG!=="PersistUnwritten"?{TAG:"Error",_0:Ue._0}:(await vd(zt,r,n,0),{TAG:"Error",_0:Ue._0})}else ge.TAG;let j=fe();if(j.TAG!=="Ok"){let $={};$.name=n,$.message=j._0,r("dev_services.log_close_failed",$)}return{TAG:"Error",_0:ge._0}}async function $d(e,t,r){let n=r!==void 0?r:xc,i=xd(e,t);if(i===void 0)return{TAG:"Error",_0:"unknown service: "+t};kd(e,i)&&await vd(i.pid,n,i.name,void 0);let o=i.watchdogVersion,s=i.name,a=i.command,u=i.cwd,c=i.ports,l=i.restartOnBranchChange,d=i.startedAtMs,h=Date.now(),m=i.lastBranch,p=i.logPath,f=i.automaticRestartAttempts,g=i.automaticRestartWindowStartedAtMs,y=i.automaticRestartCause,v={watchdogVersion:o,name:s,command:a,cwd:u,ports:c,restartOnBranchChange:l,desiredState:"DesiredStopped",pid:void 0,ownerPid:void 0,startedAtMs:d,updatedAtMs:h,lastBranch:m,logPath:p,automaticRestartAttempts:f,automaticRestartWindowStartedAtMs:g,automaticRestartCause:y,failure:void 0},b=_d(e,v,n);if(typeof b=="object")return{TAG:"Error",_0:b._0};let w={};return w.name=i.name,n("dev_services.stopped",w),{TAG:"Ok",_0:v}}async function tv(e,t,r){let n=await $d(e,t,r);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Y(Qn(Ts(e,i.name)),()=>Qn(wd(e,i.name)));if(o.TAG==="Ok")return{TAG:"Ok",_0:i};let s=o._0,a={};return a.name=i.name,a.message=s.message,r("dev_services.remove_failed",a),{TAG:"Error",_0:'could not remove dev service "'+i.name+'": '+s.message}}function rv(e,t,r){let n=kc(t);if(n===void 0)return;let i=Xy(e,n),o;try{o=Ct.openSync(i,"r")}catch{return}let s;try{let a=Ct.fstatSync(o).size,u=Math.min(a,r),c=Buffer.alloc(u|0);Ct.readSync(o,c,0,u|0,a-u),s=c.toString("utf8")}catch{s=void 0}try{Ct.closeSync(o)}catch{}return s}function nv(e){let t=wt(e.LINZUMI_DEV_SERVICES_SCOPE,i=>i.trim()),r=e.LINZUMI_DEV_SERVICES_OWNER_PID,n=Number.parseInt(r!==void 0?r:"",10);if(t!==void 0&&t!==""&&Number.isInteger(n)&&n>0)return{scopeDir:cz(t),ownerPid:n}}var ov=`<linzumi_markdown_media_guidance>
213
213
  Some Linzumi users have opted into rich Markdown media rendering. When you are
214
214
  writing a visible Linzumi message, channel message, or thread reply, you may use
215
215
  these Markdown-compatible media directives:
@@ -312,14 +312,14 @@ Why bad: External image hosts are intentionally not auto-rendered; attach the im
312
312
  Use media directives only after upload/attach returns a Linzumi download URL.
313
313
  Keep "src" required, all other fields optional, and never exceed 10 embeds in one message.
314
314
  </media_reminder>
315
- </linzumi_markdown_media_guidance>`;function zd(e){return e==="Voice"?"voice":"text"}function hE(e){switch(e){case"All":return"all";case"Coding":return"coding";case"OnboardingDiscovery":return"onboarding-discovery"}}function Ed(e){return JSON.stringify(e)}function ov(e){let t=[],r=e.argsPrefix;r!==void 0&&r.forEach(y=>{t.push(y)}),t.push("mcp"),t.push("server"),t.push("--api-url"),t.push(e.serviceUrl);let n=e.authFilePath;n!==void 0&&(t.push("--auth-file"),t.push(n));let i=e.delegationAuthFilePath;i!==void 0&&(t.push("--delegation-auth-file"),t.push(i));let o=e.ownerUsername;o!==void 0&&(t.push("--owner-username"),t.push(o));let s=e.cwd;s!==void 0&&(t.push("--cwd"),t.push(s));let a=e.threadId;a!==void 0&&(t.push("--thread-id"),t.push(a)),t.push("--mode");let u=e.operatingMode;t.push(u!==void 0?zd(u):"text");let c=e.toolScope;if(c!==void 0){let y=0;switch(c){case"All":break;case"Coding":case"OnboardingDiscovery":y=1;break}y===1&&(t.push("--tool-scope"),t.push(hE(c)))}let l=e.agentSession;l!==void 0&&l&&t.push("--agent-session");let d=e.askUserQuestionTool;d!==void 0&&d&&t.push("--ask-user-question-tool");let h=e.multiAgentJobs;h!==void 0&&h&&t.push("--multi-agent-jobs");let m={},p=e.accessToken;p!==void 0&&(m.LINZUMI_MCP_ACCESS_TOKEN=p);let f=e.devServices;f!==void 0&&(m.LINZUMI_DEV_SERVICES_SCOPE=f.scope,m.LINZUMI_DEV_SERVICES_OWNER_PID=f.ownerPid.toString()),m.ELECTRON_RUN_AS_NODE="1";let g=e.command;return{name:"linzumi",command:g!==void 0?g:"linzumi",args:t,env:m}}function gE(e){return"["+e.map(Ed).join(", ")+"]"}function _E(e){return"{ "+Object.entries(e).map(r=>r[0]+" = "+Ed(r[1])).join(", ")+" }"}function sv(e){let t={};t.command=e.command,t.args=e.args.map(o=>o);let r={};t.env=(Object.entries(e.env).forEach(o=>{r[o[0]]=o[1]}),r);let n={};n[e.name]=t;let i={};return i.mcpServers=n,JSON.stringify(i,void 0,2)+`
316
- `}function av(e){let t=Object.entries(e.env).length===0?"":"env = "+_E(e.env)+`
315
+ </linzumi_markdown_media_guidance>`;function Ed(e){return e==="Voice"?"voice":"text"}function bz(e){switch(e){case"All":return"all";case"Coding":return"coding";case"OnboardingDiscovery":return"onboarding-discovery"}}function zd(e){return JSON.stringify(e)}function sv(e){let t=[],r=e.argsPrefix;r!==void 0&&r.forEach(y=>{t.push(y)}),t.push("mcp"),t.push("server"),t.push("--api-url"),t.push(e.serviceUrl);let n=e.authFilePath;n!==void 0&&(t.push("--auth-file"),t.push(n));let i=e.delegationAuthFilePath;i!==void 0&&(t.push("--delegation-auth-file"),t.push(i));let o=e.ownerUsername;o!==void 0&&(t.push("--owner-username"),t.push(o));let s=e.cwd;s!==void 0&&(t.push("--cwd"),t.push(s));let a=e.threadId;a!==void 0&&(t.push("--thread-id"),t.push(a)),t.push("--mode");let u=e.operatingMode;t.push(u!==void 0?Ed(u):"text");let c=e.toolScope;if(c!==void 0){let y=0;switch(c){case"All":break;case"Coding":case"OnboardingDiscovery":y=1;break}y===1&&(t.push("--tool-scope"),t.push(bz(c)))}let l=e.agentSession;l!==void 0&&l&&t.push("--agent-session");let d=e.askUserQuestionTool;d!==void 0&&d&&t.push("--ask-user-question-tool");let h=e.multiAgentJobs;h!==void 0&&h&&t.push("--multi-agent-jobs");let m={},p=e.accessToken;p!==void 0&&(m.LINZUMI_MCP_ACCESS_TOKEN=p);let f=e.devServices;f!==void 0&&(m.LINZUMI_DEV_SERVICES_SCOPE=f.scope,m.LINZUMI_DEV_SERVICES_OWNER_PID=f.ownerPid.toString()),m.ELECTRON_RUN_AS_NODE="1";let g=e.command;return{name:"linzumi",command:g!==void 0?g:"linzumi",args:t,env:m}}function wz(e){return"["+e.map(zd).join(", ")+"]"}function xz(e){return"{ "+Object.entries(e).map(r=>r[0]+" = "+zd(r[1])).join(", ")+" }"}function av(e){let t={};t.command=e.command,t.args=e.args.map(o=>o);let r={};t.env=(Object.entries(e.env).forEach(o=>{r[o[0]]=o[1]}),r);let n={};n[e.name]=t;let i={};return i.mcpServers=n,JSON.stringify(i,void 0,2)+`
316
+ `}function cv(e){let t=Object.entries(e.env).length===0?"":"env = "+xz(e.env)+`
317
317
  `;return"[mcp_servers."+e.name+`]
318
- command = `+Ed(e.command)+`
319
- args = `+gE(e.args)+`
320
- `+t}var cv="Other",lv="linzumi_ask_user_question",yE="plan_mode_native_interview_tool",vE="no_active_turn";function $s(e){return JSON.stringify(e)}function bE(e){let t=e.trim().toLowerCase();switch(t){case"other":case"something else":case"something else...":return!0;default:return t.includes("other")?!0:t.includes("something else")}}function wE(e){let t=ft(e),r=xs(t!==void 0?t.questions:void 0);if(r===void 0)return{TAG:"Invalid",_0:"questions: expected an array"};let n=r.length;if(n===0)return{TAG:"Invalid",_0:"questions: min 1, got 0"};if(n>4)return{TAG:"Invalid",_0:"questions: max 4, got "+n.toString()};let i={contents:void 0},o=[],s=new Set;r.forEach((u,c)=>{if(i.contents!==void 0)return;let d=c.toString(),h=ft(u);if(h===void 0){i.contents="questions["+d+"]: expected an object";return}let m=Qe(h.question);if(m===void 0){i.contents="questions["+d+"].question: must be a non-empty string";return}if(s.has(m)){i.contents="questions: duplicate question text "+$s(m);return}let p=Qe(h.header);if(p===void 0){i.contents="questions["+d+"].header: must be a non-empty string";return}if(p.length>12){i.contents="questions["+d+"].header: max 12 chars, got "+p.length.toString();return}let f=h.multiSelect;if(f!==void 0){let K=0;if(typeof f!="boolean"&&(K=2),K===2){i.contents="questions["+d+"].multiSelect: must be a boolean";return}}let g=xs(h.options);if(g===void 0){i.contents="questions["+d+"].options: expected an array";return}let y=g.length;if(y<2){i.contents="questions["+d+"].options: min 2, got "+y.toString();return}if(y>4){i.contents="questions["+d+"].options: max 4, got "+y.toString();return}let v=[],b=new Set;if(g.forEach((K,ce)=>{if(i.contents!==void 0)return;let V=ce.toString(),H=ft(K),fe=H!==void 0?Qe(H.label):void 0;if(H!==void 0&&fe!==void 0){let ge=H.description,j=0;if(ge!==void 0){let $=0;if(typeof ge=="string"?j=2:$=3,$===3){i.contents="questions["+d+"].options["+V+"].description: must be a string";return}}else j=2;if(j===2){if(bE(fe)){i.contents="questions["+d+"].options["+V+"].label: "+$s(fe)+" is reserved for the built-in Other option";return}if(b.has(fe)){i.contents="questions["+d+"].options: duplicate label "+$s(fe);return}b.add(fe);let $=H.description,R;R=typeof $=="string"?$:"",v.push({label:fe,description:R});return}}i.contents="questions["+d+"].options["+V+"].label: must be a non-empty string"}),i.contents!==void 0)return;s.add(m);let S=h.multiSelect,q;q=S===!0,o.push({question:m,header:p,options:v,multiSelect:q})});let a=i.contents;return a!==void 0?{TAG:"Invalid",_0:a}:{TAG:"Parsed",_0:{questions:o}}}function xE(e){let t={};e.questions.forEach(a=>{let u={};u.type="string",u.description=a.header,t[a.question]=u});let r={};r.type="object",r.properties=t,r.required=e.questions.map(a=>a.question);let n=e.questions.map(a=>{let u={};return u.question=a.question,u.header=a.header,u.multiSelect=a.multiSelect,u.options=a.options.map(c=>{let l={};return l.label=c.label,l.description=c.description,l}),u}),i={};i.version=1,i.questions=n;let o={};o[lv]=i;let s={};return s.message="Linzumi interview: the user is being asked in the Linzumi thread.",s.requestedSchema=r,s._meta=o,s}function kE(e,t){let r=ft(t);if(r===void 0)return{TAG:"AnswersInvalid",_0:"the runner accepted the interview but returned no answers; it may predate linzumi_ask_user_question support"};let n={contents:void 0},i={};e.questions.forEach(s=>{if(n.contents!==void 0)return;let u=r[s.question];if(typeof u=="string"){let c=0,l;try{l=JSON.parse(u),c=2}catch{n.contents="the runner returned an undecodable answer for question "+$s(s.question);return}if(c===2){i[s.question]=l;return}}n.contents="the runner returned no answer for question "+$s(s.question)});let o=n.contents;return o!==void 0?{TAG:"AnswersInvalid",_0:o}:{TAG:"Answers",_0:i}}function SE(e){let t=ft(e);if(t===void 0)return;let r=ft(t[lv]);return Qe(r!==void 0?r.reason:void 0)}function fn(e){let t={};t.type="text",t.text=e;let r={};return r.content=[t],r.isError=!0,r}function TE(e){if(e===void 0)return"undefined";if(e===null)return"null";switch(typeof e){case"string":return e;case"number":return e.toString();default:return JSON.stringify(e)}}async function uv(e,t){let r=wE(t);if(r.TAG!=="Parsed")return fn(r._0);let n=r._0,i=0,o;try{o=await e(xE(n),2147483647),i=1}catch(s){let a=X(s);return fn("the interview could not be delivered to the user: "+Yr(a))}if(i===1){let s=ft(o),a=s!==void 0?s:{},u=a.action,c=0;if(typeof u=="string")switch(u){case"accept":let l=kE(n,a.content);if(l.TAG!=="Answers")return fn(l._0);let d={};return d.answers=l._0,St(d);case"cancel":return fn("the user dismissed the question without answering");case"decline":let h=SE(a._meta);return fn(h!==void 0?h===yE?"linzumi_ask_user_question is unavailable during a Plan-mode turn: use the native request_user_input interview tool instead":h===vE?"the interview was declined: no active turn is bound to this session":"the interview request was declined by the runner":"the interview request was declined by the runner");default:c=2}else c=2;if(c===2)return fn("the interview returned an unknown action: "+TE(u))}}var dv="linzumi_ask_user_question",Ad=4,Pd=12,Cd=2,Rd=4;function zE(e){switch(e){case"All":return!0;case"Coding":case"OnboardingDiscovery":return!1}}function EE(e){return e==="Voice"}function OE(e){return e.trim().replace(new RegExp("^:+"),"").replace(new RegExp(":+$"),"").toLowerCase()}function fv(){return _.string().min(1).refine(e=>OE(e).length<=64,{message:"Custom emoji shortcode name must be at most 64 characters after trimming surrounding colons."})}function Oi(){let e=_.discriminatedUnion("type",[_.object(Object.fromEntries([["type",_.literal("text")],["text",_.string()],["style",_.array(_.enum(["bold","italic","code"])).optional()]])).strict(),_.object(Object.fromEntries([["type",_.literal("actor")],["user_id",_.number().int().positive()],["fallback",_.string().min(1)]])).strict()]);return _.array(_.object(Object.fromEntries([["kind",_.literal("prose")],["tokens",_.array(e).min(1)]])).strict()).min(1).describe("Canonical BlockSequence. Actor mentions must be actor tokens; literal @ text stays a text token.")}function ze(){return _.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")}function Qt(){return _.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")}function Xt(e){if(typeof e=="string")return e}function mv(e,t,r){let n=ft(e[t]);return n!==void 0?n:Ge(r+" "+t+" must be an object")}function AE(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="string")return t}):[]:[]}function PE(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="number")return t}):[]:[]}function pv(e){if(typeof e=="number")return e}function hv(e){let t={};t.name=e.record.name,t.command=e.record.command,t.cwd=e.record.cwd,t.ports=e.record.ports.map(s=>s),t.restart_on_branch_change=e.record.restartOnBranchChange,t.desired_state=bd(e.record.desiredState),t.liveness=Ky(e.liveness),t.port_health=e.portProbes.map(s=>{let a={};return a.port=s.port,a.listening=s.listening,a});let r=e.record.startedAtMs;t.started_at_ms=r!==void 0?r:null;let n=e.lastExit,i;if(n!==void 0){let s={},a=n.code;s.code=a!==void 0?a:null;let u=n.signal;s.signal=u!==void 0?u:null,s.at_ms=n.atMs,i=s}else i=null;t.last_exit=i,t.log_path=e.record.logPath;let o=e.failure;return t.failure=o!==void 0?{reason:o.reason,at_ms:o.atMs}:null,t}function CE(e,t,r){e.registerTool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",Object.fromEntries([["name",_.string().regex(new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service.")],["command",_.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell.")],["cwd",_.string().optional().describe("Working directory for the service. Defaults to the session cwd.")],["ports",_.array(_.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility.")],["restart_on_branch_change",_.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts).")],["wait_for_ports_ms",_.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=Xt(n.command),a=s!==void 0?s:"",u=Xt(n.cwd),c=await Yy({scopeDir:r.scopeDir,definition:{name:o,command:a,cwd:u!==void 0?u:t,ports:PE(n.ports),restartOnBranchChange:Ot(n.restart_on_branch_change,!0)},ownerPid:r.ownerPid});if(c.TAG==="Ok"){let d=c._0,h=pv(n.wait_for_ports_ms),m=Date.now()+(h!==void 0?h:15e3),p=d.ports.length===0;for(;!p&&Date.now()<m;)p=(await Promise.all(d.ports.map(w=>Sd(w|0)))).every(w=>w),p||await Za(250);let g=(await Td(r.scopeDir)).find(b=>b.record.name===d.name),y={};y.ok=!0;let v;if(g!==void 0)v=hv(g);else{let b={};b.name=d.name,v=b}return y.service=v,g!==void 0&&g.liveness!=="Running"&&(y.hint="The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."),St(y)}let l={};return l.ok=!1,l.error=c._0,St(l)}),e.registerTool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to stop.")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=await $d(r.scopeDir,o,void 0),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.desired_state="stopped"):(a.ok=!1,a.error=s._0),St(a)}),e.registerTool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async n=>{let i=await Td(r.scopeDir),o={};return o.services=i.map(s=>hv(s)),St(o)}),e.registerTool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",Object.fromEntries([["name",_.string().min(1).describe("Service name.")],["max_bytes",_.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=pv(n.max_bytes),a=tv(r.scopeDir,o,s!==void 0?s:16384),u={};return a!==void 0?(u.ok=!0,u.name=o,u.log_tail=a):(u.ok=!1,u.error="no log for service: "+o),St(u)}),e.registerTool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to remove.")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=await ev(r.scopeDir,o,xc),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.removed=!0):(a.ok=!1,a.error=s._0),St(a)})}function gv(e,t){let r=t.devServices,n=t.agentSession,i=t.ownerUsername,o=t.defaultThreadId,s=t.serviceUrl,a=t.cwd,u=t.toolScope,c=t.client,l;switch(u){case"All":case"Coding":l=!0;break;case"OnboardingDiscovery":l=!1;break}let d=async f=>St(await f),h=async(f,g)=>(g.tool=f,await d(c.agentDocumentTool(g))),m=t.documentSurfaces;m!==void 0&&m&&(e.registerTool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",Object.fromEntries([["query",_.string().min(1).describe("Document title or content search query.")]]),async f=>await h("lookup_documents",f)),e.registerTool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")]]),async f=>await h("read_document",f)),n?(e.registerTool("linzumi_append_document_section","Use this tool for append-shaped document requests. After resolving exactly one patch target document and reading it, supply only the heading and body Markdown; the server composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading",_.string().trim().min(1).describe("Section heading.")],["body_markdown",_.string().trim().min(1).describe("Section body as Markdown.")]]),async f=>await h("append_document_section",f)),e.registerTool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["body_markdown",_.string().trim().min(1).describe("Replacement section body as Markdown.")]]),async f=>await h("replace_section",f)),e.registerTool("linzumi_decline_document_action","Decline the current document action when neither advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",Object.fromEntries([["reason",_.string().refine(f=>f.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")]]),async f=>await d(c.declineDocumentAction(f)))):(e.registerTool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["patch",_.object(Object.fromEntries([["baseRevision",_.number().int().nonnegative()],["operations",_.array(_.record(_.unknown()))],["title",_.string().min(1).optional()]])).describe("Revisioned structural document patch.")],["rationale",_.string().min(1).describe("Why this change is proposed.")]]),async f=>await h("propose_document_patch",f)),e.registerTool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",Object.fromEntries([["title",_.string().min(1).describe("Document title.")],["initial_patch",_.record(_.unknown()).describe("Bootstrap structural patch.")],["folder_id",_.string().uuid().optional().describe("Destination folder UUID.")]]),async f=>await h("create_document",f))));let p=t.askUserQuestion;if(p!==void 0&&e.registerTool(dv,"Ask the user up to "+Ad.toString()+" structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max "+Pd.toString()+" chars) and "+Cd.toString()+"-"+Rd.toString()+' options {label, description}; a built-in "'+cv+'" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.',Object.fromEntries([["questions",_.array(_.object(Object.fromEntries([["question",_.string().describe("The question to ask the user.")],["header",_.string().describe("Short category header shown above the question (max "+Pd.toString()+' chars, e.g. "Auth", "Scope").')],["options",_.array(_.object(Object.fromEntries([["label",_.string().describe("Option label the user taps.")],["description",_.string().optional().describe("One-line explanation of the option.")]]))).describe(Cd.toString()+"-"+Rd.toString()+" options for this question.")],["multiSelect",_.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")]]))).describe("1-"+Ad.toString()+" questions to ask atomically.")]]),async f=>await uv(p,f)),n){e.registerTool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",Object.fromEntries([["body",_.string().min(1).describe("Plain-text reply body to post.")],["tokens",Oi().optional()]]),async g=>{let y=g.body,v={body:y!==void 0?y:void 0},b=g.tokens;return b!==void 0&&(v.tokens=b),await d(c.agentReply(v))});let f=async(g,y)=>(y.tool=g,await d(c.agentTopicTool(y)));e.registerTool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Existing workspace topic slug to watch.")],["instruction",_.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")]]),async g=>await f("create_topic_wake_subscription",g)),e.registerTool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Workspace topic slug whose standing wake should stop.")]]),async g=>await f("disable_topic_wake_subscription",g)),e.registerTool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async g=>await d(c.agentListCodingJobs({}))),e.registerTool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["channel",_.string().describe("Channel slug to host the job thread.")],["runner_key",_.string().describe("Runner (computer) to run the job on.")],["cwd",_.string().describe("Working directory on the runner.")],["work_description",_.string().min(1).describe("What the job should do - the initial instruction.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")]]),async g=>await d(c.agentStartCodingJob(g))),e.registerTool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["mode",_.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")]]),async g=>await d(c.agentInterruptCodingJob(g))),e.registerTool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Message body to send.")],["tokens",Oi().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>await d(c.agentSendCodingJobMessage(g))),e.registerTool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async g=>await d(c.agentReadCodingJobThread(g))),e.registerTool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["source_seq",_.number().int().positive().describe("Channel seq of the message the approval request rides on.")],["request_id",_.string().describe("The approval request id.")],["decision",_.enum(["approve","deny"]).describe("The asker's decision.")]]),async g=>await d(c.agentResolveJobApproval(g))),e.registerTool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to archive.")]]),async g=>await d(c.agentArchiveCodingJob(g))),e.registerTool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to unarchive.")]]),async g=>await d(c.agentUnarchiveCodingJob(g))),e.registerTool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID.")],["status",_.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")]]),async g=>await d(c.agentSetThreadStatus(g))),e.registerTool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",Object.fromEntries([["name",_.string().min(1).describe("Channel name to create.")]]),async g=>await d(c.agentCreateChannel(g))),e.registerTool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",Object.fromEntries([["channel",_.string().describe("Current channel slug to rename.")],["name",_.string().min(1).describe("New display name.")]]),async g=>await d(c.agentRenameChannel(g))),e.registerTool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",Object.fromEntries([["channel",_.string().describe("Channel slug to archive.")]]),async g=>await d(c.agentArchiveChannel(g))),e.registerTool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug to unarchive.")]]),async g=>await d(c.agentUnarchiveChannel(g))),e.registerTool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to react to.")],["emoji",_.string().min(1).describe("Emoji to add (unicode or :shortcode:).")]]),async g=>await d(c.agentAddReaction(g))),e.registerTool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the reacted message.")],["emoji",_.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")]]),async g=>await d(c.agentRemoveReaction(g))),e.registerTool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to pin.")]]),async g=>await d(c.agentPinMessage(g))),e.registerTool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the pinned message.")]]),async g=>await d(c.agentUnpinMessage(g)))}switch(u){case"All":e.registerTool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["message_id",_.union([_.string(),_.number()]).optional().describe("Message seq inside the scoped channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Alias for message_id.")],["message_url",_.string().optional().describe("Full Linzumi message URL with #message-<seq>.")],["before",_.number().int().min(0).max(100).optional().describe("Number of visible messages before the target.")],["after",_.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")]]),async f=>await d(c.getMessage(f))),e.registerTool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async f=>await d(c.getThread(f))),e.registerTool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200).")],["cursor",_.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")]]),async f=>await d(c.getThreadTranscript(f))),e.registerTool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["limit",_.number().int().min(1).max(100).optional().describe("Maximum messages to return.")],["before_seq",_.number().int().positive().optional().describe("Return messages before this channel seq.")]]),async f=>await d(c.getChannel(f))),e.registerTool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",Object.fromEntries([["workspace",ze()],["query",_.string().min(1).describe("Natural-language or keyword query to retrieve against.")],["limit",_.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped).")],["source_types",_.array(_.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all.")],["authored_after",_.string().optional().describe("ISO8601 instant; only content authored at or after this time.")],["authored_before",_.string().optional().describe("ISO8601 instant; only content authored at or before this time.")],["repo",_.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name).")],["check_status",_.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")]]),async f=>await d(c.searchWorkspace(f))),e.registerTool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',Object.fromEntries([["workspace",ze()],["question",_.string().min(1).max(2e3).describe("Natural-language question to answer with citations.")],["channel",_.string().optional().describe("Optional channel slug providing conversational context; never widens access.")],["allow_cached",_.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")]]),async f=>await d(c.askWorkspace(f))),e.registerTool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async f=>await d(c.aboutMe(f)));break;case"Coding":case"OnboardingDiscovery":break}switch(l&&(e.registerTool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",Object.fromEntries([["query",_.string().min(1).describe("Web search query (natural language or keywords).")],["limit",_.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")]]),async f=>await d(c.webSearch(f))),e.registerTool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",Object.fromEntries([["url",_.string().min(1).describe("Absolute public http(s) URL to fetch.")]]),async f=>await d(c.fetchUrl(f)))),u){case"All":e.registerTool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async f=>await rd(c.listUiTargets({}))),e.registerTool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",Object.fromEntries([["kind",_.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout).")],["args",_.record(_.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path).")],["workspace",ze()]]),async f=>await rd(c.openUi(sr(f,o))));break;case"Coding":case"OnboardingDiscovery":break}if(l){let f=()=>_.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.");e.registerTool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()]]),async g=>await d(c.getCodingJobMetadata(sr(g,o)))),e.registerTool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()],["title",_.string().min(1).max(100).describe("Concise user-visible title for this coding job.")]]),async g=>await d(c.renameCodingJob(sr(g,o)))),e.registerTool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()],["goal",_.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")]]),async g=>await d(c.upsertCodingJobPlan(sr(g,o)))),e.registerTool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()],["goal",_.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal.")],["steps",_.array(_.object(Object.fromEntries([["title",_.string().min(1).max(255)],["description",_.string().min(1).max(1e4)],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",_.string().min(1).max(4e3).optional()],["completed_debrief",_.string().min(1).max(2e4).optional()]]))).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")]]),async g=>await d(c.replaceCodingJobPlanSteps(sr(g,o)))),e.registerTool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()],["step_id",_.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata.")],["lock_version",_.number().int().positive().describe("Current step lock_version from metadata.")],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",_.string().min(1).max(4e3).optional()],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required when marking a step completed.")]]),async g=>await d(c.updateCodingJobPlanStep(sr(g,o)))),e.registerTool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",f()],["github_repo_owner",_.string().min(1).max(255)],["github_repo_name",_.string().min(1).max(255)],["github_pr_number",_.number().int().positive()],["github_pr_url",_.string().url()],["title",_.string().min(1).max(255)],["body",_.string().min(1).max(1e5).optional()],["head_branch",_.string().min(1).max(255)],["head_sha",_.string().min(7).max(64)],["base_branch",_.string().min(1).max(255)],["base_sha",_.string().min(7).max(64)],["state",_.enum(["draft","open","closed","merged"]).optional()],["is_draft",_.boolean().optional()],["review_status",_.enum(["unknown","review_required","approved","changes_requested"]).optional()],["source_remote_url",_.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet.")],["runtime_worktree_root",_.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet.")],["dirty_status",_.enum(["unknown","clean","dirty"]).optional()],["dirty_summary",_.string().min(1).max(2e3).optional()]]),async g=>await d(c.linkCodingJobPullRequest(sr(g,o)))),e.registerTool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),Object.fromEntries([["target",_.object(Object.fromEntries([["kind",_.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Required when kind is message_seq.")],["thread_id",_.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")]])).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit.")],["files",_.array(_.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types.")],["body",_.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool.")],["workspace",ze()],["channel",_.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")]]),async g=>{let y=nd(mv(g,"target","linzumi_upload_files"),o),v;try{v=await my({client:c,cwd:a,serviceUrl:s,target:y,files:AE(g.files),workspace:Xt(g.workspace),channel:Xt(g.channel),body:Xt(g.body)})}catch(b){return uy(X(b))}return St(id(s,v))}),e.registerTool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["target",_.object(Object.fromEntries([["message_seq",_.union([_.string(),_.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here.")],["thread_id",_.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")]])).describe("Exact message target for the body edit.")],["body",_.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")]]),async g=>{let y=ln(g);return y.target=nd(mv(g,"target","linzumi_edit_message"),o),St(id(s,await c.editMessage(y)))})}switch(u){case"All":if(e.registerTool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async f=>await d(c.listVaultSecrets(f))),e.registerTool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",Object.fromEntries([["workspace",ze()]]),async f=>await d(c.listProjects(f))),e.registerTool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")]]),async f=>await d(c.getProjectTasks(sr(f,o)))),e.registerTool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")],["title",_.string().min(1).describe("Task title.")],["kind",_.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).')],["description",_.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".')],["parent_id",_.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent.")],["assignee",_.string().optional().describe("Username of a workspace member to assign.")],["position",_.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")]]),async f=>await d(c.createProjectTask(sr(f,o)))),e.registerTool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to update.")],["title",_.string().min(1).optional().describe("New title.")],["description",_.string().nullable().optional().describe("New description. Pass null to clear it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.')],["status_note",_.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it.")],["position",_.number().int().min(0).optional().describe("New sort position among siblings.")],["parent_id",_.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent.")],["clear_parent",_.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id.")],["assignee",_.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee.")],["clear_assignee",_.boolean().optional().describe("true removes the assignee. Do not combine with assignee.")],["lock_version",_.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")]]),async f=>await d(c.updateProjectTask(f))),e.registerTool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to delete.")]]),async f=>await d(c.deleteProjectTask(f))),e.registerTool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue (the one that must wait).")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")]]),async f=>await d(c.addProjectTaskDependency(f))),e.registerTool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue.")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue the edge points at.")]]),async f=>await d(c.removeProjectTaskDependency(f))),e.registerTool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",Object.fromEntries([["call_id",_.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")]]),async f=>await d(c.getCallTranscript(f))),!n){e.registerTool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job - only start tasks whose work_state is ready, and ONLY after the user explicitly accepts your offer to start them. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description.")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")],["channel",_.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel.")],["runner_key",_.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer.")],["cwd",_.string().optional().describe("Working directory on the runner. Omit to use this job's own folder.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["agent_provider",_.string().optional().describe("Agent provider override, e.g. 'codex' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["approval_policy",_.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional).")],["sandbox",_.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional).")],["fast",_.boolean().optional().describe("Fast-mode override (optional).")],["allow_port_forwarding_by_default",_.boolean().optional().describe("Default port-forwarding override (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["egress_mode",_.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")]]),async g=>await d(c.agentStartCodingJob(sr(g,o))));let f=t.multiAgentJobs;f!==void 0&&f&&(e.registerTool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone.")],["agent_provider",_.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job.")],["model",_.string().optional().describe("Model override for the child (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")]]),async g=>await d(c.agentSpawnChildJob(sr(g,o)))),e.registerTool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",Object.fromEntries([["job_id",_.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree.")],["outcome",_.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived.")],["descendant_action",_.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree.")],["expected_descendant_count",_.number().int().optional().describe("The descendant_count returned by the phase-1 call.")],["expected_descendant_job_ids",_.array(_.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed.")],["expected_descendant_fingerprint",_.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")]]),async g=>await d(c.agentArchiveChildJob(g))),e.registerTool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",Object.fromEntries([["job_id",_.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")]]),async g=>await d(c.agentUnarchiveChildJob(g))),e.registerTool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",Object.fromEntries([["query",_.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=td(wt(o,v=>v)),await d(c.agentDiscoverCodingJobs(y))}),e.registerTool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Coordination message to send.")],["tokens",Oi().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=td(wt(o,v=>v)),await d(c.agentSendCodingJobMessage(y))}))}break;case"Coding":case"OnboardingDiscovery":break}switch(zE(u)&&(e.registerTool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",Object.fromEntries([["name",fv().describe("Custom emoji shortcode name, with or without surrounding colons.")],["file",_.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji.")],["workspace",ze()]]),async f=>{let g=Xt(f.name),y=Xt(f.file);return St(await py({client:c,cwd:a,serviceUrl:s,name:g!==void 0?g:"",file:y!==void 0?y:"",workspace:Xt(f.workspace)}))}),e.registerTool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",Object.fromEntries([["emoji_id",_.union([_.string(),_.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings.")],["name",fv().describe("New shortcode name, with or without surrounding colons.")],["workspace",ze()]]),async f=>await d(c.renameCustomEmoji(f)))),e.registerTool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async f=>{let g={};g.type="text",g.text=iv;let y={};return y.content=[g],y}),e.registerTool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",Object.fromEntries([["workspace",ze()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["path",_.string().min(1).describe("Absolute local path to the repository worktree root.")],["display_name",_.string().optional().describe("Short project label. Defaults to the path basename.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["import_key",_.string().optional().describe("Stable dedupe key. Defaults to path.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")]]),async f=>await d(c.noteProjectDirectory(f))),e.registerTool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",Object.fromEntries([["workspace",ze()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["source",_.enum(["codex","claude_code"]).describe("Conversation source.")],["import_key",_.string().min(1).describe("Stable dedupe key, such as a session id or file path.")],["path",_.string().optional().describe("Absolute local path to the conversation file or directory.")],["display_name",_.string().optional().describe("Short label for the discovered conversation.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as session id or project path.")]]),async f=>await d(c.noteAgentConversation(f))),e.registerTool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",Object.fromEntries([["workspace",ze()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["phase",_.enum(["projects","conversations"]).describe("Discovery phase being reported.")],["status",_.enum(["starting","running","completed","failed"]).describe("Current phase status.")],["places_searched",_.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far.")],["message",_.string().optional().describe("Short user-facing status note.")],["current_place",_.string().optional().describe("Current folder, file, Git command target, or known location being checked.")],["current_source",_.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code.")],["last_error",_.string().optional().describe("Short failure detail when status is failed.")],["metadata",_.record(_.unknown()).optional().describe("Small structured status metadata.")]]),async f=>await d(c.noteOnboardingDiscoveryStatus(f))),u==="All"&&EE(t.operatingMode)&&(e.registerTool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",Object.fromEntries([["owner_username",_.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username.")],["workspace",ze()],["channel",_.string().optional().describe("Source channel slug used to verify owner visibility.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Oi().optional()]]),async f=>{let g=Xt(f.owner_username),y=g!==void 0?g:i;if(y===void 0)return Ge("owner_username is required for linzumi_dm_owner");let v=ln(f);return v.owner_username=y,await d(c.dmOwner(v))}),e.registerTool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["body",_.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Oi().optional()]]),async f=>await d(c.sendChannelMessage(f))),e.registerTool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",ze()],["channel",Qt()],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID.")],["body",_.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Oi().optional()]]),async f=>await d(c.sendThreadReply(f))),e.registerTool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",Object.fromEntries([["workspace",ze()],["channel",_.string().optional().describe("Source channel slug used to verify target visibility.")],["username",_.string().describe("Visible Linzumi username to DM.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Oi().optional()]]),async f=>await d(c.sendDm(f)))),u){case"All":e.registerTool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",Object.fromEntries([["workspace",ze()],["channel",_.string().optional().describe("Channel slug used to disambiguate the approval thread when needed.")],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID for the inline approval.")],["env_var_names",_.array(_.string().regex(new RegExp("^[A-Z][A-Z0-9_]{0,127}$"))).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys.")],["description",_.string().min(1).max(500).describe("Human-readable reason shown in the approval request.")],["justification",_.string().min(10).max(1e3).describe("Agent justification shown to the approver.")]]),async f=>await d(c.getVaultValues(f)));break;case"Coding":case"OnboardingDiscovery":break}switch(u){case"All":return n||r===void 0?void 0:CE(e,a,r);case"Coding":case"OnboardingDiscovery":return}}function IE(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function jE(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(IE(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}var Id=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _v(e){let t=jE(e);if(t===void 0)return!1;let n=t.document_surfaces===!0,i=t.linzumi_agent_session,o=typeof i=="string"?Id.test(i):!1,s=t.coding_job_id,a=t.coding_job_thread_id,u=typeof s=="string"&&typeof a=="string"?Id.test(s)&&Id.test(a):!1;return n?o?!0:u:!1}function ME(e){return typeof e==="undefined"?!0:e===null}function jd(e){let t=Pt(e.serviceUrl);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=e.fetchImpl,i=n!==void 0?n:Da,o=e.authMode,s=o!==void 0&&o!=="LocalRunner"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",a=e.operatingMode,u=a!==void 0?zd(a):"text",c=async(l,d,h)=>{let m=Xr(d,r),p;p=m.TAG==="Ok"?m._0:Ge(m._0);let f={};Object.entries(h).forEach(K=>{f[K[0]]=K[1]}),f.operating_mode=u;let g={};g.authorization="Bearer "+e.accessToken;let y;if(l==="Get"){let K=p.searchParams;Object.entries(f).forEach(ce=>{let C=ce[1];if(!ME(C)){K.set(ce[0],String(C));return}}),y=await i.json(p.toString(),{method:"GET",headers:g})}else g["content-type"]="application/json",y=await i.json(p.toString(),{method:"POST",headers:g,body:JSON.stringify(f)});let v=await y.json(),b;if(b=typeof v=="object"&&v!==null&&!Array.isArray(v)?v:void 0,b===void 0)return Ge("Linzumi MCP API returned non-object JSON from "+d);let w=y.ok,S=Ot(b.ok,!0),q=0;if(w){if(S)return b;q=1}else q=1;if(q===1){let K=b.error,ce,C=0;typeof K=="string"?ce=K:C=2,C===2&&(ce="HTTP "+y.status.toString());let V=b.detail,H=typeof V=="string"?" detail="+V:"";return Ge("Linzumi MCP API "+d+" failed: "+ce+H)}};return{TAG:"Ok",_0:{validateAuth:()=>c("Get",s+"/validate",{}),issueOnboardingDiscoveryToken:l=>c("Post",s+"/onboarding-discovery-token",l),getMessage:l=>c("Get",s+"/message",l),getThread:l=>c("Get",s+"/thread",l),getThreadTranscript:l=>c("Get",s+"/thread-transcript",l),getChannel:l=>c("Get",s+"/channel",l),searchWorkspace:l=>c("Get",s+"/search",l),askWorkspace:l=>c("Post",s+"/ask",l),aboutMe:l=>c("Get",s+"/about-me",l),webSearch:l=>c("Get",s+"/web-search",l),fetchUrl:l=>c("Get",s+"/fetch-url",l),listUiTargets:l=>c("Get",s+"/ui-targets",l),openUi:l=>c("Post",s+"/open-ui",l),getCodingJobMetadata:l=>c("Get",s+"/coding-job-metadata",l),listProjects:l=>c("Get",s+"/projects",l),getProjectTasks:l=>c("Get",s+"/project-tasks",l),createProjectTask:l=>c("Post",s+"/project-tasks/create",l),updateProjectTask:l=>c("Post",s+"/project-tasks/update",l),deleteProjectTask:l=>c("Post",s+"/project-tasks/delete",l),addProjectTaskDependency:l=>c("Post",s+"/project-tasks/add-dependency",l),removeProjectTaskDependency:l=>c("Post",s+"/project-tasks/remove-dependency",l),getCallTranscript:l=>c("Get",s+"/call-transcript",l),renameCodingJob:l=>c("Post",s+"/coding-job-title",l),upsertCodingJobPlan:l=>c("Post",s+"/coding-job-plan",l),replaceCodingJobPlanSteps:l=>c("Post",s+"/coding-job-plan/steps",l),updateCodingJobPlanStep:l=>c("Post",s+"/coding-job-plan/step",l),linkCodingJobPullRequest:l=>c("Post",s+"/coding-job-primary-pr",l),listVaultSecrets:l=>c("Get",s+"/vault-secrets",l),noteProjectDirectory:l=>c("Post",s+"/discovered-project",l),noteAgentConversation:l=>c("Post",s+"/discovered-conversation",l),noteOnboardingDiscoveryStatus:l=>c("Post",s+"/discovery-status",l),sendChannelMessage:l=>c("Post",s+"/channel-message",l),editMessage:l=>c("Post",s+"/message/edit",l),agentReply:l=>c("Post",s+"/agent-reply",l),declineDocumentAction:l=>c("Post",s+"/agent/decline-document-action",l),agentTurnProgress:l=>c("Post",s+"/agent-turn-progress",l),agentDocumentTool:l=>c("Post",s+"/agent/document-tool",l),agentTopicTool:l=>c("Post",s+"/agent/topic-tool",l),agentListCodingJobs:l=>c("Get",s+"/agent/coding-jobs",l),agentStartCodingJob:l=>c("Post",s+"/agent/start-coding-job",l),agentSpawnChildJob:l=>c("Post",s+"/agent/spawn-child-job",l),agentArchiveChildJob:l=>c("Post",s+"/agent/archive-child-job",l),agentUnarchiveChildJob:l=>c("Post",s+"/agent/unarchive-child-job",l),agentInterruptCodingJob:l=>c("Post",s+"/agent/interrupt-coding-job",l),agentSendCodingJobMessage:l=>c("Post",s+"/agent/send-coding-job-message",l),agentDiscoverCodingJobs:l=>c("Get",s+"/agent/discover-coding-jobs",l),agentReadCodingJobThread:l=>c("Get",s+"/agent/coding-job-thread",l),agentResolveJobApproval:l=>c("Post",s+"/agent/resolve-job-approval",l),agentArchiveCodingJob:l=>c("Post",s+"/agent/archive-coding-job",l),agentUnarchiveCodingJob:l=>c("Post",s+"/agent/unarchive-coding-job",l),agentSetThreadStatus:l=>c("Post",s+"/agent/set-thread-status",l),agentCreateChannel:l=>c("Post",s+"/agent/create-channel",l),agentRenameChannel:l=>c("Post",s+"/agent/rename-channel",l),agentArchiveChannel:l=>c("Post",s+"/agent/archive-channel",l),agentUnarchiveChannel:l=>c("Post",s+"/agent/unarchive-channel",l),agentAddReaction:l=>c("Post",s+"/agent/add-reaction",l),agentRemoveReaction:l=>c("Post",s+"/agent/remove-reaction",l),agentPinMessage:l=>c("Post",s+"/agent/pin-message",l),agentUnpinMessage:l=>c("Post",s+"/agent/unpin-message",l),prepareMessageUploads:l=>c("Post",s+"/message-uploads/prepare",l),attachMessageFiles:l=>c("Post",s+"/message-files/attach",l),prepareCustomEmoji:l=>c("Post",s+"/custom-emoji/prepare",l),renameCustomEmoji:l=>c("Post",s+"/custom-emoji/rename",l),sendThreadReply:l=>c("Post",s+"/thread-reply",l),sendDm:l=>c("Post",s+"/dm",l),dmOwner:l=>c("Post",s+"/dm-owner",l),getVaultValues:l=>c("Post",s+"/vault-values",l)}}}var ZE=Object.freeze({status:"aborted"});function k(e,t,r){function n(a,u){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(e),t(a,u);for(let l in s.prototype)l in a||Object.defineProperty(a,l,{value:s.prototype[l].bind(a)});a._zod.constr=s,a._zod.def=u}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(a){var u;let c=r?.Parent?new o:this;n(c,a),(u=c._zod).deferred??(u.deferred=[]);for(let l of c._zod.deferred)l();return c}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var mn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Sc={};function Yt(e){return e&&Object.assign(Sc,e),Sc}var ae={};cu(ae,{BIGINT_FORMAT_RANGES:()=>vv,Class:()=>Md,NUMBER_FORMAT_RANGES:()=>Vd,aborted:()=>Pi,allowsEval:()=>qd,assert:()=>VE,assertEqual:()=>LE,assertIs:()=>FE,assertNever:()=>UE,assertNotEqual:()=>qE,assignProp:()=>Ld,cached:()=>Os,captureStackTrace:()=>$c,cleanEnum:()=>nO,cleanRegex:()=>Ps,clone:()=>er,createTransparentProxy:()=>KE,defineLazy:()=>Ee,esc:()=>Ai,escapeRegex:()=>jn,extend:()=>YE,finalizeIssue:()=>xr,floatSafeRemainder:()=>Zd,getElementAtPath:()=>GE,getEnumValues:()=>Es,getLengthableOrigin:()=>Cs,getParsedType:()=>HE,getSizableOrigin:()=>bv,isObject:()=>ko,isPlainObject:()=>So,issue:()=>Gd,joinValues:()=>Tc,jsonStringifyReplacer:()=>Dd,merge:()=>eO,normalizeParams:()=>J,nullish:()=>As,numKeys:()=>WE,omit:()=>XE,optionalKeys:()=>Ud,partial:()=>tO,pick:()=>QE,prefixIssues:()=>Vr,primitiveTypes:()=>yv,promiseAllObject:()=>BE,propertyKeyTypes:()=>Fd,randomString:()=>JE,required:()=>rO,stringifyPrimitive:()=>zc,unwrapMessage:()=>zs});function LE(e){return e}function qE(e){return e}function FE(e){}function UE(e){throw new Error}function VE(e){}function Es(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function Tc(e,t="|"){return e.map(r=>zc(r)).join(t)}function Dd(e,t){return typeof t=="bigint"?t.toString():t}function Os(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function As(e){return e==null}function Ps(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zd(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}function Ee(e,t,r){Object.defineProperty(e,t,{get(){{let i=r();return e[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ld(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function GE(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function BE(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function JE(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ai(e){return JSON.stringify(e)}var $c=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ko(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var qd=Os(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function So(e){if(ko(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(ko(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function WE(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var HE=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Fd=new Set(["string","number","symbol"]),yv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function jn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function er(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function J(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function KE(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function zc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ud(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Vd={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]},vv={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function QE(e,t){let r={},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return er(e,{...e._zod.def,shape:r,checks:[]})}function XE(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return er(e,{...e._zod.def,shape:r,checks:[]})}function YE(e,t){if(!So(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Ld(this,"shape",n),n},checks:[]};return er(e,r)}function eO(e,t){return er(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Ld(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function tO(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)i[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return er(t,{...t._zod.def,shape:i,checks:[]})}function rO(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)i[o]=new e({type:"nonoptional",innerType:n[o]});return er(t,{...t._zod.def,shape:i,checks:[]})}function Pi(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Vr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function zs(e){return typeof e=="string"?e:e?.message}function xr(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=zs(e.inst?._zod.def?.error?.(e))??zs(t?.error?.(e))??zs(r.customError?.(e))??zs(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function bv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Cs(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gd(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function nO(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Md=class{constructor(...t){}};var wv=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Dd,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ec=k("$ZodError",wv),Rs=k("$ZodError",wv,{Parent:Error});function Bd(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function Jd(e,t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>i({issues:a}));else if(s.code==="invalid_key")i({issues:s.issues});else if(s.code==="invalid_element")i({issues:s.issues});else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(e),n}var Wd=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new mn;if(s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>xr(u,o,Yt())));throw $c(a,i?.callee),a}return s.value},Hd=Wd(Rs),Kd=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>xr(u,o,Yt())));throw $c(a,i?.callee),a}return s.value},Qd=Kd(Rs),Xd=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new mn;return o.issues.length?{success:!1,error:new(e??Ec)(o.issues.map(s=>xr(s,i,Yt())))}:{success:!0,data:o.value}},Ci=Xd(Rs),Yd=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>xr(s,i,Yt())))}:{success:!0,data:o.value}},Ri=Yd(Rs);var xv=/^[cC][^\s-]{8,}$/,kv=/^[0-9a-z]+$/,Sv=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Tv=/^[0-9a-vA-V]{20}$/,$v=/^[A-Za-z0-9]{27}$/,zv=/^[a-zA-Z0-9_-]{21}$/,Ev=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ov=/^([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})$/,ef=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Av=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var oO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Pv(){return new RegExp(oO,"u")}var Cv=/^(?:(?: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])$/,Rv=/^(([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})$/,Iv=/^((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])$/,jv=/^(([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])$/,Nv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tf=/^[A-Za-z0-9_-]*$/,Mv=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Dv=/^\+(?:[0-9]){6,14}[0-9]$/,Zv="(?:(?:\\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])))",Lv=new RegExp(`^${Zv}$`);function qv(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Fv(e){return new RegExp(`^${qv(e)}$`)}function Uv(e){let t=qv({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Zv}T(?:${n})$`)}var Vv=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Gv=/^\d+$/,Bv=/^-?\d+(?:\.\d+)?/i,Jv=/true|false/i,Wv=/null/i;var Hv=/^[^A-Z]*$/,Kv=/^[^a-z]*$/;var pt=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Qv={number:"number",bigint:"bigint",object:"date"},rf=k("$ZodCheckLessThan",(e,t)=>{pt.init(e,t);let r=Qv[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nf=k("$ZodCheckGreaterThan",(e,t)=>{pt.init(e,t);let r=Qv[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xv=k("$ZodCheckMultipleOf",(e,t)=>{pt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zd(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Yv=k("$ZodCheckNumberFormat",(e,t)=>{pt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Vd[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=i,a.maximum=o,r&&(a.pattern=Gv)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var eb=k("$ZodCheckMaxLength",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let s=Cs(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tb=k("$ZodCheckMinLength",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let s=Cs(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),rb=k("$ZodCheckLengthEquals",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let s=Cs(i),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Is=k("$ZodCheckStringFormat",(e,t)=>{var r,n;pt.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),nb=k("$ZodCheckRegex",(e,t)=>{Is.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ib=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Hv),Is.init(e,t)}),ob=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Kv),Is.init(e,t)}),sb=k("$ZodCheckIncludes",(e,t)=>{pt.init(e,t);let r=jn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),ab=k("$ZodCheckStartsWith",(e,t)=>{pt.init(e,t);let r=new RegExp(`^${jn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),cb=k("$ZodCheckEndsWith",(e,t)=>{pt.init(e,t);let r=new RegExp(`.*${jn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var lb=k("$ZodCheckOverwrite",(e,t)=>{pt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ac=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
318
+ command = `+zd(e.command)+`
319
+ args = `+wz(e.args)+`
320
+ `+t}var lv="Other",uv="linzumi_ask_user_question",kz="plan_mode_native_interview_tool",Sz="no_active_turn";function $s(e){return JSON.stringify(e)}function Tz(e){let t=e.trim().toLowerCase();switch(t){case"other":case"something else":case"something else...":return!0;default:return t.includes("other")?!0:t.includes("something else")}}function $z(e){let t=ft(e),r=xs(t!==void 0?t.questions:void 0);if(r===void 0)return{TAG:"Invalid",_0:"questions: expected an array"};let n=r.length;if(n===0)return{TAG:"Invalid",_0:"questions: min 1, got 0"};if(n>4)return{TAG:"Invalid",_0:"questions: max 4, got "+n.toString()};let i={contents:void 0},o=[],s=new Set;r.forEach((u,c)=>{if(i.contents!==void 0)return;let d=c.toString(),h=ft(u);if(h===void 0){i.contents="questions["+d+"]: expected an object";return}let m=Qe(h.question);if(m===void 0){i.contents="questions["+d+"].question: must be a non-empty string";return}if(s.has(m)){i.contents="questions: duplicate question text "+$s(m);return}let p=Qe(h.header);if(p===void 0){i.contents="questions["+d+"].header: must be a non-empty string";return}if(p.length>12){i.contents="questions["+d+"].header: max 12 chars, got "+p.length.toString();return}let f=h.multiSelect;if(f!==void 0){let K=0;if(typeof f!="boolean"&&(K=2),K===2){i.contents="questions["+d+"].multiSelect: must be a boolean";return}}let g=xs(h.options);if(g===void 0){i.contents="questions["+d+"].options: expected an array";return}let y=g.length;if(y<2){i.contents="questions["+d+"].options: min 2, got "+y.toString();return}if(y>4){i.contents="questions["+d+"].options: max 4, got "+y.toString();return}let v=[],b=new Set;if(g.forEach((K,ce)=>{if(i.contents!==void 0)return;let V=ce.toString(),H=ft(K),fe=H!==void 0?Qe(H.label):void 0;if(H!==void 0&&fe!==void 0){let ge=H.description,j=0;if(ge!==void 0){let $=0;if(typeof ge=="string"?j=2:$=3,$===3){i.contents="questions["+d+"].options["+V+"].description: must be a string";return}}else j=2;if(j===2){if(Tz(fe)){i.contents="questions["+d+"].options["+V+"].label: "+$s(fe)+" is reserved for the built-in Other option";return}if(b.has(fe)){i.contents="questions["+d+"].options: duplicate label "+$s(fe);return}b.add(fe);let $=H.description,R;R=typeof $=="string"?$:"",v.push({label:fe,description:R});return}}i.contents="questions["+d+"].options["+V+"].label: must be a non-empty string"}),i.contents!==void 0)return;s.add(m);let S=h.multiSelect,q;q=S===!0,o.push({question:m,header:p,options:v,multiSelect:q})});let a=i.contents;return a!==void 0?{TAG:"Invalid",_0:a}:{TAG:"Parsed",_0:{questions:o}}}function Ez(e){let t={};e.questions.forEach(a=>{let u={};u.type="string",u.description=a.header,t[a.question]=u});let r={};r.type="object",r.properties=t,r.required=e.questions.map(a=>a.question);let n=e.questions.map(a=>{let u={};return u.question=a.question,u.header=a.header,u.multiSelect=a.multiSelect,u.options=a.options.map(c=>{let l={};return l.label=c.label,l.description=c.description,l}),u}),i={};i.version=1,i.questions=n;let o={};o[uv]=i;let s={};return s.message="Linzumi interview: the user is being asked in the Linzumi thread.",s.requestedSchema=r,s._meta=o,s}function zz(e,t){let r=ft(t);if(r===void 0)return{TAG:"AnswersInvalid",_0:"the runner accepted the interview but returned no answers; it may predate linzumi_ask_user_question support"};let n={contents:void 0},i={};e.questions.forEach(s=>{if(n.contents!==void 0)return;let u=r[s.question];if(typeof u=="string"){let c=0,l;try{l=JSON.parse(u),c=2}catch{n.contents="the runner returned an undecodable answer for question "+$s(s.question);return}if(c===2){i[s.question]=l;return}}n.contents="the runner returned no answer for question "+$s(s.question)});let o=n.contents;return o!==void 0?{TAG:"AnswersInvalid",_0:o}:{TAG:"Answers",_0:i}}function Oz(e){let t=ft(e);if(t===void 0)return;let r=ft(t[uv]);return Qe(r!==void 0?r.reason:void 0)}function fn(e){let t={};t.type="text",t.text=e;let r={};return r.content=[t],r.isError=!0,r}function Az(e){if(e===void 0)return"undefined";if(e===null)return"null";switch(typeof e){case"string":return e;case"number":return e.toString();default:return JSON.stringify(e)}}async function dv(e,t){let r=$z(t);if(r.TAG!=="Parsed")return fn(r._0);let n=r._0,i=0,o;try{o=await e(Ez(n),2147483647),i=1}catch(s){let a=X(s);return fn("the interview could not be delivered to the user: "+Yr(a))}if(i===1){let s=ft(o),a=s!==void 0?s:{},u=a.action,c=0;if(typeof u=="string")switch(u){case"accept":let l=zz(n,a.content);if(l.TAG!=="Answers")return fn(l._0);let d={};return d.answers=l._0,St(d);case"cancel":return fn("the user dismissed the question without answering");case"decline":let h=Oz(a._meta);return fn(h!==void 0?h===kz?"linzumi_ask_user_question is unavailable during a Plan-mode turn: use the native request_user_input interview tool instead":h===Sz?"the interview was declined: no active turn is bound to this session":"the interview request was declined by the runner":"the interview request was declined by the runner");default:c=2}else c=2;if(c===2)return fn("the interview returned an unknown action: "+Az(u))}}var fv="linzumi_ask_user_question",Ad=4,Pd=12,Cd=2,Rd=4;var mv="One or two sentences a teammate skimming the board would want: what changed, and what happens next. Standup register, present tense, name agents and lanes plainly. No thread ids or UUIDs unless needed for lookup; proofs and evidence belong in the thread, not here. Good: 'Retired the silent watchdog and spawned Thorne to replace it \u2014 running lean at three children.' Bad: 'Broken 67f1d639 archived abandoned; board claim preceded spawn; children verified at exactly 3.'";function pv(){return _.string().min(1).refine(e=>ny(e)<=240,{message:"status_note over 240 chars \u2014 trim to what a reader needs; put evidence in the thread."})}function Cz(e){switch(e){case"All":return!0;case"Coding":case"OnboardingDiscovery":return!1}}function Rz(e){return e==="Voice"}function Iz(e){return e.trim().replace(new RegExp("^:+"),"").replace(new RegExp(":+$"),"").toLowerCase()}function hv(){return _.string().min(1).refine(e=>Iz(e).length<=64,{message:"Custom emoji shortcode name must be at most 64 characters after trimming surrounding colons."})}function Oi(){let e=_.discriminatedUnion("type",[_.object(Object.fromEntries([["type",_.literal("text")],["text",_.string()],["style",_.array(_.enum(["bold","italic","code"])).optional()]])).strict(),_.object(Object.fromEntries([["type",_.literal("actor")],["user_id",_.number().int().positive()],["fallback",_.string().min(1)]])).strict()]);return _.array(_.object(Object.fromEntries([["kind",_.literal("prose")],["tokens",_.array(e).min(1)]])).strict()).min(1).describe("Canonical BlockSequence. Actor mentions must be actor tokens; literal @ text stays a text token.")}function Ee(){return _.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")}function Qt(){return _.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")}function Xt(e){if(typeof e=="string")return e}function gv(e,t,r){let n=ft(e[t]);return n!==void 0?n:Ge(r+" "+t+" must be an object")}function jz(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="string")return t}):[]:[]}function Nz(e){return e!==void 0?Array.isArray(e)?Ht(e,t=>{if(typeof t=="number")return t}):[]:[]}function _v(e){if(typeof e=="number")return e}function yv(e){let t={};t.name=e.record.name,t.command=e.record.command,t.cwd=e.record.cwd,t.ports=e.record.ports.map(s=>s),t.restart_on_branch_change=e.record.restartOnBranchChange,t.desired_state=bd(e.record.desiredState),t.liveness=Qy(e.liveness),t.port_health=e.portProbes.map(s=>{let a={};return a.port=s.port,a.listening=s.listening,a});let r=e.record.startedAtMs;t.started_at_ms=r!==void 0?r:null;let n=e.lastExit,i;if(n!==void 0){let s={},a=n.code;s.code=a!==void 0?a:null;let u=n.signal;s.signal=u!==void 0?u:null,s.at_ms=n.atMs,i=s}else i=null;t.last_exit=i,t.log_path=e.record.logPath;let o=e.failure;return t.failure=o!==void 0?{reason:o.reason,at_ms:o.atMs}:null,t}function Mz(e,t,r){e.registerTool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",Object.fromEntries([["name",_.string().regex(new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service.")],["command",_.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell.")],["cwd",_.string().optional().describe("Working directory for the service. Defaults to the session cwd.")],["ports",_.array(_.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility.")],["restart_on_branch_change",_.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts).")],["wait_for_ports_ms",_.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=Xt(n.command),a=s!==void 0?s:"",u=Xt(n.cwd),c=await ev({scopeDir:r.scopeDir,definition:{name:o,command:a,cwd:u!==void 0?u:t,ports:Nz(n.ports),restartOnBranchChange:Ot(n.restart_on_branch_change,!0)},ownerPid:r.ownerPid});if(c.TAG==="Ok"){let d=c._0,h=_v(n.wait_for_ports_ms),m=Date.now()+(h!==void 0?h:15e3),p=d.ports.length===0;for(;!p&&Date.now()<m;)p=(await Promise.all(d.ports.map(w=>Sd(w|0)))).every(w=>w),p||await Za(250);let g=(await Td(r.scopeDir)).find(b=>b.record.name===d.name),y={};y.ok=!0;let v;if(g!==void 0)v=yv(g);else{let b={};b.name=d.name,v=b}return y.service=v,g!==void 0&&g.liveness!=="Running"&&(y.hint="The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."),St(y)}let l={};return l.ok=!1,l.error=c._0,St(l)}),e.registerTool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to stop.")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=await $d(r.scopeDir,o,void 0),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.desired_state="stopped"):(a.ok=!1,a.error=s._0),St(a)}),e.registerTool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async n=>{let i=await Td(r.scopeDir),o={};return o.services=i.map(s=>yv(s)),St(o)}),e.registerTool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",Object.fromEntries([["name",_.string().min(1).describe("Service name.")],["max_bytes",_.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=_v(n.max_bytes),a=rv(r.scopeDir,o,s!==void 0?s:16384),u={};return a!==void 0?(u.ok=!0,u.name=o,u.log_tail=a):(u.ok=!1,u.error="no log for service: "+o),St(u)}),e.registerTool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to remove.")]]),async n=>{let i=Xt(n.name),o=i!==void 0?i:"",s=await tv(r.scopeDir,o,xc),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.removed=!0):(a.ok=!1,a.error=s._0),St(a)})}function vv(e,t){let r=t.devServices,n=t.agentSession,i=t.ownerUsername,o=t.defaultThreadId,s=t.serviceUrl,a=t.cwd,u=t.toolScope,c=t.client,l;switch(u){case"All":case"Coding":l=!0;break;case"OnboardingDiscovery":l=!1;break}let d=async f=>St(await f),h=async(f,g)=>(g.tool=f,await d(c.agentDocumentTool(g))),m=t.documentSurfaces;m!==void 0&&m&&(e.registerTool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",Object.fromEntries([["query",_.string().min(1).describe("Document title or content search query.")]]),async f=>await h("lookup_documents",f)),e.registerTool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")]]),async f=>await h("read_document",f)),n?(e.registerTool("linzumi_append_document_section","Use this tool for append-shaped document requests. After resolving exactly one patch target document and reading it, supply only the heading and body Markdown; the server composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading",_.string().trim().min(1).describe("Section heading.")],["body_markdown",_.string().trim().min(1).describe("Section body as Markdown.")]]),async f=>await h("append_document_section",f)),e.registerTool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["body_markdown",_.string().trim().min(1).describe("Replacement section body as Markdown.")]]),async f=>await h("replace_section",f)),e.registerTool("linzumi_decline_document_action","Decline the current document action when neither advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",Object.fromEntries([["reason",_.string().refine(f=>f.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")]]),async f=>await d(c.declineDocumentAction(f)))):(e.registerTool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["patch",_.object(Object.fromEntries([["baseRevision",_.number().int().nonnegative()],["operations",_.array(_.record(_.unknown()))],["title",_.string().min(1).optional()]])).describe("Revisioned structural document patch.")],["rationale",_.string().min(1).describe("Why this change is proposed.")]]),async f=>await h("propose_document_patch",f)),e.registerTool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",Object.fromEntries([["title",_.string().min(1).describe("Document title.")],["initial_patch",_.record(_.unknown()).describe("Bootstrap structural patch.")],["folder_id",_.string().uuid().optional().describe("Destination folder UUID.")]]),async f=>await h("create_document",f))));let p=t.askUserQuestion;if(p!==void 0&&e.registerTool(fv,"Ask the user up to "+Ad.toString()+" structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max "+Pd.toString()+" chars) and "+Cd.toString()+"-"+Rd.toString()+' options {label, description}; a built-in "'+lv+'" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.',Object.fromEntries([["questions",_.array(_.object(Object.fromEntries([["question",_.string().describe("The question to ask the user.")],["header",_.string().describe("Short category header shown above the question (max "+Pd.toString()+' chars, e.g. "Auth", "Scope").')],["options",_.array(_.object(Object.fromEntries([["label",_.string().describe("Option label the user taps.")],["description",_.string().optional().describe("One-line explanation of the option.")]]))).describe(Cd.toString()+"-"+Rd.toString()+" options for this question.")],["multiSelect",_.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")]]))).describe("1-"+Ad.toString()+" questions to ask atomically.")]]),async f=>await dv(p,f)),n){e.registerTool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",Object.fromEntries([["body",_.string().min(1).describe("Plain-text reply body to post.")],["tokens",Oi().optional()]]),async g=>{let y=g.body,v={body:y!==void 0?y:void 0},b=g.tokens;return b!==void 0&&(v.tokens=b),await d(c.agentReply(v))});let f=async(g,y)=>(y.tool=g,await d(c.agentTopicTool(y)));e.registerTool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Existing workspace topic slug to watch.")],["instruction",_.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")]]),async g=>await f("create_topic_wake_subscription",g)),e.registerTool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Workspace topic slug whose standing wake should stop.")]]),async g=>await f("disable_topic_wake_subscription",g)),e.registerTool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async g=>await d(c.agentListCodingJobs({}))),e.registerTool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["channel",_.string().describe("Channel slug to host the job thread.")],["runner_key",_.string().describe("Runner (computer) to run the job on.")],["cwd",_.string().describe("Working directory on the runner.")],["work_description",_.string().min(1).describe("What the job should do - the initial instruction.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")]]),async g=>await d(c.agentStartCodingJob(g))),e.registerTool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["mode",_.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")]]),async g=>await d(c.agentInterruptCodingJob(g))),e.registerTool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Message body to send.")],["tokens",Oi().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>await d(c.agentSendCodingJobMessage(g))),e.registerTool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async g=>await d(c.agentReadCodingJobThread(g))),e.registerTool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["source_seq",_.number().int().positive().describe("Channel seq of the message the approval request rides on.")],["request_id",_.string().describe("The approval request id.")],["decision",_.enum(["approve","deny"]).describe("The asker's decision.")]]),async g=>await d(c.agentResolveJobApproval(g))),e.registerTool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to archive.")]]),async g=>await d(c.agentArchiveCodingJob(g))),e.registerTool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to unarchive.")]]),async g=>await d(c.agentUnarchiveCodingJob(g))),e.registerTool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID.")],["status",_.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")]]),async g=>await d(c.agentSetThreadStatus(g))),e.registerTool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",Object.fromEntries([["name",_.string().min(1).describe("Channel name to create.")]]),async g=>await d(c.agentCreateChannel(g))),e.registerTool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",Object.fromEntries([["channel",_.string().describe("Current channel slug to rename.")],["name",_.string().min(1).describe("New display name.")]]),async g=>await d(c.agentRenameChannel(g))),e.registerTool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",Object.fromEntries([["channel",_.string().describe("Channel slug to archive.")]]),async g=>await d(c.agentArchiveChannel(g))),e.registerTool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug to unarchive.")]]),async g=>await d(c.agentUnarchiveChannel(g))),e.registerTool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to react to.")],["emoji",_.string().min(1).describe("Emoji to add (unicode or :shortcode:).")]]),async g=>await d(c.agentAddReaction(g))),e.registerTool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the reacted message.")],["emoji",_.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")]]),async g=>await d(c.agentRemoveReaction(g))),e.registerTool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to pin.")]]),async g=>await d(c.agentPinMessage(g))),e.registerTool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the pinned message.")]]),async g=>await d(c.agentUnpinMessage(g)))}switch(u){case"All":e.registerTool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["message_id",_.union([_.string(),_.number()]).optional().describe("Message seq inside the scoped channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Alias for message_id.")],["message_url",_.string().optional().describe("Full Linzumi message URL with #message-<seq>.")],["before",_.number().int().min(0).max(100).optional().describe("Number of visible messages before the target.")],["after",_.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")]]),async f=>await d(c.getMessage(f))),e.registerTool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async f=>await d(c.getThread(f))),e.registerTool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200).")],["cursor",_.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")]]),async f=>await d(c.getThreadTranscript(f))),e.registerTool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["limit",_.number().int().min(1).max(100).optional().describe("Maximum messages to return.")],["before_seq",_.number().int().positive().optional().describe("Return messages before this channel seq.")]]),async f=>await d(c.getChannel(f))),e.registerTool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",Object.fromEntries([["workspace",Ee()],["query",_.string().min(1).describe("Natural-language or keyword query to retrieve against.")],["limit",_.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped).")],["source_types",_.array(_.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all.")],["authored_after",_.string().optional().describe("ISO8601 instant; only content authored at or after this time.")],["authored_before",_.string().optional().describe("ISO8601 instant; only content authored at or before this time.")],["repo",_.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name).")],["check_status",_.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")]]),async f=>await d(c.searchWorkspace(f))),e.registerTool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',Object.fromEntries([["workspace",Ee()],["question",_.string().min(1).max(2e3).describe("Natural-language question to answer with citations.")],["channel",_.string().optional().describe("Optional channel slug providing conversational context; never widens access.")],["allow_cached",_.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")]]),async f=>await d(c.askWorkspace(f))),e.registerTool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async f=>await d(c.aboutMe(f)));break;case"Coding":case"OnboardingDiscovery":break}switch(l&&(e.registerTool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",Object.fromEntries([["query",_.string().min(1).describe("Web search query (natural language or keywords).")],["limit",_.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")]]),async f=>await d(c.webSearch(f))),e.registerTool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",Object.fromEntries([["url",_.string().min(1).describe("Absolute public http(s) URL to fetch.")]]),async f=>await d(c.fetchUrl(f)))),u){case"All":e.registerTool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async f=>await rd(c.listUiTargets({}))),e.registerTool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",Object.fromEntries([["kind",_.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout).")],["args",_.record(_.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path).")],["workspace",Ee()]]),async f=>await rd(c.openUi(sr(f,o))));break;case"Coding":case"OnboardingDiscovery":break}if(l){let f=()=>_.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread.");e.registerTool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()]]),async g=>await d(c.getCodingJobMetadata(sr(g,o)))),e.registerTool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()],["title",_.string().min(1).max(100).describe("Concise user-visible title for this coding job.")]]),async g=>await d(c.renameCodingJob(sr(g,o)))),e.registerTool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()],["goal",_.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")]]),async g=>await d(c.upsertCodingJobPlan(sr(g,o)))),e.registerTool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()],["goal",_.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal.")],["steps",_.array(_.object(Object.fromEntries([["title",_.string().min(1).max(255)],["description",_.string().min(1).max(1e4)],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",pv().optional().describe(mv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required for completed steps. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]))).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")]]),async g=>await d(c.replaceCodingJobPlanSteps(sr(g,o)))),e.registerTool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()],["step_id",_.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata.")],["lock_version",_.number().int().positive().describe("Current step lock_version from metadata.")],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",pv().optional().describe(mv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required when marking a step completed. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]),async g=>await d(c.updateCodingJobPlanStep(sr(g,o)))),e.registerTool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",f()],["github_repo_owner",_.string().min(1).max(255)],["github_repo_name",_.string().min(1).max(255)],["github_pr_number",_.number().int().positive()],["github_pr_url",_.string().url()],["title",_.string().min(1).max(255)],["body",_.string().min(1).max(1e5).optional()],["head_branch",_.string().min(1).max(255)],["head_sha",_.string().min(7).max(64)],["base_branch",_.string().min(1).max(255)],["base_sha",_.string().min(7).max(64)],["state",_.enum(["draft","open","closed","merged"]).optional()],["is_draft",_.boolean().optional()],["review_status",_.enum(["unknown","review_required","approved","changes_requested"]).optional()],["source_remote_url",_.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet.")],["runtime_worktree_root",_.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet.")],["dirty_status",_.enum(["unknown","clean","dirty"]).optional()],["dirty_summary",_.string().min(1).max(2e3).optional()]]),async g=>await d(c.linkCodingJobPullRequest(sr(g,o)))),e.registerTool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),Object.fromEntries([["target",_.object(Object.fromEntries([["kind",_.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Required when kind is message_seq.")],["thread_id",_.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")]])).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit.")],["files",_.array(_.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types.")],["body",_.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool.")],["workspace",Ee()],["channel",_.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")]]),async g=>{let y=nd(gv(g,"target","linzumi_upload_files"),o),v;try{v=await py({client:c,cwd:a,serviceUrl:s,target:y,files:jz(g.files),workspace:Xt(g.workspace),channel:Xt(g.channel),body:Xt(g.body)})}catch(b){return dy(X(b))}return St(id(s,v))}),e.registerTool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["target",_.object(Object.fromEntries([["message_seq",_.union([_.string(),_.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here.")],["thread_id",_.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")]])).describe("Exact message target for the body edit.")],["body",_.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")]]),async g=>{let y=ln(g);return y.target=nd(gv(g,"target","linzumi_edit_message"),o),St(id(s,await c.editMessage(y)))})}switch(u){case"All":if(e.registerTool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async f=>await d(c.listVaultSecrets(f))),e.registerTool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",Object.fromEntries([["workspace",Ee()]]),async f=>await d(c.listProjects(f))),e.registerTool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")]]),async f=>await d(c.getProjectTasks(sr(f,o)))),e.registerTool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")],["title",_.string().min(1).describe("Task title.")],["kind",_.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).')],["description",_.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".')],["parent_id",_.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent.")],["assignee",_.string().optional().describe("Username of a workspace member to assign.")],["position",_.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")]]),async f=>await d(c.createProjectTask(sr(f,o)))),e.registerTool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to update.")],["title",_.string().min(1).optional().describe("New title.")],["description",_.string().nullable().optional().describe("New description. Pass null to clear it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.')],["status_note",_.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it.")],["position",_.number().int().min(0).optional().describe("New sort position among siblings.")],["parent_id",_.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent.")],["clear_parent",_.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id.")],["assignee",_.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee.")],["clear_assignee",_.boolean().optional().describe("true removes the assignee. Do not combine with assignee.")],["lock_version",_.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")]]),async f=>await d(c.updateProjectTask(f))),e.registerTool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to delete.")]]),async f=>await d(c.deleteProjectTask(f))),e.registerTool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue (the one that must wait).")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")]]),async f=>await d(c.addProjectTaskDependency(f))),e.registerTool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue.")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue the edge points at.")]]),async f=>await d(c.removeProjectTaskDependency(f))),e.registerTool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",Object.fromEntries([["call_id",_.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")]]),async f=>await d(c.getCallTranscript(f))),!n){e.registerTool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job - only start tasks whose work_state is ready, and ONLY after the user explicitly accepts your offer to start them. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description.")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")],["channel",_.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel.")],["runner_key",_.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer.")],["cwd",_.string().optional().describe("Working directory on the runner. Omit to use this job's own folder.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["agent_provider",_.string().optional().describe("Agent provider override, e.g. 'codex' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["approval_policy",_.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional).")],["sandbox",_.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional).")],["fast",_.boolean().optional().describe("Fast-mode override (optional).")],["allow_port_forwarding_by_default",_.boolean().optional().describe("Default port-forwarding override (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["egress_mode",_.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")]]),async g=>await d(c.agentStartCodingJob(sr(g,o))));let f=t.multiAgentJobs;f!==void 0&&f&&(e.registerTool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone.")],["agent_provider",_.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job.")],["model",_.string().optional().describe("Model override for the child (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")]]),async g=>await d(c.agentSpawnChildJob(sr(g,o)))),e.registerTool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",Object.fromEntries([["job_id",_.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree.")],["outcome",_.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived.")],["descendant_action",_.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree.")],["expected_descendant_count",_.number().int().optional().describe("The descendant_count returned by the phase-1 call.")],["expected_descendant_job_ids",_.array(_.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed.")],["expected_descendant_fingerprint",_.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")]]),async g=>await d(c.agentArchiveChildJob(g))),e.registerTool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",Object.fromEntries([["job_id",_.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")]]),async g=>await d(c.agentUnarchiveChildJob(g))),e.registerTool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",Object.fromEntries([["query",_.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=td(wt(o,v=>v)),await d(c.agentDiscoverCodingJobs(y))}),e.registerTool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Coordination message to send.")],["tokens",Oi().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=td(wt(o,v=>v)),await d(c.agentSendCodingJobMessage(y))}))}break;case"Coding":case"OnboardingDiscovery":break}switch(Cz(u)&&(e.registerTool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",Object.fromEntries([["name",hv().describe("Custom emoji shortcode name, with or without surrounding colons.")],["file",_.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji.")],["workspace",Ee()]]),async f=>{let g=Xt(f.name),y=Xt(f.file);return St(await hy({client:c,cwd:a,serviceUrl:s,name:g!==void 0?g:"",file:y!==void 0?y:"",workspace:Xt(f.workspace)}))}),e.registerTool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",Object.fromEntries([["emoji_id",_.union([_.string(),_.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings.")],["name",hv().describe("New shortcode name, with or without surrounding colons.")],["workspace",Ee()]]),async f=>await d(c.renameCustomEmoji(f)))),e.registerTool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async f=>{let g={};g.type="text",g.text=ov;let y={};return y.content=[g],y}),e.registerTool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["path",_.string().min(1).describe("Absolute local path to the repository worktree root.")],["display_name",_.string().optional().describe("Short project label. Defaults to the path basename.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["import_key",_.string().optional().describe("Stable dedupe key. Defaults to path.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")]]),async f=>await d(c.noteProjectDirectory(f))),e.registerTool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["source",_.enum(["codex","claude_code"]).describe("Conversation source.")],["import_key",_.string().min(1).describe("Stable dedupe key, such as a session id or file path.")],["path",_.string().optional().describe("Absolute local path to the conversation file or directory.")],["display_name",_.string().optional().describe("Short label for the discovered conversation.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as session id or project path.")]]),async f=>await d(c.noteAgentConversation(f))),e.registerTool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["phase",_.enum(["projects","conversations"]).describe("Discovery phase being reported.")],["status",_.enum(["starting","running","completed","failed"]).describe("Current phase status.")],["places_searched",_.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far.")],["message",_.string().optional().describe("Short user-facing status note.")],["current_place",_.string().optional().describe("Current folder, file, Git command target, or known location being checked.")],["current_source",_.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code.")],["last_error",_.string().optional().describe("Short failure detail when status is failed.")],["metadata",_.record(_.unknown()).optional().describe("Small structured status metadata.")]]),async f=>await d(c.noteOnboardingDiscoveryStatus(f))),u==="All"&&Rz(t.operatingMode)&&(e.registerTool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",Object.fromEntries([["owner_username",_.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username.")],["workspace",Ee()],["channel",_.string().optional().describe("Source channel slug used to verify owner visibility.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Oi().optional()]]),async f=>{let g=Xt(f.owner_username),y=g!==void 0?g:i;if(y===void 0)return Ge("owner_username is required for linzumi_dm_owner");let v=ln(f);return v.owner_username=y,await d(c.dmOwner(v))}),e.registerTool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["body",_.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Oi().optional()]]),async f=>await d(c.sendChannelMessage(f))),e.registerTool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Qt()],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID.")],["body",_.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Oi().optional()]]),async f=>await d(c.sendThreadReply(f))),e.registerTool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",Object.fromEntries([["workspace",Ee()],["channel",_.string().optional().describe("Source channel slug used to verify target visibility.")],["username",_.string().describe("Visible Linzumi username to DM.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Oi().optional()]]),async f=>await d(c.sendDm(f)))),u){case"All":e.registerTool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",Object.fromEntries([["workspace",Ee()],["channel",_.string().optional().describe("Channel slug used to disambiguate the approval thread when needed.")],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID for the inline approval.")],["env_var_names",_.array(_.string().regex(new RegExp("^[A-Z][A-Z0-9_]{0,127}$"))).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys.")],["description",_.string().min(1).max(500).describe("Human-readable reason shown in the approval request.")],["justification",_.string().min(10).max(1e3).describe("Agent justification shown to the approver.")]]),async f=>await d(c.getVaultValues(f)));break;case"Coding":case"OnboardingDiscovery":break}switch(u){case"All":return n||r===void 0?void 0:Mz(e,a,r);case"Coding":case"OnboardingDiscovery":return}}function Zz(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function Lz(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(Zz(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}var Id=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function bv(e){let t=Lz(e);if(t===void 0)return!1;let n=t.document_surfaces===!0,i=t.linzumi_agent_session,o=typeof i=="string"?Id.test(i):!1,s=t.coding_job_id,a=t.coding_job_thread_id,u=typeof s=="string"&&typeof a=="string"?Id.test(s)&&Id.test(a):!1;return n?o?!0:u:!1}function Fz(e){return typeof e==="undefined"?!0:e===null}function jd(e){let t=Pt(e.serviceUrl);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=e.fetchImpl,i=n!==void 0?n:Da,o=e.authMode,s=o!==void 0&&o!=="LocalRunner"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",a=e.operatingMode,u=a!==void 0?Ed(a):"text",c=async(l,d,h)=>{let m=Xr(d,r),p;p=m.TAG==="Ok"?m._0:Ge(m._0);let f={};Object.entries(h).forEach(K=>{f[K[0]]=K[1]}),f.operating_mode=u;let g={};g.authorization="Bearer "+e.accessToken;let y;if(l==="Get"){let K=p.searchParams;Object.entries(f).forEach(ce=>{let C=ce[1];if(!Fz(C)){K.set(ce[0],String(C));return}}),y=await i.json(p.toString(),{method:"GET",headers:g})}else g["content-type"]="application/json",y=await i.json(p.toString(),{method:"POST",headers:g,body:JSON.stringify(f)});let v=await y.json(),b;if(b=typeof v=="object"&&v!==null&&!Array.isArray(v)?v:void 0,b===void 0)return Ge("Linzumi MCP API returned non-object JSON from "+d);let w=y.ok,S=Ot(b.ok,!0),q=0;if(w){if(S)return b;q=1}else q=1;if(q===1){let K=b.error,ce,C=0;typeof K=="string"?ce=K:C=2,C===2&&(ce="HTTP "+y.status.toString());let V=b.detail,H=typeof V=="string"?" detail="+V:"";return Ge("Linzumi MCP API "+d+" failed: "+ce+H)}};return{TAG:"Ok",_0:{validateAuth:()=>c("Get",s+"/validate",{}),issueOnboardingDiscoveryToken:l=>c("Post",s+"/onboarding-discovery-token",l),getMessage:l=>c("Get",s+"/message",l),getThread:l=>c("Get",s+"/thread",l),getThreadTranscript:l=>c("Get",s+"/thread-transcript",l),getChannel:l=>c("Get",s+"/channel",l),searchWorkspace:l=>c("Get",s+"/search",l),askWorkspace:l=>c("Post",s+"/ask",l),aboutMe:l=>c("Get",s+"/about-me",l),webSearch:l=>c("Get",s+"/web-search",l),fetchUrl:l=>c("Get",s+"/fetch-url",l),listUiTargets:l=>c("Get",s+"/ui-targets",l),openUi:l=>c("Post",s+"/open-ui",l),getCodingJobMetadata:l=>c("Get",s+"/coding-job-metadata",l),listProjects:l=>c("Get",s+"/projects",l),getProjectTasks:l=>c("Get",s+"/project-tasks",l),createProjectTask:l=>c("Post",s+"/project-tasks/create",l),updateProjectTask:l=>c("Post",s+"/project-tasks/update",l),deleteProjectTask:l=>c("Post",s+"/project-tasks/delete",l),addProjectTaskDependency:l=>c("Post",s+"/project-tasks/add-dependency",l),removeProjectTaskDependency:l=>c("Post",s+"/project-tasks/remove-dependency",l),getCallTranscript:l=>c("Get",s+"/call-transcript",l),renameCodingJob:l=>c("Post",s+"/coding-job-title",l),upsertCodingJobPlan:l=>c("Post",s+"/coding-job-plan",l),replaceCodingJobPlanSteps:l=>c("Post",s+"/coding-job-plan/steps",l),updateCodingJobPlanStep:l=>c("Post",s+"/coding-job-plan/step",l),linkCodingJobPullRequest:l=>c("Post",s+"/coding-job-primary-pr",l),listVaultSecrets:l=>c("Get",s+"/vault-secrets",l),noteProjectDirectory:l=>c("Post",s+"/discovered-project",l),noteAgentConversation:l=>c("Post",s+"/discovered-conversation",l),noteOnboardingDiscoveryStatus:l=>c("Post",s+"/discovery-status",l),sendChannelMessage:l=>c("Post",s+"/channel-message",l),editMessage:l=>c("Post",s+"/message/edit",l),agentReply:l=>c("Post",s+"/agent-reply",l),declineDocumentAction:l=>c("Post",s+"/agent/decline-document-action",l),agentTurnProgress:l=>c("Post",s+"/agent-turn-progress",l),agentDocumentTool:l=>c("Post",s+"/agent/document-tool",l),agentTopicTool:l=>c("Post",s+"/agent/topic-tool",l),agentListCodingJobs:l=>c("Get",s+"/agent/coding-jobs",l),agentStartCodingJob:l=>c("Post",s+"/agent/start-coding-job",l),agentSpawnChildJob:l=>c("Post",s+"/agent/spawn-child-job",l),agentArchiveChildJob:l=>c("Post",s+"/agent/archive-child-job",l),agentUnarchiveChildJob:l=>c("Post",s+"/agent/unarchive-child-job",l),agentInterruptCodingJob:l=>c("Post",s+"/agent/interrupt-coding-job",l),agentSendCodingJobMessage:l=>c("Post",s+"/agent/send-coding-job-message",l),agentDiscoverCodingJobs:l=>c("Get",s+"/agent/discover-coding-jobs",l),agentReadCodingJobThread:l=>c("Get",s+"/agent/coding-job-thread",l),agentResolveJobApproval:l=>c("Post",s+"/agent/resolve-job-approval",l),agentArchiveCodingJob:l=>c("Post",s+"/agent/archive-coding-job",l),agentUnarchiveCodingJob:l=>c("Post",s+"/agent/unarchive-coding-job",l),agentSetThreadStatus:l=>c("Post",s+"/agent/set-thread-status",l),agentCreateChannel:l=>c("Post",s+"/agent/create-channel",l),agentRenameChannel:l=>c("Post",s+"/agent/rename-channel",l),agentArchiveChannel:l=>c("Post",s+"/agent/archive-channel",l),agentUnarchiveChannel:l=>c("Post",s+"/agent/unarchive-channel",l),agentAddReaction:l=>c("Post",s+"/agent/add-reaction",l),agentRemoveReaction:l=>c("Post",s+"/agent/remove-reaction",l),agentPinMessage:l=>c("Post",s+"/agent/pin-message",l),agentUnpinMessage:l=>c("Post",s+"/agent/unpin-message",l),prepareMessageUploads:l=>c("Post",s+"/message-uploads/prepare",l),attachMessageFiles:l=>c("Post",s+"/message-files/attach",l),prepareCustomEmoji:l=>c("Post",s+"/custom-emoji/prepare",l),renameCustomEmoji:l=>c("Post",s+"/custom-emoji/rename",l),sendThreadReply:l=>c("Post",s+"/thread-reply",l),sendDm:l=>c("Post",s+"/dm",l),dmOwner:l=>c("Post",s+"/dm-owner",l),getVaultValues:l=>c("Post",s+"/vault-values",l)}}}var Vz=Object.freeze({status:"aborted"});function k(e,t,r){function n(a,u){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(e),t(a,u);for(let l in s.prototype)l in a||Object.defineProperty(a,l,{value:s.prototype[l].bind(a)});a._zod.constr=s,a._zod.def=u}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(a){var u;let c=r?.Parent?new o:this;n(c,a),(u=c._zod).deferred??(u.deferred=[]);for(let l of c._zod.deferred)l();return c}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var mn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Sc={};function Yt(e){return e&&Object.assign(Sc,e),Sc}var ae={};cu(ae,{BIGINT_FORMAT_RANGES:()=>xv,Class:()=>Md,NUMBER_FORMAT_RANGES:()=>Vd,aborted:()=>Pi,allowsEval:()=>qd,assert:()=>Hz,assertEqual:()=>Gz,assertIs:()=>Jz,assertNever:()=>Wz,assertNotEqual:()=>Bz,assignProp:()=>Ld,cached:()=>Os,captureStackTrace:()=>$c,cleanEnum:()=>cO,cleanRegex:()=>Ps,clone:()=>er,createTransparentProxy:()=>tO,defineLazy:()=>ze,esc:()=>Ai,escapeRegex:()=>jn,extend:()=>iO,finalizeIssue:()=>xr,floatSafeRemainder:()=>Zd,getElementAtPath:()=>Kz,getEnumValues:()=>zs,getLengthableOrigin:()=>Cs,getParsedType:()=>eO,getSizableOrigin:()=>kv,isObject:()=>ko,isPlainObject:()=>So,issue:()=>Gd,joinValues:()=>Tc,jsonStringifyReplacer:()=>Dd,merge:()=>oO,normalizeParams:()=>J,nullish:()=>As,numKeys:()=>Yz,omit:()=>nO,optionalKeys:()=>Ud,partial:()=>sO,pick:()=>rO,prefixIssues:()=>Vr,primitiveTypes:()=>wv,promiseAllObject:()=>Qz,propertyKeyTypes:()=>Fd,randomString:()=>Xz,required:()=>aO,stringifyPrimitive:()=>Ec,unwrapMessage:()=>Es});function Gz(e){return e}function Bz(e){return e}function Jz(e){}function Wz(e){throw new Error}function Hz(e){}function zs(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function Tc(e,t="|"){return e.map(r=>Ec(r)).join(t)}function Dd(e,t){return typeof t=="bigint"?t.toString():t}function Os(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function As(e){return e==null}function Ps(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zd(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}function ze(e,t,r){Object.defineProperty(e,t,{get(){{let i=r();return e[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ld(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kz(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Qz(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function Xz(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ai(e){return JSON.stringify(e)}var $c=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ko(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var qd=Os(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function So(e){if(ko(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(ko(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Yz(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var eO=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Fd=new Set(["string","number","symbol"]),wv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function jn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function er(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function J(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function tO(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function Ec(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ud(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Vd={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]},xv={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function rO(e,t){let r={},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return er(e,{...e._zod.def,shape:r,checks:[]})}function nO(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return er(e,{...e._zod.def,shape:r,checks:[]})}function iO(e,t){if(!So(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Ld(this,"shape",n),n},checks:[]};return er(e,r)}function oO(e,t){return er(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Ld(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function sO(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)i[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return er(t,{...t._zod.def,shape:i,checks:[]})}function aO(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)i[o]=new e({type:"nonoptional",innerType:n[o]});return er(t,{...t._zod.def,shape:i,checks:[]})}function Pi(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Vr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Es(e){return typeof e=="string"?e:e?.message}function xr(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=Es(e.inst?._zod.def?.error?.(e))??Es(t?.error?.(e))??Es(r.customError?.(e))??Es(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function kv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Cs(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gd(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function cO(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Md=class{constructor(...t){}};var Sv=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Dd,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zc=k("$ZodError",Sv),Rs=k("$ZodError",Sv,{Parent:Error});function Bd(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function Jd(e,t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>i({issues:a}));else if(s.code==="invalid_key")i({issues:s.issues});else if(s.code==="invalid_element")i({issues:s.issues});else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(e),n}var Wd=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new mn;if(s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>xr(u,o,Yt())));throw $c(a,i?.callee),a}return s.value},Hd=Wd(Rs),Kd=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>xr(u,o,Yt())));throw $c(a,i?.callee),a}return s.value},Qd=Kd(Rs),Xd=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new mn;return o.issues.length?{success:!1,error:new(e??zc)(o.issues.map(s=>xr(s,i,Yt())))}:{success:!0,data:o.value}},Ci=Xd(Rs),Yd=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>xr(s,i,Yt())))}:{success:!0,data:o.value}},Ri=Yd(Rs);var Tv=/^[cC][^\s-]{8,}$/,$v=/^[0-9a-z]+$/,Ev=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zv=/^[0-9a-vA-V]{20}$/,Ov=/^[A-Za-z0-9]{27}$/,Av=/^[a-zA-Z0-9_-]{21}$/,Pv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Cv=/^([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})$/,ef=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Rv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var uO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Iv(){return new RegExp(uO,"u")}var jv=/^(?:(?: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])$/,Nv=/^(([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})$/,Mv=/^((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])$/,Dv=/^(([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])$/,Zv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tf=/^[A-Za-z0-9_-]*$/,Lv=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var qv=/^\+(?:[0-9]){6,14}[0-9]$/,Fv="(?:(?:\\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])))",Uv=new RegExp(`^${Fv}$`);function Vv(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Gv(e){return new RegExp(`^${Vv(e)}$`)}function Bv(e){let t=Vv({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Fv}T(?:${n})$`)}var Jv=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Wv=/^\d+$/,Hv=/^-?\d+(?:\.\d+)?/i,Kv=/true|false/i,Qv=/null/i;var Xv=/^[^A-Z]*$/,Yv=/^[^a-z]*$/;var pt=k("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),eb={number:"number",bigint:"bigint",object:"date"},rf=k("$ZodCheckLessThan",(e,t)=>{pt.init(e,t);let r=eb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nf=k("$ZodCheckGreaterThan",(e,t)=>{pt.init(e,t);let r=eb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tb=k("$ZodCheckMultipleOf",(e,t)=>{pt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zd(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),rb=k("$ZodCheckNumberFormat",(e,t)=>{pt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Vd[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=i,a.maximum=o,r&&(a.pattern=Wv)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var nb=k("$ZodCheckMaxLength",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let s=Cs(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ib=k("$ZodCheckMinLength",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let s=Cs(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ob=k("$ZodCheckLengthEquals",(e,t)=>{var r;pt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!As(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let s=Cs(i),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Is=k("$ZodCheckStringFormat",(e,t)=>{var r,n;pt.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),sb=k("$ZodCheckRegex",(e,t)=>{Is.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ab=k("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Xv),Is.init(e,t)}),cb=k("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Yv),Is.init(e,t)}),lb=k("$ZodCheckIncludes",(e,t)=>{pt.init(e,t);let r=jn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),ub=k("$ZodCheckStartsWith",(e,t)=>{pt.init(e,t);let r=new RegExp(`^${jn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),db=k("$ZodCheckEndsWith",(e,t)=>{pt.init(e,t);let r=new RegExp(`.*${jn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var fb=k("$ZodCheckOverwrite",(e,t)=>{pt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ac=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
321
321
  `).filter(s=>s),i=Math.min(...n.map(s=>s.length-s.trimStart().length)),o=n.map(s=>s.slice(i)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...r,i.join(`
322
- `))}};var db={major:4,minor:0,patch:0};var Se=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=db;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,s,a)=>{let u=Pi(o),c;for(let l of s){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(u)continue;let d=o.issues.length,h=l._zod.check(o);if(h instanceof Promise&&a?.async===!1)throw new mn;if(c||h instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await h,o.issues.length!==d&&(u||(u=Pi(o,d)))});else{if(o.issues.length===d)continue;u||(u=Pi(o,d))}}return c?c.then(()=>o):o};e._zod.run=(o,s)=>{let a=e._zod.parse(o,s);if(a instanceof Promise){if(s.async===!1)throw new mn;return a.then(u=>i(u,n,s))}return i(a,n,s)}}e["~standard"]={validate:i=>{try{let o=Ci(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ri(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),js=k("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Vv(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Oe=k("$ZodStringFormat",(e,t)=>{Is.init(e,t),js.init(e,t)}),sf=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ov),Oe.init(e,t)}),af=k("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ef(n))}else t.pattern??(t.pattern=ef());Oe.init(e,t)}),cf=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Av),Oe.init(e,t)}),lf=k("$ZodURL",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{try{let n=r.value,i=new URL(n),o=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Mv.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),uf=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Pv()),Oe.init(e,t)}),df=k("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=zv),Oe.init(e,t)}),ff=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xv),Oe.init(e,t)}),mf=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=kv),Oe.init(e,t)}),pf=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Sv),Oe.init(e,t)}),hf=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Tv),Oe.init(e,t)}),gf=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=$v),Oe.init(e,t)}),wb=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Uv(t)),Oe.init(e,t)}),xb=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Lv),Oe.init(e,t)}),kb=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fv(t)),Oe.init(e,t)}),Sb=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ev),Oe.init(e,t)}),_f=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Cv),Oe.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),yf=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Rv),Oe.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),vf=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Iv),Oe.init(e,t)}),bf=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jv),Oe.init(e,t),e._zod.check=r=>{let[n,i]=r.value.split("/");try{if(!i)throw new Error;let o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Tb(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var wf=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Nv),Oe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Tb(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function sO(e){if(!tf.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Tb(r)}var xf=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tf),Oe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{sO(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),kf=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dv),Oe.init(e,t)});function aO(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Sf=k("$ZodJWT",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{aO(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Cc=k("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??Bv,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Tf=k("$ZodNumber",(e,t)=>{Yv.init(e,t),Cc.init(e,t)}),$f=k("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=Jv,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}});var zf=k("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=Wv,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}});var Ef=k("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),Of=k("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function fb(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}var Af=k("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=t.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(c=>fb(c,r,s))):fb(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Pc(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}function mb(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...Vr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var Rc=k("$ZodObject",(e,t)=>{Se.init(e,t);let r=Os(()=>{let d=Object.keys(t.shape);for(let m of d)if(!(t.shape[m]instanceof Se))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let h=Ud(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(h)}});Ee(e._zod,"propValues",()=>{let d=t.shape,h={};for(let m in d){let p=d[m]._zod;if(p.values){h[m]??(h[m]=new Set);for(let f of p.values)h[m].add(f)}}return h});let n=d=>{let h=new Ac(["shape","payload","ctx"]),m=r.value,p=v=>{let b=Ai(v);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};h.write("const input = payload.value;");let f=Object.create(null),g=0;for(let v of m.keys)f[v]=`key_${g++}`;h.write("const newResult = {}");for(let v of m.keys)if(m.optionalKeys.has(v)){let b=f[v];h.write(`const ${b} = ${p(v)};`);let w=Ai(v);h.write(`
322
+ `))}};var pb={major:4,minor:0,patch:0};var Se=k("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pb;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,s,a)=>{let u=Pi(o),c;for(let l of s){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(u)continue;let d=o.issues.length,h=l._zod.check(o);if(h instanceof Promise&&a?.async===!1)throw new mn;if(c||h instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await h,o.issues.length!==d&&(u||(u=Pi(o,d)))});else{if(o.issues.length===d)continue;u||(u=Pi(o,d))}}return c?c.then(()=>o):o};e._zod.run=(o,s)=>{let a=e._zod.parse(o,s);if(a instanceof Promise){if(s.async===!1)throw new mn;return a.then(u=>i(u,n,s))}return i(a,n,s)}}e["~standard"]={validate:i=>{try{let o=Ci(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ri(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),js=k("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Jv(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Oe=k("$ZodStringFormat",(e,t)=>{Is.init(e,t),js.init(e,t)}),sf=k("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Cv),Oe.init(e,t)}),af=k("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ef(n))}else t.pattern??(t.pattern=ef());Oe.init(e,t)}),cf=k("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Rv),Oe.init(e,t)}),lf=k("$ZodURL",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{try{let n=r.value,i=new URL(n),o=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Lv.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),uf=k("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Iv()),Oe.init(e,t)}),df=k("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Av),Oe.init(e,t)}),ff=k("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Tv),Oe.init(e,t)}),mf=k("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$v),Oe.init(e,t)}),pf=k("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ev),Oe.init(e,t)}),hf=k("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zv),Oe.init(e,t)}),gf=k("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ov),Oe.init(e,t)}),Sb=k("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Bv(t)),Oe.init(e,t)}),Tb=k("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Uv),Oe.init(e,t)}),$b=k("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Gv(t)),Oe.init(e,t)}),Eb=k("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Pv),Oe.init(e,t)}),_f=k("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jv),Oe.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),yf=k("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Nv),Oe.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),vf=k("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Mv),Oe.init(e,t)}),bf=k("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Dv),Oe.init(e,t),e._zod.check=r=>{let[n,i]=r.value.split("/");try{if(!i)throw new Error;let o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function zb(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var wf=k("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Zv),Oe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{zb(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function dO(e){if(!tf.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return zb(r)}var xf=k("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tf),Oe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{dO(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),kf=k("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qv),Oe.init(e,t)});function fO(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Sf=k("$ZodJWT",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{fO(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Cc=k("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??Hv,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Tf=k("$ZodNumber",(e,t)=>{rb.init(e,t),Cc.init(e,t)}),$f=k("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=Kv,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}});var Ef=k("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=Qv,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}});var zf=k("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),Of=k("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function hb(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}var Af=k("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=t.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(c=>hb(c,r,s))):hb(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Pc(e,t,r){e.issues.length&&t.issues.push(...Vr(r,e.issues)),t.value[r]=e.value}function gb(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...Vr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var Rc=k("$ZodObject",(e,t)=>{Se.init(e,t);let r=Os(()=>{let d=Object.keys(t.shape);for(let m of d)if(!(t.shape[m]instanceof Se))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let h=Ud(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(h)}});ze(e._zod,"propValues",()=>{let d=t.shape,h={};for(let m in d){let p=d[m]._zod;if(p.values){h[m]??(h[m]=new Set);for(let f of p.values)h[m].add(f)}}return h});let n=d=>{let h=new Ac(["shape","payload","ctx"]),m=r.value,p=v=>{let b=Ai(v);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};h.write("const input = payload.value;");let f=Object.create(null),g=0;for(let v of m.keys)f[v]=`key_${g++}`;h.write("const newResult = {}");for(let v of m.keys)if(m.optionalKeys.has(v)){let b=f[v];h.write(`const ${b} = ${p(v)};`);let w=Ai(v);h.write(`
323
323
  if (${b}.issues.length) {
324
324
  if (input[${w}] === undefined) {
325
325
  if (${w} in input) {
@@ -342,15 +342,15 @@ args = `+gE(e.args)+`
342
342
  if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
343
343
  ...iss,
344
344
  path: iss.path ? [${Ai(v)}, ...iss.path] : [${Ai(v)}]
345
- })));`),h.write(`newResult[${Ai(v)}] = ${b}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let y=h.compile();return(v,b)=>y(d,v,b)},i,o=ko,s=!Sc.jitless,u=s&&qd.value,c=t.catchall,l;e._zod.parse=(d,h)=>{l??(l=r.value);let m=d.value;if(!o(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;let p=[];if(s&&u&&h?.async===!1&&h.jitless!==!0)i||(i=n(t.shape)),d=i(d,h);else{d.value={};let b=l.shape;for(let w of l.keys){let S=b[w],q=S._zod.run({value:m[w],issues:[]},h),K=S._zod.optin==="optional"&&S._zod.optout==="optional";q instanceof Promise?p.push(q.then(ce=>K?mb(ce,d,w,m):Pc(ce,d,w))):K?mb(q,d,w,m):Pc(q,d,w)}}if(!c)return p.length?Promise.all(p).then(()=>d):d;let f=[],g=l.keySet,y=c._zod,v=y.def.type;for(let b of Object.keys(m)){if(g.has(b))continue;if(v==="never"){f.push(b);continue}let w=y.run({value:m[b],issues:[]},h);w instanceof Promise?p.push(w.then(S=>Pc(S,d,b))):Pc(w,d,b)}return f.length&&d.issues.push({code:"unrecognized_keys",keys:f,input:m,inst:e}),p.length?Promise.all(p).then(()=>d):d}});function pb(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>xr(o,n,Yt())))}),t}var Ic=k("$ZodUnion",(e,t)=>{Se.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Ps(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let i=!1,o=[];for(let s of t.options){let a=s._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),i=!0;else{if(a.issues.length===0)return a;o.push(a)}}return i?Promise.all(o).then(s=>pb(s,r,e,n)):pb(o,r,e,n)}}),Pf=k("$ZodDiscriminatedUnion",(e,t)=>{Ic.init(e,t);let r=e._zod.parse;Ee(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let c of u)i[a].add(c)}}return i});let n=Os(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!ko(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),i)}}),Cf=k("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>hb(r,u,c)):hb(r,o,s)}});function of(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(So(e)&&So(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=of(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=of(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function hb(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Pi(e))return e;let n=of(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var Rf=k("$ZodRecord",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!So(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let s=t.keyType._zod.values;r.value={};for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){let c=t.valueType._zod.run({value:i[u],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...Vr(u,l.issues)),r.value[u]=l.value})):(c.issues.length&&r.issues.push(...Vr(u,c.issues)),r.value[u]=c.value)}let a;for(let u in i)s.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let a=t.keyType._zod.run({value:s,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(c=>xr(c,n,Yt())),input:s,path:[s],inst:e}),r.value[a.value]=a.value;continue}let u=t.valueType._zod.run({value:i[s],issues:[]},n);u instanceof Promise?o.push(u.then(c=>{c.issues.length&&r.issues.push(...Vr(s,c.issues)),r.value[a.value]=c.value})):(u.issues.length&&r.issues.push(...Vr(s,u.issues)),r.value[a.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}});var If=k("$ZodEnum",(e,t)=>{Se.init(e,t);let r=Es(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Fd.has(typeof n)).map(n=>typeof n=="string"?jn(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),jf=k("$ZodLiteral",(e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?jn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Nf=k("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new mn;return r.value=i,r}}),Mf=k("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ps(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Df=k("$ZodNullable",(e,t)=>{Se.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ps(r.source)}|null)$`):void 0}),Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Zf=k("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>gb(o,t)):gb(i,t)}});function gb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Lf=k("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),qf=k("$ZodNonOptional",(e,t)=>{Se.init(e,t),Ee(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>_b(o,e)):_b(i,e)}});function _b(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Ff=k("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>xr(s,n,Yt()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>xr(o,n,Yt()))},input:r.value}),r.issues=[]),r)}});var Uf=k("$ZodPipe",(e,t)=>{Se.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>yb(o,t,n)):yb(i,t,n)}});function yb(e,t,r){return Pi(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Vf=k("$ZodReadonly",(e,t)=>{Se.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(vb):vb(i)}});function vb(e){return e.value=Object.freeze(e.value),e}var Gf=k("$ZodCustom",(e,t)=>{pt.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>bb(o,r,n,e));bb(i,r,n,e)}});function bb(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(Gd(i))}}var cO=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},lO=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${cO(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${zc(n.values[0])}`:`Invalid option: expected one of ${Tc(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.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":""}: ${Tc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function $b(){return{localeError:lO()}}var Ns=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function zb(){return new Ns}var Nn=zb();function Bf(e,t){return new e({type:"string",...J(t)})}function Jf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function jc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function Hf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function Qf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function Xf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function Yf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function em(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function tm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function rm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function nm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function im(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function om(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function sm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function am(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function cm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function lm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function um(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function dm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function fm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function mm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function Eb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function Ob(e,t){return new e({type:"string",format:"date",check:"string_format",...J(t)})}function Ab(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function Pb(e,t){return new e({type:"string",format:"duration",check:"string_format",...J(t)})}function pm(e,t){return new e({type:"number",checks:[],...J(t)})}function hm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function gm(e,t){return new e({type:"boolean",...J(t)})}function _m(e,t){return new e({type:"null",...J(t)})}function ym(e){return new e({type:"unknown"})}function vm(e,t){return new e({type:"never",...J(t)})}function Nc(e,t){return new rf({check:"less_than",...J(t),value:e,inclusive:!1})}function Ms(e,t){return new rf({check:"less_than",...J(t),value:e,inclusive:!0})}function Mc(e,t){return new nf({check:"greater_than",...J(t),value:e,inclusive:!1})}function Ds(e,t){return new nf({check:"greater_than",...J(t),value:e,inclusive:!0})}function Dc(e,t){return new Xv({check:"multiple_of",...J(t),value:e})}function Zc(e,t){return new eb({check:"max_length",...J(t),maximum:e})}function To(e,t){return new tb({check:"min_length",...J(t),minimum:e})}function Lc(e,t){return new rb({check:"length_equals",...J(t),length:e})}function bm(e,t){return new nb({check:"string_format",format:"regex",...J(t),pattern:e})}function wm(e){return new ib({check:"string_format",format:"lowercase",...J(e)})}function xm(e){return new ob({check:"string_format",format:"uppercase",...J(e)})}function km(e,t){return new sb({check:"string_format",format:"includes",...J(t),includes:e})}function Sm(e,t){return new ab({check:"string_format",format:"starts_with",...J(t),prefix:e})}function Tm(e,t){return new cb({check:"string_format",format:"ends_with",...J(t),suffix:e})}function Ii(e){return new lb({check:"overwrite",tx:e})}function $m(e){return Ii(t=>t.normalize(e))}function zm(){return Ii(e=>e.trim())}function Em(){return Ii(e=>e.toLowerCase())}function Om(){return Ii(e=>e.toUpperCase())}function Cb(e,t,r){return new e({type:"array",element:t,...J(r)})}function Am(e,t,r){let n=J(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Pm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...J(r)})}var qc=class{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Nn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let i=t._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s=this.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,a);let u=t._zod.toJSONSchema?.();if(u)a.schema=u;else{let d={...r,schemaPath:[...r.schemaPath,t],path:r.path},h=t._zod.parent;if(h)a.ref=h,this.process(h,d),this.seen.get(h).isParent=!0;else{let m=a.schema;switch(i.type){case"string":{let p=m;p.type="string";let{minimum:f,maximum:g,format:y,patterns:v,contentEncoding:b}=t._zod.bag;if(typeof f=="number"&&(p.minLength=f),typeof g=="number"&&(p.maxLength=g),y&&(p.format=o[y]??y,p.format===""&&delete p.format),b&&(p.contentEncoding=b),v&&v.size>0){let w=[...v];w.length===1?p.pattern=w[0].source:w.length>1&&(a.schema.allOf=[...w.map(S=>({...this.target==="draft-7"?{type:"string"}:{},pattern:S.source}))])}break}case"number":{let p=m,{minimum:f,maximum:g,format:y,multipleOf:v,exclusiveMaximum:b,exclusiveMinimum:w}=t._zod.bag;typeof y=="string"&&y.includes("int")?p.type="integer":p.type="number",typeof w=="number"&&(p.exclusiveMinimum=w),typeof f=="number"&&(p.minimum=f,typeof w=="number"&&(w>=f?delete p.minimum:delete p.exclusiveMinimum)),typeof b=="number"&&(p.exclusiveMaximum=b),typeof g=="number"&&(p.maximum=g,typeof b=="number"&&(b<=g?delete p.maximum:delete p.exclusiveMaximum)),typeof v=="number"&&(p.multipleOf=v);break}case"boolean":{let p=m;p.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let p=m,{minimum:f,maximum:g}=t._zod.bag;typeof f=="number"&&(p.minItems=f),typeof g=="number"&&(p.maxItems=g),p.type="array",p.items=this.process(i.element,{...d,path:[...d.path,"items"]});break}case"object":{let p=m;p.type="object",p.properties={};let f=i.shape;for(let v in f)p.properties[v]=this.process(f[v],{...d,path:[...d.path,"properties",v]});let g=new Set(Object.keys(f)),y=new Set([...g].filter(v=>{let b=i.shape[v]._zod;return this.io==="input"?b.optin===void 0:b.optout===void 0}));y.size>0&&(p.required=Array.from(y)),i.catchall?._zod.def.type==="never"?p.additionalProperties=!1:i.catchall?i.catchall&&(p.additionalProperties=this.process(i.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=m;p.anyOf=i.options.map((f,g)=>this.process(f,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let p=m,f=this.process(i.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(i.right,{...d,path:[...d.path,"allOf",1]}),y=b=>"allOf"in b&&Object.keys(b).length===1,v=[...y(f)?f.allOf:[f],...y(g)?g.allOf:[g]];p.allOf=v;break}case"tuple":{let p=m;p.type="array";let f=i.items.map((v,b)=>this.process(v,{...d,path:[...d.path,"prefixItems",b]}));if(this.target==="draft-2020-12"?p.prefixItems=f:p.items=f,i.rest){let v=this.process(i.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=v:p.additionalItems=v}i.rest&&(p.items=this.process(i.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=t._zod.bag;typeof g=="number"&&(p.minItems=g),typeof y=="number"&&(p.maxItems=y);break}case"record":{let p=m;p.type="object",p.propertyNames=this.process(i.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(i.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 p=m,f=Es(i.entries);f.every(g=>typeof g=="number")&&(p.type="number"),f.every(g=>typeof g=="string")&&(p.type="string"),p.enum=f;break}case"literal":{let p=m,f=[];for(let g of i.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");f.push(Number(g))}else f.push(g);if(f.length!==0)if(f.length===1){let g=f[0];p.type=g===null?"null":typeof g,p.const=g}else f.every(g=>typeof g=="number")&&(p.type="number"),f.every(g=>typeof g=="string")&&(p.type="string"),f.every(g=>typeof g=="boolean")&&(p.type="string"),f.every(g=>g===null)&&(p.type="null"),p.enum=f;break}case"file":{let p=m,f={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:v}=t._zod.bag;g!==void 0&&(f.minLength=g),y!==void 0&&(f.maxLength=y),v?v.length===1?(f.contentMediaType=v[0],Object.assign(p,f)):p.anyOf=v.map(b=>({...f,contentMediaType:b})):Object.assign(p,f);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let p=this.process(i.innerType,d);m.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"success":{let p=m;p.type="boolean";break}case"default":{this.process(i.innerType,d),a.ref=i.innerType,m.default=JSON.parse(JSON.stringify(i.defaultValue));break}case"prefault":{this.process(i.innerType,d),a.ref=i.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(i.defaultValue)));break}case"catch":{this.process(i.innerType,d),a.ref=i.innerType;let p;try{p=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let p=m,f=t._zod.pattern;if(!f)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=f.source;break}case"pipe":{let p=this.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;this.process(p,d),a.ref=p;break}case"readonly":{this.process(i.innerType,d),a.ref=i.innerType,m.readOnly=!0;break}case"promise":{this.process(i.innerType,d),a.ref=i.innerType;break}case"optional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"lazy":{let p=t._zod.innerType;this.process(p,d),a.ref=p;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let c=this.metadataRegistry.get(t);return c&&Object.assign(a.schema,c),this.io==="input"&&rt(t)&&(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(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},i=this.seen.get(t);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let f=n.external.registry.get(l[0])?.id,g=n.external.uri??(v=>v);if(f)return{ref:g(f)};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]===i)return{ref:"#"};let m=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:m+p}},s=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:h,defId:m}=o(l);d.def={...d.schema},m&&(d.defId=m);let p=d.schema;for(let f in p)delete p[f];p.$ref=h};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>
345
+ })));`),h.write(`newResult[${Ai(v)}] = ${b}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let y=h.compile();return(v,b)=>y(d,v,b)},i,o=ko,s=!Sc.jitless,u=s&&qd.value,c=t.catchall,l;e._zod.parse=(d,h)=>{l??(l=r.value);let m=d.value;if(!o(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;let p=[];if(s&&u&&h?.async===!1&&h.jitless!==!0)i||(i=n(t.shape)),d=i(d,h);else{d.value={};let b=l.shape;for(let w of l.keys){let S=b[w],q=S._zod.run({value:m[w],issues:[]},h),K=S._zod.optin==="optional"&&S._zod.optout==="optional";q instanceof Promise?p.push(q.then(ce=>K?gb(ce,d,w,m):Pc(ce,d,w))):K?gb(q,d,w,m):Pc(q,d,w)}}if(!c)return p.length?Promise.all(p).then(()=>d):d;let f=[],g=l.keySet,y=c._zod,v=y.def.type;for(let b of Object.keys(m)){if(g.has(b))continue;if(v==="never"){f.push(b);continue}let w=y.run({value:m[b],issues:[]},h);w instanceof Promise?p.push(w.then(S=>Pc(S,d,b))):Pc(w,d,b)}return f.length&&d.issues.push({code:"unrecognized_keys",keys:f,input:m,inst:e}),p.length?Promise.all(p).then(()=>d):d}});function _b(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>xr(o,n,Yt())))}),t}var Ic=k("$ZodUnion",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Ps(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let i=!1,o=[];for(let s of t.options){let a=s._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),i=!0;else{if(a.issues.length===0)return a;o.push(a)}}return i?Promise.all(o).then(s=>_b(s,r,e,n)):_b(o,r,e,n)}}),Pf=k("$ZodDiscriminatedUnion",(e,t)=>{Ic.init(e,t);let r=e._zod.parse;ze(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let c of u)i[a].add(c)}}return i});let n=Os(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!ko(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),i)}}),Cf=k("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>yb(r,u,c)):yb(r,o,s)}});function of(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(So(e)&&So(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=of(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=of(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function yb(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Pi(e))return e;let n=of(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var Rf=k("$ZodRecord",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!So(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let s=t.keyType._zod.values;r.value={};for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){let c=t.valueType._zod.run({value:i[u],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...Vr(u,l.issues)),r.value[u]=l.value})):(c.issues.length&&r.issues.push(...Vr(u,c.issues)),r.value[u]=c.value)}let a;for(let u in i)s.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let a=t.keyType._zod.run({value:s,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(c=>xr(c,n,Yt())),input:s,path:[s],inst:e}),r.value[a.value]=a.value;continue}let u=t.valueType._zod.run({value:i[s],issues:[]},n);u instanceof Promise?o.push(u.then(c=>{c.issues.length&&r.issues.push(...Vr(s,c.issues)),r.value[a.value]=c.value})):(u.issues.length&&r.issues.push(...Vr(s,u.issues)),r.value[a.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}});var If=k("$ZodEnum",(e,t)=>{Se.init(e,t);let r=zs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Fd.has(typeof n)).map(n=>typeof n=="string"?jn(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),jf=k("$ZodLiteral",(e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?jn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Nf=k("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new mn;return r.value=i,r}}),Mf=k("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ps(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Df=k("$ZodNullable",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ps(r.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Zf=k("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>vb(o,t)):vb(i,t)}});function vb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Lf=k("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),qf=k("$ZodNonOptional",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>bb(o,e)):bb(i,e)}});function bb(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Ff=k("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>xr(s,n,Yt()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>xr(o,n,Yt()))},input:r.value}),r.issues=[]),r)}});var Uf=k("$ZodPipe",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>wb(o,t,n)):wb(i,t,n)}});function wb(e,t,r){return Pi(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Vf=k("$ZodReadonly",(e,t)=>{Se.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(xb):xb(i)}});function xb(e){return e.value=Object.freeze(e.value),e}var Gf=k("$ZodCustom",(e,t)=>{pt.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>kb(o,r,n,e));kb(i,r,n,e)}});function kb(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(Gd(i))}}var mO=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},pO=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${mO(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Ec(n.values[0])}`:`Invalid option: expected one of ${Tc(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.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":""}: ${Tc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Ob(){return{localeError:pO()}}var Ns=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Ab(){return new Ns}var Nn=Ab();function Bf(e,t){return new e({type:"string",...J(t)})}function Jf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function jc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function Hf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function Qf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function Xf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function Yf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function em(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function tm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function rm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function nm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function im(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function om(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function sm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function am(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function cm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function lm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function um(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function dm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function fm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function mm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function Pb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function Cb(e,t){return new e({type:"string",format:"date",check:"string_format",...J(t)})}function Rb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function Ib(e,t){return new e({type:"string",format:"duration",check:"string_format",...J(t)})}function pm(e,t){return new e({type:"number",checks:[],...J(t)})}function hm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function gm(e,t){return new e({type:"boolean",...J(t)})}function _m(e,t){return new e({type:"null",...J(t)})}function ym(e){return new e({type:"unknown"})}function vm(e,t){return new e({type:"never",...J(t)})}function Nc(e,t){return new rf({check:"less_than",...J(t),value:e,inclusive:!1})}function Ms(e,t){return new rf({check:"less_than",...J(t),value:e,inclusive:!0})}function Mc(e,t){return new nf({check:"greater_than",...J(t),value:e,inclusive:!1})}function Ds(e,t){return new nf({check:"greater_than",...J(t),value:e,inclusive:!0})}function Dc(e,t){return new tb({check:"multiple_of",...J(t),value:e})}function Zc(e,t){return new nb({check:"max_length",...J(t),maximum:e})}function To(e,t){return new ib({check:"min_length",...J(t),minimum:e})}function Lc(e,t){return new ob({check:"length_equals",...J(t),length:e})}function bm(e,t){return new sb({check:"string_format",format:"regex",...J(t),pattern:e})}function wm(e){return new ab({check:"string_format",format:"lowercase",...J(e)})}function xm(e){return new cb({check:"string_format",format:"uppercase",...J(e)})}function km(e,t){return new lb({check:"string_format",format:"includes",...J(t),includes:e})}function Sm(e,t){return new ub({check:"string_format",format:"starts_with",...J(t),prefix:e})}function Tm(e,t){return new db({check:"string_format",format:"ends_with",...J(t),suffix:e})}function Ii(e){return new fb({check:"overwrite",tx:e})}function $m(e){return Ii(t=>t.normalize(e))}function Em(){return Ii(e=>e.trim())}function zm(){return Ii(e=>e.toLowerCase())}function Om(){return Ii(e=>e.toUpperCase())}function jb(e,t,r){return new e({type:"array",element:t,...J(r)})}function Am(e,t,r){let n=J(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Pm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...J(r)})}var qc=class{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Nn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let i=t._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s=this.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,a);let u=t._zod.toJSONSchema?.();if(u)a.schema=u;else{let d={...r,schemaPath:[...r.schemaPath,t],path:r.path},h=t._zod.parent;if(h)a.ref=h,this.process(h,d),this.seen.get(h).isParent=!0;else{let m=a.schema;switch(i.type){case"string":{let p=m;p.type="string";let{minimum:f,maximum:g,format:y,patterns:v,contentEncoding:b}=t._zod.bag;if(typeof f=="number"&&(p.minLength=f),typeof g=="number"&&(p.maxLength=g),y&&(p.format=o[y]??y,p.format===""&&delete p.format),b&&(p.contentEncoding=b),v&&v.size>0){let w=[...v];w.length===1?p.pattern=w[0].source:w.length>1&&(a.schema.allOf=[...w.map(S=>({...this.target==="draft-7"?{type:"string"}:{},pattern:S.source}))])}break}case"number":{let p=m,{minimum:f,maximum:g,format:y,multipleOf:v,exclusiveMaximum:b,exclusiveMinimum:w}=t._zod.bag;typeof y=="string"&&y.includes("int")?p.type="integer":p.type="number",typeof w=="number"&&(p.exclusiveMinimum=w),typeof f=="number"&&(p.minimum=f,typeof w=="number"&&(w>=f?delete p.minimum:delete p.exclusiveMinimum)),typeof b=="number"&&(p.exclusiveMaximum=b),typeof g=="number"&&(p.maximum=g,typeof b=="number"&&(b<=g?delete p.maximum:delete p.exclusiveMaximum)),typeof v=="number"&&(p.multipleOf=v);break}case"boolean":{let p=m;p.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let p=m,{minimum:f,maximum:g}=t._zod.bag;typeof f=="number"&&(p.minItems=f),typeof g=="number"&&(p.maxItems=g),p.type="array",p.items=this.process(i.element,{...d,path:[...d.path,"items"]});break}case"object":{let p=m;p.type="object",p.properties={};let f=i.shape;for(let v in f)p.properties[v]=this.process(f[v],{...d,path:[...d.path,"properties",v]});let g=new Set(Object.keys(f)),y=new Set([...g].filter(v=>{let b=i.shape[v]._zod;return this.io==="input"?b.optin===void 0:b.optout===void 0}));y.size>0&&(p.required=Array.from(y)),i.catchall?._zod.def.type==="never"?p.additionalProperties=!1:i.catchall?i.catchall&&(p.additionalProperties=this.process(i.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=m;p.anyOf=i.options.map((f,g)=>this.process(f,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let p=m,f=this.process(i.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(i.right,{...d,path:[...d.path,"allOf",1]}),y=b=>"allOf"in b&&Object.keys(b).length===1,v=[...y(f)?f.allOf:[f],...y(g)?g.allOf:[g]];p.allOf=v;break}case"tuple":{let p=m;p.type="array";let f=i.items.map((v,b)=>this.process(v,{...d,path:[...d.path,"prefixItems",b]}));if(this.target==="draft-2020-12"?p.prefixItems=f:p.items=f,i.rest){let v=this.process(i.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=v:p.additionalItems=v}i.rest&&(p.items=this.process(i.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=t._zod.bag;typeof g=="number"&&(p.minItems=g),typeof y=="number"&&(p.maxItems=y);break}case"record":{let p=m;p.type="object",p.propertyNames=this.process(i.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(i.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 p=m,f=zs(i.entries);f.every(g=>typeof g=="number")&&(p.type="number"),f.every(g=>typeof g=="string")&&(p.type="string"),p.enum=f;break}case"literal":{let p=m,f=[];for(let g of i.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");f.push(Number(g))}else f.push(g);if(f.length!==0)if(f.length===1){let g=f[0];p.type=g===null?"null":typeof g,p.const=g}else f.every(g=>typeof g=="number")&&(p.type="number"),f.every(g=>typeof g=="string")&&(p.type="string"),f.every(g=>typeof g=="boolean")&&(p.type="string"),f.every(g=>g===null)&&(p.type="null"),p.enum=f;break}case"file":{let p=m,f={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:v}=t._zod.bag;g!==void 0&&(f.minLength=g),y!==void 0&&(f.maxLength=y),v?v.length===1?(f.contentMediaType=v[0],Object.assign(p,f)):p.anyOf=v.map(b=>({...f,contentMediaType:b})):Object.assign(p,f);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let p=this.process(i.innerType,d);m.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"success":{let p=m;p.type="boolean";break}case"default":{this.process(i.innerType,d),a.ref=i.innerType,m.default=JSON.parse(JSON.stringify(i.defaultValue));break}case"prefault":{this.process(i.innerType,d),a.ref=i.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(i.defaultValue)));break}case"catch":{this.process(i.innerType,d),a.ref=i.innerType;let p;try{p=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let p=m,f=t._zod.pattern;if(!f)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=f.source;break}case"pipe":{let p=this.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;this.process(p,d),a.ref=p;break}case"readonly":{this.process(i.innerType,d),a.ref=i.innerType,m.readOnly=!0;break}case"promise":{this.process(i.innerType,d),a.ref=i.innerType;break}case"optional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"lazy":{let p=t._zod.innerType;this.process(p,d),a.ref=p;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let c=this.metadataRegistry.get(t);return c&&Object.assign(a.schema,c),this.io==="input"&&rt(t)&&(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(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},i=this.seen.get(t);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let f=n.external.registry.get(l[0])?.id,g=n.external.uri??(v=>v);if(f)return{ref:g(f)};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]===i)return{ref:"#"};let m=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:m+p}},s=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:h,defId:m}=o(l);d.def={...d.schema},m&&(d.defId=m);let p=d.schema;for(let f in p)delete p[f];p.$ref=h};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>
346
346
 
347
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(t===l[0]){s(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(t!==l[0]&&m){s(l);continue}}if(this.metadataRegistry.get(l[0])?.id){s(l);continue}if(d.cycle){s(l);continue}if(d.count>1&&n.reused==="ref"){s(l);continue}}let a=(l,d)=>{let h=this.seen.get(l),m=h.def??h.schema,p={...m};if(h.ref===null)return;let f=h.ref;if(h.ref=null,f){a(f,d);let g=this.seen.get(f).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,p))}h.isParent||this.override({zodSchema:l,jsonSchema:m,path:h.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let u={};if(this.target==="draft-2020-12"?u.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?u.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");u.$id=n.external.uri(l)}Object.assign(u,i.def);let c=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(c[d.defId]=d.def)}n.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?u.$defs=c:u.definitions=c);try{return JSON.parse(JSON.stringify(u))}catch{throw new Error("Error converting schema to JSON.")}}};function Cm(e,t){if(e instanceof Ns){let n=new qc(t),i={};for(let a of e._idmap.entries()){let[u,c]=a;n.process(c)}let o={},s={registry:e,uri:t?.uri,defs:i};for(let a of e._idmap.entries()){let[u,c]=a;o[u]=n.emit(c,{...t,external:s})}if(Object.keys(i).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:i}}return{schemas:o}}let r=new qc(t);return r.process(e),r.emit(e,t)}function rt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;switch(i.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 rt(i.element,r);case"object":{for(let o in i.shape)if(rt(i.shape[o],r))return!0;return!1}case"union":{for(let o of i.options)if(rt(o,r))return!0;return!1}case"intersection":return rt(i.left,r)||rt(i.right,r);case"tuple":{for(let o of i.items)if(rt(o,r))return!0;return!!(i.rest&&rt(i.rest,r))}case"record":return rt(i.keyType,r)||rt(i.valueType,r);case"map":return rt(i.keyType,r)||rt(i.valueType,r);case"set":return rt(i.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return rt(i.innerType,r);case"lazy":return rt(i.getter(),r);case"default":return rt(i.innerType,r);case"prefault":return rt(i.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return rt(i.in,r)||rt(i.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${i.type}`)}var Zs={};cu(Zs,{ZodISODate:()=>jb,ZodISODateTime:()=>Ib,ZodISODuration:()=>Mb,ZodISOTime:()=>Nb,date:()=>Im,datetime:()=>Rm,duration:()=>Nm,time:()=>jm});var Ib=k("ZodISODateTime",(e,t)=>{wb.init(e,t),Me.init(e,t)});function Rm(e){return Eb(Ib,e)}var jb=k("ZodISODate",(e,t)=>{xb.init(e,t),Me.init(e,t)});function Im(e){return Ob(jb,e)}var Nb=k("ZodISOTime",(e,t)=>{kb.init(e,t),Me.init(e,t)});function jm(e){return Ab(Nb,e)}var Mb=k("ZodISODuration",(e,t)=>{Sb.init(e,t),Me.init(e,t)});function Nm(e){return Pb(Mb,e)}var Db=(e,t)=>{Ec.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Jd(e,r)},flatten:{value:r=>Bd(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},JL=k("ZodError",Db),Ls=k("ZodError",Db,{Parent:Error});var Zb=Wd(Ls),Lb=Kd(Ls),qb=Xd(Ls),Fb=Yd(Ls);var Je=k("ZodType",(e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>er(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Zb(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>qb(e,r,n),e.parseAsync=async(r,n)=>Lb(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Fb(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(DA(r,n)),e.superRefine=r=>e.check(ZA(r)),e.overwrite=r=>e.check(Ii(r)),e.optional=()=>Ze(e),e.nullable=()=>Gb(e),e.nullish=()=>Ze(Gb(e)),e.nonoptional=r=>PA(e,r),e.array=()=>le(e),e.or=r=>Ce([e,r]),e.and=r=>Uc(e,r),e.transform=r=>Dm(e,Qb(r)),e.default=r=>EA(e,r),e.prefault=r=>AA(e,r),e.catch=r=>RA(e,r),e.pipe=r=>Dm(e,r),e.readonly=()=>NA(e),e.describe=r=>{let n=e.clone();return Nn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Nn.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Nn.get(e);let n=e.clone();return Nn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Bb=k("_ZodString",(e,t)=>{js.init(e,t),Je.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(bm(...n)),e.includes=(...n)=>e.check(km(...n)),e.startsWith=(...n)=>e.check(Sm(...n)),e.endsWith=(...n)=>e.check(Tm(...n)),e.min=(...n)=>e.check(To(...n)),e.max=(...n)=>e.check(Zc(...n)),e.length=(...n)=>e.check(Lc(...n)),e.nonempty=(...n)=>e.check(To(1,...n)),e.lowercase=n=>e.check(wm(n)),e.uppercase=n=>e.check(xm(n)),e.trim=()=>e.check(zm()),e.normalize=(...n)=>e.check($m(...n)),e.toLowerCase=()=>e.check(Em()),e.toUpperCase=()=>e.check(Om())}),KO=k("ZodString",(e,t)=>{js.init(e,t),Bb.init(e,t),e.email=r=>e.check(Jf(QO,r)),e.url=r=>e.check(Xf(XO,r)),e.jwt=r=>e.check(mm(mA,r)),e.emoji=r=>e.check(Yf(YO,r)),e.guid=r=>e.check(jc(Ub,r)),e.uuid=r=>e.check(Wf(Fc,r)),e.uuidv4=r=>e.check(Hf(Fc,r)),e.uuidv6=r=>e.check(Kf(Fc,r)),e.uuidv7=r=>e.check(Qf(Fc,r)),e.nanoid=r=>e.check(em(eA,r)),e.guid=r=>e.check(jc(Ub,r)),e.cuid=r=>e.check(tm(tA,r)),e.cuid2=r=>e.check(rm(rA,r)),e.ulid=r=>e.check(nm(nA,r)),e.base64=r=>e.check(um(uA,r)),e.base64url=r=>e.check(dm(dA,r)),e.xid=r=>e.check(im(iA,r)),e.ksuid=r=>e.check(om(oA,r)),e.ipv4=r=>e.check(sm(sA,r)),e.ipv6=r=>e.check(am(aA,r)),e.cidrv4=r=>e.check(cm(cA,r)),e.cidrv6=r=>e.check(lm(lA,r)),e.e164=r=>e.check(fm(fA,r)),e.datetime=r=>e.check(Rm(r)),e.date=r=>e.check(Im(r)),e.time=r=>e.check(jm(r)),e.duration=r=>e.check(Nm(r))});function x(e){return Bf(KO,e)}var Me=k("ZodStringFormat",(e,t)=>{Oe.init(e,t),Bb.init(e,t)}),QO=k("ZodEmail",(e,t)=>{cf.init(e,t),Me.init(e,t)});var Ub=k("ZodGUID",(e,t)=>{sf.init(e,t),Me.init(e,t)});var Fc=k("ZodUUID",(e,t)=>{af.init(e,t),Me.init(e,t)});var XO=k("ZodURL",(e,t)=>{lf.init(e,t),Me.init(e,t)});var YO=k("ZodEmoji",(e,t)=>{uf.init(e,t),Me.init(e,t)});var eA=k("ZodNanoID",(e,t)=>{df.init(e,t),Me.init(e,t)});var tA=k("ZodCUID",(e,t)=>{ff.init(e,t),Me.init(e,t)});var rA=k("ZodCUID2",(e,t)=>{mf.init(e,t),Me.init(e,t)});var nA=k("ZodULID",(e,t)=>{pf.init(e,t),Me.init(e,t)});var iA=k("ZodXID",(e,t)=>{hf.init(e,t),Me.init(e,t)});var oA=k("ZodKSUID",(e,t)=>{gf.init(e,t),Me.init(e,t)});var sA=k("ZodIPv4",(e,t)=>{_f.init(e,t),Me.init(e,t)});var aA=k("ZodIPv6",(e,t)=>{yf.init(e,t),Me.init(e,t)});var cA=k("ZodCIDRv4",(e,t)=>{vf.init(e,t),Me.init(e,t)});var lA=k("ZodCIDRv6",(e,t)=>{bf.init(e,t),Me.init(e,t)});var uA=k("ZodBase64",(e,t)=>{wf.init(e,t),Me.init(e,t)});var dA=k("ZodBase64URL",(e,t)=>{xf.init(e,t),Me.init(e,t)});var fA=k("ZodE164",(e,t)=>{kf.init(e,t),Me.init(e,t)});var mA=k("ZodJWT",(e,t)=>{Sf.init(e,t),Me.init(e,t)});var Jb=k("ZodNumber",(e,t)=>{Cc.init(e,t),Je.init(e,t),e.gt=(n,i)=>e.check(Mc(n,i)),e.gte=(n,i)=>e.check(Ds(n,i)),e.min=(n,i)=>e.check(Ds(n,i)),e.lt=(n,i)=>e.check(Nc(n,i)),e.lte=(n,i)=>e.check(Ms(n,i)),e.max=(n,i)=>e.check(Ms(n,i)),e.int=n=>e.check(Vb(n)),e.safe=n=>e.check(Vb(n)),e.positive=n=>e.check(Mc(0,n)),e.nonnegative=n=>e.check(Ds(0,n)),e.negative=n=>e.check(Nc(0,n)),e.nonpositive=n=>e.check(Ms(0,n)),e.multipleOf=(n,i)=>e.check(Dc(n,i)),e.step=(n,i)=>e.check(Dc(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function we(e){return pm(Jb,e)}var pA=k("ZodNumberFormat",(e,t)=>{Tf.init(e,t),Jb.init(e,t)});function Vb(e){return hm(pA,e)}var hA=k("ZodBoolean",(e,t)=>{$f.init(e,t),Je.init(e,t)});function ct(e){return gm(hA,e)}var gA=k("ZodNull",(e,t)=>{zf.init(e,t),Je.init(e,t)});function Wb(e){return _m(gA,e)}var _A=k("ZodUnknown",(e,t)=>{Ef.init(e,t),Je.init(e,t)});function De(){return ym(_A)}var yA=k("ZodNever",(e,t)=>{Of.init(e,t),Je.init(e,t)});function vA(e){return vm(yA,e)}var bA=k("ZodArray",(e,t)=>{Af.init(e,t),Je.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(To(r,n)),e.nonempty=r=>e.check(To(1,r)),e.max=(r,n)=>e.check(Zc(r,n)),e.length=(r,n)=>e.check(Lc(r,n)),e.unwrap=()=>e.element});function le(e,t){return Cb(bA,e,t)}var Hb=k("ZodObject",(e,t)=>{Rc.init(e,t),Je.init(e,t),ae.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ft(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:De()}),e.loose=()=>e.clone({...e._zod.def,catchall:De()}),e.strict=()=>e.clone({...e._zod.def,catchall:vA()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ae.extend(e,r),e.merge=r=>ae.merge(e,r),e.pick=r=>ae.pick(e,r),e.omit=r=>ae.omit(e,r),e.partial=(...r)=>ae.partial(Xb,e,r[0]),e.required=(...r)=>ae.required(Yb,e,r[0])});function P(e,t){let r={type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},...ae.normalizeParams(t)};return new Hb(r)}function Rt(e,t){return new Hb({type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},catchall:De(),...ae.normalizeParams(t)})}var Kb=k("ZodUnion",(e,t)=>{Ic.init(e,t),Je.init(e,t),e.options=t.options});function Ce(e,t){return new Kb({type:"union",options:e,...ae.normalizeParams(t)})}var wA=k("ZodDiscriminatedUnion",(e,t)=>{Kb.init(e,t),Pf.init(e,t)});function Zm(e,t,r){return new wA({type:"union",options:t,discriminator:e,...ae.normalizeParams(r)})}var xA=k("ZodIntersection",(e,t)=>{Cf.init(e,t),Je.init(e,t)});function Uc(e,t){return new xA({type:"intersection",left:e,right:t})}var kA=k("ZodRecord",(e,t)=>{Rf.init(e,t),Je.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ae(e,t,r){return new kA({type:"record",keyType:e,valueType:t,...ae.normalizeParams(r)})}var Mm=k("ZodEnum",(e,t)=>{If.init(e,t),Je.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Mm({...t,checks:[],...ae.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Mm({...t,checks:[],...ae.normalizeParams(i),entries:o})}});function Ft(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Mm({type:"enum",entries:r,...ae.normalizeParams(t)})}var SA=k("ZodLiteral",(e,t)=>{jf.init(e,t),Je.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Z(e,t){return new SA({type:"literal",values:Array.isArray(e)?e:[e],...ae.normalizeParams(t)})}var TA=k("ZodTransform",(e,t)=>{Nf.init(e,t),Je.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ae.issue(o,r.value,t));else{let s=o;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=!0),r.issues.push(ae.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function Qb(e){return new TA({type:"transform",transform:e})}var Xb=k("ZodOptional",(e,t)=>{Mf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ze(e){return new Xb({type:"optional",innerType:e})}var $A=k("ZodNullable",(e,t)=>{Df.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Gb(e){return new $A({type:"nullable",innerType:e})}var zA=k("ZodDefault",(e,t)=>{Zf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function EA(e,t){return new zA({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var OA=k("ZodPrefault",(e,t)=>{Lf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function AA(e,t){return new OA({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var Yb=k("ZodNonOptional",(e,t)=>{qf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function PA(e,t){return new Yb({type:"nonoptional",innerType:e,...ae.normalizeParams(t)})}var CA=k("ZodCatch",(e,t)=>{Ff.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function RA(e,t){return new CA({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var IA=k("ZodPipe",(e,t)=>{Uf.init(e,t),Je.init(e,t),e.in=t.in,e.out=t.out});function Dm(e,t){return new IA({type:"pipe",in:e,out:t})}var jA=k("ZodReadonly",(e,t)=>{Vf.init(e,t),Je.init(e,t)});function NA(e){return new jA({type:"readonly",innerType:e})}var ew=k("ZodCustom",(e,t)=>{Gf.init(e,t),Je.init(e,t)});function MA(e){let t=new pt({check:"custom"});return t._zod.check=e,t}function tw(e,t){return Am(ew,e??(()=>!0),t)}function DA(e,t={}){return Pm(ew,e,t)}function ZA(e){let t=MA(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ae.issue(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(ae.issue(i))}},e(r.value,r)));return t}function Lm(e,t){return Dm(Qb(e),t)}Yt($b());var Fm="2025-11-25";var rw=[Fm,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Mn="io.modelcontextprotocol/related-task",Gc="2.0",nt=tw(e=>e!==null&&(typeof e=="object"||typeof e=="function")),nw=Ce([x(),we().int()]),iw=x(),aq=Rt({ttl:we().optional(),pollInterval:we().optional()}),LA=P({ttl:we().optional()}),qA=P({taskId:x()}),Um=Rt({progressToken:nw.optional(),[Mn]:qA.optional()}),tr=P({_meta:Um.optional()}),qs=tr.extend({task:LA.optional()}),ow=e=>qs.safeParse(e).success,ht=P({method:x(),params:tr.loose().optional()}),cr=P({_meta:Um.optional()}),lr=P({method:x(),params:cr.loose().optional()}),gt=Rt({_meta:Um.optional()}),Bc=Ce([x(),we().int()]),sw=P({jsonrpc:Z(Gc),id:Bc,...ht.shape}).strict(),Vm=e=>sw.safeParse(e).success,aw=P({jsonrpc:Z(Gc),...lr.shape}).strict(),cw=e=>aw.safeParse(e).success,Gm=P({jsonrpc:Z(Gc),id:Bc,result:gt}).strict(),Fs=e=>Gm.safeParse(e).success;var U;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(U||(U={}));var Bm=P({jsonrpc:Z(Gc),id:Bc.optional(),error:P({code:we().int(),message:x(),data:De().optional()})}).strict();var lw=e=>Bm.safeParse(e).success;var uw=Ce([sw,aw,Gm,Bm]),cq=Ce([Gm,Bm]),Jc=gt.strict(),FA=cr.extend({requestId:Bc.optional(),reason:x().optional()}),Wc=lr.extend({method:Z("notifications/cancelled"),params:FA}),UA=P({src:x(),mimeType:x().optional(),sizes:le(x()).optional(),theme:Ft(["light","dark"]).optional()}),Us=P({icons:le(UA).optional()}),$o=P({name:x(),title:x().optional()}),dw=$o.extend({...$o.shape,...Us.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),VA=Uc(P({applyDefaults:ct().optional()}),Ae(x(),De())),GA=Lm(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Uc(P({form:VA.optional(),url:nt.optional()}),Ae(x(),De()).optional())),BA=Rt({list:nt.optional(),cancel:nt.optional(),requests:Rt({sampling:Rt({createMessage:nt.optional()}).optional(),elicitation:Rt({create:nt.optional()}).optional()}).optional()}),JA=Rt({list:nt.optional(),cancel:nt.optional(),requests:Rt({tools:Rt({call:nt.optional()}).optional()}).optional()}),WA=P({experimental:Ae(x(),nt).optional(),sampling:P({context:nt.optional(),tools:nt.optional()}).optional(),elicitation:GA.optional(),roots:P({listChanged:ct().optional()}).optional(),tasks:BA.optional(),extensions:Ae(x(),nt).optional()}),HA=tr.extend({protocolVersion:x(),capabilities:WA,clientInfo:dw}),Jm=ht.extend({method:Z("initialize"),params:HA});var KA=P({experimental:Ae(x(),nt).optional(),logging:nt.optional(),completions:nt.optional(),prompts:P({listChanged:ct().optional()}).optional(),resources:P({subscribe:ct().optional(),listChanged:ct().optional()}).optional(),tools:P({listChanged:ct().optional()}).optional(),tasks:JA.optional(),extensions:Ae(x(),nt).optional()}),QA=gt.extend({protocolVersion:x(),capabilities:KA,serverInfo:dw,instructions:x().optional()}),Wm=lr.extend({method:Z("notifications/initialized"),params:cr.optional()});var Hc=ht.extend({method:Z("ping"),params:tr.optional()}),XA=P({progress:we(),total:Ze(we()),message:Ze(x())}),YA=P({...cr.shape,...XA.shape,progressToken:nw}),Kc=lr.extend({method:Z("notifications/progress"),params:YA}),eP=tr.extend({cursor:iw.optional()}),Vs=ht.extend({params:eP.optional()}),Gs=gt.extend({nextCursor:iw.optional()}),tP=Ft(["working","input_required","completed","failed","cancelled"]),Bs=P({taskId:x(),status:tP,ttl:Ce([we(),Wb()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Ze(we()),statusMessage:Ze(x())}),zo=gt.extend({task:Bs}),rP=cr.merge(Bs),Js=lr.extend({method:Z("notifications/tasks/status"),params:rP}),Qc=ht.extend({method:Z("tasks/get"),params:tr.extend({taskId:x()})}),Xc=gt.merge(Bs),Yc=ht.extend({method:Z("tasks/result"),params:tr.extend({taskId:x()})}),lq=gt.loose(),el=Vs.extend({method:Z("tasks/list")}),tl=Gs.extend({tasks:le(Bs)}),rl=ht.extend({method:Z("tasks/cancel"),params:tr.extend({taskId:x()})}),fw=gt.merge(Bs),mw=P({uri:x(),mimeType:Ze(x()),_meta:Ae(x(),De()).optional()}),pw=mw.extend({text:x()}),Hm=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),hw=mw.extend({blob:Hm}),Ws=Ft(["user","assistant"]),Eo=P({audience:le(Ws).optional(),priority:we().min(0).max(1).optional(),lastModified:Zs.datetime({offset:!0}).optional()}),gw=P({...$o.shape,...Us.shape,uri:x(),description:Ze(x()),mimeType:Ze(x()),size:Ze(we()),annotations:Eo.optional(),_meta:Ze(Rt({}))}),nP=P({...$o.shape,...Us.shape,uriTemplate:x(),description:Ze(x()),mimeType:Ze(x()),annotations:Eo.optional(),_meta:Ze(Rt({}))}),Oo=Vs.extend({method:Z("resources/list")}),iP=Gs.extend({resources:le(gw)}),Ao=Vs.extend({method:Z("resources/templates/list")}),oP=Gs.extend({resourceTemplates:le(nP)}),Km=tr.extend({uri:x()}),sP=Km,nl=ht.extend({method:Z("resources/read"),params:sP}),aP=gt.extend({contents:le(Ce([pw,hw]))}),cP=lr.extend({method:Z("notifications/resources/list_changed"),params:cr.optional()}),lP=Km,uP=ht.extend({method:Z("resources/subscribe"),params:lP}),dP=Km,fP=ht.extend({method:Z("resources/unsubscribe"),params:dP}),mP=cr.extend({uri:x()}),pP=lr.extend({method:Z("notifications/resources/updated"),params:mP}),hP=P({name:x(),description:Ze(x()),required:Ze(ct())}),gP=P({...$o.shape,...Us.shape,description:Ze(x()),arguments:Ze(le(hP)),_meta:Ze(Rt({}))}),il=Vs.extend({method:Z("prompts/list")}),_P=Gs.extend({prompts:le(gP)}),yP=tr.extend({name:x(),arguments:Ae(x(),x()).optional()}),ol=ht.extend({method:Z("prompts/get"),params:yP}),Qm=P({type:Z("text"),text:x(),annotations:Eo.optional(),_meta:Ae(x(),De()).optional()}),Xm=P({type:Z("image"),data:Hm,mimeType:x(),annotations:Eo.optional(),_meta:Ae(x(),De()).optional()}),Ym=P({type:Z("audio"),data:Hm,mimeType:x(),annotations:Eo.optional(),_meta:Ae(x(),De()).optional()}),vP=P({type:Z("tool_use"),name:x(),id:x(),input:Ae(x(),De()),_meta:Ae(x(),De()).optional()}),bP=P({type:Z("resource"),resource:Ce([pw,hw]),annotations:Eo.optional(),_meta:Ae(x(),De()).optional()}),wP=gw.extend({type:Z("resource_link")}),ep=Ce([Qm,Xm,Ym,wP,bP]),xP=P({role:Ws,content:ep}),kP=gt.extend({description:x().optional(),messages:le(xP)}),SP=lr.extend({method:Z("notifications/prompts/list_changed"),params:cr.optional()}),TP=P({title:x().optional(),readOnlyHint:ct().optional(),destructiveHint:ct().optional(),idempotentHint:ct().optional(),openWorldHint:ct().optional()}),$P=P({taskSupport:Ft(["required","optional","forbidden"]).optional()}),_w=P({...$o.shape,...Us.shape,description:x().optional(),inputSchema:P({type:Z("object"),properties:Ae(x(),nt).optional(),required:le(x()).optional()}).catchall(De()),outputSchema:P({type:Z("object"),properties:Ae(x(),nt).optional(),required:le(x()).optional()}).catchall(De()).optional(),annotations:TP.optional(),execution:$P.optional(),_meta:Ae(x(),De()).optional()}),sl=Vs.extend({method:Z("tools/list")}),zP=Gs.extend({tools:le(_w)}),al=gt.extend({content:le(ep).default([]),structuredContent:Ae(x(),De()).optional(),isError:ct().optional()}),uq=al.or(gt.extend({toolResult:De()})),EP=qs.extend({name:x(),arguments:Ae(x(),De()).optional()}),Po=ht.extend({method:Z("tools/call"),params:EP}),OP=lr.extend({method:Z("notifications/tools/list_changed"),params:cr.optional()}),dq=P({autoRefresh:ct().default(!0),debounceMs:we().int().nonnegative().default(300)}),Hs=Ft(["debug","info","notice","warning","error","critical","alert","emergency"]),AP=tr.extend({level:Hs}),tp=ht.extend({method:Z("logging/setLevel"),params:AP}),PP=cr.extend({level:Hs,logger:x().optional(),data:De()}),CP=lr.extend({method:Z("notifications/message"),params:PP}),RP=P({name:x().optional()}),IP=P({hints:le(RP).optional(),costPriority:we().min(0).max(1).optional(),speedPriority:we().min(0).max(1).optional(),intelligencePriority:we().min(0).max(1).optional()}),jP=P({mode:Ft(["auto","required","none"]).optional()}),NP=P({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:le(ep).default([]),structuredContent:P({}).loose().optional(),isError:ct().optional(),_meta:Ae(x(),De()).optional()}),MP=Zm("type",[Qm,Xm,Ym]),Vc=Zm("type",[Qm,Xm,Ym,vP,NP]),DP=P({role:Ws,content:Ce([Vc,le(Vc)]),_meta:Ae(x(),De()).optional()}),ZP=qs.extend({messages:le(DP),modelPreferences:IP.optional(),systemPrompt:x().optional(),includeContext:Ft(["none","thisServer","allServers"]).optional(),temperature:we().optional(),maxTokens:we().int(),stopSequences:le(x()).optional(),metadata:nt.optional(),tools:le(_w).optional(),toolChoice:jP.optional()}),LP=ht.extend({method:Z("sampling/createMessage"),params:ZP}),Ks=gt.extend({model:x(),stopReason:Ze(Ft(["endTurn","stopSequence","maxTokens"]).or(x())),role:Ws,content:MP}),rp=gt.extend({model:x(),stopReason:Ze(Ft(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:Ws,content:Ce([Vc,le(Vc)])}),qP=P({type:Z("boolean"),title:x().optional(),description:x().optional(),default:ct().optional()}),FP=P({type:Z("string"),title:x().optional(),description:x().optional(),minLength:we().optional(),maxLength:we().optional(),format:Ft(["email","uri","date","date-time"]).optional(),default:x().optional()}),UP=P({type:Ft(["number","integer"]),title:x().optional(),description:x().optional(),minimum:we().optional(),maximum:we().optional(),default:we().optional()}),VP=P({type:Z("string"),title:x().optional(),description:x().optional(),enum:le(x()),default:x().optional()}),GP=P({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:le(P({const:x(),title:x()})),default:x().optional()}),BP=P({type:Z("string"),title:x().optional(),description:x().optional(),enum:le(x()),enumNames:le(x()).optional(),default:x().optional()}),JP=Ce([VP,GP]),WP=P({type:Z("array"),title:x().optional(),description:x().optional(),minItems:we().optional(),maxItems:we().optional(),items:P({type:Z("string"),enum:le(x())}),default:le(x()).optional()}),HP=P({type:Z("array"),title:x().optional(),description:x().optional(),minItems:we().optional(),maxItems:we().optional(),items:P({anyOf:le(P({const:x(),title:x()}))}),default:le(x()).optional()}),KP=Ce([WP,HP]),QP=Ce([BP,JP,KP]),XP=Ce([QP,qP,FP,UP]),YP=qs.extend({mode:Z("form").optional(),message:x(),requestedSchema:P({type:Z("object"),properties:Ae(x(),XP),required:le(x()).optional()})}),eC=qs.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),tC=Ce([YP,eC]),rC=ht.extend({method:Z("elicitation/create"),params:tC}),nC=cr.extend({elicitationId:x()}),iC=lr.extend({method:Z("notifications/elicitation/complete"),params:nC}),Co=gt.extend({action:Ft(["accept","decline","cancel"]),content:Lm(e=>e===null?void 0:e,Ae(x(),Ce([x(),we(),ct(),le(x())])).optional())}),oC=P({type:Z("ref/resource"),uri:x()});var sC=P({type:Z("ref/prompt"),name:x()}),aC=tr.extend({ref:Ce([sC,oC]),argument:P({name:x(),value:x()}),context:P({arguments:Ae(x(),x()).optional()}).optional()}),cl=ht.extend({method:Z("completion/complete"),params:aC});function yw(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function vw(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var cC=gt.extend({completion:Rt({values:le(x()).max(100),total:Ze(we().int()),hasMore:Ze(ct())})}),lC=P({uri:x().startsWith("file://"),name:x().optional(),_meta:Ae(x(),De()).optional()}),uC=ht.extend({method:Z("roots/list"),params:tr.optional()}),np=gt.extend({roots:le(lC)}),dC=lr.extend({method:Z("notifications/roots/list_changed"),params:cr.optional()}),fq=Ce([Hc,Jm,cl,tp,ol,il,Oo,Ao,nl,uP,fP,Po,sl,Qc,Yc,el,rl]),mq=Ce([Wc,Kc,Wm,dC,Js]),pq=Ce([Jc,Ks,rp,Co,np,Xc,tl,zo]),hq=Ce([Hc,LP,rC,uC,Qc,Yc,el,rl]),gq=Ce([Wc,Kc,CP,pP,cP,OP,SP,Js,iC]),_q=Ce([Jc,QA,cC,kP,_P,iP,oP,aP,al,zP,Xc,tl,zo]),D=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===U.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new qm(i.elicitations,r)}return new e(t,r,n)}},qm=class extends D{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var pC=k("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Se.init(e,t),e.def=t,e.parse=(r,n)=>Hd(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Ci(e,r,n),e.parseAsync=async(r,n)=>Qd(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Ri(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>er(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e))});var hC=k("ZodMiniObject",(e,t)=>{Rc.init(e,t),pC.init(e,t),ae.defineLazy(e,"shape",()=>t.shape)});function ip(e,t){let r={type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},...ae.normalizeParams(t)};return new hC(r)}function ur(e){return!!e._zod}function Ni(e){let t=Object.values(e);if(t.length===0)return ip({});let r=t.every(ur),n=t.every(i=>!ur(i));if(r)return ip(e);if(n)return Xu(e);throw new Error("Mixed Zod versions detected in object shape.")}function Dn(e,t){return ur(e)?Ci(e,t):e.safeParse(t)}async function ll(e,t){return ur(e)?await Ri(e,t):await e.safeParseAsync(t)}function Zn(e){if(!e)return;let t;if(ur(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Ro(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(i=>typeof i=="object"&&i!==null&&(i._def!==void 0||i._zod!==void 0||typeof i.parse=="function")))return Ni(e)}}if(ur(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function ul(e){if(e&&typeof e=="object"){if("message"in e&&typeof e.message=="string")return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t=="object"&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function bw(e){return e.description}function ww(e){if(ur(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function dl(e){if(ur(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=e._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=e.value;if(n!==void 0)return n}function Ln(e){return e==="completed"||e==="failed"||e==="cancelled"}var kw=Symbol("Let zodToJsonSchema decide on which parser to use");var xw={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"},Sw=e=>typeof e=="string"?{...xw,name:e}:{...xw,...e};var Tw=e=>{let t=Sw(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function op(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ue(e,t,r,n,i){e[t]=r,op(e,t,n,i)}var fl=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function Le(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?fl(t,e.currentPath):t.join("/")}}function $w(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==z.ZodAny&&(r.items=W(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function zw(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}function Ew(){return{type:"boolean"}}function ml(e,t){return W(e.type._def,t)}var Ow=(e,t)=>W(e.innerType._def,t);function sp(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>sp(e,t,i))};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 _C(e,t)}}var _C=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":ue(r,"minimum",n.value,n.message,t);break;case"max":ue(r,"maximum",n.value,n.message,t);break}return r};function Aw(e,t){return{...W(e.innerType._def,t),default:e.defaultValue()}}function Pw(e,t){return t.effectStrategy==="input"?W(e.schema._def,t):Le(t)}function Cw(e){return{type:"string",enum:Array.from(e.values)}}var yC=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function Rw(e,t){let r=[W(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),W(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(yC(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...u}=o;s=u}else n=void 0;i.push(s)}}),i.length?{allOf:i,...n}:void 0}function Iw(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var ap,kr={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:()=>(ap===void 0&&(ap=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ap),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function pl(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Sr(r,"email",n.message,t);break;case"format:idn-email":Sr(r,"idn-email",n.message,t);break;case"pattern:zod":It(r,kr.email,n.message,t);break}break;case"url":Sr(r,"uri",n.message,t);break;case"uuid":Sr(r,"uuid",n.message,t);break;case"regex":It(r,n.regex,n.message,t);break;case"cuid":It(r,kr.cuid,n.message,t);break;case"cuid2":It(r,kr.cuid2,n.message,t);break;case"startsWith":It(r,RegExp(`^${cp(n.value,t)}`),n.message,t);break;case"endsWith":It(r,RegExp(`${cp(n.value,t)}$`),n.message,t);break;case"datetime":Sr(r,"date-time",n.message,t);break;case"date":Sr(r,"date",n.message,t);break;case"time":Sr(r,"time",n.message,t);break;case"duration":Sr(r,"duration",n.message,t);break;case"length":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{It(r,RegExp(cp(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&Sr(r,"ipv4",n.message,t),n.version!=="v4"&&Sr(r,"ipv6",n.message,t);break}case"base64url":It(r,kr.base64url,n.message,t);break;case"jwt":It(r,kr.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&It(r,kr.ipv4Cidr,n.message,t),n.version!=="v4"&&It(r,kr.ipv6Cidr,n.message,t);break}case"emoji":It(r,kr.emoji(),n.message,t);break;case"ulid":{It(r,kr.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Sr(r,"binary",n.message,t);break}case"contentEncoding:base64":{ue(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{It(r,kr.base64,n.message,t);break}}break}case"nanoid":It(r,kr.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function cp(e,t){return t.patternStrategy==="escape"?bC(e):e}var vC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function bC(e){let t="";for(let r=0;r<e.length;r++)vC.has(e[r])||(t+="\\"),t+=e[r];return t}function Sr(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ue(e,"format",t,r,n)}function It(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:jw(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ue(e,"pattern",jw(t,n),r,n)}function jw(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,s=!1,a=!1;for(let u=0;u<n.length;u++){if(o){i+=n[u],o=!1;continue}if(r.i){if(s){if(n[u].match(/[a-z]/)){a?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),a=!1):n[u+1]==="-"&&n[u+2]?.match(/[a-z]/)?(i+=n[u],a=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(r.m){if(n[u]==="^"){i+=`(^|(?<=[\r
347
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(t===l[0]){s(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(t!==l[0]&&m){s(l);continue}}if(this.metadataRegistry.get(l[0])?.id){s(l);continue}if(d.cycle){s(l);continue}if(d.count>1&&n.reused==="ref"){s(l);continue}}let a=(l,d)=>{let h=this.seen.get(l),m=h.def??h.schema,p={...m};if(h.ref===null)return;let f=h.ref;if(h.ref=null,f){a(f,d);let g=this.seen.get(f).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,p))}h.isParent||this.override({zodSchema:l,jsonSchema:m,path:h.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let u={};if(this.target==="draft-2020-12"?u.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?u.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");u.$id=n.external.uri(l)}Object.assign(u,i.def);let c=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(c[d.defId]=d.def)}n.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?u.$defs=c:u.definitions=c);try{return JSON.parse(JSON.stringify(u))}catch{throw new Error("Error converting schema to JSON.")}}};function Cm(e,t){if(e instanceof Ns){let n=new qc(t),i={};for(let a of e._idmap.entries()){let[u,c]=a;n.process(c)}let o={},s={registry:e,uri:t?.uri,defs:i};for(let a of e._idmap.entries()){let[u,c]=a;o[u]=n.emit(c,{...t,external:s})}if(Object.keys(i).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:i}}return{schemas:o}}let r=new qc(t);return r.process(e),r.emit(e,t)}function rt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;switch(i.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 rt(i.element,r);case"object":{for(let o in i.shape)if(rt(i.shape[o],r))return!0;return!1}case"union":{for(let o of i.options)if(rt(o,r))return!0;return!1}case"intersection":return rt(i.left,r)||rt(i.right,r);case"tuple":{for(let o of i.items)if(rt(o,r))return!0;return!!(i.rest&&rt(i.rest,r))}case"record":return rt(i.keyType,r)||rt(i.valueType,r);case"map":return rt(i.keyType,r)||rt(i.valueType,r);case"set":return rt(i.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return rt(i.innerType,r);case"lazy":return rt(i.getter(),r);case"default":return rt(i.innerType,r);case"prefault":return rt(i.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return rt(i.in,r)||rt(i.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${i.type}`)}var Zs={};cu(Zs,{ZodISODate:()=>Db,ZodISODateTime:()=>Mb,ZodISODuration:()=>Lb,ZodISOTime:()=>Zb,date:()=>Im,datetime:()=>Rm,duration:()=>Nm,time:()=>jm});var Mb=k("ZodISODateTime",(e,t)=>{Sb.init(e,t),Me.init(e,t)});function Rm(e){return Pb(Mb,e)}var Db=k("ZodISODate",(e,t)=>{Tb.init(e,t),Me.init(e,t)});function Im(e){return Cb(Db,e)}var Zb=k("ZodISOTime",(e,t)=>{$b.init(e,t),Me.init(e,t)});function jm(e){return Rb(Zb,e)}var Lb=k("ZodISODuration",(e,t)=>{Eb.init(e,t),Me.init(e,t)});function Nm(e){return Ib(Lb,e)}var qb=(e,t)=>{zc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Jd(e,r)},flatten:{value:r=>Bd(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},XL=k("ZodError",qb),Ls=k("ZodError",qb,{Parent:Error});var Fb=Wd(Ls),Ub=Kd(Ls),Vb=Xd(Ls),Gb=Yd(Ls);var Je=k("ZodType",(e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>er(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>Fb(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Vb(e,r,n),e.parseAsync=async(r,n)=>Ub(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Gb(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(UA(r,n)),e.superRefine=r=>e.check(VA(r)),e.overwrite=r=>e.check(Ii(r)),e.optional=()=>Ze(e),e.nullable=()=>Wb(e),e.nullish=()=>Ze(Wb(e)),e.nonoptional=r=>NA(e,r),e.array=()=>le(e),e.or=r=>Ce([e,r]),e.and=r=>Uc(e,r),e.transform=r=>Dm(e,ew(r)),e.default=r=>RA(e,r),e.prefault=r=>jA(e,r),e.catch=r=>DA(e,r),e.pipe=r=>Dm(e,r),e.readonly=()=>qA(e),e.describe=r=>{let n=e.clone();return Nn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Nn.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Nn.get(e);let n=e.clone();return Nn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Hb=k("_ZodString",(e,t)=>{js.init(e,t),Je.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(bm(...n)),e.includes=(...n)=>e.check(km(...n)),e.startsWith=(...n)=>e.check(Sm(...n)),e.endsWith=(...n)=>e.check(Tm(...n)),e.min=(...n)=>e.check(To(...n)),e.max=(...n)=>e.check(Zc(...n)),e.length=(...n)=>e.check(Lc(...n)),e.nonempty=(...n)=>e.check(To(1,...n)),e.lowercase=n=>e.check(wm(n)),e.uppercase=n=>e.check(xm(n)),e.trim=()=>e.check(Em()),e.normalize=(...n)=>e.check($m(...n)),e.toLowerCase=()=>e.check(zm()),e.toUpperCase=()=>e.check(Om())}),tA=k("ZodString",(e,t)=>{js.init(e,t),Hb.init(e,t),e.email=r=>e.check(Jf(rA,r)),e.url=r=>e.check(Xf(nA,r)),e.jwt=r=>e.check(mm(yA,r)),e.emoji=r=>e.check(Yf(iA,r)),e.guid=r=>e.check(jc(Bb,r)),e.uuid=r=>e.check(Wf(Fc,r)),e.uuidv4=r=>e.check(Hf(Fc,r)),e.uuidv6=r=>e.check(Kf(Fc,r)),e.uuidv7=r=>e.check(Qf(Fc,r)),e.nanoid=r=>e.check(em(oA,r)),e.guid=r=>e.check(jc(Bb,r)),e.cuid=r=>e.check(tm(sA,r)),e.cuid2=r=>e.check(rm(aA,r)),e.ulid=r=>e.check(nm(cA,r)),e.base64=r=>e.check(um(hA,r)),e.base64url=r=>e.check(dm(gA,r)),e.xid=r=>e.check(im(lA,r)),e.ksuid=r=>e.check(om(uA,r)),e.ipv4=r=>e.check(sm(dA,r)),e.ipv6=r=>e.check(am(fA,r)),e.cidrv4=r=>e.check(cm(mA,r)),e.cidrv6=r=>e.check(lm(pA,r)),e.e164=r=>e.check(fm(_A,r)),e.datetime=r=>e.check(Rm(r)),e.date=r=>e.check(Im(r)),e.time=r=>e.check(jm(r)),e.duration=r=>e.check(Nm(r))});function x(e){return Bf(tA,e)}var Me=k("ZodStringFormat",(e,t)=>{Oe.init(e,t),Hb.init(e,t)}),rA=k("ZodEmail",(e,t)=>{cf.init(e,t),Me.init(e,t)});var Bb=k("ZodGUID",(e,t)=>{sf.init(e,t),Me.init(e,t)});var Fc=k("ZodUUID",(e,t)=>{af.init(e,t),Me.init(e,t)});var nA=k("ZodURL",(e,t)=>{lf.init(e,t),Me.init(e,t)});var iA=k("ZodEmoji",(e,t)=>{uf.init(e,t),Me.init(e,t)});var oA=k("ZodNanoID",(e,t)=>{df.init(e,t),Me.init(e,t)});var sA=k("ZodCUID",(e,t)=>{ff.init(e,t),Me.init(e,t)});var aA=k("ZodCUID2",(e,t)=>{mf.init(e,t),Me.init(e,t)});var cA=k("ZodULID",(e,t)=>{pf.init(e,t),Me.init(e,t)});var lA=k("ZodXID",(e,t)=>{hf.init(e,t),Me.init(e,t)});var uA=k("ZodKSUID",(e,t)=>{gf.init(e,t),Me.init(e,t)});var dA=k("ZodIPv4",(e,t)=>{_f.init(e,t),Me.init(e,t)});var fA=k("ZodIPv6",(e,t)=>{yf.init(e,t),Me.init(e,t)});var mA=k("ZodCIDRv4",(e,t)=>{vf.init(e,t),Me.init(e,t)});var pA=k("ZodCIDRv6",(e,t)=>{bf.init(e,t),Me.init(e,t)});var hA=k("ZodBase64",(e,t)=>{wf.init(e,t),Me.init(e,t)});var gA=k("ZodBase64URL",(e,t)=>{xf.init(e,t),Me.init(e,t)});var _A=k("ZodE164",(e,t)=>{kf.init(e,t),Me.init(e,t)});var yA=k("ZodJWT",(e,t)=>{Sf.init(e,t),Me.init(e,t)});var Kb=k("ZodNumber",(e,t)=>{Cc.init(e,t),Je.init(e,t),e.gt=(n,i)=>e.check(Mc(n,i)),e.gte=(n,i)=>e.check(Ds(n,i)),e.min=(n,i)=>e.check(Ds(n,i)),e.lt=(n,i)=>e.check(Nc(n,i)),e.lte=(n,i)=>e.check(Ms(n,i)),e.max=(n,i)=>e.check(Ms(n,i)),e.int=n=>e.check(Jb(n)),e.safe=n=>e.check(Jb(n)),e.positive=n=>e.check(Mc(0,n)),e.nonnegative=n=>e.check(Ds(0,n)),e.negative=n=>e.check(Nc(0,n)),e.nonpositive=n=>e.check(Ms(0,n)),e.multipleOf=(n,i)=>e.check(Dc(n,i)),e.step=(n,i)=>e.check(Dc(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function we(e){return pm(Kb,e)}var vA=k("ZodNumberFormat",(e,t)=>{Tf.init(e,t),Kb.init(e,t)});function Jb(e){return hm(vA,e)}var bA=k("ZodBoolean",(e,t)=>{$f.init(e,t),Je.init(e,t)});function ct(e){return gm(bA,e)}var wA=k("ZodNull",(e,t)=>{Ef.init(e,t),Je.init(e,t)});function Qb(e){return _m(wA,e)}var xA=k("ZodUnknown",(e,t)=>{zf.init(e,t),Je.init(e,t)});function De(){return ym(xA)}var kA=k("ZodNever",(e,t)=>{Of.init(e,t),Je.init(e,t)});function SA(e){return vm(kA,e)}var TA=k("ZodArray",(e,t)=>{Af.init(e,t),Je.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(To(r,n)),e.nonempty=r=>e.check(To(1,r)),e.max=(r,n)=>e.check(Zc(r,n)),e.length=(r,n)=>e.check(Lc(r,n)),e.unwrap=()=>e.element});function le(e,t){return jb(TA,e,t)}var Xb=k("ZodObject",(e,t)=>{Rc.init(e,t),Je.init(e,t),ae.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ft(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:De()}),e.loose=()=>e.clone({...e._zod.def,catchall:De()}),e.strict=()=>e.clone({...e._zod.def,catchall:SA()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ae.extend(e,r),e.merge=r=>ae.merge(e,r),e.pick=r=>ae.pick(e,r),e.omit=r=>ae.omit(e,r),e.partial=(...r)=>ae.partial(tw,e,r[0]),e.required=(...r)=>ae.required(rw,e,r[0])});function P(e,t){let r={type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},...ae.normalizeParams(t)};return new Xb(r)}function Rt(e,t){return new Xb({type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},catchall:De(),...ae.normalizeParams(t)})}var Yb=k("ZodUnion",(e,t)=>{Ic.init(e,t),Je.init(e,t),e.options=t.options});function Ce(e,t){return new Yb({type:"union",options:e,...ae.normalizeParams(t)})}var $A=k("ZodDiscriminatedUnion",(e,t)=>{Yb.init(e,t),Pf.init(e,t)});function Zm(e,t,r){return new $A({type:"union",options:t,discriminator:e,...ae.normalizeParams(r)})}var EA=k("ZodIntersection",(e,t)=>{Cf.init(e,t),Je.init(e,t)});function Uc(e,t){return new EA({type:"intersection",left:e,right:t})}var zA=k("ZodRecord",(e,t)=>{Rf.init(e,t),Je.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ae(e,t,r){return new zA({type:"record",keyType:e,valueType:t,...ae.normalizeParams(r)})}var Mm=k("ZodEnum",(e,t)=>{If.init(e,t),Je.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Mm({...t,checks:[],...ae.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Mm({...t,checks:[],...ae.normalizeParams(i),entries:o})}});function Ft(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Mm({type:"enum",entries:r,...ae.normalizeParams(t)})}var OA=k("ZodLiteral",(e,t)=>{jf.init(e,t),Je.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Z(e,t){return new OA({type:"literal",values:Array.isArray(e)?e:[e],...ae.normalizeParams(t)})}var AA=k("ZodTransform",(e,t)=>{Nf.init(e,t),Je.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ae.issue(o,r.value,t));else{let s=o;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=!0),r.issues.push(ae.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function ew(e){return new AA({type:"transform",transform:e})}var tw=k("ZodOptional",(e,t)=>{Mf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ze(e){return new tw({type:"optional",innerType:e})}var PA=k("ZodNullable",(e,t)=>{Df.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wb(e){return new PA({type:"nullable",innerType:e})}var CA=k("ZodDefault",(e,t)=>{Zf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function RA(e,t){return new CA({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var IA=k("ZodPrefault",(e,t)=>{Lf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function jA(e,t){return new IA({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var rw=k("ZodNonOptional",(e,t)=>{qf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function NA(e,t){return new rw({type:"nonoptional",innerType:e,...ae.normalizeParams(t)})}var MA=k("ZodCatch",(e,t)=>{Ff.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function DA(e,t){return new MA({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ZA=k("ZodPipe",(e,t)=>{Uf.init(e,t),Je.init(e,t),e.in=t.in,e.out=t.out});function Dm(e,t){return new ZA({type:"pipe",in:e,out:t})}var LA=k("ZodReadonly",(e,t)=>{Vf.init(e,t),Je.init(e,t)});function qA(e){return new LA({type:"readonly",innerType:e})}var nw=k("ZodCustom",(e,t)=>{Gf.init(e,t),Je.init(e,t)});function FA(e){let t=new pt({check:"custom"});return t._zod.check=e,t}function iw(e,t){return Am(nw,e??(()=>!0),t)}function UA(e,t={}){return Pm(nw,e,t)}function VA(e){let t=FA(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ae.issue(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(ae.issue(i))}},e(r.value,r)));return t}function Lm(e,t){return Dm(ew(e),t)}Yt(Ob());var Fm="2025-11-25";var ow=[Fm,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Mn="io.modelcontextprotocol/related-task",Gc="2.0",nt=iw(e=>e!==null&&(typeof e=="object"||typeof e=="function")),sw=Ce([x(),we().int()]),aw=x(),fq=Rt({ttl:we().optional(),pollInterval:we().optional()}),GA=P({ttl:we().optional()}),BA=P({taskId:x()}),Um=Rt({progressToken:sw.optional(),[Mn]:BA.optional()}),tr=P({_meta:Um.optional()}),qs=tr.extend({task:GA.optional()}),cw=e=>qs.safeParse(e).success,ht=P({method:x(),params:tr.loose().optional()}),cr=P({_meta:Um.optional()}),lr=P({method:x(),params:cr.loose().optional()}),gt=Rt({_meta:Um.optional()}),Bc=Ce([x(),we().int()]),lw=P({jsonrpc:Z(Gc),id:Bc,...ht.shape}).strict(),Vm=e=>lw.safeParse(e).success,uw=P({jsonrpc:Z(Gc),...lr.shape}).strict(),dw=e=>uw.safeParse(e).success,Gm=P({jsonrpc:Z(Gc),id:Bc,result:gt}).strict(),Fs=e=>Gm.safeParse(e).success;var U;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(U||(U={}));var Bm=P({jsonrpc:Z(Gc),id:Bc.optional(),error:P({code:we().int(),message:x(),data:De().optional()})}).strict();var fw=e=>Bm.safeParse(e).success;var mw=Ce([lw,uw,Gm,Bm]),mq=Ce([Gm,Bm]),Jc=gt.strict(),JA=cr.extend({requestId:Bc.optional(),reason:x().optional()}),Wc=lr.extend({method:Z("notifications/cancelled"),params:JA}),WA=P({src:x(),mimeType:x().optional(),sizes:le(x()).optional(),theme:Ft(["light","dark"]).optional()}),Us=P({icons:le(WA).optional()}),$o=P({name:x(),title:x().optional()}),pw=$o.extend({...$o.shape,...Us.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),HA=Uc(P({applyDefaults:ct().optional()}),Ae(x(),De())),KA=Lm(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Uc(P({form:HA.optional(),url:nt.optional()}),Ae(x(),De()).optional())),QA=Rt({list:nt.optional(),cancel:nt.optional(),requests:Rt({sampling:Rt({createMessage:nt.optional()}).optional(),elicitation:Rt({create:nt.optional()}).optional()}).optional()}),XA=Rt({list:nt.optional(),cancel:nt.optional(),requests:Rt({tools:Rt({call:nt.optional()}).optional()}).optional()}),YA=P({experimental:Ae(x(),nt).optional(),sampling:P({context:nt.optional(),tools:nt.optional()}).optional(),elicitation:KA.optional(),roots:P({listChanged:ct().optional()}).optional(),tasks:QA.optional(),extensions:Ae(x(),nt).optional()}),eP=tr.extend({protocolVersion:x(),capabilities:YA,clientInfo:pw}),Jm=ht.extend({method:Z("initialize"),params:eP});var tP=P({experimental:Ae(x(),nt).optional(),logging:nt.optional(),completions:nt.optional(),prompts:P({listChanged:ct().optional()}).optional(),resources:P({subscribe:ct().optional(),listChanged:ct().optional()}).optional(),tools:P({listChanged:ct().optional()}).optional(),tasks:XA.optional(),extensions:Ae(x(),nt).optional()}),rP=gt.extend({protocolVersion:x(),capabilities:tP,serverInfo:pw,instructions:x().optional()}),Wm=lr.extend({method:Z("notifications/initialized"),params:cr.optional()});var Hc=ht.extend({method:Z("ping"),params:tr.optional()}),nP=P({progress:we(),total:Ze(we()),message:Ze(x())}),iP=P({...cr.shape,...nP.shape,progressToken:sw}),Kc=lr.extend({method:Z("notifications/progress"),params:iP}),oP=tr.extend({cursor:aw.optional()}),Vs=ht.extend({params:oP.optional()}),Gs=gt.extend({nextCursor:aw.optional()}),sP=Ft(["working","input_required","completed","failed","cancelled"]),Bs=P({taskId:x(),status:sP,ttl:Ce([we(),Qb()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Ze(we()),statusMessage:Ze(x())}),Eo=gt.extend({task:Bs}),aP=cr.merge(Bs),Js=lr.extend({method:Z("notifications/tasks/status"),params:aP}),Qc=ht.extend({method:Z("tasks/get"),params:tr.extend({taskId:x()})}),Xc=gt.merge(Bs),Yc=ht.extend({method:Z("tasks/result"),params:tr.extend({taskId:x()})}),pq=gt.loose(),el=Vs.extend({method:Z("tasks/list")}),tl=Gs.extend({tasks:le(Bs)}),rl=ht.extend({method:Z("tasks/cancel"),params:tr.extend({taskId:x()})}),hw=gt.merge(Bs),gw=P({uri:x(),mimeType:Ze(x()),_meta:Ae(x(),De()).optional()}),_w=gw.extend({text:x()}),Hm=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),yw=gw.extend({blob:Hm}),Ws=Ft(["user","assistant"]),zo=P({audience:le(Ws).optional(),priority:we().min(0).max(1).optional(),lastModified:Zs.datetime({offset:!0}).optional()}),vw=P({...$o.shape,...Us.shape,uri:x(),description:Ze(x()),mimeType:Ze(x()),size:Ze(we()),annotations:zo.optional(),_meta:Ze(Rt({}))}),cP=P({...$o.shape,...Us.shape,uriTemplate:x(),description:Ze(x()),mimeType:Ze(x()),annotations:zo.optional(),_meta:Ze(Rt({}))}),Oo=Vs.extend({method:Z("resources/list")}),lP=Gs.extend({resources:le(vw)}),Ao=Vs.extend({method:Z("resources/templates/list")}),uP=Gs.extend({resourceTemplates:le(cP)}),Km=tr.extend({uri:x()}),dP=Km,nl=ht.extend({method:Z("resources/read"),params:dP}),fP=gt.extend({contents:le(Ce([_w,yw]))}),mP=lr.extend({method:Z("notifications/resources/list_changed"),params:cr.optional()}),pP=Km,hP=ht.extend({method:Z("resources/subscribe"),params:pP}),gP=Km,_P=ht.extend({method:Z("resources/unsubscribe"),params:gP}),yP=cr.extend({uri:x()}),vP=lr.extend({method:Z("notifications/resources/updated"),params:yP}),bP=P({name:x(),description:Ze(x()),required:Ze(ct())}),wP=P({...$o.shape,...Us.shape,description:Ze(x()),arguments:Ze(le(bP)),_meta:Ze(Rt({}))}),il=Vs.extend({method:Z("prompts/list")}),xP=Gs.extend({prompts:le(wP)}),kP=tr.extend({name:x(),arguments:Ae(x(),x()).optional()}),ol=ht.extend({method:Z("prompts/get"),params:kP}),Qm=P({type:Z("text"),text:x(),annotations:zo.optional(),_meta:Ae(x(),De()).optional()}),Xm=P({type:Z("image"),data:Hm,mimeType:x(),annotations:zo.optional(),_meta:Ae(x(),De()).optional()}),Ym=P({type:Z("audio"),data:Hm,mimeType:x(),annotations:zo.optional(),_meta:Ae(x(),De()).optional()}),SP=P({type:Z("tool_use"),name:x(),id:x(),input:Ae(x(),De()),_meta:Ae(x(),De()).optional()}),TP=P({type:Z("resource"),resource:Ce([_w,yw]),annotations:zo.optional(),_meta:Ae(x(),De()).optional()}),$P=vw.extend({type:Z("resource_link")}),ep=Ce([Qm,Xm,Ym,$P,TP]),EP=P({role:Ws,content:ep}),zP=gt.extend({description:x().optional(),messages:le(EP)}),OP=lr.extend({method:Z("notifications/prompts/list_changed"),params:cr.optional()}),AP=P({title:x().optional(),readOnlyHint:ct().optional(),destructiveHint:ct().optional(),idempotentHint:ct().optional(),openWorldHint:ct().optional()}),PP=P({taskSupport:Ft(["required","optional","forbidden"]).optional()}),bw=P({...$o.shape,...Us.shape,description:x().optional(),inputSchema:P({type:Z("object"),properties:Ae(x(),nt).optional(),required:le(x()).optional()}).catchall(De()),outputSchema:P({type:Z("object"),properties:Ae(x(),nt).optional(),required:le(x()).optional()}).catchall(De()).optional(),annotations:AP.optional(),execution:PP.optional(),_meta:Ae(x(),De()).optional()}),sl=Vs.extend({method:Z("tools/list")}),CP=Gs.extend({tools:le(bw)}),al=gt.extend({content:le(ep).default([]),structuredContent:Ae(x(),De()).optional(),isError:ct().optional()}),hq=al.or(gt.extend({toolResult:De()})),RP=qs.extend({name:x(),arguments:Ae(x(),De()).optional()}),Po=ht.extend({method:Z("tools/call"),params:RP}),IP=lr.extend({method:Z("notifications/tools/list_changed"),params:cr.optional()}),gq=P({autoRefresh:ct().default(!0),debounceMs:we().int().nonnegative().default(300)}),Hs=Ft(["debug","info","notice","warning","error","critical","alert","emergency"]),jP=tr.extend({level:Hs}),tp=ht.extend({method:Z("logging/setLevel"),params:jP}),NP=cr.extend({level:Hs,logger:x().optional(),data:De()}),MP=lr.extend({method:Z("notifications/message"),params:NP}),DP=P({name:x().optional()}),ZP=P({hints:le(DP).optional(),costPriority:we().min(0).max(1).optional(),speedPriority:we().min(0).max(1).optional(),intelligencePriority:we().min(0).max(1).optional()}),LP=P({mode:Ft(["auto","required","none"]).optional()}),qP=P({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:le(ep).default([]),structuredContent:P({}).loose().optional(),isError:ct().optional(),_meta:Ae(x(),De()).optional()}),FP=Zm("type",[Qm,Xm,Ym]),Vc=Zm("type",[Qm,Xm,Ym,SP,qP]),UP=P({role:Ws,content:Ce([Vc,le(Vc)]),_meta:Ae(x(),De()).optional()}),VP=qs.extend({messages:le(UP),modelPreferences:ZP.optional(),systemPrompt:x().optional(),includeContext:Ft(["none","thisServer","allServers"]).optional(),temperature:we().optional(),maxTokens:we().int(),stopSequences:le(x()).optional(),metadata:nt.optional(),tools:le(bw).optional(),toolChoice:LP.optional()}),GP=ht.extend({method:Z("sampling/createMessage"),params:VP}),Ks=gt.extend({model:x(),stopReason:Ze(Ft(["endTurn","stopSequence","maxTokens"]).or(x())),role:Ws,content:FP}),rp=gt.extend({model:x(),stopReason:Ze(Ft(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:Ws,content:Ce([Vc,le(Vc)])}),BP=P({type:Z("boolean"),title:x().optional(),description:x().optional(),default:ct().optional()}),JP=P({type:Z("string"),title:x().optional(),description:x().optional(),minLength:we().optional(),maxLength:we().optional(),format:Ft(["email","uri","date","date-time"]).optional(),default:x().optional()}),WP=P({type:Ft(["number","integer"]),title:x().optional(),description:x().optional(),minimum:we().optional(),maximum:we().optional(),default:we().optional()}),HP=P({type:Z("string"),title:x().optional(),description:x().optional(),enum:le(x()),default:x().optional()}),KP=P({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:le(P({const:x(),title:x()})),default:x().optional()}),QP=P({type:Z("string"),title:x().optional(),description:x().optional(),enum:le(x()),enumNames:le(x()).optional(),default:x().optional()}),XP=Ce([HP,KP]),YP=P({type:Z("array"),title:x().optional(),description:x().optional(),minItems:we().optional(),maxItems:we().optional(),items:P({type:Z("string"),enum:le(x())}),default:le(x()).optional()}),eC=P({type:Z("array"),title:x().optional(),description:x().optional(),minItems:we().optional(),maxItems:we().optional(),items:P({anyOf:le(P({const:x(),title:x()}))}),default:le(x()).optional()}),tC=Ce([YP,eC]),rC=Ce([QP,XP,tC]),nC=Ce([rC,BP,JP,WP]),iC=qs.extend({mode:Z("form").optional(),message:x(),requestedSchema:P({type:Z("object"),properties:Ae(x(),nC),required:le(x()).optional()})}),oC=qs.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),sC=Ce([iC,oC]),aC=ht.extend({method:Z("elicitation/create"),params:sC}),cC=cr.extend({elicitationId:x()}),lC=lr.extend({method:Z("notifications/elicitation/complete"),params:cC}),Co=gt.extend({action:Ft(["accept","decline","cancel"]),content:Lm(e=>e===null?void 0:e,Ae(x(),Ce([x(),we(),ct(),le(x())])).optional())}),uC=P({type:Z("ref/resource"),uri:x()});var dC=P({type:Z("ref/prompt"),name:x()}),fC=tr.extend({ref:Ce([dC,uC]),argument:P({name:x(),value:x()}),context:P({arguments:Ae(x(),x()).optional()}).optional()}),cl=ht.extend({method:Z("completion/complete"),params:fC});function ww(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function xw(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var mC=gt.extend({completion:Rt({values:le(x()).max(100),total:Ze(we().int()),hasMore:Ze(ct())})}),pC=P({uri:x().startsWith("file://"),name:x().optional(),_meta:Ae(x(),De()).optional()}),hC=ht.extend({method:Z("roots/list"),params:tr.optional()}),np=gt.extend({roots:le(pC)}),gC=lr.extend({method:Z("notifications/roots/list_changed"),params:cr.optional()}),_q=Ce([Hc,Jm,cl,tp,ol,il,Oo,Ao,nl,hP,_P,Po,sl,Qc,Yc,el,rl]),yq=Ce([Wc,Kc,Wm,gC,Js]),vq=Ce([Jc,Ks,rp,Co,np,Xc,tl,Eo]),bq=Ce([Hc,GP,aC,hC,Qc,Yc,el,rl]),wq=Ce([Wc,Kc,MP,vP,mP,IP,OP,Js,lC]),xq=Ce([Jc,rP,mC,zP,xP,lP,uP,fP,al,CP,Xc,tl,Eo]),D=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===U.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new qm(i.elicitations,r)}return new e(t,r,n)}},qm=class extends D{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var vC=k("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Se.init(e,t),e.def=t,e.parse=(r,n)=>Hd(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Ci(e,r,n),e.parseAsync=async(r,n)=>Qd(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Ri(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>er(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e))});var bC=k("ZodMiniObject",(e,t)=>{Rc.init(e,t),vC.init(e,t),ae.defineLazy(e,"shape",()=>t.shape)});function ip(e,t){let r={type:"object",get shape(){return ae.assignProp(this,"shape",{...e}),this.shape},...ae.normalizeParams(t)};return new bC(r)}function ur(e){return!!e._zod}function Ni(e){let t=Object.values(e);if(t.length===0)return ip({});let r=t.every(ur),n=t.every(i=>!ur(i));if(r)return ip(e);if(n)return Xu(e);throw new Error("Mixed Zod versions detected in object shape.")}function Dn(e,t){return ur(e)?Ci(e,t):e.safeParse(t)}async function ll(e,t){return ur(e)?await Ri(e,t):await e.safeParseAsync(t)}function Zn(e){if(!e)return;let t;if(ur(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Ro(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(i=>typeof i=="object"&&i!==null&&(i._def!==void 0||i._zod!==void 0||typeof i.parse=="function")))return Ni(e)}}if(ur(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function ul(e){if(e&&typeof e=="object"){if("message"in e&&typeof e.message=="string")return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t=="object"&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function kw(e){return e.description}function Sw(e){if(ur(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function dl(e){if(ur(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=e._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=e.value;if(n!==void 0)return n}function Ln(e){return e==="completed"||e==="failed"||e==="cancelled"}var $w=Symbol("Let zodToJsonSchema decide on which parser to use");var Tw={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"},Ew=e=>typeof e=="string"?{...Tw,name:e}:{...Tw,...e};var zw=e=>{let t=Ew(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function op(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ue(e,t,r,n,i){e[t]=r,op(e,t,n,i)}var fl=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function Le(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?fl(t,e.currentPath):t.join("/")}}function Ow(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==E.ZodAny&&(r.items=W(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function Aw(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}function Pw(){return{type:"boolean"}}function ml(e,t){return W(e.type._def,t)}var Cw=(e,t)=>W(e.innerType._def,t);function sp(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>sp(e,t,i))};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 xC(e,t)}}var xC=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":ue(r,"minimum",n.value,n.message,t);break;case"max":ue(r,"maximum",n.value,n.message,t);break}return r};function Rw(e,t){return{...W(e.innerType._def,t),default:e.defaultValue()}}function Iw(e,t){return t.effectStrategy==="input"?W(e.schema._def,t):Le(t)}function jw(e){return{type:"string",enum:Array.from(e.values)}}var kC=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function Nw(e,t){let r=[W(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),W(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(kC(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...u}=o;s=u}else n=void 0;i.push(s)}}),i.length?{allOf:i,...n}:void 0}function Mw(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var ap,kr={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:()=>(ap===void 0&&(ap=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ap),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function pl(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Sr(r,"email",n.message,t);break;case"format:idn-email":Sr(r,"idn-email",n.message,t);break;case"pattern:zod":It(r,kr.email,n.message,t);break}break;case"url":Sr(r,"uri",n.message,t);break;case"uuid":Sr(r,"uuid",n.message,t);break;case"regex":It(r,n.regex,n.message,t);break;case"cuid":It(r,kr.cuid,n.message,t);break;case"cuid2":It(r,kr.cuid2,n.message,t);break;case"startsWith":It(r,RegExp(`^${cp(n.value,t)}`),n.message,t);break;case"endsWith":It(r,RegExp(`${cp(n.value,t)}$`),n.message,t);break;case"datetime":Sr(r,"date-time",n.message,t);break;case"date":Sr(r,"date",n.message,t);break;case"time":Sr(r,"time",n.message,t);break;case"duration":Sr(r,"duration",n.message,t);break;case"length":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{It(r,RegExp(cp(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&Sr(r,"ipv4",n.message,t),n.version!=="v4"&&Sr(r,"ipv6",n.message,t);break}case"base64url":It(r,kr.base64url,n.message,t);break;case"jwt":It(r,kr.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&It(r,kr.ipv4Cidr,n.message,t),n.version!=="v4"&&It(r,kr.ipv6Cidr,n.message,t);break}case"emoji":It(r,kr.emoji(),n.message,t);break;case"ulid":{It(r,kr.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Sr(r,"binary",n.message,t);break}case"contentEncoding:base64":{ue(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{It(r,kr.base64,n.message,t);break}}break}case"nanoid":It(r,kr.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function cp(e,t){return t.patternStrategy==="escape"?TC(e):e}var SC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function TC(e){let t="";for(let r=0;r<e.length;r++)SC.has(e[r])||(t+="\\"),t+=e[r];return t}function Sr(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ue(e,"format",t,r,n)}function It(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:Dw(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ue(e,"pattern",Dw(t,n),r,n)}function Dw(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,s=!1,a=!1;for(let u=0;u<n.length;u++){if(o){i+=n[u],o=!1;continue}if(r.i){if(s){if(n[u].match(/[a-z]/)){a?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),a=!1):n[u+1]==="-"&&n[u+2]?.match(/[a-z]/)?(i+=n[u],a=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(r.m){if(n[u]==="^"){i+=`(^|(?<=[\r
348
348
  ]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
349
349
  ]))`;continue}}if(r.s&&n[u]==="."){i+=s?`${n[u]}\r
350
350
  `:`[${n[u]}\r
351
- ]`;continue}i+=n[u],n[u]==="\\"?o=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hl(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===z.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??Le(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===z.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=pl(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===z.ZodBranded&&e.keyType._def.type._def.typeName===z.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=ml(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function Nw(e,t){if(t.mapStrategy==="record")return hl(e,t);let r=W(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Le(t),n=W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Le(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Mw(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function Dw(e){return e.target==="openAi"?void 0:{not:Le({...e,currentPath:[...e.currentPath,"not"]})}}function Zw(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Qs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function qw(e,t){if(t.target==="openApi3")return Lw(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Qs&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let s=Qs[o._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,s,a)=>a.indexOf(o)===s);return{type:i.length>1?i:i[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return Lw(e,t)}var Lw=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>W(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Fw(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:Qs[e.innerType._def.typeName],nullable:!0}:{type:[Qs[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=W(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Uw(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",op(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}function Vw(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let a in o){let u=o[a];if(u===void 0||u._def===void 0)continue;let c=xC(u);c&&r&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),c=!1);let l=W(u._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,c||i.push(a))}i.length&&(n.required=i);let s=wC(e,t);return s!==void 0&&(n.additionalProperties=s),n}function wC(e,t){if(e.catchall._def.typeName!=="ZodNever")return W(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function xC(e){try{return e.isOptional()}catch{return!0}}var Gw=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return W(e.innerType._def,t);let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Le(t)},r]}:Le(t)};var Bw=(e,t)=>{if(t.pipeStrategy==="input")return W(e.in._def,t);if(t.pipeStrategy==="output")return W(e.out._def,t);let r=W(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=W(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function Jw(e,t){return W(e.type._def,t)}function Ww(e,t){let n={type:"array",uniqueItems:!0,items:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ue(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ue(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function Hw(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:W(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function Kw(e){return{not:Le(e)}}function Qw(e){return Le(e)}var Xw=(e,t)=>W(e.innerType._def,t);var Yw=(e,t,r)=>{switch(t){case z.ZodString:return pl(e,r);case z.ZodNumber:return Uw(e,r);case z.ZodObject:return Vw(e,r);case z.ZodBigInt:return zw(e,r);case z.ZodBoolean:return Ew();case z.ZodDate:return sp(e,r);case z.ZodUndefined:return Kw(r);case z.ZodNull:return Zw(r);case z.ZodArray:return $w(e,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return qw(e,r);case z.ZodIntersection:return Rw(e,r);case z.ZodTuple:return Hw(e,r);case z.ZodRecord:return hl(e,r);case z.ZodLiteral:return Iw(e,r);case z.ZodEnum:return Cw(e);case z.ZodNativeEnum:return Mw(e);case z.ZodNullable:return Fw(e,r);case z.ZodOptional:return Gw(e,r);case z.ZodMap:return Nw(e,r);case z.ZodSet:return Ww(e,r);case z.ZodLazy:return()=>e.getter()._def;case z.ZodPromise:return Jw(e,r);case z.ZodNaN:case z.ZodNever:return Dw(r);case z.ZodEffects:return Pw(e,r);case z.ZodAny:return Le(r);case z.ZodUnknown:return Qw(r);case z.ZodDefault:return Aw(e,r);case z.ZodBranded:return ml(e,r);case z.ZodReadonly:return Xw(e,r);case z.ZodCatch:return Ow(e,r);case z.ZodPipeline:return Bw(e,r);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(n=>{})(t)}};function W(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==kw)return a}if(n&&!r){let a=kC(n,t);if(a!==void 0)return a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=Yw(e,e.typeName,t),s=typeof o=="function"?W(o(),t):o;if(s&&SC(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return i.jsonSchema=s,a}return i.jsonSchema=s,s}var kC=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:fl(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Le(t)):t.$refStrategy==="seen"?Le(t):void 0}},SC=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var lp=(e,t)=>{let r=Tw(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,l])=>({...u,[c]:W(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??Le(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=W(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??Le(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(o.title=s),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=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};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};function TC(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function up(e,t){return ur(e)?Cm(e,{target:TC(t?.target),io:t?.pipeStrategy??"input"}):lp(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function dp(e){let r=Zn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=dl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function fp(e,t){let r=Dn(e,t);if(!r.success)throw r.error;return r.data}var $C=6e4,gl=class{constructor(t){this._options=t,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(Wc,r=>{this._oncancel(r)}),this.setNotificationHandler(Kc,r=>{this._onprogress(r)}),this.setRequestHandler(Hc,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Qc,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(U.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Yc,async(r,n)=>{let i=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{let d=u,h=new D(d.error.code,d.error.message,d.error.data);l(h)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(o,n.sessionId);if(!s)throw new D(U.InvalidParams,`Task not found: ${o}`);if(!Ln(s.status))return await this._waitForTaskUpdate(o,n.signal),await i();if(Ln(s.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[Mn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(el,async(r,n)=>{try{let{tasks:i,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new D(U.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(rl,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ln(i.status))throw new D(U.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new D(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof D?i:new D(U.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),D.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Fs(o)||lw(o)?this._onresponse(o):Vm(o)?this._onrequest(o,s):cw(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=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(U.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[Mn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:U.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):i?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=ow(t.params)?t.params.task:void 0,u=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,c={signal:s.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(s.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,h)=>{if(s.signal.aborted)throw new D(U.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:t.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});let p=m.relatedTask?.taskId??o;return p&&u&&await u.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,c)).then(async l=>{if(s.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)},async l=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:U.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===s&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Fs(t))n(t);else{let s=new D(t.error.code,t.error.message,t.error.data);n(s)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Fs(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Fs(t))i(t);else{let s=D.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof D?s:new D(U.InternalError,String(s))}}return}let o;try{let s=await this.request(t,zo,n);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new D(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},Ln(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new D(U.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new D(U.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof D?s:new D(U.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=n??{};return new Promise((c,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),a&&(m.params={...m.params,task:a}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Mn]:u}});let p=v=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(v)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(w=>this._onerror(new Error(`Failed to send cancellation: ${w}`)));let b=v instanceof D?v:new D(U.RequestTimeout,String(v));l(b)};this._responseHandlers.set(h,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let b=Dn(r,v.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let f=n?.timeout??$C,g=()=>p(D.fromError(U.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=u?.taskId;if(y){let v=b=>{let w=this._responseHandlers.get(h);w?w(b):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(h),l(b)})}else this._transport.send(m,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(h),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Xc,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},tl,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},fw,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Mn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Mn]:r.relatedTask}}}),this._transport?.send(a,r).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Mn]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=dp(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>{let s=fp(t,i);return Promise.resolve(r(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=dp(t);this._notificationHandlers.set(n,i=>{let o=fp(t,i);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&Vm(i.message)){let o=i.message.id,s=this._requestResolvers.get(o);s?(s(new D(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new D(U.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new D(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let o=await n.getTask(i,r);if(!o)throw new D(U.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await n.storeTaskResult(i,o,s,r);let a=await n.getTask(i,r);if(a){let u=Js.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Ln(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,o,s)=>{let a=await n.getTask(i,r);if(!a)throw new D(U.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Ln(a.status))throw new D(U.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,o,s,r);let u=await n.getTask(i,r);if(u){let c=Js.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Ln(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function e0(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function t0(e,t){let r={...e};for(let n in t){let i=n,o=t[i];if(o===void 0)continue;let s=r[i];e0(s)&&e0(o)?r[i]={...s,...o}:r[i]=o}return r}var qk=lu(Qh(),1),Fk=lu(Lk(),1);function gM(){let e=new qk.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Fk.default)(e),e}var Yl=class{constructor(t){this._ajv=t??gM()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var eu=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],o=Array.isArray(i.content)?i.content:[i.content],s=o.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,u=a?Array.isArray(a.content)?a.content:[a.content]:[],c=u.some(l=>l.type==="tool_use");if(s){if(o.some(l=>l.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 l=new Set(u.filter(h=>h.type==="tool_use").map(h=>h.id)),d=new Set(o.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(l.size!==d.size||![...l].every(h=>d.has(h)))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:t},Ks,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){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 o=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Co,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function Uk(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Vk(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var tu=class extends gl{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Hs.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Yl,this.setRequestHandler(Jm,n=>this._oninitialize(n)),this.setNotificationHandler(Wm,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(tp,async(n,i)=>{let o=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=Hs.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new eu(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=t0(this._capabilities,t)}setRequestHandler(t,r){let i=Zn(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(ur(i)){let a=i;o=a._zod?.def?.value??a.value}else{let a=i;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(u,c)=>{let l=Dn(Po,u);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new D(U.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,h=await Promise.resolve(r(u,c));if(d.task){let p=Dn(zo,h);if(!p.success){let f=p.error instanceof Error?p.error.message:String(p.error);throw new D(U.InvalidParams,`Invalid task creation result: ${f}`)}return p.data}let m=Dn(al,h);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new D(U.InvalidParams,`Invalid tools/call result: ${p}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);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 ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);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 ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Vk(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Uk(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:rw.includes(r)?r:Fm,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"},Jc)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(c=>c.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],u=a.some(c=>c.type==="tool_use");if(o){if(i.some(c=>c.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 c=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(i.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==l.size||![...c].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},rp,r):this.request({method:"sampling/createMessage",params:t},Ks,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},Co,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:i},Co,r);if(o.action==="accept"&&o.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!a.valid)throw new D(U.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof D?s:new D(U.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(t,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:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},np,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};var Bk=Symbol.for("mcp.completable");function og(e){return!!e&&typeof e=="object"&&Bk in e}function Jk(e){return e[Bk]?.complete}var Gk;(function(e){e.Completable="McpCompletable"})(Gk||(Gk={}));var _M=/^[A-Za-z0-9._-]{1,128}$/;function yM(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!_M.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,o)=>o.indexOf(n)===i);return t.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:t}}return{isValid:!0,warnings:t}}function vM(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)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 sg(e){let t=yM(e);return vM(e,t.warnings),t.isValid}var ru=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var nu=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new tu(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ru(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(sl)),this.server.assertCanSetRequestHandler(Hn(Po)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(sl,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=Ro(r.inputSchema);return i?up(i,{strictUnions:!0,pipeStrategy:"input"}):bM})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=Ro(r.outputSchema);i&&(n.outputSchema=up(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Po,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new D(U.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,o=n.execution?.taskSupport,s="createTask"in n.handler;if((o==="required"||o==="optional")&&!s)throw new D(U.InternalError,`Tool ${t.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!i)throw new D(U.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),u=await this.executeToolHandler(n,a,r);return i||await this.validateToolOutput(n,u,t.params.name),u}catch(n){if(n instanceof D&&n.code===U.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let o=Ro(t.inputSchema)??t.inputSchema,s=await ll(o,r);if(!s.success){let a="error"in s?s.error:"Unknown error",u=ul(a);throw new D(U.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${u}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new D(U.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=Ro(t.outputSchema),o=await ll(i,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=ul(s);throw new D(U.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let i=t.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=i;return await Promise.resolve(a.createTask(r,s))}else{let a=i;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,n))}else{let s=i;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),o=t.handler,s={...n,taskStore:n.taskStore},a=i?await Promise.resolve(o.createTask(i,s)):await Promise.resolve(o.createTask(s)),u=a.task.taskId,c=a.task,l=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let d=await n.taskStore.getTask(u);if(!d)throw new D(U.InternalError,`Task ${u} not found during polling`);c=d}return await n.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Hn(cl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(cl,async t=>{switch(t.params.ref.type){case"ref/prompt":return yw(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return vw(t),this.handleResourceCompletion(t,t.params.ref);default:throw new D(U.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new D(U.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return za;let o=Zn(n.argsSchema)?.[t.params.argument.name];if(!og(o))return za;let s=Jk(o);if(!s)return za;let a=await s(t.params.argument.value,t.params.context);return Hk(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return za;throw new D(U.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return za;let o=await i(t.params.argument.value,t.params.context);return Hk(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(Oo)),this.server.assertCanSetRequestHandler(Hn(Ao)),this.server.assertCanSetRequestHandler(Hn(nl)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Oo,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),i=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)i.push({...o.metadata,...a})}return{resources:[...n,...i]}}),this.server.setRequestHandler(Ao,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(nl,async(t,r)=>{let n=new URL(t.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new D(U.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(n.toString());if(s)return o.readCallback(n,s,r)}throw new D(U.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(il)),this.server.assertCanSetRequestHandler(Hn(ol)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(il,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?wM(r.argsSchema):void 0}))})),this.server.setRequestHandler(ol,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new D(U.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let i=Ro(n.argsSchema),o=await ll(i,t.params.arguments);if(!o.success){let u="error"in o?o.error:"Unknown error",c=ul(u);throw new D(U.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let s=o.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(t,r,n,i,o){let s={name:t,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,i,o){let s={resourceTemplate:n,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=s)),typeof c.title<"u"&&(s.title=c.title),typeof c.template<"u"&&(s.resourceTemplate=c.template),typeof c.metadata<"u"&&(s.metadata=c.metadata),typeof c.callback<"u"&&(s.readCallback=c.callback),typeof c.enabled<"u"&&(s.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(c=>!!n.completeCallback(c))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,i,o){let s={title:r,description:n,argsSchema:i===void 0?void 0:Ni(i),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Ni(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let c=u instanceof Zt?u._def?.innerType:u;return og(c)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,i,o,s,a,u,c){sg(t);let l={title:r,description:n,inputSchema:Wk(i),outputSchema:Wk(o),annotations:s,execution:a,_meta:u,handler:c,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!==t&&(typeof d.name=="string"&&sg(d.name),delete this._registeredTools[t],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=Ni(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Ni(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[t]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,i,o,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let u=r[0];if(ag(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!ag(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,i,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:o,inputSchema:s,outputSchema:a,annotations:u,_meta:c}=r;return this._createRegisteredTool(t,i,o,s,a,u,{taskSupport:"forbidden"},c,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let o=r[0],s=this._createRegisteredPrompt(t,void 0,n,i,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(t,i,o,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var bM={type:"object",properties:{}};function Kk(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function Qk(e){return"_def"in e||"_zod"in e||Kk(e)}function ag(e){return typeof e!="object"||e===null||Qk(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(Kk)}function Wk(e){if(e){if(ag(e))return Ni(e);if(!Qk(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function wM(e){let t=Zn(e);return t?Object.entries(t).map(([r,n])=>{let i=bw(n),o=ww(n);return{name:r,description:i,required:!o}}):[]}function Hn(e){let r=Zn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=dl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Hk(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var za={completion:{values:[],hasMore:!1}};import Yk from"node:process";var iu=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
352
- `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),kM(r)}clear(){this._buffer=void 0}};function kM(e){return uw.parse(JSON.parse(e))}function Xk(e){return JSON.stringify(e)+`
353
- `}var ou=class{constructor(t=Yk.stdin,r=Yk.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new iu,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 t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}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(t){return new Promise(r=>{let n=Xk(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function TM(e){let t={};t.listChanged=!1;let r={};r.resources=t,e.server.registerCapabilities(r),e.server.setRequestHandler(Oo,()=>{let n={};return n.resources=[],n}),e.server.setRequestHandler(Ao,()=>{let n={};return n.resourceTemplates=[],n})}function $M(e){return{registerTool:(t,r,n,i)=>{e.tool(t,r,n,i)}}}function zM(e){return(t,r)=>e.server.elicitInput(t,{timeout:r})}async function cg(e){let t=e.delegationAuthFilePath;if(t!==void 0){let n=e.explicitToken,i=e.authFilePath;if(n!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};if(i!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};let o=b_(t,Date.now());return o.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:o._0.accessToken,mode:"PersonalAgentDelegation"}}:{TAG:"Error",_0:o._0.summary}}let r=await V_(e.serviceUrl,e.explicitToken,e.authFilePath,e.workspaceSlug,e.channelSlug,void 0);return r.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:r._0,mode:"LocalRunner"}}:{TAG:"Error",_0:r._0.summary}}function lg(e,t){let r=We(e,"token");return{serviceUrl:t,explicitToken:r!==void 0?r:process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:We(e,"auth-file"),delegationAuthFilePath:We(e,"delegation-auth-file"),workspaceSlug:We(e,"workspace"),channelSlug:We(e,"channel")}}async function EM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0;if(Ki(r,"help"))return Xn(Ma()),{TAG:"Ok",_0:void 0};let n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await cg(lg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=Na(We(r,"mode")),u=mu(We(r,"tool-scope"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let c=a._0;if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let l=We(r,"owner-username"),d=l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,h=We(r,"cwd"),m=h!==void 0?h:process.cwd(),p=We(r,"thread-id"),f=p!==void 0?p:process.env[oy],g=jd({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c});if(g.TAG!=="Ok")return{TAG:"Error",_0:g._0};let y=new nu({name:"linzumi",version:"0.1.0"});return TM(y),gv($M(y),{client:g._0,toolScope:u._0,operatingMode:c,cwd:m,serviceUrl:i,defaultThreadId:f,ownerUsername:d,agentSession:Ki(r,"agent-session"),documentSurfaces:_v(s.accessToken),multiAgentJobs:Ki(r,"multi-agent-jobs"),devServices:rv(process.env),askUserQuestion:Ki(r,"ask-user-question-tool")?zM(y):void 0}),await y.connect(new ou),{TAG:"Ok",_0:void 0}}async function OM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=We(r,"format"),s=o!==void 0?o:"codex",a=Na(We(r,"mode"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u;if(Ki(r,"include-token")){let h=await cg(lg(r,i));u=h.TAG==="Ok"?{TAG:"Ok",_0:h._0.accessToken}:{TAG:"Error",_0:h._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=mu(We(r,"tool-scope"));if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let l=We(r,"owner-username"),d=ov({command:We(r,"command"),serviceUrl:i,accessToken:u._0,delegationAuthFilePath:We(r,"delegation-auth-file"),ownerUsername:l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:a._0,toolScope:c._0});switch(s){case"claude-code":return Xn(sv(d)),{TAG:"Ok",_0:void 0};case"codex":return Xn(av(d)),{TAG:"Ok",_0:void 0};default:return{TAG:"Error",_0:"--format must be codex or claude-code"}}}async function AM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await cg(lg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=s.mode,u;if(a==="LocalRunner"){let c=await oo(i,s.accessToken,We(r,"workspace"),We(r,"channel"),void 0);if(c.TAG==="Ok")switch(c._0){case"Usable":u={TAG:"Ok",_0:void 0};break;case"Rejected":case"NotFound":u={TAG:"Error",_0:"Linzumi MCP auth validation failed"};break}else u={TAG:"Error",_0:c._0.summary}}else{let c=Na(We(r,"mode"));if(c.TAG==="Ok"){let l=jd({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c._0});if(l.TAG==="Ok")try{await l._0.validateAuth(),u={TAG:"Ok",_0:void 0}}catch(d){let h=X(d);u={TAG:"Error",_0:Yr(h)}}else u={TAG:"Error",_0:l._0}}else u={TAG:"Error",_0:c._0}}return u.TAG!=="Ok"?{TAG:"Error",_0:u._0}:(Xn(`Linzumi MCP auth OK
354
- `),{TAG:"Ok",_0:void 0})}async function eS(e){let t=e.slice(1),r=e[0];if(r!==void 0)switch(r){case"--help":case"-h":return Xn(Ma()),{TAG:"Ok",_0:void 0};case"config":return await OM(t);case"doctor":return await AM(t);case"server":return await EM(t);default:return{TAG:"Error",_0:"unknown linzumi mcp command: "+r}}else return Xn(Ma()),{TAG:"Ok",_0:void 0}}async function CM(e){let t;try{t=await eS(kg(e))}catch(r){let n=X(r);return es("linzumi mcp server failed: "+Yr(n)+`
351
+ ]`;continue}i+=n[u],n[u]==="\\"?o=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hl(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===E.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??Le(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===E.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=pl(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===E.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===E.ZodBranded&&e.keyType._def.type._def.typeName===E.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=ml(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function Zw(e,t){if(t.mapStrategy==="record")return hl(e,t);let r=W(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Le(t),n=W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Le(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Lw(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function qw(e){return e.target==="openAi"?void 0:{not:Le({...e,currentPath:[...e.currentPath,"not"]})}}function Fw(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Qs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Vw(e,t){if(t.target==="openApi3")return Uw(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Qs&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let s=Qs[o._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,s,a)=>a.indexOf(o)===s);return{type:i.length>1?i:i[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return Uw(e,t)}var Uw=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>W(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Gw(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:Qs[e.innerType._def.typeName],nullable:!0}:{type:[Qs[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=W(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Bw(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",op(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}function Jw(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let a in o){let u=o[a];if(u===void 0||u._def===void 0)continue;let c=EC(u);c&&r&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),c=!1);let l=W(u._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,c||i.push(a))}i.length&&(n.required=i);let s=$C(e,t);return s!==void 0&&(n.additionalProperties=s),n}function $C(e,t){if(e.catchall._def.typeName!=="ZodNever")return W(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function EC(e){try{return e.isOptional()}catch{return!0}}var Ww=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return W(e.innerType._def,t);let r=W(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Le(t)},r]}:Le(t)};var Hw=(e,t)=>{if(t.pipeStrategy==="input")return W(e.in._def,t);if(t.pipeStrategy==="output")return W(e.out._def,t);let r=W(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=W(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function Kw(e,t){return W(e.type._def,t)}function Qw(e,t){let n={type:"array",uniqueItems:!0,items:W(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ue(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ue(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function Xw(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:W(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>W(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function Yw(e){return{not:Le(e)}}function e0(e){return Le(e)}var t0=(e,t)=>W(e.innerType._def,t);var r0=(e,t,r)=>{switch(t){case E.ZodString:return pl(e,r);case E.ZodNumber:return Bw(e,r);case E.ZodObject:return Jw(e,r);case E.ZodBigInt:return Aw(e,r);case E.ZodBoolean:return Pw();case E.ZodDate:return sp(e,r);case E.ZodUndefined:return Yw(r);case E.ZodNull:return Fw(r);case E.ZodArray:return Ow(e,r);case E.ZodUnion:case E.ZodDiscriminatedUnion:return Vw(e,r);case E.ZodIntersection:return Nw(e,r);case E.ZodTuple:return Xw(e,r);case E.ZodRecord:return hl(e,r);case E.ZodLiteral:return Mw(e,r);case E.ZodEnum:return jw(e);case E.ZodNativeEnum:return Lw(e);case E.ZodNullable:return Gw(e,r);case E.ZodOptional:return Ww(e,r);case E.ZodMap:return Zw(e,r);case E.ZodSet:return Qw(e,r);case E.ZodLazy:return()=>e.getter()._def;case E.ZodPromise:return Kw(e,r);case E.ZodNaN:case E.ZodNever:return qw(r);case E.ZodEffects:return Iw(e,r);case E.ZodAny:return Le(r);case E.ZodUnknown:return e0(r);case E.ZodDefault:return Rw(e,r);case E.ZodBranded:return ml(e,r);case E.ZodReadonly:return t0(e,r);case E.ZodCatch:return Cw(e,r);case E.ZodPipeline:return Hw(e,r);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(n=>{})(t)}};function W(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==$w)return a}if(n&&!r){let a=zC(n,t);if(a!==void 0)return a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=r0(e,e.typeName,t),s=typeof o=="function"?W(o(),t):o;if(s&&OC(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return i.jsonSchema=s,a}return i.jsonSchema=s,s}var zC=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:fl(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Le(t)):t.$refStrategy==="seen"?Le(t):void 0}},OC=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var lp=(e,t)=>{let r=zw(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,l])=>({...u,[c]:W(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??Le(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=W(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??Le(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(o.title=s),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=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};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};function AC(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function up(e,t){return ur(e)?Cm(e,{target:AC(t?.target),io:t?.pipeStrategy??"input"}):lp(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function dp(e){let r=Zn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=dl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function fp(e,t){let r=Dn(e,t);if(!r.success)throw r.error;return r.data}var PC=6e4,gl=class{constructor(t){this._options=t,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(Wc,r=>{this._oncancel(r)}),this.setNotificationHandler(Kc,r=>{this._onprogress(r)}),this.setRequestHandler(Hc,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Qc,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(U.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Yc,async(r,n)=>{let i=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{let d=u,h=new D(d.error.code,d.error.message,d.error.data);l(h)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(o,n.sessionId);if(!s)throw new D(U.InvalidParams,`Task not found: ${o}`);if(!Ln(s.status))return await this._waitForTaskUpdate(o,n.signal),await i();if(Ln(s.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[Mn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(el,async(r,n)=>{try{let{tasks:i,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new D(U.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(rl,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new D(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ln(i.status))throw new D(U.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new D(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof D?i:new D(U.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),D.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Fs(o)||fw(o)?this._onresponse(o):Vm(o)?this._onrequest(o,s):dw(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=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(U.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[Mn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:U.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):i?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=cw(t.params)?t.params.task:void 0,u=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,c={signal:s.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(s.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,h)=>{if(s.signal.aborted)throw new D(U.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:t.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});let p=m.relatedTask?.taskId??o;return p&&u&&await u.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,c)).then(async l=>{if(s.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)},async l=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:U.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===s&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Fs(t))n(t);else{let s=new D(t.error.code,t.error.message,t.error.data);n(s)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Fs(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Fs(t))i(t);else{let s=D.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof D?s:new D(U.InternalError,String(s))}}return}let o;try{let s=await this.request(t,Eo,n);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new D(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},Ln(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new D(U.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new D(U.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof D?s:new D(U.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=n??{};return new Promise((c,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),a&&(m.params={...m.params,task:a}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Mn]:u}});let p=v=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(v)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(w=>this._onerror(new Error(`Failed to send cancellation: ${w}`)));let b=v instanceof D?v:new D(U.RequestTimeout,String(v));l(b)};this._responseHandlers.set(h,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let b=Dn(r,v.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let f=n?.timeout??PC,g=()=>p(D.fromError(U.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=u?.taskId;if(y){let v=b=>{let w=this._responseHandlers.get(h);w?w(b):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(h),l(b)})}else this._transport.send(m,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(h),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Xc,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},tl,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},hw,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Mn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Mn]:r.relatedTask}}}),this._transport?.send(a,r).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Mn]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=dp(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>{let s=fp(t,i);return Promise.resolve(r(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=dp(t);this._notificationHandlers.set(n,i=>{let o=fp(t,i);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&Vm(i.message)){let o=i.message.id,s=this._requestResolvers.get(o);s?(s(new D(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new D(U.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new D(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let o=await n.getTask(i,r);if(!o)throw new D(U.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await n.storeTaskResult(i,o,s,r);let a=await n.getTask(i,r);if(a){let u=Js.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Ln(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,o,s)=>{let a=await n.getTask(i,r);if(!a)throw new D(U.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Ln(a.status))throw new D(U.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,o,s,r);let u=await n.getTask(i,r);if(u){let c=Js.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Ln(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function n0(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function i0(e,t){let r={...e};for(let n in t){let i=n,o=t[i];if(o===void 0)continue;let s=r[i];n0(s)&&n0(o)?r[i]={...s,...o}:r[i]=o}return r}var Vk=lu(Qh(),1),Gk=lu(Uk(),1);function wM(){let e=new Vk.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Gk.default)(e),e}var Yl=class{constructor(t){this._ajv=t??wM()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var eu=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],o=Array.isArray(i.content)?i.content:[i.content],s=o.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,u=a?Array.isArray(a.content)?a.content:[a.content]:[],c=u.some(l=>l.type==="tool_use");if(s){if(o.some(l=>l.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 l=new Set(u.filter(h=>h.type==="tool_use").map(h=>h.id)),d=new Set(o.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(l.size!==d.size||![...l].every(h=>d.has(h)))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:t},Ks,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){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 o=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Co,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function Bk(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Jk(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var tu=class extends gl{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Hs.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Yl,this.setRequestHandler(Jm,n=>this._oninitialize(n)),this.setNotificationHandler(Wm,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(tp,async(n,i)=>{let o=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=Hs.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new eu(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=i0(this._capabilities,t)}setRequestHandler(t,r){let i=Zn(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(ur(i)){let a=i;o=a._zod?.def?.value??a.value}else{let a=i;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(u,c)=>{let l=Dn(Po,u);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new D(U.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,h=await Promise.resolve(r(u,c));if(d.task){let p=Dn(Eo,h);if(!p.success){let f=p.error instanceof Error?p.error.message:String(p.error);throw new D(U.InvalidParams,`Invalid task creation result: ${f}`)}return p.data}let m=Dn(al,h);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new D(U.InvalidParams,`Invalid tools/call result: ${p}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);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 ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);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 ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Jk(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Bk(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:ow.includes(r)?r:Fm,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"},Jc)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(c=>c.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],u=a.some(c=>c.type==="tool_use");if(o){if(i.some(c=>c.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 c=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(i.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==l.size||![...c].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},rp,r):this.request({method:"sampling/createMessage",params:t},Ks,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},Co,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:i},Co,r);if(o.action==="accept"&&o.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!a.valid)throw new D(U.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof D?s:new D(U.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(t,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:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},np,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};var Hk=Symbol.for("mcp.completable");function og(e){return!!e&&typeof e=="object"&&Hk in e}function Kk(e){return e[Hk]?.complete}var Wk;(function(e){e.Completable="McpCompletable"})(Wk||(Wk={}));var xM=/^[A-Za-z0-9._-]{1,128}$/;function kM(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!xM.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,o)=>o.indexOf(n)===i);return t.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:t}}return{isValid:!0,warnings:t}}function SM(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)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 sg(e){let t=kM(e);return SM(e,t.warnings),t.isValid}var ru=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var nu=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new tu(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ru(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(sl)),this.server.assertCanSetRequestHandler(Hn(Po)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(sl,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=Ro(r.inputSchema);return i?up(i,{strictUnions:!0,pipeStrategy:"input"}):TM})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=Ro(r.outputSchema);i&&(n.outputSchema=up(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Po,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new D(U.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,o=n.execution?.taskSupport,s="createTask"in n.handler;if((o==="required"||o==="optional")&&!s)throw new D(U.InternalError,`Tool ${t.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!i)throw new D(U.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),u=await this.executeToolHandler(n,a,r);return i||await this.validateToolOutput(n,u,t.params.name),u}catch(n){if(n instanceof D&&n.code===U.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let o=Ro(t.inputSchema)??t.inputSchema,s=await ll(o,r);if(!s.success){let a="error"in s?s.error:"Unknown error",u=ul(a);throw new D(U.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${u}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new D(U.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=Ro(t.outputSchema),o=await ll(i,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=ul(s);throw new D(U.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let i=t.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=i;return await Promise.resolve(a.createTask(r,s))}else{let a=i;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,n))}else{let s=i;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),o=t.handler,s={...n,taskStore:n.taskStore},a=i?await Promise.resolve(o.createTask(i,s)):await Promise.resolve(o.createTask(s)),u=a.task.taskId,c=a.task,l=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let d=await n.taskStore.getTask(u);if(!d)throw new D(U.InternalError,`Task ${u} not found during polling`);c=d}return await n.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Hn(cl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(cl,async t=>{switch(t.params.ref.type){case"ref/prompt":return ww(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return xw(t),this.handleResourceCompletion(t,t.params.ref);default:throw new D(U.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new D(U.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Ea;let o=Zn(n.argsSchema)?.[t.params.argument.name];if(!og(o))return Ea;let s=Kk(o);if(!s)return Ea;let a=await s(t.params.argument.value,t.params.context);return Xk(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Ea;throw new D(U.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return Ea;let o=await i(t.params.argument.value,t.params.context);return Xk(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(Oo)),this.server.assertCanSetRequestHandler(Hn(Ao)),this.server.assertCanSetRequestHandler(Hn(nl)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Oo,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),i=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)i.push({...o.metadata,...a})}return{resources:[...n,...i]}}),this.server.setRequestHandler(Ao,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(nl,async(t,r)=>{let n=new URL(t.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new D(U.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(n.toString());if(s)return o.readCallback(n,s,r)}throw new D(U.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Hn(il)),this.server.assertCanSetRequestHandler(Hn(ol)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(il,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?$M(r.argsSchema):void 0}))})),this.server.setRequestHandler(ol,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new D(U.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new D(U.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let i=Ro(n.argsSchema),o=await ll(i,t.params.arguments);if(!o.success){let u="error"in o?o.error:"Unknown error",c=ul(u);throw new D(U.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let s=o.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(t,r,n,i,o){let s={name:t,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,i,o){let s={resourceTemplate:n,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=s)),typeof c.title<"u"&&(s.title=c.title),typeof c.template<"u"&&(s.resourceTemplate=c.template),typeof c.metadata<"u"&&(s.metadata=c.metadata),typeof c.callback<"u"&&(s.readCallback=c.callback),typeof c.enabled<"u"&&(s.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(c=>!!n.completeCallback(c))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,i,o){let s={title:r,description:n,argsSchema:i===void 0?void 0:Ni(i),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Ni(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let c=u instanceof Zt?u._def?.innerType:u;return og(c)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,i,o,s,a,u,c){sg(t);let l={title:r,description:n,inputSchema:Qk(i),outputSchema:Qk(o),annotations:s,execution:a,_meta:u,handler:c,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!==t&&(typeof d.name=="string"&&sg(d.name),delete this._registeredTools[t],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=Ni(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Ni(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[t]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,i,o,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let u=r[0];if(ag(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!ag(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,i,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:o,inputSchema:s,outputSchema:a,annotations:u,_meta:c}=r;return this._createRegisteredTool(t,i,o,s,a,u,{taskSupport:"forbidden"},c,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let o=r[0],s=this._createRegisteredPrompt(t,void 0,n,i,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(t,i,o,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var TM={type:"object",properties:{}};function Yk(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function eS(e){return"_def"in e||"_zod"in e||Yk(e)}function ag(e){return typeof e!="object"||e===null||eS(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(Yk)}function Qk(e){if(e){if(ag(e))return Ni(e);if(!eS(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function $M(e){let t=Zn(e);return t?Object.entries(t).map(([r,n])=>{let i=kw(n),o=Sw(n);return{name:r,description:i,required:!o}}):[]}function Hn(e){let r=Zn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=dl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Xk(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var Ea={completion:{values:[],hasMore:!1}};import rS from"node:process";var iu=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
352
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),zM(r)}clear(){this._buffer=void 0}};function zM(e){return mw.parse(JSON.parse(e))}function tS(e){return JSON.stringify(e)+`
353
+ `}var ou=class{constructor(t=rS.stdin,r=rS.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new iu,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 t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}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(t){return new Promise(r=>{let n=tS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function AM(e){let t={};t.listChanged=!1;let r={};r.resources=t,e.server.registerCapabilities(r),e.server.setRequestHandler(Oo,()=>{let n={};return n.resources=[],n}),e.server.setRequestHandler(Ao,()=>{let n={};return n.resourceTemplates=[],n})}function PM(e){return{registerTool:(t,r,n,i)=>{e.tool(t,r,n,i)}}}function CM(e){return(t,r)=>e.server.elicitInput(t,{timeout:r})}async function cg(e){let t=e.delegationAuthFilePath;if(t!==void 0){let n=e.explicitToken,i=e.authFilePath;if(n!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};if(i!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};let o=b_(t,Date.now());return o.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:o._0.accessToken,mode:"PersonalAgentDelegation"}}:{TAG:"Error",_0:o._0.summary}}let r=await V_(e.serviceUrl,e.explicitToken,e.authFilePath,e.workspaceSlug,e.channelSlug,void 0);return r.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:r._0,mode:"LocalRunner"}}:{TAG:"Error",_0:r._0.summary}}function lg(e,t){let r=We(e,"token");return{serviceUrl:t,explicitToken:r!==void 0?r:process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:We(e,"auth-file"),delegationAuthFilePath:We(e,"delegation-auth-file"),workspaceSlug:We(e,"workspace"),channelSlug:We(e,"channel")}}async function RM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0;if(Ki(r,"help"))return Xn(Ma()),{TAG:"Ok",_0:void 0};let n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await cg(lg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=Na(We(r,"mode")),u=mu(We(r,"tool-scope"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let c=a._0;if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let l=We(r,"owner-username"),d=l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,h=We(r,"cwd"),m=h!==void 0?h:process.cwd(),p=We(r,"thread-id"),f=p!==void 0?p:process.env[sy],g=jd({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c});if(g.TAG!=="Ok")return{TAG:"Error",_0:g._0};let y=new nu({name:"linzumi",version:"0.1.0"});return AM(y),vv(PM(y),{client:g._0,toolScope:u._0,operatingMode:c,cwd:m,serviceUrl:i,defaultThreadId:f,ownerUsername:d,agentSession:Ki(r,"agent-session"),documentSurfaces:bv(s.accessToken),multiAgentJobs:Ki(r,"multi-agent-jobs"),devServices:nv(process.env),askUserQuestion:Ki(r,"ask-user-question-tool")?CM(y):void 0}),await y.connect(new ou),{TAG:"Ok",_0:void 0}}async function IM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=We(r,"format"),s=o!==void 0?o:"codex",a=Na(We(r,"mode"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u;if(Ki(r,"include-token")){let h=await cg(lg(r,i));u=h.TAG==="Ok"?{TAG:"Ok",_0:h._0.accessToken}:{TAG:"Error",_0:h._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=mu(We(r,"tool-scope"));if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let l=We(r,"owner-username"),d=sv({command:We(r,"command"),serviceUrl:i,accessToken:u._0,delegationAuthFilePath:We(r,"delegation-auth-file"),ownerUsername:l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:a._0,toolScope:c._0});switch(s){case"claude-code":return Xn(av(d)),{TAG:"Ok",_0:void 0};case"codex":return Xn(cv(d)),{TAG:"Ok",_0:void 0};default:return{TAG:"Error",_0:"--format must be codex or claude-code"}}}async function jM(e){let t=Ia(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=ja(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await cg(lg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=s.mode,u;if(a==="LocalRunner"){let c=await oo(i,s.accessToken,We(r,"workspace"),We(r,"channel"),void 0);if(c.TAG==="Ok")switch(c._0){case"Usable":u={TAG:"Ok",_0:void 0};break;case"Rejected":case"NotFound":u={TAG:"Error",_0:"Linzumi MCP auth validation failed"};break}else u={TAG:"Error",_0:c._0.summary}}else{let c=Na(We(r,"mode"));if(c.TAG==="Ok"){let l=jd({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c._0});if(l.TAG==="Ok")try{await l._0.validateAuth(),u={TAG:"Ok",_0:void 0}}catch(d){let h=X(d);u={TAG:"Error",_0:Yr(h)}}else u={TAG:"Error",_0:l._0}}else u={TAG:"Error",_0:c._0}}return u.TAG!=="Ok"?{TAG:"Error",_0:u._0}:(Xn(`Linzumi MCP auth OK
354
+ `),{TAG:"Ok",_0:void 0})}async function nS(e){let t=e.slice(1),r=e[0];if(r!==void 0)switch(r){case"--help":case"-h":return Xn(Ma()),{TAG:"Ok",_0:void 0};case"config":return await IM(t);case"doctor":return await jM(t);case"server":return await RM(t);default:return{TAG:"Error",_0:"unknown linzumi mcp command: "+r}}else return Xn(Ma()),{TAG:"Ok",_0:void 0}}async function MM(e){let t;try{t=await nS(kg(e))}catch(r){let n=X(r);return es("linzumi mcp server failed: "+Yr(n)+`
355
355
  `),hu(1)}if(t.TAG!=="Ok")return es("linzumi mcp server failed: "+t._0+`
356
- `),hu(1)}var tS=process.argv[1],RM=tS!==void 0?import.meta.url===rS.pathToFileURL(tS).href:!1;RM&&CM(process.argv.slice(2));export{RM as invokedDirectly,CM as runMcpServerEntry};
356
+ `),hu(1)}var iS=process.argv[1],DM=iS!==void 0?import.meta.url===oS.pathToFileURL(iS).href:!1;DM&&MM(process.argv.slice(2));export{DM as invokedDirectly,MM as runMcpServerEntry};