flowpad-mcp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,58 +1,58 @@
1
1
  #!/usr/bin/env node
2
- var Eb=Object.create;var dc=Object.defineProperty;var kb=Object.getOwnPropertyDescriptor;var Tb=Object.getOwnPropertyNames;var Pb=Object.getPrototypeOf,Rb=Object.prototype.hasOwnProperty;var Ks=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},pc=(t,e)=>{for(var r in e)dc(t,r,{get:e[r],enumerable:!0})},Ib=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Tb(e))!Rb.call(t,o)&&o!==r&&dc(t,o,{get:()=>e[o],enumerable:!(n=kb(e,o))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?Eb(Pb(t)):{},Ib(e||!t||!t.__esModule?dc(r,"default",{value:t,enumerable:!0}):r,t));var kf=S((bO,sr)=>{var fc=Ks("fs"),Js=Ks("path"),zb=Ks("os"),Ob=Ks("crypto"),wf=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function Nb(){return wf[Math.floor(Math.random()*wf.length)]}function jn(t){return typeof t=="string"?!["false","0","no","off",""].includes(t.toLowerCase()):!!t}function Ab(){return process.stdout.isTTY}function Cb(t){return Ab()?`\x1B[2m${t}\x1B[0m`:t}var Mb=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function jb(t){let e={},r=t.toString();r=r.replace(/\r\n?/mg,`
3
- `);let n;for(;(n=Mb.exec(r))!=null;){let o=n[1],s=n[2]||"";s=s.trim();let i=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(s=s.replace(/\\n/g,`
4
- `),s=s.replace(/\\r/g,"\r")),e[o]=s}return e}function Db(t){t=t||{};let e=Ef(t);t.path=e;let r=Ze.configDotenv(t);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=Sf(t).split(","),o=n.length,s;for(let i=0;i<o;i++)try{let a=n[i].trim(),c=Zb(r,a);s=Ze.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=o)throw a}return Ze.parse(s)}function Lb(t){console.error(`\u26A0 ${t}`)}function No(t){console.log(`\u2506 ${t}`)}function $f(t){console.log(`\u25C7 ${t}`)}function Sf(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Zb(t,e){let r;try{r=new URL(e)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let o=r.searchParams.get("environment");if(!o){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let s=`DOTENV_VAULT_${o.toUpperCase()}`,i=t.parsed[s];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function Ef(t){let e=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let r of t.path)fc.existsSync(r)&&(e=r.endsWith(".vault")?r:`${r}.vault`);else e=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else e=Js.resolve(process.cwd(),".env.vault");return fc.existsSync(e)?e:null}function xf(t){return t[0]==="~"?Js.join(zb.homedir(),t.slice(1)):t}function Ub(t){let e=jn(process.env.DOTENV_CONFIG_DEBUG||t&&t.debug),r=jn(process.env.DOTENV_CONFIG_QUIET||t&&t.quiet);(e||!r)&&$f("loading env from encrypted .env.vault");let n=Ze._parseVault(t),o=process.env;return t&&t.processEnv!=null&&(o=t.processEnv),Ze.populate(o,n,t),{parsed:n}}function qb(t){let e=Js.resolve(process.cwd(),".env"),r="utf8",n=process.env;t&&t.processEnv!=null&&(n=t.processEnv);let o=jn(n.DOTENV_CONFIG_DEBUG||t&&t.debug),s=jn(n.DOTENV_CONFIG_QUIET||t&&t.quiet);t&&t.encoding?r=t.encoding:o&&No("no encoding is specified (UTF-8 is used by default)");let i=[e];if(t&&t.path)if(!Array.isArray(t.path))i=[xf(t.path)];else{i=[];for(let l of t.path)i.push(xf(l))}let a,c={};for(let l of i)try{let d=Ze.parse(fc.readFileSync(l,{encoding:r}));Ze.populate(c,d,t)}catch(d){o&&No(`failed to load ${l} ${d.message}`),a=d}let u=Ze.populate(n,c,t);if(o=jn(n.DOTENV_CONFIG_DEBUG||o),s=jn(n.DOTENV_CONFIG_QUIET||s),o||!s){let l=Object.keys(u).length,d=[];for(let h of i)try{let m=Js.relative(process.cwd(),h);d.push(m)}catch(m){o&&No(`failed to load ${h} ${m.message}`),a=m}$f(`injected env (${l}) from ${d.join(",")} ${Cb(`// tip: ${Nb()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function Fb(t){if(Sf(t).length===0)return Ze.configDotenv(t);let e=Ef(t);return e?Ze._configVault(t):(Lb(`you set DOTENV_KEY but you are missing a .env.vault file at ${e}`),Ze.configDotenv(t))}function Vb(t,e){let r=Buffer.from(e.slice(-64),"hex"),n=Buffer.from(t,"base64"),o=n.subarray(0,12),s=n.subarray(-16);n=n.subarray(12,-16);try{let i=Ob.createDecipheriv("aes-256-gcm",r,o);return i.setAuthTag(s),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(a||c){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(u){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw i}}function Hb(t,e,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),s={};if(typeof e!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(e))Object.prototype.hasOwnProperty.call(t,i)?(o===!0&&(t[i]=e[i],s[i]=e[i]),n&&No(o===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(t[i]=e[i],s[i]=e[i]);return s}var Ze={configDotenv:qb,_configVault:Ub,_parseVault:Db,config:Fb,decrypt:Vb,parse:jb,populate:Hb};sr.exports.configDotenv=Ze.configDotenv;sr.exports._configVault=Ze._configVault;sr.exports._parseVault=Ze._parseVault;sr.exports.config=Ze.config;sr.exports.decrypt=Ze.decrypt;sr.exports.parse=Ze.parse;sr.exports.populate=Ze.populate;sr.exports=Ze});var Pf=S((wO,Tf)=>{var Hr={};process.env.DOTENV_CONFIG_ENCODING!=null&&(Hr.encoding=process.env.DOTENV_CONFIG_ENCODING);process.env.DOTENV_CONFIG_PATH!=null&&(Hr.path=process.env.DOTENV_CONFIG_PATH);process.env.DOTENV_CONFIG_QUIET!=null&&(Hr.quiet=process.env.DOTENV_CONFIG_QUIET);process.env.DOTENV_CONFIG_DEBUG!=null&&(Hr.debug=process.env.DOTENV_CONFIG_DEBUG);process.env.DOTENV_CONFIG_OVERRIDE!=null&&(Hr.override=process.env.DOTENV_CONFIG_OVERRIDE);process.env.DOTENV_CONFIG_DOTENV_KEY!=null&&(Hr.DOTENV_KEY=process.env.DOTENV_CONFIG_DOTENV_KEY);Tf.exports=Hr});var If=S((xO,Rf)=>{var Gb=/^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;Rf.exports=function(e){let r=e.reduce(function(n,o){let s=o.match(Gb);return s&&(n[s[1]]=s[2]),n},{});return"quiet"in r||(r.quiet="true"),r}});var ps=S(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.regexpCode=le.getEsmExportName=le.getProperty=le.safeStringify=le.stringify=le.strConcat=le.addCodeArg=le.str=le._=le.nil=le._Code=le.Name=le.IDENTIFIER=le._CodeOrName=void 0;var ls=class{};le._CodeOrName=ls;le.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var gn=class extends ls{constructor(e){if(super(),!le.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};le.Name=gn;var Rt=class extends ls{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof gn&&(r[n.str]=(r[n.str]||0)+1),r),{})}};le._Code=Rt;le.nil=new Rt("");function Tg(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Bl(r,e[n]),r.push(t[++n]);return new Rt(r)}le._=Tg;var Gl=new Rt("+");function Pg(t,...e){let r=[ds(t[0])],n=0;for(;n<e.length;)r.push(Gl),Bl(r,e[n]),r.push(Gl,ds(t[++n]));return VS(r),new Rt(r)}le.str=Pg;function Bl(t,e){e instanceof Rt?t.push(...e._items):e instanceof gn?t.push(e):t.push(BS(e))}le.addCodeArg=Bl;function VS(t){let e=1;for(;e<t.length-1;){if(t[e]===Gl){let r=HS(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function HS(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof gn||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof gn))return`"${t}${e.slice(1)}`}function GS(t,e){return e.emptyStr()?t:t.emptyStr()?e:Pg`${t}${e}`}le.strConcat=GS;function BS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ds(Array.isArray(t)?t.join(","):t)}function KS(t){return new Rt(ds(t))}le.stringify=KS;function ds(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}le.safeStringify=ds;function WS(t){return typeof t=="string"&&le.IDENTIFIER.test(t)?new Rt(`.${t}`):Tg`[${t}]`}le.getProperty=WS;function JS(t){if(typeof t=="string"&&le.IDENTIFIER.test(t))return new Rt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}le.getEsmExportName=JS;function XS(t){return new Rt(t.toString())}le.regexpCode=XS});var Jl=S(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.ValueScope=ft.ValueScopeName=ft.Scope=ft.varKinds=ft.UsedValueState=void 0;var pt=ps(),Kl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},ea;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(ea||(ft.UsedValueState=ea={}));ft.varKinds={const:new pt.Name("const"),let:new pt.Name("let"),var:new pt.Name("var")};var ta=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof pt.Name?e:this.name(e)}name(e){return new pt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};ft.Scope=ta;var ra=class extends pt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,pt._)`.${new pt.Name(r)}[${n}]`}};ft.ValueScopeName=ra;var YS=(0,pt._)`\n`,Wl=class extends ta{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?YS:pt.nil}}get(){return this._scope}name(e){return new ra(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,pt._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=pt.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,ea.Started);let l=r(u);if(l){let d=this.opts.es5?ft.varKinds.var:ft.varKinds.const;s=(0,pt._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,pt._)`${s}${l}${this.opts._n}`;else throw new Kl(u);c.set(u,ea.Completed)})}return s}};ft.ValueScope=Wl});var W=S(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var se=ps(),Dt=Jl(),zr=ps();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return zr._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return zr.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return zr.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return zr.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return zr.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return zr.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return zr.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return zr.Name}});var ia=Jl();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return ia.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return ia.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return ia.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return ia.varKinds}});J.operators={GT:new se._Code(">"),GTE:new se._Code(">="),LT:new se._Code("<"),LTE:new se._Code("<="),EQ:new se._Code("==="),NEQ:new se._Code("!=="),NOT:new se._Code("!"),OR:new se._Code("||"),AND:new se._Code("&&"),ADD:new se._Code("+")};var fr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Xl=class extends fr{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Dt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=io(this.rhs,e,r)),this}get names(){return this.rhs instanceof se._CodeOrName?this.rhs.names:{}}},na=class extends fr{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof se.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=io(this.rhs,e,r),this}get names(){let e=this.lhs instanceof se.Name?{}:{...this.lhs.names};return sa(e,this.rhs)}},Yl=class extends na{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Ql=class extends fr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ed=class extends fr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},td=class extends fr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},rd=class extends fr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=io(this.code,e,r),this}get names(){return this.code instanceof se._CodeOrName?this.code.names:{}}},fs=class extends fr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(QS(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>vn(e,r.names),{})}},mr=class extends fs{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},nd=class extends fs{},so=class extends mr{};so.kind="else";var _n=class t extends mr{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new so(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Rg(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=io(this.condition,e,r),this}get names(){let e=super.names;return sa(e,this.condition),this.else&&vn(e,this.else.names),e}};_n.kind="if";var yn=class extends mr{};yn.kind="for";var od=class extends yn{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=io(this.iteration,e,r),this}get names(){return vn(super.names,this.iteration.names)}},sd=class extends yn{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Dt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=sa(super.names,this.from);return sa(e,this.to)}},oa=class extends yn{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=io(this.iterable,e,r),this}get names(){return vn(super.names,this.iterable.names)}},ms=class extends mr{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ms.kind="func";var hs=class extends fs{render(e){return"return "+super.render(e)}};hs.kind="return";var id=class extends mr{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&vn(e,this.catch.names),this.finally&&vn(e,this.finally.names),e}},gs=class extends mr{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};gs.kind="catch";var _s=class extends mr{render(e){return"finally"+super.render(e)}};_s.kind="finally";var ad=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
- `:""},this._extScope=e,this._scope=new Dt.Scope({parent:e}),this._nodes=[new nd]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Xl(e,s,n)),s}const(e,r,n){return this._def(Dt.varKinds.const,e,r,n)}let(e,r,n){return this._def(Dt.varKinds.let,e,r,n)}var(e,r,n){return this._def(Dt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new na(e,r,n))}add(e,r){return this._leafNode(new Yl(e,J.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==se.nil&&this._leafNode(new rd(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,se.addCodeArg)(r,o));return r.push("}"),new se._Code(r)}if(e,r,n){if(this._blockNode(new _n(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new _n(e))}else(){return this._elseNode(new so)}endIf(){return this._endBlockNode(_n,so)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new od(e),r)}forRange(e,r,n,o,s=this.opts.es5?Dt.varKinds.var:Dt.varKinds.let){let i=this._scope.toName(e);return this._for(new sd(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Dt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof se.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,se._)`${i}.length`,a=>{this.var(s,(0,se._)`${i}[${a}]`),n(s)})}return this._for(new oa("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Dt.varKinds.var:Dt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,se._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new oa("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(yn)}label(e){return this._leafNode(new Ql(e))}break(e){return this._leafNode(new ed(e))}return(e){let r=new hs;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(hs)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new id;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new gs(s),r(s)}return n&&(this._currNode=o.finally=new _s,this.code(n)),this._endBlockNode(gs,_s)}throw(e){return this._leafNode(new td(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=se.nil,n,o){return this._blockNode(new ms(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ms)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof _n))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};J.CodeGen=ad;function vn(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function sa(t,e){return e instanceof se._CodeOrName?vn(t,e.names):t}function io(t,e,r){if(t instanceof se.Name)return n(t);if(!o(t))return t;return new se._Code(t._items.reduce((s,i)=>(i instanceof se.Name&&(i=n(i)),i instanceof se._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof se._Code&&s._items.some(i=>i instanceof se.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function QS(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Rg(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,se._)`!${cd(t)}`}J.not=Rg;var eE=Ig(J.operators.AND);function tE(...t){return t.reduce(eE)}J.and=tE;var rE=Ig(J.operators.OR);function nE(...t){return t.reduce(rE)}J.or=nE;function Ig(t){return(e,r)=>e===se.nil?r:r===se.nil?e:(0,se._)`${cd(e)} ${t} ${cd(r)}`}function cd(t){return t instanceof se.Name?t:(0,se._)`(${t})`}});var ie=S(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var ye=W(),oE=ps();function sE(t){let e={};for(let r of t)e[r]=!0;return e}Y.toHash=sE;function iE(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ng(t,e),!Ag(e,t.self.RULES.all))}Y.alwaysValidSchema=iE;function Ng(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||jg(t,`unknown keyword: "${s}"`)}Y.checkUnknownRules=Ng;function Ag(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Y.schemaHasRules=Ag;function aE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Y.schemaHasRulesButRef=aE;function cE({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${t}${e}${(0,ye.getProperty)(n)}`}Y.schemaRefOrVal=cE;function uE(t){return Cg(decodeURIComponent(t))}Y.unescapeFragment=uE;function lE(t){return encodeURIComponent(ld(t))}Y.escapeFragment=lE;function ld(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=ld;function Cg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Cg;function dE(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Y.eachItem=dE;function zg({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ye.Name?(s instanceof ye.Name?t(o,s,i):e(o,s,i),i):s instanceof ye.Name?(e(o,i,s),s):r(s,i);return a===ye.Name&&!(c instanceof ye.Name)?n(o,c):c}}Y.mergeEvaluated={props:zg({mergeNames:(t,e,r)=>t.if((0,ye._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ye._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ye._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ye._)`${r} || {}`),dd(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Mg}),items:zg({mergeNames:(t,e,r)=>t.if((0,ye._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ye._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ye._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ye._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Mg(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ye._)`{}`);return e!==void 0&&dd(t,r,e),r}Y.evaluatedPropsToName=Mg;function dd(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ye._)`${e}${(0,ye.getProperty)(n)}`,!0))}Y.setEvaluated=dd;var Og={};function pE(t,e){return t.scopeValue("func",{ref:e,code:Og[e.code]||(Og[e.code]=new oE._Code(e.code))})}Y.useFunc=pE;var ud;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ud||(Y.Type=ud={}));function fE(t,e,r){if(t instanceof ye.Name){let n=e===ud.Num;return r?n?(0,ye._)`"[" + ${t} + "]"`:(0,ye._)`"['" + ${t} + "']"`:n?(0,ye._)`"/" + ${t}`:(0,ye._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(t).toString():"/"+ld(t)}Y.getErrorPath=fE;function jg(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Y.checkStrictMode=jg});var hr=S(pd=>{"use strict";Object.defineProperty(pd,"__esModule",{value:!0});var Qe=W(),mE={data:new Qe.Name("data"),valCxt:new Qe.Name("valCxt"),instancePath:new Qe.Name("instancePath"),parentData:new Qe.Name("parentData"),parentDataProperty:new Qe.Name("parentDataProperty"),rootData:new Qe.Name("rootData"),dynamicAnchors:new Qe.Name("dynamicAnchors"),vErrors:new Qe.Name("vErrors"),errors:new Qe.Name("errors"),this:new Qe.Name("this"),self:new Qe.Name("self"),scope:new Qe.Name("scope"),json:new Qe.Name("json"),jsonPos:new Qe.Name("jsonPos"),jsonLen:new Qe.Name("jsonLen"),jsonPart:new Qe.Name("jsonPart")};pd.default=mE});var ys=S(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.extendErrors=et.resetErrorsCount=et.reportExtraError=et.reportError=et.keyword$DataError=et.keywordError=void 0;var ae=W(),aa=ie(),st=hr();et.keywordError={message:({keyword:t})=>(0,ae.str)`must pass "${t}" keyword validation`};et.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ae.str)`"${t}" keyword must be ${e} ($data)`:(0,ae.str)`"${t}" keyword is invalid ($data)`};function hE(t,e=et.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Zg(t,e,r);n??(i||a)?Dg(s,c):Lg(o,(0,ae._)`[${c}]`)}et.reportError=hE;function gE(t,e=et.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Zg(t,e,r);Dg(o,a),s||i||Lg(n,st.default.vErrors)}et.reportExtraError=gE;function _E(t,e){t.assign(st.default.errors,e),t.if((0,ae._)`${st.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ae._)`${st.default.vErrors}.length`,e),()=>t.assign(st.default.vErrors,null)))}et.resetErrorsCount=_E;function yE({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,st.default.errors,a=>{t.const(i,(0,ae._)`${st.default.vErrors}[${a}]`),t.if((0,ae._)`${i}.instancePath === undefined`,()=>t.assign((0,ae._)`${i}.instancePath`,(0,ae.strConcat)(st.default.instancePath,s.errorPath))),t.assign((0,ae._)`${i}.schemaPath`,(0,ae.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,ae._)`${i}.schema`,r),t.assign((0,ae._)`${i}.data`,n))})}et.extendErrors=yE;function Dg(t,e){let r=t.const("err",e);t.if((0,ae._)`${st.default.vErrors} === null`,()=>t.assign(st.default.vErrors,(0,ae._)`[${r}]`),(0,ae._)`${st.default.vErrors}.push(${r})`),t.code((0,ae._)`${st.default.errors}++`)}function Lg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,ae._)`new ${t.ValidationError}(${e})`):(r.assign((0,ae._)`${n}.errors`,e),r.return(!1))}var bn={keyword:new ae.Name("keyword"),schemaPath:new ae.Name("schemaPath"),params:new ae.Name("params"),propertyName:new ae.Name("propertyName"),message:new ae.Name("message"),schema:new ae.Name("schema"),parentSchema:new ae.Name("parentSchema")};function Zg(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ae._)`{}`:vE(t,e,r)}function vE(t,e,r={}){let{gen:n,it:o}=t,s=[bE(o,r),wE(t,r)];return xE(t,e,s),n.object(...s)}function bE({errorPath:t},{instancePath:e}){let r=e?(0,ae.str)`${t}${(0,aa.getErrorPath)(e,aa.Type.Str)}`:t;return[st.default.instancePath,(0,ae.strConcat)(st.default.instancePath,r)]}function wE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,ae.str)`${e}/${t}`;return r&&(o=(0,ae.str)`${o}${(0,aa.getErrorPath)(r,aa.Type.Str)}`),[bn.schemaPath,o]}function xE(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([bn.keyword,o],[bn.params,typeof e=="function"?e(t):e||(0,ae._)`{}`]),c.messages&&n.push([bn.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([bn.schema,i],[bn.parentSchema,(0,ae._)`${l}${d}`],[st.default.data,s]),u&&n.push([bn.propertyName,u])}});var qg=S(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.boolOrEmptySchema=ao.topBoolOrEmptySchema=void 0;var $E=ys(),SE=W(),EE=hr(),kE={message:"boolean schema is false"};function TE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Ug(t,!1):typeof r=="object"&&r.$async===!0?e.return(EE.default.data):(e.assign((0,SE._)`${n}.errors`,null),e.return(!0))}ao.topBoolOrEmptySchema=TE;function PE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Ug(t)):r.var(e,!0)}ao.boolOrEmptySchema=PE;function Ug(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,$E.reportError)(o,kE,void 0,e)}});var fd=S(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.getRules=co.isJSONType=void 0;var RE=["string","number","integer","boolean","null","object","array"],IE=new Set(RE);function zE(t){return typeof t=="string"&&IE.has(t)}co.isJSONType=zE;function OE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}co.getRules=OE});var md=S(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.shouldUseRule=Or.shouldUseGroup=Or.schemaHasRulesForType=void 0;function NE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Fg(t,n)}Or.schemaHasRulesForType=NE;function Fg(t,e){return e.rules.some(r=>Vg(t,r))}Or.shouldUseGroup=Fg;function Vg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Or.shouldUseRule=Vg});var vs=S(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.reportTypeError=tt.checkDataTypes=tt.checkDataType=tt.coerceAndCheckDataType=tt.getJSONTypes=tt.getSchemaTypes=tt.DataType=void 0;var AE=fd(),CE=md(),ME=ys(),B=W(),Hg=ie(),uo;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(uo||(tt.DataType=uo={}));function jE(t){let e=Gg(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}tt.getSchemaTypes=jE;function Gg(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(AE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}tt.getJSONTypes=Gg;function DE(t,e){let{gen:r,data:n,opts:o}=t,s=LE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,CE.schemaHasRulesForType)(t,e[0]));if(i){let a=gd(e,n,o.strictNumbers,uo.Wrong);r.if(a,()=>{s.length?ZE(t,e,s):_d(t)})}return i}tt.coerceAndCheckDataType=DE;var Bg=new Set(["string","number","integer","boolean","null"]);function LE(t,e){return e?t.filter(r=>Bg.has(r)||e==="array"&&r==="array"):[]}function ZE(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,B._)`typeof ${o}`),a=n.let("coerced",(0,B._)`undefined`);s.coerceTypes==="array"&&n.if((0,B._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,B._)`${o}[0]`).assign(i,(0,B._)`typeof ${o}`).if(gd(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,B._)`${a} !== undefined`);for(let u of r)(Bg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),_d(t),n.endIf(),n.if((0,B._)`${a} !== undefined`,()=>{n.assign(o,a),UE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,B._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,B._)`"" + ${o}`).elseIf((0,B._)`${o} === null`).assign(a,(0,B._)`""`);return;case"number":n.elseIf((0,B._)`${i} == "boolean" || ${o} === null
2
+ var zb=Object.create;var dc=Object.defineProperty;var Ob=Object.getOwnPropertyDescriptor;var Nb=Object.getOwnPropertyNames;var Ab=Object.getPrototypeOf,Cb=Object.prototype.hasOwnProperty;var Ks=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},pc=(t,e)=>{for(var r in e)dc(t,r,{get:e[r],enumerable:!0})},Mb=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Nb(e))!Cb.call(t,o)&&o!==r&&dc(t,o,{get:()=>e[o],enumerable:!(n=Ob(e,o))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?zb(Ab(t)):{},Mb(e||!t||!t.__esModule?dc(r,"default",{value:t,enumerable:!0}):r,t));var kf=$((PO,ir)=>{var fc=Ks("fs"),Js=Ks("path"),jb=Ks("os"),Db=Ks("crypto"),wf=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function Lb(){return wf[Math.floor(Math.random()*wf.length)]}function Dn(t){return typeof t=="string"?!["false","0","no","off",""].includes(t.toLowerCase()):!!t}function Zb(){return process.stdout.isTTY}function Ub(t){return Zb()?`\x1B[2m${t}\x1B[0m`:t}var qb=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Fb(t){let e={},r=t.toString();r=r.replace(/\r\n?/mg,`
3
+ `);let n;for(;(n=qb.exec(r))!=null;){let o=n[1],s=n[2]||"";s=s.trim();let i=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(s=s.replace(/\\n/g,`
4
+ `),s=s.replace(/\\r/g,"\r")),e[o]=s}return e}function Vb(t){t=t||{};let e=Ef(t);t.path=e;let r=Ze.configDotenv(t);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=$f(t).split(","),o=n.length,s;for(let i=0;i<o;i++)try{let a=n[i].trim(),c=Gb(r,a);s=Ze.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=o)throw a}return Ze.parse(s)}function Hb(t){console.error(`\u26A0 ${t}`)}function No(t){console.log(`\u2506 ${t}`)}function Sf(t){console.log(`\u25C7 ${t}`)}function $f(t){return t&&t.DOTENV_KEY&&t.DOTENV_KEY.length>0?t.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Gb(t,e){let r;try{r=new URL(e)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let o=r.searchParams.get("environment");if(!o){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let s=`DOTENV_VAULT_${o.toUpperCase()}`,i=t.parsed[s];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function Ef(t){let e=null;if(t&&t.path&&t.path.length>0)if(Array.isArray(t.path))for(let r of t.path)fc.existsSync(r)&&(e=r.endsWith(".vault")?r:`${r}.vault`);else e=t.path.endsWith(".vault")?t.path:`${t.path}.vault`;else e=Js.resolve(process.cwd(),".env.vault");return fc.existsSync(e)?e:null}function xf(t){return t[0]==="~"?Js.join(jb.homedir(),t.slice(1)):t}function Bb(t){let e=Dn(process.env.DOTENV_CONFIG_DEBUG||t&&t.debug),r=Dn(process.env.DOTENV_CONFIG_QUIET||t&&t.quiet);(e||!r)&&Sf("loading env from encrypted .env.vault");let n=Ze._parseVault(t),o=process.env;return t&&t.processEnv!=null&&(o=t.processEnv),Ze.populate(o,n,t),{parsed:n}}function Kb(t){let e=Js.resolve(process.cwd(),".env"),r="utf8",n=process.env;t&&t.processEnv!=null&&(n=t.processEnv);let o=Dn(n.DOTENV_CONFIG_DEBUG||t&&t.debug),s=Dn(n.DOTENV_CONFIG_QUIET||t&&t.quiet);t&&t.encoding?r=t.encoding:o&&No("no encoding is specified (UTF-8 is used by default)");let i=[e];if(t&&t.path)if(!Array.isArray(t.path))i=[xf(t.path)];else{i=[];for(let l of t.path)i.push(xf(l))}let a,c={};for(let l of i)try{let d=Ze.parse(fc.readFileSync(l,{encoding:r}));Ze.populate(c,d,t)}catch(d){o&&No(`failed to load ${l} ${d.message}`),a=d}let u=Ze.populate(n,c,t);if(o=Dn(n.DOTENV_CONFIG_DEBUG||o),s=Dn(n.DOTENV_CONFIG_QUIET||s),o||!s){let l=Object.keys(u).length,d=[];for(let h of i)try{let m=Js.relative(process.cwd(),h);d.push(m)}catch(m){o&&No(`failed to load ${h} ${m.message}`),a=m}Sf(`injected env (${l}) from ${d.join(",")} ${Ub(`// tip: ${Lb()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function Wb(t){if($f(t).length===0)return Ze.configDotenv(t);let e=Ef(t);return e?Ze._configVault(t):(Hb(`you set DOTENV_KEY but you are missing a .env.vault file at ${e}`),Ze.configDotenv(t))}function Jb(t,e){let r=Buffer.from(e.slice(-64),"hex"),n=Buffer.from(t,"base64"),o=n.subarray(0,12),s=n.subarray(-16);n=n.subarray(12,-16);try{let i=Db.createDecipheriv("aes-256-gcm",r,o);return i.setAuthTag(s),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(a||c){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(u){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw i}}function Xb(t,e,r={}){let n=!!(r&&r.debug),o=!!(r&&r.override),s={};if(typeof e!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(e))Object.prototype.hasOwnProperty.call(t,i)?(o===!0&&(t[i]=e[i],s[i]=e[i]),n&&No(o===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(t[i]=e[i],s[i]=e[i]);return s}var Ze={configDotenv:Kb,_configVault:Bb,_parseVault:Vb,config:Wb,decrypt:Jb,parse:Fb,populate:Xb};ir.exports.configDotenv=Ze.configDotenv;ir.exports._configVault=Ze._configVault;ir.exports._parseVault=Ze._parseVault;ir.exports.config=Ze.config;ir.exports.decrypt=Ze.decrypt;ir.exports.parse=Ze.parse;ir.exports.populate=Ze.populate;ir.exports=Ze});var Pf=$((RO,Tf)=>{var Hr={};process.env.DOTENV_CONFIG_ENCODING!=null&&(Hr.encoding=process.env.DOTENV_CONFIG_ENCODING);process.env.DOTENV_CONFIG_PATH!=null&&(Hr.path=process.env.DOTENV_CONFIG_PATH);process.env.DOTENV_CONFIG_QUIET!=null&&(Hr.quiet=process.env.DOTENV_CONFIG_QUIET);process.env.DOTENV_CONFIG_DEBUG!=null&&(Hr.debug=process.env.DOTENV_CONFIG_DEBUG);process.env.DOTENV_CONFIG_OVERRIDE!=null&&(Hr.override=process.env.DOTENV_CONFIG_OVERRIDE);process.env.DOTENV_CONFIG_DOTENV_KEY!=null&&(Hr.DOTENV_KEY=process.env.DOTENV_CONFIG_DOTENV_KEY);Tf.exports=Hr});var If=$((IO,Rf)=>{var Yb=/^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;Rf.exports=function(e){let r=e.reduce(function(n,o){let s=o.match(Yb);return s&&(n[s[1]]=s[2]),n},{});return"quiet"in r||(r.quiet="true"),r}});var ps=$(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.regexpCode=le.getEsmExportName=le.getProperty=le.safeStringify=le.stringify=le.strConcat=le.addCodeArg=le.str=le._=le.nil=le._Code=le.Name=le.IDENTIFIER=le._CodeOrName=void 0;var ls=class{};le._CodeOrName=ls;le.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var gn=class extends ls{constructor(e){if(super(),!le.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};le.Name=gn;var Rt=class extends ls{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof gn&&(r[n.str]=(r[n.str]||0)+1),r),{})}};le._Code=Rt;le.nil=new Rt("");function zg(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Bl(r,e[n]),r.push(t[++n]);return new Rt(r)}le._=zg;var Gl=new Rt("+");function Og(t,...e){let r=[ds(t[0])],n=0;for(;n<e.length;)r.push(Gl),Bl(r,e[n]),r.push(Gl,ds(t[++n]));return J$(r),new Rt(r)}le.str=Og;function Bl(t,e){e instanceof Rt?t.push(...e._items):e instanceof gn?t.push(e):t.push(Q$(e))}le.addCodeArg=Bl;function J$(t){let e=1;for(;e<t.length-1;){if(t[e]===Gl){let r=X$(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function X$(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof gn||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof gn))return`"${t}${e.slice(1)}`}function Y$(t,e){return e.emptyStr()?t:t.emptyStr()?e:Og`${t}${e}`}le.strConcat=Y$;function Q$(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ds(Array.isArray(t)?t.join(","):t)}function eE(t){return new Rt(ds(t))}le.stringify=eE;function ds(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}le.safeStringify=ds;function tE(t){return typeof t=="string"&&le.IDENTIFIER.test(t)?new Rt(`.${t}`):zg`[${t}]`}le.getProperty=tE;function rE(t){if(typeof t=="string"&&le.IDENTIFIER.test(t))return new Rt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}le.getEsmExportName=rE;function nE(t){return new Rt(t.toString())}le.regexpCode=nE});var Jl=$(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.ValueScope=ft.ValueScopeName=ft.Scope=ft.varKinds=ft.UsedValueState=void 0;var pt=ps(),Kl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},ea;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(ea||(ft.UsedValueState=ea={}));ft.varKinds={const:new pt.Name("const"),let:new pt.Name("let"),var:new pt.Name("var")};var ta=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof pt.Name?e:this.name(e)}name(e){return new pt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};ft.Scope=ta;var ra=class extends pt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,pt._)`.${new pt.Name(r)}[${n}]`}};ft.ValueScopeName=ra;var oE=(0,pt._)`\n`,Wl=class extends ta{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?oE:pt.nil}}get(){return this._scope}name(e){return new ra(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,pt._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=pt.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,ea.Started);let l=r(u);if(l){let d=this.opts.es5?ft.varKinds.var:ft.varKinds.const;s=(0,pt._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,pt._)`${s}${l}${this.opts._n}`;else throw new Kl(u);c.set(u,ea.Completed)})}return s}};ft.ValueScope=Wl});var W=$(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var se=ps(),Dt=Jl(),zr=ps();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return zr._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return zr.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return zr.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return zr.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return zr.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return zr.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return zr.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return zr.Name}});var ia=Jl();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return ia.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return ia.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return ia.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return ia.varKinds}});J.operators={GT:new se._Code(">"),GTE:new se._Code(">="),LT:new se._Code("<"),LTE:new se._Code("<="),EQ:new se._Code("==="),NEQ:new se._Code("!=="),NOT:new se._Code("!"),OR:new se._Code("||"),AND:new se._Code("&&"),ADD:new se._Code("+")};var fr=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Xl=class extends fr{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Dt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ao(this.rhs,e,r)),this}get names(){return this.rhs instanceof se._CodeOrName?this.rhs.names:{}}},na=class extends fr{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof se.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ao(this.rhs,e,r),this}get names(){let e=this.lhs instanceof se.Name?{}:{...this.lhs.names};return sa(e,this.rhs)}},Yl=class extends na{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Ql=class extends fr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ed=class extends fr{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},td=class extends fr{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},rd=class extends fr{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ao(this.code,e,r),this}get names(){return this.code instanceof se._CodeOrName?this.code.names:{}}},fs=class extends fr{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(sE(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>vn(e,r.names),{})}},mr=class extends fs{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},nd=class extends fs{},io=class extends mr{};io.kind="else";var _n=class t extends mr{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new io(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Ng(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ao(this.condition,e,r),this}get names(){let e=super.names;return sa(e,this.condition),this.else&&vn(e,this.else.names),e}};_n.kind="if";var yn=class extends mr{};yn.kind="for";var od=class extends yn{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ao(this.iteration,e,r),this}get names(){return vn(super.names,this.iteration.names)}},sd=class extends yn{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Dt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=sa(super.names,this.from);return sa(e,this.to)}},oa=class extends yn{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ao(this.iterable,e,r),this}get names(){return vn(super.names,this.iterable.names)}},ms=class extends mr{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ms.kind="func";var hs=class extends fs{render(e){return"return "+super.render(e)}};hs.kind="return";var id=class extends mr{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&vn(e,this.catch.names),this.finally&&vn(e,this.finally.names),e}},gs=class extends mr{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};gs.kind="catch";var _s=class extends mr{render(e){return"finally"+super.render(e)}};_s.kind="finally";var ad=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
+ `:""},this._extScope=e,this._scope=new Dt.Scope({parent:e}),this._nodes=[new nd]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Xl(e,s,n)),s}const(e,r,n){return this._def(Dt.varKinds.const,e,r,n)}let(e,r,n){return this._def(Dt.varKinds.let,e,r,n)}var(e,r,n){return this._def(Dt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new na(e,r,n))}add(e,r){return this._leafNode(new Yl(e,J.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==se.nil&&this._leafNode(new rd(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,se.addCodeArg)(r,o));return r.push("}"),new se._Code(r)}if(e,r,n){if(this._blockNode(new _n(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new _n(e))}else(){return this._elseNode(new io)}endIf(){return this._endBlockNode(_n,io)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new od(e),r)}forRange(e,r,n,o,s=this.opts.es5?Dt.varKinds.var:Dt.varKinds.let){let i=this._scope.toName(e);return this._for(new sd(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Dt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof se.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,se._)`${i}.length`,a=>{this.var(s,(0,se._)`${i}[${a}]`),n(s)})}return this._for(new oa("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Dt.varKinds.var:Dt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,se._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new oa("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(yn)}label(e){return this._leafNode(new Ql(e))}break(e){return this._leafNode(new ed(e))}return(e){let r=new hs;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(hs)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new id;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new gs(s),r(s)}return n&&(this._currNode=o.finally=new _s,this.code(n)),this._endBlockNode(gs,_s)}throw(e){return this._leafNode(new td(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=se.nil,n,o){return this._blockNode(new ms(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ms)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof _n))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};J.CodeGen=ad;function vn(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function sa(t,e){return e instanceof se._CodeOrName?vn(t,e.names):t}function ao(t,e,r){if(t instanceof se.Name)return n(t);if(!o(t))return t;return new se._Code(t._items.reduce((s,i)=>(i instanceof se.Name&&(i=n(i)),i instanceof se._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof se._Code&&s._items.some(i=>i instanceof se.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function sE(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Ng(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,se._)`!${cd(t)}`}J.not=Ng;var iE=Ag(J.operators.AND);function aE(...t){return t.reduce(iE)}J.and=aE;var cE=Ag(J.operators.OR);function uE(...t){return t.reduce(cE)}J.or=uE;function Ag(t){return(e,r)=>e===se.nil?r:r===se.nil?e:(0,se._)`${cd(e)} ${t} ${cd(r)}`}function cd(t){return t instanceof se.Name?t:(0,se._)`(${t})`}});var ie=$(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var ye=W(),lE=ps();function dE(t){let e={};for(let r of t)e[r]=!0;return e}Y.toHash=dE;function pE(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(jg(t,e),!Dg(e,t.self.RULES.all))}Y.alwaysValidSchema=pE;function jg(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||Ug(t,`unknown keyword: "${s}"`)}Y.checkUnknownRules=jg;function Dg(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Y.schemaHasRules=Dg;function fE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Y.schemaHasRulesButRef=fE;function mE({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${t}${e}${(0,ye.getProperty)(n)}`}Y.schemaRefOrVal=mE;function hE(t){return Lg(decodeURIComponent(t))}Y.unescapeFragment=hE;function gE(t){return encodeURIComponent(ld(t))}Y.escapeFragment=gE;function ld(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=ld;function Lg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Lg;function _E(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Y.eachItem=_E;function Cg({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ye.Name?(s instanceof ye.Name?t(o,s,i):e(o,s,i),i):s instanceof ye.Name?(e(o,i,s),s):r(s,i);return a===ye.Name&&!(c instanceof ye.Name)?n(o,c):c}}Y.mergeEvaluated={props:Cg({mergeNames:(t,e,r)=>t.if((0,ye._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ye._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ye._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ye._)`${r} || {}`),dd(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Zg}),items:Cg({mergeNames:(t,e,r)=>t.if((0,ye._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ye._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ye._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ye._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Zg(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ye._)`{}`);return e!==void 0&&dd(t,r,e),r}Y.evaluatedPropsToName=Zg;function dd(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ye._)`${e}${(0,ye.getProperty)(n)}`,!0))}Y.setEvaluated=dd;var Mg={};function yE(t,e){return t.scopeValue("func",{ref:e,code:Mg[e.code]||(Mg[e.code]=new lE._Code(e.code))})}Y.useFunc=yE;var ud;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ud||(Y.Type=ud={}));function vE(t,e,r){if(t instanceof ye.Name){let n=e===ud.Num;return r?n?(0,ye._)`"[" + ${t} + "]"`:(0,ye._)`"['" + ${t} + "']"`:n?(0,ye._)`"/" + ${t}`:(0,ye._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(t).toString():"/"+ld(t)}Y.getErrorPath=vE;function Ug(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Y.checkStrictMode=Ug});var hr=$(pd=>{"use strict";Object.defineProperty(pd,"__esModule",{value:!0});var Qe=W(),bE={data:new Qe.Name("data"),valCxt:new Qe.Name("valCxt"),instancePath:new Qe.Name("instancePath"),parentData:new Qe.Name("parentData"),parentDataProperty:new Qe.Name("parentDataProperty"),rootData:new Qe.Name("rootData"),dynamicAnchors:new Qe.Name("dynamicAnchors"),vErrors:new Qe.Name("vErrors"),errors:new Qe.Name("errors"),this:new Qe.Name("this"),self:new Qe.Name("self"),scope:new Qe.Name("scope"),json:new Qe.Name("json"),jsonPos:new Qe.Name("jsonPos"),jsonLen:new Qe.Name("jsonLen"),jsonPart:new Qe.Name("jsonPart")};pd.default=bE});var ys=$(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.extendErrors=et.resetErrorsCount=et.reportExtraError=et.reportError=et.keyword$DataError=et.keywordError=void 0;var ae=W(),aa=ie(),st=hr();et.keywordError={message:({keyword:t})=>(0,ae.str)`must pass "${t}" keyword validation`};et.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ae.str)`"${t}" keyword must be ${e} ($data)`:(0,ae.str)`"${t}" keyword is invalid ($data)`};function wE(t,e=et.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Vg(t,e,r);n??(i||a)?qg(s,c):Fg(o,(0,ae._)`[${c}]`)}et.reportError=wE;function xE(t,e=et.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Vg(t,e,r);qg(o,a),s||i||Fg(n,st.default.vErrors)}et.reportExtraError=xE;function SE(t,e){t.assign(st.default.errors,e),t.if((0,ae._)`${st.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ae._)`${st.default.vErrors}.length`,e),()=>t.assign(st.default.vErrors,null)))}et.resetErrorsCount=SE;function $E({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,st.default.errors,a=>{t.const(i,(0,ae._)`${st.default.vErrors}[${a}]`),t.if((0,ae._)`${i}.instancePath === undefined`,()=>t.assign((0,ae._)`${i}.instancePath`,(0,ae.strConcat)(st.default.instancePath,s.errorPath))),t.assign((0,ae._)`${i}.schemaPath`,(0,ae.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,ae._)`${i}.schema`,r),t.assign((0,ae._)`${i}.data`,n))})}et.extendErrors=$E;function qg(t,e){let r=t.const("err",e);t.if((0,ae._)`${st.default.vErrors} === null`,()=>t.assign(st.default.vErrors,(0,ae._)`[${r}]`),(0,ae._)`${st.default.vErrors}.push(${r})`),t.code((0,ae._)`${st.default.errors}++`)}function Fg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,ae._)`new ${t.ValidationError}(${e})`):(r.assign((0,ae._)`${n}.errors`,e),r.return(!1))}var bn={keyword:new ae.Name("keyword"),schemaPath:new ae.Name("schemaPath"),params:new ae.Name("params"),propertyName:new ae.Name("propertyName"),message:new ae.Name("message"),schema:new ae.Name("schema"),parentSchema:new ae.Name("parentSchema")};function Vg(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ae._)`{}`:EE(t,e,r)}function EE(t,e,r={}){let{gen:n,it:o}=t,s=[kE(o,r),TE(t,r)];return PE(t,e,s),n.object(...s)}function kE({errorPath:t},{instancePath:e}){let r=e?(0,ae.str)`${t}${(0,aa.getErrorPath)(e,aa.Type.Str)}`:t;return[st.default.instancePath,(0,ae.strConcat)(st.default.instancePath,r)]}function TE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,ae.str)`${e}/${t}`;return r&&(o=(0,ae.str)`${o}${(0,aa.getErrorPath)(r,aa.Type.Str)}`),[bn.schemaPath,o]}function PE(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([bn.keyword,o],[bn.params,typeof e=="function"?e(t):e||(0,ae._)`{}`]),c.messages&&n.push([bn.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([bn.schema,i],[bn.parentSchema,(0,ae._)`${l}${d}`],[st.default.data,s]),u&&n.push([bn.propertyName,u])}});var Gg=$(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.boolOrEmptySchema=co.topBoolOrEmptySchema=void 0;var RE=ys(),IE=W(),zE=hr(),OE={message:"boolean schema is false"};function NE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Hg(t,!1):typeof r=="object"&&r.$async===!0?e.return(zE.default.data):(e.assign((0,IE._)`${n}.errors`,null),e.return(!0))}co.topBoolOrEmptySchema=NE;function AE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Hg(t)):r.var(e,!0)}co.boolOrEmptySchema=AE;function Hg(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,RE.reportError)(o,OE,void 0,e)}});var fd=$(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.getRules=uo.isJSONType=void 0;var CE=["string","number","integer","boolean","null","object","array"],ME=new Set(CE);function jE(t){return typeof t=="string"&&ME.has(t)}uo.isJSONType=jE;function DE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}uo.getRules=DE});var md=$(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.shouldUseRule=Or.shouldUseGroup=Or.schemaHasRulesForType=void 0;function LE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Bg(t,n)}Or.schemaHasRulesForType=LE;function Bg(t,e){return e.rules.some(r=>Kg(t,r))}Or.shouldUseGroup=Bg;function Kg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Or.shouldUseRule=Kg});var vs=$(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.reportTypeError=tt.checkDataTypes=tt.checkDataType=tt.coerceAndCheckDataType=tt.getJSONTypes=tt.getSchemaTypes=tt.DataType=void 0;var ZE=fd(),UE=md(),qE=ys(),B=W(),Wg=ie(),lo;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(lo||(tt.DataType=lo={}));function FE(t){let e=Jg(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}tt.getSchemaTypes=FE;function Jg(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(ZE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}tt.getJSONTypes=Jg;function VE(t,e){let{gen:r,data:n,opts:o}=t,s=HE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,UE.schemaHasRulesForType)(t,e[0]));if(i){let a=gd(e,n,o.strictNumbers,lo.Wrong);r.if(a,()=>{s.length?GE(t,e,s):_d(t)})}return i}tt.coerceAndCheckDataType=VE;var Xg=new Set(["string","number","integer","boolean","null"]);function HE(t,e){return e?t.filter(r=>Xg.has(r)||e==="array"&&r==="array"):[]}function GE(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,B._)`typeof ${o}`),a=n.let("coerced",(0,B._)`undefined`);s.coerceTypes==="array"&&n.if((0,B._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,B._)`${o}[0]`).assign(i,(0,B._)`typeof ${o}`).if(gd(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,B._)`${a} !== undefined`);for(let u of r)(Xg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),_d(t),n.endIf(),n.if((0,B._)`${a} !== undefined`,()=>{n.assign(o,a),BE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,B._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,B._)`"" + ${o}`).elseIf((0,B._)`${o} === null`).assign(a,(0,B._)`""`);return;case"number":n.elseIf((0,B._)`${i} == "boolean" || ${o} === null
6
6
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,B._)`+${o}`);return;case"integer":n.elseIf((0,B._)`${i} === "boolean" || ${o} === null
7
7
  || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,B._)`+${o}`);return;case"boolean":n.elseIf((0,B._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,B._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,B._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,B._)`${i} === "string" || ${i} === "number"
8
- || ${i} === "boolean" || ${o} === null`).assign(a,(0,B._)`[${o}]`)}}}function UE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,B._)`${e} !== undefined`,()=>t.assign((0,B._)`${e}[${r}]`,n))}function hd(t,e,r,n=uo.Correct){let o=n===uo.Correct?B.operators.EQ:B.operators.NEQ,s;switch(t){case"null":return(0,B._)`${e} ${o} null`;case"array":s=(0,B._)`Array.isArray(${e})`;break;case"object":s=(0,B._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,B._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,B._)`typeof ${e} ${o} ${t}`}return n===uo.Correct?s:(0,B.not)(s);function i(a=B.nil){return(0,B.and)((0,B._)`typeof ${e} == "number"`,a,r?(0,B._)`isFinite(${e})`:B.nil)}}tt.checkDataType=hd;function gd(t,e,r,n){if(t.length===1)return hd(t[0],e,r,n);let o,s=(0,Hg.toHash)(t);if(s.array&&s.object){let i=(0,B._)`typeof ${e} != "object"`;o=s.null?i:(0,B._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=B.nil;s.number&&delete s.integer;for(let i in s)o=(0,B.and)(o,hd(i,e,r,n));return o}tt.checkDataTypes=gd;var qE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,B._)`{type: ${t}}`:(0,B._)`{type: ${e}}`};function _d(t){let e=FE(t);(0,ME.reportError)(e,qE)}tt.reportTypeError=_d;function FE(t){let{gen:e,data:r,schema:n}=t,o=(0,Hg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Wg=S(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.assignDefaults=void 0;var lo=W(),VE=ie();function HE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Kg(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Kg(t,s,o.default))}ca.assignDefaults=HE;function Kg(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,lo._)`${s}${(0,lo.getProperty)(e)}`;if(o){(0,VE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,lo._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,lo._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,lo._)`${a} = ${(0,lo.stringify)(r)}`)}});var It=S(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.validateUnion=ge.validateArray=ge.usePattern=ge.callValidateCode=ge.schemaProperties=ge.allSchemaProperties=ge.noPropertyInData=ge.propertyInData=ge.isOwnProperty=ge.hasPropFunc=ge.reportMissingProp=ge.checkMissingProp=ge.checkReportMissingProp=void 0;var ke=W(),yd=ie(),Nr=hr(),GE=ie();function BE(t,e){let{gen:r,data:n,it:o}=t;r.if(bd(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ke._)`${e}`},!0),t.error()})}ge.checkReportMissingProp=BE;function KE({gen:t,data:e,it:{opts:r}},n,o){return(0,ke.or)(...n.map(s=>(0,ke.and)(bd(t,e,s,r.ownProperties),(0,ke._)`${o} = ${s}`)))}ge.checkMissingProp=KE;function WE(t,e){t.setParams({missingProperty:e},!0),t.error()}ge.reportMissingProp=WE;function Jg(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ke._)`Object.prototype.hasOwnProperty`})}ge.hasPropFunc=Jg;function vd(t,e,r){return(0,ke._)`${Jg(t)}.call(${e}, ${r})`}ge.isOwnProperty=vd;function JE(t,e,r,n){let o=(0,ke._)`${e}${(0,ke.getProperty)(r)} !== undefined`;return n?(0,ke._)`${o} && ${vd(t,e,r)}`:o}ge.propertyInData=JE;function bd(t,e,r,n){let o=(0,ke._)`${e}${(0,ke.getProperty)(r)} === undefined`;return n?(0,ke.or)(o,(0,ke.not)(vd(t,e,r))):o}ge.noPropertyInData=bd;function Xg(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}ge.allSchemaProperties=Xg;function XE(t,e){return Xg(e).filter(r=>!(0,yd.alwaysValidSchema)(t,e[r]))}ge.schemaProperties=XE;function YE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ke._)`${t}, ${e}, ${n}${o}`:e,d=[[Nr.default.instancePath,(0,ke.strConcat)(Nr.default.instancePath,s)],[Nr.default.parentData,i.parentData],[Nr.default.parentDataProperty,i.parentDataProperty],[Nr.default.rootData,Nr.default.rootData]];i.opts.dynamicRef&&d.push([Nr.default.dynamicAnchors,Nr.default.dynamicAnchors]);let h=(0,ke._)`${l}, ${r.object(...d)}`;return c!==ke.nil?(0,ke._)`${a}.call(${c}, ${h})`:(0,ke._)`${a}(${h})`}ge.callValidateCode=YE;var QE=(0,ke._)`new RegExp`;function ek({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ke._)`${o.code==="new RegExp"?QE:(0,GE.useFunc)(t,o)}(${r}, ${n})`})}ge.usePattern=ek;function tk(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,ke._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:yd.Type.Num},s),e.if((0,ke.not)(s),a)})}}ge.validateArray=tk;function rk(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,yd.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ke._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ke.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}ge.validateUnion=rk});var e_=S(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.validateKeywordUsage=Kt.validSchemaType=Kt.funcKeywordCode=Kt.macroKeywordCode=void 0;var it=W(),wn=hr(),nk=It(),ok=ys();function sk(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Qg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:it.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Kt.macroKeywordCode=sk;function ik(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;ck(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Qg(n,o,u),d=n.let("valid");t.block$data(d,h),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function h(){if(e.errors===!1)f(),e.modifying&&Yg(t),g(()=>t.error());else{let _=e.async?m():p();e.modifying&&Yg(t),g(()=>ak(t,_))}}function m(){let _=n.let("ruleErrs",null);return n.try(()=>f((0,it._)`await `),v=>n.assign(d,!1).if((0,it._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(_,(0,it._)`${v}.errors`),()=>n.throw(v))),_}function p(){let _=(0,it._)`${l}.errors`;return n.assign(_,null),f(it.nil),_}function f(_=e.async?(0,it._)`await `:it.nil){let v=c.opts.passContext?wn.default.this:wn.default.self,$=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,it._)`${_}${(0,nk.callValidateCode)(t,l,v,$)}`,e.modifying)}function g(_){var v;n.if((0,it.not)((v=e.valid)!==null&&v!==void 0?v:d),_)}}Kt.funcKeywordCode=ik;function Yg(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,it._)`${n.parentData}[${n.parentDataProperty}]`))}function ak(t,e){let{gen:r}=t;r.if((0,it._)`Array.isArray(${e})`,()=>{r.assign(wn.default.vErrors,(0,it._)`${wn.default.vErrors} === null ? ${e} : ${wn.default.vErrors}.concat(${e})`).assign(wn.default.errors,(0,it._)`${wn.default.vErrors}.length`),(0,ok.extendErrors)(t)},()=>t.error())}function ck({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Qg(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,it.stringify)(r)})}function uk(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Kt.validSchemaType=uk;function lk({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Kt.validateKeywordUsage=lk});var r_=S(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.extendSubschemaMode=Ar.extendSubschemaData=Ar.getSubschema=void 0;var Wt=W(),t_=ie();function dk(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Wt._)`${t.schemaPath}${(0,Wt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Wt._)`${t.schemaPath}${(0,Wt.getProperty)(e)}${(0,Wt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,t_.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ar.getSubschema=dk;function pk(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,h=a.let("data",(0,Wt._)`${e.data}${(0,Wt.getProperty)(r)}`,!0);c(h),t.errorPath=(0,Wt.str)`${u}${(0,t_.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Wt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Wt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Ar.extendSubschemaData=pk;function fk(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Ar.extendSubschemaMode=fk});var wd=S((Kj,n_)=>{"use strict";n_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var s_=S((Wj,o_)=>{"use strict";var Cr=o_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};ua(e,n,o,t,"",t)};Cr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Cr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Cr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Cr.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 ua(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Cr.arrayKeywords)for(var h=0;h<d.length;h++)ua(t,e,r,d[h],o+"/"+l+"/"+h,s,o,l,n,h)}else if(l in Cr.propsKeywords){if(d&&typeof d=="object")for(var m in d)ua(t,e,r,d[m],o+"/"+l+"/"+mk(m),s,o,l,n,m)}else(l in Cr.keywords||t.allKeys&&!(l in Cr.skipKeywords))&&ua(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function mk(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var bs=S(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.getSchemaRefs=mt.resolveUrl=mt.normalizeId=mt._getFullPath=mt.getFullPath=mt.inlineRef=void 0;var hk=ie(),gk=wd(),_k=s_(),yk=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function vk(t,e=!0){return typeof t=="boolean"?!0:e===!0?!xd(t):e?i_(t)<=e:!1}mt.inlineRef=vk;var bk=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function xd(t){for(let e in t){if(bk.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(xd)||typeof r=="object"&&xd(r))return!0}return!1}function i_(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!yk.has(r)&&(typeof t[r]=="object"&&(0,hk.eachItem)(t[r],n=>e+=i_(n)),e===1/0))return 1/0}return e}function a_(t,e="",r){r!==!1&&(e=po(e));let n=t.parse(e);return c_(t,n)}mt.getFullPath=a_;function c_(t,e){return t.serialize(e).split("#")[0]+"#"}mt._getFullPath=c_;var wk=/#\/?$/;function po(t){return t?t.replace(wk,""):""}mt.normalizeId=po;function xk(t,e,r){return r=po(r),t.resolve(e,r)}mt.resolveUrl=xk;var $k=/^[a-z_][-a-z0-9._]*$/i;function Sk(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=po(t[r]||e),s={"":o},i=a_(n,o,!1),a={},c=new Set;return _k(t,{allKeys:!0},(d,h,m,p)=>{if(p===void 0)return;let f=i+h,g=s[p];typeof d[r]=="string"&&(g=_.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[h]=g;function _($){let y=this.opts.uriResolver.resolve;if($=po(g?y(g,$):$),c.has($))throw l($);c.add($);let T=this.refs[$];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?u(d,T.schema,$):$!==po(f)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=f),$}function v($){if(typeof $=="string"){if(!$k.test($))throw new Error(`invalid anchor "${$}"`);_.call(this,`#${$}`)}}}),a;function u(d,h,m){if(h!==void 0&&!gk(d,h))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}mt.getSchemaRefs=Sk});var $s=S(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.getData=Mr.KeywordCxt=Mr.validateFunctionCode=void 0;var f_=qg(),u_=vs(),Sd=md(),la=vs(),Ek=Wg(),xs=e_(),$d=r_(),C=W(),H=hr(),kk=bs(),gr=ie(),ws=ys();function Tk(t){if(g_(t)&&(__(t),h_(t))){Ik(t);return}m_(t,()=>(0,f_.topBoolOrEmptySchema)(t))}Mr.validateFunctionCode=Tk;function m_({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,C._)`${H.default.data}, ${H.default.valCxt}`,n.$async,()=>{t.code((0,C._)`"use strict"; ${l_(r,o)}`),Rk(t,o),t.code(s)}):t.func(e,(0,C._)`${H.default.data}, ${Pk(o)}`,n.$async,()=>t.code(l_(r,o)).code(s))}function Pk(t){return(0,C._)`{${H.default.instancePath}="", ${H.default.parentData}, ${H.default.parentDataProperty}, ${H.default.rootData}=${H.default.data}${t.dynamicRef?(0,C._)`, ${H.default.dynamicAnchors}={}`:C.nil}}={}`}function Rk(t,e){t.if(H.default.valCxt,()=>{t.var(H.default.instancePath,(0,C._)`${H.default.valCxt}.${H.default.instancePath}`),t.var(H.default.parentData,(0,C._)`${H.default.valCxt}.${H.default.parentData}`),t.var(H.default.parentDataProperty,(0,C._)`${H.default.valCxt}.${H.default.parentDataProperty}`),t.var(H.default.rootData,(0,C._)`${H.default.valCxt}.${H.default.rootData}`),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,C._)`${H.default.valCxt}.${H.default.dynamicAnchors}`)},()=>{t.var(H.default.instancePath,(0,C._)`""`),t.var(H.default.parentData,(0,C._)`undefined`),t.var(H.default.parentDataProperty,(0,C._)`undefined`),t.var(H.default.rootData,H.default.data),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,C._)`{}`)})}function Ik(t){let{schema:e,opts:r,gen:n}=t;m_(t,()=>{r.$comment&&e.$comment&&v_(t),Ck(t),n.let(H.default.vErrors,null),n.let(H.default.errors,0),r.unevaluated&&zk(t),y_(t),Dk(t)})}function zk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,C._)`${r}.evaluated`),e.if((0,C._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,C._)`${t.evaluated}.props`,(0,C._)`undefined`)),e.if((0,C._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,C._)`${t.evaluated}.items`,(0,C._)`undefined`))}function l_(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,C._)`/*# sourceURL=${r} */`:C.nil}function Ok(t,e){if(g_(t)&&(__(t),h_(t))){Nk(t,e);return}(0,f_.boolOrEmptySchema)(t,e)}function h_({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function g_(t){return typeof t.schema!="boolean"}function Nk(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&v_(t),Mk(t),jk(t);let s=n.const("_errs",H.default.errors);y_(t,s),n.var(e,(0,C._)`${s} === ${H.default.errors}`)}function __(t){(0,gr.checkUnknownRules)(t),Ak(t)}function y_(t,e){if(t.opts.jtd)return d_(t,[],!1,e);let r=(0,u_.getSchemaTypes)(t.schema),n=(0,u_.coerceAndCheckDataType)(t,r);d_(t,r,!n,e)}function Ak(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,gr.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ck(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,gr.checkStrictMode)(t,"default is ignored in the schema root")}function Mk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,kk.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function jk(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function v_({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,C._)`${H.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,C.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,C._)`${H.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Dk(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,C._)`${H.default.errors} === 0`,()=>e.return(H.default.data),()=>e.throw((0,C._)`new ${o}(${H.default.vErrors})`)):(e.assign((0,C._)`${n}.errors`,H.default.vErrors),s.unevaluated&&Lk(t),e.return((0,C._)`${H.default.errors} === 0`))}function Lk({gen:t,evaluated:e,props:r,items:n}){r instanceof C.Name&&t.assign((0,C._)`${e}.props`,r),n instanceof C.Name&&t.assign((0,C._)`${e}.items`,n)}function d_(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,gr.schemaHasRulesButRef)(s,l))){o.block(()=>w_(t,"$ref",l.all.$ref.definition));return}c.jtd||Zk(t,e),o.block(()=>{for(let h of l.rules)d(h);d(l.post)});function d(h){(0,Sd.shouldUseGroup)(s,h)&&(h.type?(o.if((0,la.checkDataType)(h.type,i,c.strictNumbers)),p_(t,h),e.length===1&&e[0]===h.type&&r&&(o.else(),(0,la.reportTypeError)(t)),o.endIf()):p_(t,h),a||o.if((0,C._)`${H.default.errors} === ${n||0}`))}}function p_(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,Ek.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Sd.shouldUseRule)(n,s)&&w_(t,s.keyword,s.definition,e.type)})}function Zk(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Uk(t,e),t.opts.allowUnionTypes||qk(t,e),Fk(t,t.dataTypes))}function Uk(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{b_(t.dataTypes,r)||Ed(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Hk(t,e)}}function qk(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ed(t,"use allowUnionTypes to allow union type keyword")}function Fk(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Sd.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Vk(e,i))&&Ed(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Vk(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function b_(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Hk(t,e){let r=[];for(let n of t.dataTypes)b_(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ed(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,gr.checkStrictMode)(t,e,t.opts.strictTypes)}var da=class{constructor(e,r,n){if((0,xs.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,gr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",x_(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,xs.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",H.default.errors))}result(e,r,n){this.failResult((0,C.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,C.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,C._)`${r} !== undefined && (${(0,C.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?ws.reportExtraError:ws.reportError)(this,this.def.error,r)}$dataError(){(0,ws.reportError)(this,this.def.$dataError||ws.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ws.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=C.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=C.nil,r=C.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,C.or)((0,C._)`${o} === undefined`,r)),e!==C.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==C.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,C.or)(i(),a());function i(){if(n.length){if(!(r instanceof C.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,C._)`${(0,la.checkDataTypes)(c,r,s.opts.strictNumbers,la.DataType.Wrong)}`}return C.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,C._)`!${c}(${r})`}return C.nil}}subschema(e,r){let n=(0,$d.getSubschema)(this.it,e);(0,$d.extendSubschemaData)(n,this.it,e),(0,$d.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Ok(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=gr.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=gr.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,C.Name)),!0}};Mr.KeywordCxt=da;function w_(t,e,r,n){let o=new da(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,xs.funcKeywordCode)(o,r):"macro"in r?(0,xs.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,xs.funcKeywordCode)(o,r)}var Gk=/^\/(?:[^~]|~0|~1)*$/,Bk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x_(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return H.default.rootData;if(t[0]==="/"){if(!Gk.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=H.default.rootData}else{let u=Bk.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,C._)`${s}${(0,C.getProperty)((0,gr.unescapeJsonPointer)(u))}`,i=(0,C._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Mr.getData=x_});var pa=S(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});var kd=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Td.default=kd});var Ss=S(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});var Pd=bs(),Rd=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Pd.resolveUrl)(e,r,n),this.missingSchema=(0,Pd.normalizeId)((0,Pd.getFullPath)(e,this.missingRef))}};Id.default=Rd});var ma=S(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.resolveSchema=zt.getCompilingSchema=zt.resolveRef=zt.compileSchema=zt.SchemaEnv=void 0;var Lt=W(),Kk=pa(),xn=hr(),Zt=bs(),$_=ie(),Wk=$s(),fo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Zt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};zt.SchemaEnv=fo;function Od(t){let e=S_.call(this,t);if(e)return e;let r=(0,Zt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Lt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Kk.default,code:(0,Lt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:xn.default.data,parentData:xn.default.parentData,parentDataProperty:xn.default.parentDataProperty,dataNames:[xn.default.data],dataPathArr:[Lt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Lt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Lt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Lt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Wk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(xn.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${xn.default.self}`,`${xn.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:p,items:f}=u;m.evaluated={props:p instanceof Lt.Name?void 0:p,items:f instanceof Lt.Name?void 0:f,dynamicProps:p instanceof Lt.Name,dynamicItems:f instanceof Lt.Name},m.source&&(m.source.evaluated=(0,Lt.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}zt.compileSchema=Od;function Jk(t,e,r){var n;r=(0,Zt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Qk.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new fo({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Xk.call(this,s)}zt.resolveRef=Jk;function Xk(t){return(0,Zt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Od.call(this,t)}function S_(t){for(let e of this._compilations)if(Yk(e,t))return e}zt.getCompilingSchema=S_;function Yk(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Qk(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||fa.call(this,t,e)}function fa(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Zt._getFullPath)(this.opts.uriResolver,r),o=(0,Zt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return zd.call(this,r,t);let s=(0,Zt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=fa.call(this,t,i);return typeof a?.schema!="object"?void 0:zd.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Od.call(this,i),s===(0,Zt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Zt.resolveUrl)(this.opts.uriResolver,o,u)),new fo({schema:a,schemaId:c,root:t,baseId:o})}return zd.call(this,r,i)}}zt.resolveSchema=fa;var eT=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function zd(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,$_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!eT.has(a)&&u&&(e=(0,Zt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,$_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Zt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=fa.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new fo({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var E_=S((tD,tT)=>{tT.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 Cd=S((rD,z_)=>{"use strict";var rT=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),T_=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),Nd=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),P_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),nT=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ad(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var oT=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function k_(t){return t.length=0,!0}function sT(t,e,r){if(t.length){let n=Ad(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function iT(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=sT;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=k_}else{o.push(u);continue}}return o.length&&(a===k_?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ad(o))),r.address=n.join(""),r}function R_(t){if(aT(t,":")<2)return{host:t,isIPV6:!1};let e=iT(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function aT(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function cT(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var uT={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},lT=/[@/?#:]/g,dT=/[@/?#]/g;function I_(t,e){let r=e?dT:lT;return r.lastIndex=0,t.replace(r,n=>uT[n])}function pT(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Nd(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&P_(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function fT(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Nd(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&P_(s)?e+=s:e+="%"+o,r+=2;continue}}nT(t[r])?e+=t[r]:e+=escape(t[r])}return e}function mT(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Nd(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function hT(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!T_(r)){let n=R_(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=I_(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}z_.exports={nonSimpleDomain:oT,recomposeAuthority:hT,reescapeHostDelimiters:I_,normalizePercentEncoding:pT,normalizePathEncoding:fT,escapePreservingEscapes:mT,removeDotSegments:cT,isIPv4:T_,isUUID:rT,normalizeIPv6:R_,stringArrayToHexStripped:Ad}});var M_=S((nD,C_)=>{"use strict";var{isUUID:gT}=Cd(),_T=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,yT=["http","https","ws","wss","urn","urn:uuid"];function vT(t){return yT.indexOf(t)!==-1}function Md(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function O_(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function N_(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function bT(t){return t.secure=Md(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function wT(t){if((t.port===(Md(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function xT(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(_T);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=jd(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function $T(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=jd(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function ST(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!gT(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function ET(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var A_={scheme:"http",domainHost:!0,parse:O_,serialize:N_},kT={scheme:"https",domainHost:A_.domainHost,parse:O_,serialize:N_},ha={scheme:"ws",domainHost:!0,parse:bT,serialize:wT},TT={scheme:"wss",domainHost:ha.domainHost,parse:ha.parse,serialize:ha.serialize},PT={scheme:"urn",parse:xT,serialize:$T,skipNormalize:!0},RT={scheme:"urn:uuid",parse:ST,serialize:ET,skipNormalize:!0},ga={http:A_,https:kT,ws:ha,wss:TT,urn:PT,"urn:uuid":RT};Object.setPrototypeOf(ga,null);function jd(t){return t&&(ga[t]||ga[t.toLowerCase()])||void 0}C_.exports={wsIsSecure:Md,SCHEMES:ga,isValidSchemeName:vT,getSchemeHandler:jd}});var q_=S((oD,_a)=>{"use strict";var{normalizeIPv6:IT,removeDotSegments:Es,recomposeAuthority:zT,normalizePercentEncoding:OT,normalizePathEncoding:NT,escapePreservingEscapes:AT,reescapeHostDelimiters:CT,isIPv4:MT,nonSimpleDomain:jT}=Cd(),{SCHEMES:DT,getSchemeHandler:D_}=M_();function LT(t,e){return typeof t=="string"?t=VT(t,e):typeof t=="object"&&(t=mo($n(t,e),e)),t}function ZT(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=L_(mo(t,n),mo(e,n),n,!0);return n.skipEscape=!0,$n(o,n)}function L_(t,e,r,n){let o={};return n||(t=mo($n(t,r),r),e=mo($n(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Es(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Es(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Es(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=Es(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function UT(t,e,r){let n=j_(t,r),o=j_(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function $n(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=D_(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=OT(r.path):(r.path=AT(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=zT(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=Es(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var qT=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function FT(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Z_(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(qT);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=FT(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(MT(n.host)===!1){let l=IT(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=D_(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&jT(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=CT(unescape(n.host),s))),n.path&&(n.path=NT(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function mo(t,e){return Z_(t,e).parsed}function VT(t,e){return U_(t,e).normalized}function U_(t,e){let{parsed:r,malformedAuthorityOrPort:n}=Z_(t,e);return{normalized:n?t:$n(r,e),malformedAuthorityOrPort:n}}function j_(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=U_(t,e);return n?void 0:r}if(typeof t=="object")return $n(t,e)}var Dd={SCHEMES:DT,normalize:LT,resolve:ZT,resolveComponent:L_,equal:UT,serialize:$n,parse:mo};_a.exports=Dd;_a.exports.default=Dd;_a.exports.fastUri=Dd});var V_=S(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});var F_=q_();F_.code='require("ajv/dist/runtime/uri").default';Ld.default=F_});var Y_=S(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.CodeGen=We.Name=We.nil=We.stringify=We.str=We._=We.KeywordCxt=void 0;var HT=$s();Object.defineProperty(We,"KeywordCxt",{enumerable:!0,get:function(){return HT.KeywordCxt}});var ho=W();Object.defineProperty(We,"_",{enumerable:!0,get:function(){return ho._}});Object.defineProperty(We,"str",{enumerable:!0,get:function(){return ho.str}});Object.defineProperty(We,"stringify",{enumerable:!0,get:function(){return ho.stringify}});Object.defineProperty(We,"nil",{enumerable:!0,get:function(){return ho.nil}});Object.defineProperty(We,"Name",{enumerable:!0,get:function(){return ho.Name}});Object.defineProperty(We,"CodeGen",{enumerable:!0,get:function(){return ho.CodeGen}});var GT=pa(),W_=Ss(),BT=fd(),ks=ma(),KT=W(),Ts=bs(),ya=vs(),Ud=ie(),H_=E_(),WT=V_(),J_=(t,e)=>new RegExp(t,e);J_.code="new RegExp";var JT=["removeAdditional","useDefaults","coerceTypes"],XT=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),YT={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."},QT={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G_=200;function eP(t){var e,r,n,o,s,i,a,c,u,l,d,h,m,p,f,g,_,v,$,y,T,F,te,Xe,q;let ce=t.strict,Ce=(e=t.code)===null||e===void 0?void 0:e.optimize,Q=Ce===!0||Ce===void 0?1:Ce||0,er=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:J_,tr=(o=t.uriResolver)!==null&&o!==void 0?o:WT.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ce)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ce)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ce)!==null&&l!==void 0?l:"log",strictTuples:(h=(d=t.strictTuples)!==null&&d!==void 0?d:ce)!==null&&h!==void 0?h:"log",strictRequired:(p=(m=t.strictRequired)!==null&&m!==void 0?m:ce)!==null&&p!==void 0?p:!1,code:t.code?{...t.code,optimize:Q,regExp:er}:{optimize:Q,regExp:er},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:G_,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:G_,meta:(_=t.meta)!==null&&_!==void 0?_:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:($=t.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(y=t.schemaId)!==null&&y!==void 0?y:"$id",addUsedSchema:(T=t.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(F=t.validateSchema)!==null&&F!==void 0?F:!0,validateFormats:(te=t.validateFormats)!==null&&te!==void 0?te:!0,unicodeRegExp:(Xe=t.unicodeRegExp)!==null&&Xe!==void 0?Xe:!0,int32range:(q=t.int32range)!==null&&q!==void 0?q:!0,uriResolver:tr}}var Ps=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...eP(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new KT.ValueScope({scope:{},prefixes:XT,es5:r,lines:n}),this.logger=iP(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,BT.getRules)(),B_.call(this,YT,e,"NOT SUPPORTED"),B_.call(this,QT,e,"DEPRECATED","warn"),this._metaOpts=oP.call(this),e.formats&&rP.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&nP.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),tP.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=H_;n==="id"&&(o={...H_},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let h=this._addSchema(l,d);return h.validate||i.call(this,h)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof W_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Ts.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=K_.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ks.SchemaEnv({schema:{},schemaId:n});if(r=ks.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=K_.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Ts.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(cP.call(this,n,r),!r)return(0,Ud.eachItem)(n,s=>Zd.call(this,s)),this;lP.call(this,r);let o={...r,type:(0,ya.getJSONTypes)(r.type),schemaType:(0,ya.getJSONTypes)(r.schemaType)};return(0,Ud.eachItem)(n,o.type.length===0?s=>Zd.call(this,s,o):s=>o.type.forEach(i=>Zd.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=X_(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Ts.normalizeId)(i||n);let u=Ts.getSchemaRefs.call(this,e,n);return c=new ks.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ks.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ks.compileSchema.call(this,e)}finally{this.opts=r}}};Ps.ValidationError=GT.default;Ps.MissingRefError=W_.default;We.default=Ps;function B_(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function K_(t){return t=(0,Ts.normalizeId)(t),this.schemas[t]||this.refs[t]}function tP(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function rP(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function nP(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function oP(){let t={...this.opts};for(let e of JT)delete t[e];return t}var sP={log(){},warn(){},error(){}};function iP(t){if(t===!1)return sP;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var aP=/^[a-z_$][a-z0-9_$:-]*$/i;function cP(t,e){let{RULES:r}=this;if((0,Ud.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!aP.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Zd(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ya.getJSONTypes)(e.type),schemaType:(0,ya.getJSONTypes)(e.schemaType)}};e.before?uP.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function uP(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function lP(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=X_(e)),t.validateSchema=this.compile(e,!0))}var dP={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function X_(t){return{anyOf:[t,dP]}}});var Q_=S(qd=>{"use strict";Object.defineProperty(qd,"__esModule",{value:!0});var pP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};qd.default=pP});var ny=S(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.callRef=Sn.getValidate=void 0;var fP=Ss(),ey=It(),ht=W(),go=hr(),ty=ma(),va=ie(),mP={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=ty.resolveRef.call(c,u,o,r);if(l===void 0)throw new fP.default(n.opts.uriResolver,o,r);if(l instanceof ty.SchemaEnv)return h(l);return m(l);function d(){if(s===u)return ba(t,i,s,s.$async);let p=e.scopeValue("root",{ref:u});return ba(t,(0,ht._)`${p}.validate`,u,u.$async)}function h(p){let f=ry(t,p);ba(t,f,p,p.$async)}function m(p){let f=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,ht.stringify)(p)}:{ref:p}),g=e.name("valid"),_=t.subschema({schema:p,dataTypes:[],schemaPath:ht.nil,topSchemaRef:f,errSchemaPath:r},g);t.mergeEvaluated(_),t.ok(g)}}};function ry(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,ht._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Sn.getValidate=ry;function ba(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?go.default.this:ht.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=o.let("valid");o.try(()=>{o.code((0,ht._)`await ${(0,ey.callValidateCode)(t,e,u)}`),m(e),i||o.assign(p,!0)},f=>{o.if((0,ht._)`!(${f} instanceof ${s.ValidationError})`,()=>o.throw(f)),h(f),i||o.assign(p,!1)}),t.ok(p)}function d(){t.result((0,ey.callValidateCode)(t,e,u),()=>m(e),()=>h(e))}function h(p){let f=(0,ht._)`${p}.errors`;o.assign(go.default.vErrors,(0,ht._)`${go.default.vErrors} === null ? ${f} : ${go.default.vErrors}.concat(${f})`),o.assign(go.default.errors,(0,ht._)`${go.default.vErrors}.length`)}function m(p){var f;if(!s.opts.unevaluated)return;let g=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=va.mergeEvaluated.props(o,g.props,s.props));else{let _=o.var("props",(0,ht._)`${p}.evaluated.props`);s.props=va.mergeEvaluated.props(o,_,s.props,ht.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=va.mergeEvaluated.items(o,g.items,s.items));else{let _=o.var("items",(0,ht._)`${p}.evaluated.items`);s.items=va.mergeEvaluated.items(o,_,s.items,ht.Name)}}}Sn.callRef=ba;Sn.default=mP});var oy=S(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});var hP=Q_(),gP=ny(),_P=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",hP.default,gP.default];Fd.default=_P});var sy=S(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});var wa=W(),jr=wa.operators,xa={maximum:{okStr:"<=",ok:jr.LTE,fail:jr.GT},minimum:{okStr:">=",ok:jr.GTE,fail:jr.LT},exclusiveMaximum:{okStr:"<",ok:jr.LT,fail:jr.GTE},exclusiveMinimum:{okStr:">",ok:jr.GT,fail:jr.LTE}},yP={message:({keyword:t,schemaCode:e})=>(0,wa.str)`must be ${xa[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,wa._)`{comparison: ${xa[t].okStr}, limit: ${e}}`},vP={keyword:Object.keys(xa),type:"number",schemaType:"number",$data:!0,error:yP,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,wa._)`${r} ${xa[e].fail} ${n} || isNaN(${r})`)}};Vd.default=vP});var iy=S(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});var Rs=W(),bP={message:({schemaCode:t})=>(0,Rs.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Rs._)`{multipleOf: ${t}}`},wP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:bP,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Rs._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Rs._)`${i} !== parseInt(${i})`;t.fail$data((0,Rs._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Hd.default=wP});var cy=S(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});function ay(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}Gd.default=ay;ay.code='require("ajv/dist/runtime/ucs2length").default'});var uy=S(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});var En=W(),xP=ie(),$P=cy(),SP={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,En.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,En._)`{limit: ${t}}`},EP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:SP,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?En.operators.GT:En.operators.LT,i=o.opts.unicode===!1?(0,En._)`${r}.length`:(0,En._)`${(0,xP.useFunc)(t.gen,$P.default)}(${r})`;t.fail$data((0,En._)`${i} ${s} ${n}`)}};Bd.default=EP});var ly=S(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});var kP=It(),TP=ie(),_o=W(),PP={message:({schemaCode:t})=>(0,_o.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,_o._)`{pattern: ${t}}`},RP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:PP,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,_o._)`new RegExp`:(0,TP.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,_o._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,_o._)`!${l}`)}else{let c=(0,kP.usePattern)(t,o);t.fail$data((0,_o._)`!${c}.test(${r})`)}}};Kd.default=RP});var dy=S(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});var Is=W(),IP={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Is.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Is._)`{limit: ${t}}`},zP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:IP,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Is.operators.GT:Is.operators.LT;t.fail$data((0,Is._)`Object.keys(${r}).length ${o} ${n}`)}};Wd.default=zP});var py=S(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});var zs=It(),Os=W(),OP=ie(),NP={message:({params:{missingProperty:t}})=>(0,Os.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Os._)`{missingProperty: ${t}}`},AP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:NP,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:p}=t.it;for(let f of r)if(m?.[f]===void 0&&!p.has(f)){let g=i.schemaEnv.baseId+i.errSchemaPath,_=`required property "${f}" is not defined at "${g}" (strictRequired)`;(0,OP.checkStrictMode)(i,_,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Os.nil,d);else for(let m of r)(0,zs.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let p=e.let("valid",!0);t.block$data(p,()=>h(m,p)),t.ok(p)}else e.if((0,zs.checkMissingProp)(t,r,m)),(0,zs.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,zs.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function h(m,p){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(p,(0,zs.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Os.not)(p),()=>{t.error(),e.break()})},Os.nil)}}};Jd.default=AP});var fy=S(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});var Ns=W(),CP={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Ns.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Ns._)`{limit: ${t}}`},MP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:CP,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Ns.operators.GT:Ns.operators.LT;t.fail$data((0,Ns._)`${r}.length ${o} ${n}`)}};Xd.default=MP});var $a=S(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});var my=wd();my.code='require("ajv/dist/runtime/equal").default';Yd.default=my});var hy=S(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var Qd=vs(),Je=W(),jP=ie(),DP=$a(),LP={message:({params:{i:t,j:e}})=>(0,Je.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Je._)`{i: ${t}, j: ${e}}`},ZP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:LP,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Qd.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Je._)`${i} === false`),t.ok(c);function l(){let p=e.let("i",(0,Je._)`${r}.length`),f=e.let("j");t.setParams({i:p,j:f}),e.assign(c,!0),e.if((0,Je._)`${p} > 1`,()=>(d()?h:m)(p,f))}function d(){return u.length>0&&!u.some(p=>p==="object"||p==="array")}function h(p,f){let g=e.name("item"),_=(0,Qd.checkDataTypes)(u,g,a.opts.strictNumbers,Qd.DataType.Wrong),v=e.const("indices",(0,Je._)`{}`);e.for((0,Je._)`;${p}--;`,()=>{e.let(g,(0,Je._)`${r}[${p}]`),e.if(_,(0,Je._)`continue`),u.length>1&&e.if((0,Je._)`typeof ${g} == "string"`,(0,Je._)`${g} += "_"`),e.if((0,Je._)`typeof ${v}[${g}] == "number"`,()=>{e.assign(f,(0,Je._)`${v}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Je._)`${v}[${g}] = ${p}`)})}function m(p,f){let g=(0,jP.useFunc)(e,DP.default),_=e.name("outer");e.label(_).for((0,Je._)`;${p}--;`,()=>e.for((0,Je._)`${f} = ${p}; ${f}--;`,()=>e.if((0,Je._)`${g}(${r}[${p}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(_)})))}}};ep.default=ZP});var gy=S(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var tp=W(),UP=ie(),qP=$a(),FP={message:"must be equal to constant",params:({schemaCode:t})=>(0,tp._)`{allowedValue: ${t}}`},VP={keyword:"const",$data:!0,error:FP,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,tp._)`!${(0,UP.useFunc)(e,qP.default)}(${r}, ${o})`):t.fail((0,tp._)`${s} !== ${r}`)}};rp.default=VP});var _y=S(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});var As=W(),HP=ie(),GP=$a(),BP={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,As._)`{allowedValues: ${t}}`},KP={keyword:"enum",schemaType:"array",$data:!0,error:BP,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,HP.useFunc)(e,GP.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,As.or)(...o.map((p,f)=>h(m,f)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,As._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function h(m,p){let f=o[p];return typeof f=="object"&&f!==null?(0,As._)`${u()}(${r}, ${m}[${p}])`:(0,As._)`${r} === ${f}`}}};np.default=KP});var yy=S(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});var WP=sy(),JP=iy(),XP=uy(),YP=ly(),QP=dy(),eR=py(),tR=fy(),rR=hy(),nR=gy(),oR=_y(),sR=[WP.default,JP.default,XP.default,YP.default,QP.default,eR.default,tR.default,rR.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},nR.default,oR.default];op.default=sR});var ip=S(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.validateAdditionalItems=void 0;var kn=W(),sp=ie(),iR={message:({params:{len:t}})=>(0,kn.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,kn._)`{limit: ${t}}`},aR={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:iR,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,sp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}vy(t,n)}};function vy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,kn._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,kn._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,sp.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,kn._)`${a} <= ${e.length}`);r.if((0,kn.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:sp.Type.Num},u),i.allErrors||r.if((0,kn.not)(u),()=>r.break())})}}Cs.validateAdditionalItems=vy;Cs.default=aR});var ap=S(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.validateTuple=void 0;var by=W(),Sa=ie(),cR=It(),uR={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return wy(t,"additionalItems",e);r.items=!0,!(0,Sa.alwaysValidSchema)(r,e)&&t.ok((0,cR.validateArray)(t))}};function wy(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Sa.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,by._)`${s}.length`);r.forEach((d,h)=>{(0,Sa.alwaysValidSchema)(a,d)||(n.if((0,by._)`${u} > ${h}`,()=>t.subschema({keyword:i,schemaProp:h,dataProp:h},c)),t.ok(c))});function l(d){let{opts:h,errSchemaPath:m}=a,p=r.length,f=p===d.minItems&&(p===d.maxItems||d[e]===!1);if(h.strictTuples&&!f){let g=`"${i}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,Sa.checkStrictMode)(a,g,h.strictTuples)}}}Ms.validateTuple=wy;Ms.default=uR});var xy=S(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});var lR=ap(),dR={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,lR.validateTuple)(t,"items")};cp.default=dR});var Sy=S(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});var $y=W(),pR=ie(),fR=It(),mR=ip(),hR={message:({params:{len:t}})=>(0,$y.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,$y._)`{limit: ${t}}`},gR={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:hR,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,pR.alwaysValidSchema)(n,e)&&(o?(0,mR.validateAdditionalItems)(t,o):t.ok((0,fR.validateArray)(t)))}};up.default=gR});var Ey=S(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});var Ot=W(),Ea=ie(),_R={message:({params:{min:t,max:e}})=>e===void 0?(0,Ot.str)`must contain at least ${t} valid item(s)`:(0,Ot.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Ot._)`{minContains: ${t}}`:(0,Ot._)`{minContains: ${t}, maxContains: ${e}}`},yR={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:_R,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,Ot._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Ea.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Ea.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Ea.alwaysValidSchema)(s,r)){let f=(0,Ot._)`${l} >= ${i}`;a!==void 0&&(f=(0,Ot._)`${f} && ${l} <= ${a}`),t.pass(f);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,Ot._)`${o}.length > 0`,h)):(e.let(d,!1),h()),t.result(d,()=>t.reset());function h(){let f=e.name("_valid"),g=e.let("count",0);m(f,()=>e.if(f,()=>p(g)))}function m(f,g){e.forRange("i",0,l,_=>{t.subschema({keyword:"contains",dataProp:_,dataPropType:Ea.Type.Num,compositeRule:!0},f),g()})}function p(f){e.code((0,Ot._)`${f}++`),a===void 0?e.if((0,Ot._)`${f} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,Ot._)`${f} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,Ot._)`${f} >= ${i}`,()=>e.assign(d,!0)))}}};lp.default=yR});var Py=S(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.validateSchemaDeps=Jt.validatePropertyDeps=Jt.error=void 0;var dp=W(),vR=ie(),js=It();Jt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,dp.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,dp._)`{property: ${t},
8
+ || ${i} === "boolean" || ${o} === null`).assign(a,(0,B._)`[${o}]`)}}}function BE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,B._)`${e} !== undefined`,()=>t.assign((0,B._)`${e}[${r}]`,n))}function hd(t,e,r,n=lo.Correct){let o=n===lo.Correct?B.operators.EQ:B.operators.NEQ,s;switch(t){case"null":return(0,B._)`${e} ${o} null`;case"array":s=(0,B._)`Array.isArray(${e})`;break;case"object":s=(0,B._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,B._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,B._)`typeof ${e} ${o} ${t}`}return n===lo.Correct?s:(0,B.not)(s);function i(a=B.nil){return(0,B.and)((0,B._)`typeof ${e} == "number"`,a,r?(0,B._)`isFinite(${e})`:B.nil)}}tt.checkDataType=hd;function gd(t,e,r,n){if(t.length===1)return hd(t[0],e,r,n);let o,s=(0,Wg.toHash)(t);if(s.array&&s.object){let i=(0,B._)`typeof ${e} != "object"`;o=s.null?i:(0,B._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=B.nil;s.number&&delete s.integer;for(let i in s)o=(0,B.and)(o,hd(i,e,r,n));return o}tt.checkDataTypes=gd;var KE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,B._)`{type: ${t}}`:(0,B._)`{type: ${e}}`};function _d(t){let e=WE(t);(0,qE.reportError)(e,KE)}tt.reportTypeError=_d;function WE(t){let{gen:e,data:r,schema:n}=t,o=(0,Wg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Qg=$(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.assignDefaults=void 0;var po=W(),JE=ie();function XE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Yg(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Yg(t,s,o.default))}ca.assignDefaults=XE;function Yg(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,po._)`${s}${(0,po.getProperty)(e)}`;if(o){(0,JE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,po._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,po._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,po._)`${a} = ${(0,po.stringify)(r)}`)}});var It=$(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.validateUnion=ge.validateArray=ge.usePattern=ge.callValidateCode=ge.schemaProperties=ge.allSchemaProperties=ge.noPropertyInData=ge.propertyInData=ge.isOwnProperty=ge.hasPropFunc=ge.reportMissingProp=ge.checkMissingProp=ge.checkReportMissingProp=void 0;var ke=W(),yd=ie(),Nr=hr(),YE=ie();function QE(t,e){let{gen:r,data:n,it:o}=t;r.if(bd(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ke._)`${e}`},!0),t.error()})}ge.checkReportMissingProp=QE;function ek({gen:t,data:e,it:{opts:r}},n,o){return(0,ke.or)(...n.map(s=>(0,ke.and)(bd(t,e,s,r.ownProperties),(0,ke._)`${o} = ${s}`)))}ge.checkMissingProp=ek;function tk(t,e){t.setParams({missingProperty:e},!0),t.error()}ge.reportMissingProp=tk;function e_(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ke._)`Object.prototype.hasOwnProperty`})}ge.hasPropFunc=e_;function vd(t,e,r){return(0,ke._)`${e_(t)}.call(${e}, ${r})`}ge.isOwnProperty=vd;function rk(t,e,r,n){let o=(0,ke._)`${e}${(0,ke.getProperty)(r)} !== undefined`;return n?(0,ke._)`${o} && ${vd(t,e,r)}`:o}ge.propertyInData=rk;function bd(t,e,r,n){let o=(0,ke._)`${e}${(0,ke.getProperty)(r)} === undefined`;return n?(0,ke.or)(o,(0,ke.not)(vd(t,e,r))):o}ge.noPropertyInData=bd;function t_(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}ge.allSchemaProperties=t_;function nk(t,e){return t_(e).filter(r=>!(0,yd.alwaysValidSchema)(t,e[r]))}ge.schemaProperties=nk;function ok({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ke._)`${t}, ${e}, ${n}${o}`:e,d=[[Nr.default.instancePath,(0,ke.strConcat)(Nr.default.instancePath,s)],[Nr.default.parentData,i.parentData],[Nr.default.parentDataProperty,i.parentDataProperty],[Nr.default.rootData,Nr.default.rootData]];i.opts.dynamicRef&&d.push([Nr.default.dynamicAnchors,Nr.default.dynamicAnchors]);let h=(0,ke._)`${l}, ${r.object(...d)}`;return c!==ke.nil?(0,ke._)`${a}.call(${c}, ${h})`:(0,ke._)`${a}(${h})`}ge.callValidateCode=ok;var sk=(0,ke._)`new RegExp`;function ik({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ke._)`${o.code==="new RegExp"?sk:(0,YE.useFunc)(t,o)}(${r}, ${n})`})}ge.usePattern=ik;function ak(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,ke._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:yd.Type.Num},s),e.if((0,ke.not)(s),a)})}}ge.validateArray=ak;function ck(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,yd.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ke._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ke.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}ge.validateUnion=ck});var o_=$(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.validateKeywordUsage=Wt.validSchemaType=Wt.funcKeywordCode=Wt.macroKeywordCode=void 0;var it=W(),wn=hr(),uk=It(),lk=ys();function dk(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=n_(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:it.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Wt.macroKeywordCode=dk;function pk(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;mk(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=n_(n,o,u),d=n.let("valid");t.block$data(d,h),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function h(){if(e.errors===!1)f(),e.modifying&&r_(t),g(()=>t.error());else{let _=e.async?m():p();e.modifying&&r_(t),g(()=>fk(t,_))}}function m(){let _=n.let("ruleErrs",null);return n.try(()=>f((0,it._)`await `),v=>n.assign(d,!1).if((0,it._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(_,(0,it._)`${v}.errors`),()=>n.throw(v))),_}function p(){let _=(0,it._)`${l}.errors`;return n.assign(_,null),f(it.nil),_}function f(_=e.async?(0,it._)`await `:it.nil){let v=c.opts.passContext?wn.default.this:wn.default.self,S=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,it._)`${_}${(0,uk.callValidateCode)(t,l,v,S)}`,e.modifying)}function g(_){var v;n.if((0,it.not)((v=e.valid)!==null&&v!==void 0?v:d),_)}}Wt.funcKeywordCode=pk;function r_(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,it._)`${n.parentData}[${n.parentDataProperty}]`))}function fk(t,e){let{gen:r}=t;r.if((0,it._)`Array.isArray(${e})`,()=>{r.assign(wn.default.vErrors,(0,it._)`${wn.default.vErrors} === null ? ${e} : ${wn.default.vErrors}.concat(${e})`).assign(wn.default.errors,(0,it._)`${wn.default.vErrors}.length`),(0,lk.extendErrors)(t)},()=>t.error())}function mk({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function n_(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,it.stringify)(r)})}function hk(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Wt.validSchemaType=hk;function gk({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Wt.validateKeywordUsage=gk});var i_=$(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.extendSubschemaMode=Ar.extendSubschemaData=Ar.getSubschema=void 0;var Jt=W(),s_=ie();function _k(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Jt._)`${t.schemaPath}${(0,Jt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Jt._)`${t.schemaPath}${(0,Jt.getProperty)(e)}${(0,Jt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,s_.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ar.getSubschema=_k;function yk(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,h=a.let("data",(0,Jt._)`${e.data}${(0,Jt.getProperty)(r)}`,!0);c(h),t.errorPath=(0,Jt.str)`${u}${(0,s_.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Jt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Jt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Ar.extendSubschemaData=yk;function vk(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Ar.extendSubschemaMode=vk});var wd=$((aD,a_)=>{"use strict";a_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var u_=$((cD,c_)=>{"use strict";var Cr=c_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};ua(e,n,o,t,"",t)};Cr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Cr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Cr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Cr.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 ua(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Cr.arrayKeywords)for(var h=0;h<d.length;h++)ua(t,e,r,d[h],o+"/"+l+"/"+h,s,o,l,n,h)}else if(l in Cr.propsKeywords){if(d&&typeof d=="object")for(var m in d)ua(t,e,r,d[m],o+"/"+l+"/"+bk(m),s,o,l,n,m)}else(l in Cr.keywords||t.allKeys&&!(l in Cr.skipKeywords))&&ua(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function bk(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var bs=$(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.getSchemaRefs=mt.resolveUrl=mt.normalizeId=mt._getFullPath=mt.getFullPath=mt.inlineRef=void 0;var wk=ie(),xk=wd(),Sk=u_(),$k=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Ek(t,e=!0){return typeof t=="boolean"?!0:e===!0?!xd(t):e?l_(t)<=e:!1}mt.inlineRef=Ek;var kk=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function xd(t){for(let e in t){if(kk.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(xd)||typeof r=="object"&&xd(r))return!0}return!1}function l_(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!$k.has(r)&&(typeof t[r]=="object"&&(0,wk.eachItem)(t[r],n=>e+=l_(n)),e===1/0))return 1/0}return e}function d_(t,e="",r){r!==!1&&(e=fo(e));let n=t.parse(e);return p_(t,n)}mt.getFullPath=d_;function p_(t,e){return t.serialize(e).split("#")[0]+"#"}mt._getFullPath=p_;var Tk=/#\/?$/;function fo(t){return t?t.replace(Tk,""):""}mt.normalizeId=fo;function Pk(t,e,r){return r=fo(r),t.resolve(e,r)}mt.resolveUrl=Pk;var Rk=/^[a-z_][-a-z0-9._]*$/i;function Ik(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=fo(t[r]||e),s={"":o},i=d_(n,o,!1),a={},c=new Set;return Sk(t,{allKeys:!0},(d,h,m,p)=>{if(p===void 0)return;let f=i+h,g=s[p];typeof d[r]=="string"&&(g=_.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[h]=g;function _(S){let y=this.opts.uriResolver.resolve;if(S=fo(g?y(g,S):S),c.has(S))throw l(S);c.add(S);let T=this.refs[S];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?u(d,T.schema,S):S!==fo(f)&&(S[0]==="#"?(u(d,a[S],S),a[S]=d):this.refs[S]=f),S}function v(S){if(typeof S=="string"){if(!Rk.test(S))throw new Error(`invalid anchor "${S}"`);_.call(this,`#${S}`)}}}),a;function u(d,h,m){if(h!==void 0&&!xk(d,h))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}mt.getSchemaRefs=Ik});var Ss=$(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.getData=Mr.KeywordCxt=Mr.validateFunctionCode=void 0;var __=Gg(),f_=vs(),$d=md(),la=vs(),zk=Qg(),xs=o_(),Sd=i_(),C=W(),H=hr(),Ok=bs(),gr=ie(),ws=ys();function Nk(t){if(b_(t)&&(w_(t),v_(t))){Mk(t);return}y_(t,()=>(0,__.topBoolOrEmptySchema)(t))}Mr.validateFunctionCode=Nk;function y_({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,C._)`${H.default.data}, ${H.default.valCxt}`,n.$async,()=>{t.code((0,C._)`"use strict"; ${m_(r,o)}`),Ck(t,o),t.code(s)}):t.func(e,(0,C._)`${H.default.data}, ${Ak(o)}`,n.$async,()=>t.code(m_(r,o)).code(s))}function Ak(t){return(0,C._)`{${H.default.instancePath}="", ${H.default.parentData}, ${H.default.parentDataProperty}, ${H.default.rootData}=${H.default.data}${t.dynamicRef?(0,C._)`, ${H.default.dynamicAnchors}={}`:C.nil}}={}`}function Ck(t,e){t.if(H.default.valCxt,()=>{t.var(H.default.instancePath,(0,C._)`${H.default.valCxt}.${H.default.instancePath}`),t.var(H.default.parentData,(0,C._)`${H.default.valCxt}.${H.default.parentData}`),t.var(H.default.parentDataProperty,(0,C._)`${H.default.valCxt}.${H.default.parentDataProperty}`),t.var(H.default.rootData,(0,C._)`${H.default.valCxt}.${H.default.rootData}`),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,C._)`${H.default.valCxt}.${H.default.dynamicAnchors}`)},()=>{t.var(H.default.instancePath,(0,C._)`""`),t.var(H.default.parentData,(0,C._)`undefined`),t.var(H.default.parentDataProperty,(0,C._)`undefined`),t.var(H.default.rootData,H.default.data),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,C._)`{}`)})}function Mk(t){let{schema:e,opts:r,gen:n}=t;y_(t,()=>{r.$comment&&e.$comment&&S_(t),Uk(t),n.let(H.default.vErrors,null),n.let(H.default.errors,0),r.unevaluated&&jk(t),x_(t),Vk(t)})}function jk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,C._)`${r}.evaluated`),e.if((0,C._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,C._)`${t.evaluated}.props`,(0,C._)`undefined`)),e.if((0,C._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,C._)`${t.evaluated}.items`,(0,C._)`undefined`))}function m_(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,C._)`/*# sourceURL=${r} */`:C.nil}function Dk(t,e){if(b_(t)&&(w_(t),v_(t))){Lk(t,e);return}(0,__.boolOrEmptySchema)(t,e)}function v_({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function b_(t){return typeof t.schema!="boolean"}function Lk(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&S_(t),qk(t),Fk(t);let s=n.const("_errs",H.default.errors);x_(t,s),n.var(e,(0,C._)`${s} === ${H.default.errors}`)}function w_(t){(0,gr.checkUnknownRules)(t),Zk(t)}function x_(t,e){if(t.opts.jtd)return h_(t,[],!1,e);let r=(0,f_.getSchemaTypes)(t.schema),n=(0,f_.coerceAndCheckDataType)(t,r);h_(t,r,!n,e)}function Zk(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,gr.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Uk(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,gr.checkStrictMode)(t,"default is ignored in the schema root")}function qk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Ok.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Fk(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function S_({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,C._)`${H.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,C.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,C._)`${H.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Vk(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,C._)`${H.default.errors} === 0`,()=>e.return(H.default.data),()=>e.throw((0,C._)`new ${o}(${H.default.vErrors})`)):(e.assign((0,C._)`${n}.errors`,H.default.vErrors),s.unevaluated&&Hk(t),e.return((0,C._)`${H.default.errors} === 0`))}function Hk({gen:t,evaluated:e,props:r,items:n}){r instanceof C.Name&&t.assign((0,C._)`${e}.props`,r),n instanceof C.Name&&t.assign((0,C._)`${e}.items`,n)}function h_(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,gr.schemaHasRulesButRef)(s,l))){o.block(()=>E_(t,"$ref",l.all.$ref.definition));return}c.jtd||Gk(t,e),o.block(()=>{for(let h of l.rules)d(h);d(l.post)});function d(h){(0,$d.shouldUseGroup)(s,h)&&(h.type?(o.if((0,la.checkDataType)(h.type,i,c.strictNumbers)),g_(t,h),e.length===1&&e[0]===h.type&&r&&(o.else(),(0,la.reportTypeError)(t)),o.endIf()):g_(t,h),a||o.if((0,C._)`${H.default.errors} === ${n||0}`))}}function g_(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,zk.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,$d.shouldUseRule)(n,s)&&E_(t,s.keyword,s.definition,e.type)})}function Gk(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Bk(t,e),t.opts.allowUnionTypes||Kk(t,e),Wk(t,t.dataTypes))}function Bk(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{$_(t.dataTypes,r)||Ed(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Xk(t,e)}}function Kk(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ed(t,"use allowUnionTypes to allow union type keyword")}function Wk(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,$d.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Jk(e,i))&&Ed(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Jk(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function $_(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Xk(t,e){let r=[];for(let n of t.dataTypes)$_(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ed(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,gr.checkStrictMode)(t,e,t.opts.strictTypes)}var da=class{constructor(e,r,n){if((0,xs.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,gr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",k_(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,xs.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",H.default.errors))}result(e,r,n){this.failResult((0,C.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,C.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,C._)`${r} !== undefined && (${(0,C.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?ws.reportExtraError:ws.reportError)(this,this.def.error,r)}$dataError(){(0,ws.reportError)(this,this.def.$dataError||ws.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ws.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=C.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=C.nil,r=C.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,C.or)((0,C._)`${o} === undefined`,r)),e!==C.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==C.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,C.or)(i(),a());function i(){if(n.length){if(!(r instanceof C.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,C._)`${(0,la.checkDataTypes)(c,r,s.opts.strictNumbers,la.DataType.Wrong)}`}return C.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,C._)`!${c}(${r})`}return C.nil}}subschema(e,r){let n=(0,Sd.getSubschema)(this.it,e);(0,Sd.extendSubschemaData)(n,this.it,e),(0,Sd.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Dk(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=gr.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=gr.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,C.Name)),!0}};Mr.KeywordCxt=da;function E_(t,e,r,n){let o=new da(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,xs.funcKeywordCode)(o,r):"macro"in r?(0,xs.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,xs.funcKeywordCode)(o,r)}var Yk=/^\/(?:[^~]|~0|~1)*$/,Qk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function k_(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return H.default.rootData;if(t[0]==="/"){if(!Yk.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=H.default.rootData}else{let u=Qk.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,C._)`${s}${(0,C.getProperty)((0,gr.unescapeJsonPointer)(u))}`,i=(0,C._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Mr.getData=k_});var pa=$(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});var kd=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Td.default=kd});var $s=$(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});var Pd=bs(),Rd=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Pd.resolveUrl)(e,r,n),this.missingSchema=(0,Pd.normalizeId)((0,Pd.getFullPath)(e,this.missingRef))}};Id.default=Rd});var ma=$(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.resolveSchema=zt.getCompilingSchema=zt.resolveRef=zt.compileSchema=zt.SchemaEnv=void 0;var Lt=W(),eT=pa(),xn=hr(),Zt=bs(),T_=ie(),tT=Ss(),mo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Zt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};zt.SchemaEnv=mo;function Od(t){let e=P_.call(this,t);if(e)return e;let r=(0,Zt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Lt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:eT.default,code:(0,Lt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:xn.default.data,parentData:xn.default.parentData,parentDataProperty:xn.default.parentDataProperty,dataNames:[xn.default.data],dataPathArr:[Lt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Lt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Lt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Lt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,tT.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(xn.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${xn.default.self}`,`${xn.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:p,items:f}=u;m.evaluated={props:p instanceof Lt.Name?void 0:p,items:f instanceof Lt.Name?void 0:f,dynamicProps:p instanceof Lt.Name,dynamicItems:f instanceof Lt.Name},m.source&&(m.source.evaluated=(0,Lt.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}zt.compileSchema=Od;function rT(t,e,r){var n;r=(0,Zt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=sT.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new mo({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=nT.call(this,s)}zt.resolveRef=rT;function nT(t){return(0,Zt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Od.call(this,t)}function P_(t){for(let e of this._compilations)if(oT(e,t))return e}zt.getCompilingSchema=P_;function oT(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function sT(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||fa.call(this,t,e)}function fa(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Zt._getFullPath)(this.opts.uriResolver,r),o=(0,Zt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return zd.call(this,r,t);let s=(0,Zt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=fa.call(this,t,i);return typeof a?.schema!="object"?void 0:zd.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Od.call(this,i),s===(0,Zt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Zt.resolveUrl)(this.opts.uriResolver,o,u)),new mo({schema:a,schemaId:c,root:t,baseId:o})}return zd.call(this,r,i)}}zt.resolveSchema=fa;var iT=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function zd(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,T_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!iT.has(a)&&u&&(e=(0,Zt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,T_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Zt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=fa.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new mo({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var R_=$((mD,aT)=>{aT.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 Cd=$((hD,C_)=>{"use strict";var cT=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),z_=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),Nd=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),O_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),uT=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ad(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var lT=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function I_(t){return t.length=0,!0}function dT(t,e,r){if(t.length){let n=Ad(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function pT(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=dT;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=I_}else{o.push(u);continue}}return o.length&&(a===I_?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ad(o))),r.address=n.join(""),r}function N_(t){if(fT(t,":")<2)return{host:t,isIPV6:!1};let e=pT(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function fT(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function mT(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var hT={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},gT=/[@/?#:]/g,_T=/[@/?#]/g;function A_(t,e){let r=e?_T:gT;return r.lastIndex=0,t.replace(r,n=>hT[n])}function yT(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Nd(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&O_(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function vT(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Nd(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&O_(s)?e+=s:e+="%"+o,r+=2;continue}}uT(t[r])?e+=t[r]:e+=escape(t[r])}return e}function bT(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Nd(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function wT(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!z_(r)){let n=N_(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=A_(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}C_.exports={nonSimpleDomain:lT,recomposeAuthority:wT,reescapeHostDelimiters:A_,normalizePercentEncoding:yT,normalizePathEncoding:vT,escapePreservingEscapes:bT,removeDotSegments:mT,isIPv4:z_,isUUID:cT,normalizeIPv6:N_,stringArrayToHexStripped:Ad}});var Z_=$((gD,L_)=>{"use strict";var{isUUID:xT}=Cd(),ST=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,$T=["http","https","ws","wss","urn","urn:uuid"];function ET(t){return $T.indexOf(t)!==-1}function Md(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function M_(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function j_(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function kT(t){return t.secure=Md(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function TT(t){if((t.port===(Md(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function PT(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(ST);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=jd(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function RT(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=jd(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function IT(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!xT(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function zT(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var D_={scheme:"http",domainHost:!0,parse:M_,serialize:j_},OT={scheme:"https",domainHost:D_.domainHost,parse:M_,serialize:j_},ha={scheme:"ws",domainHost:!0,parse:kT,serialize:TT},NT={scheme:"wss",domainHost:ha.domainHost,parse:ha.parse,serialize:ha.serialize},AT={scheme:"urn",parse:PT,serialize:RT,skipNormalize:!0},CT={scheme:"urn:uuid",parse:IT,serialize:zT,skipNormalize:!0},ga={http:D_,https:OT,ws:ha,wss:NT,urn:AT,"urn:uuid":CT};Object.setPrototypeOf(ga,null);function jd(t){return t&&(ga[t]||ga[t.toLowerCase()])||void 0}L_.exports={wsIsSecure:Md,SCHEMES:ga,isValidSchemeName:ET,getSchemeHandler:jd}});var G_=$((_D,_a)=>{"use strict";var{normalizeIPv6:MT,removeDotSegments:Es,recomposeAuthority:jT,normalizePercentEncoding:DT,normalizePathEncoding:LT,escapePreservingEscapes:ZT,reescapeHostDelimiters:UT,isIPv4:qT,nonSimpleDomain:FT}=Cd(),{SCHEMES:VT,getSchemeHandler:q_}=Z_();function HT(t,e){return typeof t=="string"?t=JT(t,e):typeof t=="object"&&(t=ho(Sn(t,e),e)),t}function GT(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=F_(ho(t,n),ho(e,n),n,!0);return n.skipEscape=!0,Sn(o,n)}function F_(t,e,r,n){let o={};return n||(t=ho(Sn(t,r),r),e=ho(Sn(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Es(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Es(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Es(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=Es(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function BT(t,e,r){let n=U_(t,r),o=U_(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Sn(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=q_(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=DT(r.path):(r.path=ZT(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=jT(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=Es(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var KT=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function WT(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function V_(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(KT);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=WT(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(qT(n.host)===!1){let l=MT(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=q_(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&FT(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=UT(unescape(n.host),s))),n.path&&(n.path=LT(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function ho(t,e){return V_(t,e).parsed}function JT(t,e){return H_(t,e).normalized}function H_(t,e){let{parsed:r,malformedAuthorityOrPort:n}=V_(t,e);return{normalized:n?t:Sn(r,e),malformedAuthorityOrPort:n}}function U_(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=H_(t,e);return n?void 0:r}if(typeof t=="object")return Sn(t,e)}var Dd={SCHEMES:VT,normalize:HT,resolve:GT,resolveComponent:F_,equal:BT,serialize:Sn,parse:ho};_a.exports=Dd;_a.exports.default=Dd;_a.exports.fastUri=Dd});var K_=$(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});var B_=G_();B_.code='require("ajv/dist/runtime/uri").default';Ld.default=B_});var ry=$(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.CodeGen=We.Name=We.nil=We.stringify=We.str=We._=We.KeywordCxt=void 0;var XT=Ss();Object.defineProperty(We,"KeywordCxt",{enumerable:!0,get:function(){return XT.KeywordCxt}});var go=W();Object.defineProperty(We,"_",{enumerable:!0,get:function(){return go._}});Object.defineProperty(We,"str",{enumerable:!0,get:function(){return go.str}});Object.defineProperty(We,"stringify",{enumerable:!0,get:function(){return go.stringify}});Object.defineProperty(We,"nil",{enumerable:!0,get:function(){return go.nil}});Object.defineProperty(We,"Name",{enumerable:!0,get:function(){return go.Name}});Object.defineProperty(We,"CodeGen",{enumerable:!0,get:function(){return go.CodeGen}});var YT=pa(),Q_=$s(),QT=fd(),ks=ma(),eP=W(),Ts=bs(),ya=vs(),Ud=ie(),W_=R_(),tP=K_(),ey=(t,e)=>new RegExp(t,e);ey.code="new RegExp";var rP=["removeAdditional","useDefaults","coerceTypes"],nP=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),oP={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."},sP={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},J_=200;function iP(t){var e,r,n,o,s,i,a,c,u,l,d,h,m,p,f,g,_,v,S,y,T,L,te,Xe,F;let ce=t.strict,Ce=(e=t.code)===null||e===void 0?void 0:e.optimize,Q=Ce===!0||Ce===void 0?1:Ce||0,tr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:ey,rr=(o=t.uriResolver)!==null&&o!==void 0?o:tP.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ce)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ce)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ce)!==null&&l!==void 0?l:"log",strictTuples:(h=(d=t.strictTuples)!==null&&d!==void 0?d:ce)!==null&&h!==void 0?h:"log",strictRequired:(p=(m=t.strictRequired)!==null&&m!==void 0?m:ce)!==null&&p!==void 0?p:!1,code:t.code?{...t.code,optimize:Q,regExp:tr}:{optimize:Q,regExp:tr},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:J_,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:J_,meta:(_=t.meta)!==null&&_!==void 0?_:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:(S=t.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(y=t.schemaId)!==null&&y!==void 0?y:"$id",addUsedSchema:(T=t.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(L=t.validateSchema)!==null&&L!==void 0?L:!0,validateFormats:(te=t.validateFormats)!==null&&te!==void 0?te:!0,unicodeRegExp:(Xe=t.unicodeRegExp)!==null&&Xe!==void 0?Xe:!0,int32range:(F=t.int32range)!==null&&F!==void 0?F:!0,uriResolver:rr}}var Ps=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...iP(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new eP.ValueScope({scope:{},prefixes:nP,es5:r,lines:n}),this.logger=pP(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,QT.getRules)(),X_.call(this,oP,e,"NOT SUPPORTED"),X_.call(this,sP,e,"DEPRECATED","warn"),this._metaOpts=lP.call(this),e.formats&&cP.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&uP.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),aP.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=W_;n==="id"&&(o={...W_},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let h=this._addSchema(l,d);return h.validate||i.call(this,h)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Q_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Ts.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=Y_.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ks.SchemaEnv({schema:{},schemaId:n});if(r=ks.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Y_.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Ts.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(mP.call(this,n,r),!r)return(0,Ud.eachItem)(n,s=>Zd.call(this,s)),this;gP.call(this,r);let o={...r,type:(0,ya.getJSONTypes)(r.type),schemaType:(0,ya.getJSONTypes)(r.schemaType)};return(0,Ud.eachItem)(n,o.type.length===0?s=>Zd.call(this,s,o):s=>o.type.forEach(i=>Zd.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=ty(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Ts.normalizeId)(i||n);let u=Ts.getSchemaRefs.call(this,e,n);return c=new ks.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ks.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ks.compileSchema.call(this,e)}finally{this.opts=r}}};Ps.ValidationError=YT.default;Ps.MissingRefError=Q_.default;We.default=Ps;function X_(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function Y_(t){return t=(0,Ts.normalizeId)(t),this.schemas[t]||this.refs[t]}function aP(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function cP(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function uP(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function lP(){let t={...this.opts};for(let e of rP)delete t[e];return t}var dP={log(){},warn(){},error(){}};function pP(t){if(t===!1)return dP;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var fP=/^[a-z_$][a-z0-9_$:-]*$/i;function mP(t,e){let{RULES:r}=this;if((0,Ud.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!fP.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Zd(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ya.getJSONTypes)(e.type),schemaType:(0,ya.getJSONTypes)(e.schemaType)}};e.before?hP.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function hP(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function gP(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ty(e)),t.validateSchema=this.compile(e,!0))}var _P={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ty(t){return{anyOf:[t,_P]}}});var ny=$(qd=>{"use strict";Object.defineProperty(qd,"__esModule",{value:!0});var yP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};qd.default=yP});var ay=$($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.callRef=$n.getValidate=void 0;var vP=$s(),oy=It(),ht=W(),_o=hr(),sy=ma(),va=ie(),bP={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=sy.resolveRef.call(c,u,o,r);if(l===void 0)throw new vP.default(n.opts.uriResolver,o,r);if(l instanceof sy.SchemaEnv)return h(l);return m(l);function d(){if(s===u)return ba(t,i,s,s.$async);let p=e.scopeValue("root",{ref:u});return ba(t,(0,ht._)`${p}.validate`,u,u.$async)}function h(p){let f=iy(t,p);ba(t,f,p,p.$async)}function m(p){let f=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,ht.stringify)(p)}:{ref:p}),g=e.name("valid"),_=t.subschema({schema:p,dataTypes:[],schemaPath:ht.nil,topSchemaRef:f,errSchemaPath:r},g);t.mergeEvaluated(_),t.ok(g)}}};function iy(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,ht._)`${r.scopeValue("wrapper",{ref:e})}.validate`}$n.getValidate=iy;function ba(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?_o.default.this:ht.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=o.let("valid");o.try(()=>{o.code((0,ht._)`await ${(0,oy.callValidateCode)(t,e,u)}`),m(e),i||o.assign(p,!0)},f=>{o.if((0,ht._)`!(${f} instanceof ${s.ValidationError})`,()=>o.throw(f)),h(f),i||o.assign(p,!1)}),t.ok(p)}function d(){t.result((0,oy.callValidateCode)(t,e,u),()=>m(e),()=>h(e))}function h(p){let f=(0,ht._)`${p}.errors`;o.assign(_o.default.vErrors,(0,ht._)`${_o.default.vErrors} === null ? ${f} : ${_o.default.vErrors}.concat(${f})`),o.assign(_o.default.errors,(0,ht._)`${_o.default.vErrors}.length`)}function m(p){var f;if(!s.opts.unevaluated)return;let g=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=va.mergeEvaluated.props(o,g.props,s.props));else{let _=o.var("props",(0,ht._)`${p}.evaluated.props`);s.props=va.mergeEvaluated.props(o,_,s.props,ht.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=va.mergeEvaluated.items(o,g.items,s.items));else{let _=o.var("items",(0,ht._)`${p}.evaluated.items`);s.items=va.mergeEvaluated.items(o,_,s.items,ht.Name)}}}$n.callRef=ba;$n.default=bP});var cy=$(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});var wP=ny(),xP=ay(),SP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",wP.default,xP.default];Fd.default=SP});var uy=$(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});var wa=W(),jr=wa.operators,xa={maximum:{okStr:"<=",ok:jr.LTE,fail:jr.GT},minimum:{okStr:">=",ok:jr.GTE,fail:jr.LT},exclusiveMaximum:{okStr:"<",ok:jr.LT,fail:jr.GTE},exclusiveMinimum:{okStr:">",ok:jr.GT,fail:jr.LTE}},$P={message:({keyword:t,schemaCode:e})=>(0,wa.str)`must be ${xa[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,wa._)`{comparison: ${xa[t].okStr}, limit: ${e}}`},EP={keyword:Object.keys(xa),type:"number",schemaType:"number",$data:!0,error:$P,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,wa._)`${r} ${xa[e].fail} ${n} || isNaN(${r})`)}};Vd.default=EP});var ly=$(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});var Rs=W(),kP={message:({schemaCode:t})=>(0,Rs.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Rs._)`{multipleOf: ${t}}`},TP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:kP,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Rs._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Rs._)`${i} !== parseInt(${i})`;t.fail$data((0,Rs._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Hd.default=TP});var py=$(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});function dy(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}Gd.default=dy;dy.code='require("ajv/dist/runtime/ucs2length").default'});var fy=$(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});var En=W(),PP=ie(),RP=py(),IP={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,En.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,En._)`{limit: ${t}}`},zP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:IP,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?En.operators.GT:En.operators.LT,i=o.opts.unicode===!1?(0,En._)`${r}.length`:(0,En._)`${(0,PP.useFunc)(t.gen,RP.default)}(${r})`;t.fail$data((0,En._)`${i} ${s} ${n}`)}};Bd.default=zP});var my=$(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});var OP=It(),NP=ie(),yo=W(),AP={message:({schemaCode:t})=>(0,yo.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,yo._)`{pattern: ${t}}`},CP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:AP,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,yo._)`new RegExp`:(0,NP.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,yo._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,yo._)`!${l}`)}else{let c=(0,OP.usePattern)(t,o);t.fail$data((0,yo._)`!${c}.test(${r})`)}}};Kd.default=CP});var hy=$(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});var Is=W(),MP={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Is.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Is._)`{limit: ${t}}`},jP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:MP,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Is.operators.GT:Is.operators.LT;t.fail$data((0,Is._)`Object.keys(${r}).length ${o} ${n}`)}};Wd.default=jP});var gy=$(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});var zs=It(),Os=W(),DP=ie(),LP={message:({params:{missingProperty:t}})=>(0,Os.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Os._)`{missingProperty: ${t}}`},ZP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:LP,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:p}=t.it;for(let f of r)if(m?.[f]===void 0&&!p.has(f)){let g=i.schemaEnv.baseId+i.errSchemaPath,_=`required property "${f}" is not defined at "${g}" (strictRequired)`;(0,DP.checkStrictMode)(i,_,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Os.nil,d);else for(let m of r)(0,zs.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let p=e.let("valid",!0);t.block$data(p,()=>h(m,p)),t.ok(p)}else e.if((0,zs.checkMissingProp)(t,r,m)),(0,zs.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,zs.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function h(m,p){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(p,(0,zs.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Os.not)(p),()=>{t.error(),e.break()})},Os.nil)}}};Jd.default=ZP});var _y=$(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});var Ns=W(),UP={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Ns.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Ns._)`{limit: ${t}}`},qP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:UP,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Ns.operators.GT:Ns.operators.LT;t.fail$data((0,Ns._)`${r}.length ${o} ${n}`)}};Xd.default=qP});var Sa=$(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});var yy=wd();yy.code='require("ajv/dist/runtime/equal").default';Yd.default=yy});var vy=$(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var Qd=vs(),Je=W(),FP=ie(),VP=Sa(),HP={message:({params:{i:t,j:e}})=>(0,Je.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Je._)`{i: ${t}, j: ${e}}`},GP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:HP,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Qd.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Je._)`${i} === false`),t.ok(c);function l(){let p=e.let("i",(0,Je._)`${r}.length`),f=e.let("j");t.setParams({i:p,j:f}),e.assign(c,!0),e.if((0,Je._)`${p} > 1`,()=>(d()?h:m)(p,f))}function d(){return u.length>0&&!u.some(p=>p==="object"||p==="array")}function h(p,f){let g=e.name("item"),_=(0,Qd.checkDataTypes)(u,g,a.opts.strictNumbers,Qd.DataType.Wrong),v=e.const("indices",(0,Je._)`{}`);e.for((0,Je._)`;${p}--;`,()=>{e.let(g,(0,Je._)`${r}[${p}]`),e.if(_,(0,Je._)`continue`),u.length>1&&e.if((0,Je._)`typeof ${g} == "string"`,(0,Je._)`${g} += "_"`),e.if((0,Je._)`typeof ${v}[${g}] == "number"`,()=>{e.assign(f,(0,Je._)`${v}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Je._)`${v}[${g}] = ${p}`)})}function m(p,f){let g=(0,FP.useFunc)(e,VP.default),_=e.name("outer");e.label(_).for((0,Je._)`;${p}--;`,()=>e.for((0,Je._)`${f} = ${p}; ${f}--;`,()=>e.if((0,Je._)`${g}(${r}[${p}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(_)})))}}};ep.default=GP});var by=$(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var tp=W(),BP=ie(),KP=Sa(),WP={message:"must be equal to constant",params:({schemaCode:t})=>(0,tp._)`{allowedValue: ${t}}`},JP={keyword:"const",$data:!0,error:WP,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,tp._)`!${(0,BP.useFunc)(e,KP.default)}(${r}, ${o})`):t.fail((0,tp._)`${s} !== ${r}`)}};rp.default=JP});var wy=$(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});var As=W(),XP=ie(),YP=Sa(),QP={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,As._)`{allowedValues: ${t}}`},eR={keyword:"enum",schemaType:"array",$data:!0,error:QP,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,XP.useFunc)(e,YP.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,As.or)(...o.map((p,f)=>h(m,f)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,As._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function h(m,p){let f=o[p];return typeof f=="object"&&f!==null?(0,As._)`${u()}(${r}, ${m}[${p}])`:(0,As._)`${r} === ${f}`}}};np.default=eR});var xy=$(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});var tR=uy(),rR=ly(),nR=fy(),oR=my(),sR=hy(),iR=gy(),aR=_y(),cR=vy(),uR=by(),lR=wy(),dR=[tR.default,rR.default,nR.default,oR.default,sR.default,iR.default,aR.default,cR.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},uR.default,lR.default];op.default=dR});var ip=$(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.validateAdditionalItems=void 0;var kn=W(),sp=ie(),pR={message:({params:{len:t}})=>(0,kn.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,kn._)`{limit: ${t}}`},fR={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:pR,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,sp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Sy(t,n)}};function Sy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,kn._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,kn._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,sp.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,kn._)`${a} <= ${e.length}`);r.if((0,kn.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:sp.Type.Num},u),i.allErrors||r.if((0,kn.not)(u),()=>r.break())})}}Cs.validateAdditionalItems=Sy;Cs.default=fR});var ap=$(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.validateTuple=void 0;var $y=W(),$a=ie(),mR=It(),hR={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Ey(t,"additionalItems",e);r.items=!0,!(0,$a.alwaysValidSchema)(r,e)&&t.ok((0,mR.validateArray)(t))}};function Ey(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=$a.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,$y._)`${s}.length`);r.forEach((d,h)=>{(0,$a.alwaysValidSchema)(a,d)||(n.if((0,$y._)`${u} > ${h}`,()=>t.subschema({keyword:i,schemaProp:h,dataProp:h},c)),t.ok(c))});function l(d){let{opts:h,errSchemaPath:m}=a,p=r.length,f=p===d.minItems&&(p===d.maxItems||d[e]===!1);if(h.strictTuples&&!f){let g=`"${i}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,$a.checkStrictMode)(a,g,h.strictTuples)}}}Ms.validateTuple=Ey;Ms.default=hR});var ky=$(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});var gR=ap(),_R={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,gR.validateTuple)(t,"items")};cp.default=_R});var Py=$(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});var Ty=W(),yR=ie(),vR=It(),bR=ip(),wR={message:({params:{len:t}})=>(0,Ty.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ty._)`{limit: ${t}}`},xR={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:wR,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,yR.alwaysValidSchema)(n,e)&&(o?(0,bR.validateAdditionalItems)(t,o):t.ok((0,vR.validateArray)(t)))}};up.default=xR});var Ry=$(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});var Ot=W(),Ea=ie(),SR={message:({params:{min:t,max:e}})=>e===void 0?(0,Ot.str)`must contain at least ${t} valid item(s)`:(0,Ot.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Ot._)`{minContains: ${t}}`:(0,Ot._)`{minContains: ${t}, maxContains: ${e}}`},$R={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:SR,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,Ot._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Ea.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Ea.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Ea.alwaysValidSchema)(s,r)){let f=(0,Ot._)`${l} >= ${i}`;a!==void 0&&(f=(0,Ot._)`${f} && ${l} <= ${a}`),t.pass(f);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,Ot._)`${o}.length > 0`,h)):(e.let(d,!1),h()),t.result(d,()=>t.reset());function h(){let f=e.name("_valid"),g=e.let("count",0);m(f,()=>e.if(f,()=>p(g)))}function m(f,g){e.forRange("i",0,l,_=>{t.subschema({keyword:"contains",dataProp:_,dataPropType:Ea.Type.Num,compositeRule:!0},f),g()})}function p(f){e.code((0,Ot._)`${f}++`),a===void 0?e.if((0,Ot._)`${f} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,Ot._)`${f} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,Ot._)`${f} >= ${i}`,()=>e.assign(d,!0)))}}};lp.default=$R});var Oy=$(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.validateSchemaDeps=Xt.validatePropertyDeps=Xt.error=void 0;var dp=W(),ER=ie(),js=It();Xt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,dp.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,dp._)`{property: ${t},
9
9
  missingProperty: ${n},
10
10
  depsCount: ${e},
11
- deps: ${r}}`};var bR={keyword:"dependencies",type:"object",schemaType:"object",error:Jt.error,code(t){let[e,r]=wR(t);ky(t,e),Ty(t,r)}};function wR({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function ky(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,js.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,js.checkReportMissingProp)(t,u)}):(r.if((0,dp._)`${c} && (${(0,js.checkMissingProp)(t,a,s)})`),(0,js.reportMissingProp)(t,s),r.else())}}Jt.validatePropertyDeps=ky;function Ty(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,vR.alwaysValidSchema)(s,e[a])||(r.if((0,js.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Jt.validateSchemaDeps=Ty;Jt.default=bR});var Iy=S(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var Ry=W(),xR=ie(),$R={message:"property name must be valid",params:({params:t})=>(0,Ry._)`{propertyName: ${t.propertyName}}`},SR={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:$R,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,xR.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Ry.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};pp.default=SR});var mp=S(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});var ka=It(),Ut=W(),ER=hr(),Ta=ie(),kR={message:"must NOT have additional properties",params:({params:t})=>(0,Ut._)`{additionalProperty: ${t.additionalProperty}}`},TR={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:kR,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Ta.alwaysValidSchema)(i,r))return;let u=(0,ka.allSchemaProperties)(n.properties),l=(0,ka.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Ut._)`${s} === ${ER.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?p(g):e.if(h(g),()=>p(g))})}function h(g){let _;if(u.length>8){let v=(0,Ta.schemaRefOrVal)(i,n.properties,"properties");_=(0,ka.isOwnProperty)(e,v,g)}else u.length?_=(0,Ut.or)(...u.map(v=>(0,Ut._)`${g} === ${v}`)):_=Ut.nil;return l.length&&(_=(0,Ut.or)(_,...l.map(v=>(0,Ut._)`${(0,ka.usePattern)(t,v)}.test(${g})`))),(0,Ut.not)(_)}function m(g){e.code((0,Ut._)`delete ${o}[${g}]`)}function p(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Ta.alwaysValidSchema)(i,r)){let _=e.name("valid");c.removeAdditional==="failing"?(f(g,_,!1),e.if((0,Ut.not)(_),()=>{t.reset(),m(g)})):(f(g,_),a||e.if((0,Ut.not)(_),()=>e.break()))}}function f(g,_,v){let $={keyword:"additionalProperties",dataProp:g,dataPropType:Ta.Type.Str};v===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema($,_)}}};fp.default=TR});var Ny=S(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});var PR=$s(),zy=It(),hp=ie(),Oy=mp(),RR={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Oy.default.code(new PR.KeywordCxt(s,Oy.default,"additionalProperties"));let i=(0,zy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=hp.mergeEvaluated.props(e,(0,hp.toHash)(i),s.props));let a=i.filter(d=>!(0,hp.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,zy.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};gp.default=RR});var jy=S(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var Ay=It(),Pa=W(),Cy=ie(),My=ie(),IR={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,Ay.allSchemaProperties)(r),c=a.filter(f=>(0,Cy.alwaysValidSchema)(s,r[f]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof Pa.Name)&&(s.props=(0,My.evaluatedPropsToName)(e,s.props));let{props:d}=s;h();function h(){for(let f of a)u&&m(f),s.allErrors?p(f):(e.var(l,!0),p(f),e.if(l))}function m(f){for(let g in u)new RegExp(f).test(g)&&(0,Cy.checkStrictMode)(s,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function p(f){e.forIn("key",n,g=>{e.if((0,Pa._)`${(0,Ay.usePattern)(t,f)}.test(${g})`,()=>{let _=c.includes(f);_||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:My.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,Pa._)`${d}[${g}]`,!0):!_&&!s.allErrors&&e.if((0,Pa.not)(l),()=>e.break())})})}}};_p.default=IR});var Dy=S(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var zR=ie(),OR={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,zR.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};yp.default=OR});var Ly=S(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var NR=It(),AR={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:NR.validateUnion,error:{message:"must match a schema in anyOf"}};vp.default=AR});var Zy=S(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});var Ra=W(),CR=ie(),MR={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ra._)`{passingSchemas: ${t.passing}}`},jR={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:MR,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let h;(0,CR.alwaysValidSchema)(o,l)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ra._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ra._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),h&&t.mergeEvaluated(h,Ra.Name)})})}}};bp.default=jR});var Uy=S(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var DR=ie(),LR={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,DR.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};wp.default=LR});var Vy=S(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});var Ia=W(),Fy=ie(),ZR={message:({params:t})=>(0,Ia.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ia._)`{failingKeyword: ${t.ifClause}}`},UR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ZR,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Fy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=qy(n,"then"),s=qy(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Ia.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let h=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(h,i),d?e.assign(d,(0,Ia._)`${l}`):t.setParams({ifClause:l})}}}};function qy(t,e){let r=t.schema[e];return r!==void 0&&!(0,Fy.alwaysValidSchema)(t,r)}xp.default=UR});var Hy=S($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});var qR=ie(),FR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,qR.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};$p.default=FR});var Gy=S(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});var VR=ip(),HR=xy(),GR=ap(),BR=Sy(),KR=Ey(),WR=Py(),JR=Iy(),XR=mp(),YR=Ny(),QR=jy(),eI=Dy(),tI=Ly(),rI=Zy(),nI=Uy(),oI=Vy(),sI=Hy();function iI(t=!1){let e=[eI.default,tI.default,rI.default,nI.default,oI.default,sI.default,JR.default,XR.default,WR.default,YR.default,QR.default];return t?e.push(HR.default,BR.default):e.push(VR.default,GR.default),e.push(KR.default),e}Sp.default=iI});var By=S(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});var De=W(),aI={message:({schemaCode:t})=>(0,De.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,De._)`{format: ${t}}`},cI={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:aI,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?h():m();function h(){let p=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,De._)`${p}[${i}]`),g=r.let("fType"),_=r.let("format");r.if((0,De._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,De._)`${f}.type || "string"`).assign(_,(0,De._)`${f}.validate`),()=>r.assign(g,(0,De._)`"string"`).assign(_,f)),t.fail$data((0,De.or)(v(),$()));function v(){return c.strictSchema===!1?De.nil:(0,De._)`${i} && !${_}`}function $(){let y=l.$async?(0,De._)`(${f}.async ? await ${_}(${n}) : ${_}(${n}))`:(0,De._)`${_}(${n})`,T=(0,De._)`(typeof ${_} == "function" ? ${y} : ${_}.test(${n}))`;return(0,De._)`${_} && ${_} !== true && ${g} === ${e} && !${T}`}}function m(){let p=d.formats[s];if(!p){v();return}if(p===!0)return;let[f,g,_]=$(p);f===e&&t.pass(y());function v(){if(c.strictSchema===!1){d.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(T){let F=T instanceof RegExp?(0,De.regexpCode)(T):c.code.formats?(0,De._)`${c.code.formats}${(0,De.getProperty)(s)}`:void 0,te=r.scopeValue("formats",{key:s,ref:T,code:F});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,De._)`${te}.validate`]:["string",T,te]}function y(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,De._)`await ${_}(${n})`}return typeof g=="function"?(0,De._)`${_}(${n})`:(0,De._)`${_}.test(${n})`}}}};Ep.default=cI});var Ky=S(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});var uI=By(),lI=[uI.default];kp.default=lI});var Wy=S(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.contentVocabulary=yo.metadataVocabulary=void 0;yo.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];yo.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Xy=S(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});var dI=oy(),pI=yy(),fI=Gy(),mI=Ky(),Jy=Wy(),hI=[dI.default,pI.default,(0,fI.default)(),mI.default,Jy.metadataVocabulary,Jy.contentVocabulary];Tp.default=hI});var Qy=S(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.DiscrError=void 0;var Yy;(function(t){t.Tag="tag",t.Mapping="mapping"})(Yy||(za.DiscrError=Yy={}))});var tv=S(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var vo=W(),Pp=Qy(),ev=ma(),gI=Ss(),_I=ie(),yI={message:({params:{discrError:t,tagName:e}})=>t===Pp.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,vo._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},vI={keyword:"discriminator",type:"object",schemaType:"object",error:yI,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.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(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,vo._)`${r}${(0,vo.getProperty)(a)}`);e.if((0,vo._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Pp.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=h();e.if(!1);for(let p in m)e.elseIf((0,vo._)`${u} === ${p}`),e.assign(c,d(m[p]));e.else(),t.error(!1,{discrError:Pp.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let p=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},p);return t.mergeEvaluated(f,vo.Name),p}function h(){var m;let p={},f=_(o),g=!0;for(let y=0;y<i.length;y++){let T=i[y];if(T?.$ref&&!(0,_I.schemaHasRulesButRef)(T,s.self.RULES)){let te=T.$ref;if(T=ev.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,te),T instanceof ev.SchemaEnv&&(T=T.schema),T===void 0)throw new gI.default(s.opts.uriResolver,s.baseId,te)}let F=(m=T?.properties)===null||m===void 0?void 0:m[a];if(typeof F!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||_(T)),v(F,y)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return p;function _({required:y}){return Array.isArray(y)&&y.includes(a)}function v(y,T){if(y.const)$(y.const,T);else if(y.enum)for(let F of y.enum)$(F,T);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(y,T){if(typeof y!="string"||y in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[y]=T}}}};Rp.default=vI});var rv=S((GD,bI)=>{bI.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 zp=S((Te,Ip)=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.MissingRefError=Te.ValidationError=Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=Te.Ajv=void 0;var wI=Y_(),xI=Xy(),$I=tv(),nv=rv(),SI=["/properties"],Oa="http://json-schema.org/draft-07/schema",bo=class extends wI.default{_addVocabularies(){super._addVocabularies(),xI.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword($I.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(nv,SI):nv;this.addMetaSchema(e,Oa,!1),this.refs["http://json-schema.org/schema"]=Oa}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Oa)?Oa:void 0)}};Te.Ajv=bo;Ip.exports=Te=bo;Ip.exports.Ajv=bo;Object.defineProperty(Te,"__esModule",{value:!0});Te.default=bo;var EI=$s();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return EI.KeywordCxt}});var wo=W();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return wo._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return wo.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return wo.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return wo.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return wo.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return wo.CodeGen}});var kI=pa();Object.defineProperty(Te,"ValidationError",{enumerable:!0,get:function(){return kI.default}});var TI=Ss();Object.defineProperty(Te,"MissingRefError",{enumerable:!0,get:function(){return TI.default}})});var dv=S(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.formatNames=Yt.fastFormats=Yt.fullFormats=void 0;function Xt(t,e){return{validate:t,compare:e}}Yt.fullFormats={date:Xt(av,Cp),time:Xt(Np(!0),Mp),"date-time":Xt(ov(!0),uv),"iso-time":Xt(Np(),cv),"iso-date-time":Xt(ov(),lv),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:NI,"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:ZI,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:AI,int32:{type:"number",validate:jI},int64:{type:"number",validate:DI},float:{type:"number",validate:iv},double:{type:"number",validate:iv},password:!0,binary:!0};Yt.fastFormats={...Yt.fullFormats,date:Xt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Cp),time:Xt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Mp),"date-time":Xt(/^\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,uv),"iso-time":Xt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,cv),"iso-date-time":Xt(/^\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,lv),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};Yt.formatNames=Object.keys(Yt.fullFormats);function PI(t){return t%4===0&&(t%100!==0||t%400===0)}var RI=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,II=[0,31,28,31,30,31,30,31,31,30,31,30,31];function av(t){let e=RI.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&PI(r)?29:II[n])}function Cp(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Op=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Np(t){return function(r){let n=Op.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,h=o-u*c-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&i<61}}function Mp(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function cv(t,e){if(!(t&&e))return;let r=Op.exec(t),n=Op.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Ap=/t|\s/i;function ov(t){let e=Np(t);return function(n){let o=n.split(Ap);return o.length===2&&av(o[0])&&e(o[1])}}function uv(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function lv(t,e){if(!(t&&e))return;let[r,n]=t.split(Ap),[o,s]=e.split(Ap),i=Cp(r,o);if(i!==void 0)return i||Mp(n,s)}var zI=/\/|:/,OI=/^(?:[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 NI(t){return zI.test(t)&&OI.test(t)}var sv=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function AI(t){return sv.lastIndex=0,sv.test(t)}var CI=-(2**31),MI=2**31-1;function jI(t){return Number.isInteger(t)&&t<=MI&&t>=CI}function DI(t){return Number.isInteger(t)}function iv(){return!0}var LI=/[^\\]\\Z/;function ZI(t){if(LI.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var pv=S(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.formatLimitDefinition=void 0;var UI=zp(),qt=W(),Dr=qt.operators,Na={formatMaximum:{okStr:"<=",ok:Dr.LTE,fail:Dr.GT},formatMinimum:{okStr:">=",ok:Dr.GTE,fail:Dr.LT},formatExclusiveMaximum:{okStr:"<",ok:Dr.LT,fail:Dr.GTE},formatExclusiveMinimum:{okStr:">",ok:Dr.GT,fail:Dr.LTE}},qI={message:({keyword:t,schemaCode:e})=>(0,qt.str)`should be ${Na[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,qt._)`{comparison: ${Na[t].okStr}, limit: ${e}}`};xo.formatLimitDefinition={keyword:Object.keys(Na),type:"string",schemaType:"string",$data:!0,error:qI,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new UI.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,qt._)`${h}[${c.schemaCode}]`);t.fail$data((0,qt.or)((0,qt._)`typeof ${m} != "object"`,(0,qt._)`${m} instanceof RegExp`,(0,qt._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let h=c.schema,m=a.formats[h];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${h}" does not define "compare" function`);let p=e.scopeValue("formats",{key:h,ref:m,code:i.code.formats?(0,qt._)`${i.code.formats}${(0,qt.getProperty)(h)}`:void 0});t.fail$data(d(p))}function d(h){return(0,qt._)`${h}.compare(${r}, ${n}) ${Na[o].fail} 0`}},dependencies:["format"]};var FI=t=>(t.addKeyword(xo.formatLimitDefinition),t);xo.default=FI});var gv=S((Ds,hv)=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});var $o=dv(),VI=pv(),jp=W(),fv=new jp.Name("fullFormats"),HI=new jp.Name("fastFormats"),Dp=(t,e={keywords:!0})=>{if(Array.isArray(e))return mv(t,e,$o.fullFormats,fv),t;let[r,n]=e.mode==="fast"?[$o.fastFormats,HI]:[$o.fullFormats,fv],o=e.formats||$o.formatNames;return mv(t,o,r,n),e.keywords&&(0,VI.default)(t),t};Dp.get=(t,e="full")=>{let n=(e==="fast"?$o.fastFormats:$o.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function mv(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,jp._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}hv.exports=Ds=Dp;Object.defineProperty(Ds,"__esModule",{value:!0});Ds.default=Dp});var zv=S(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.EdgePort=void 0;var Iv;(function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"})(Iv||(La.EdgePort=Iv={}))});var Za=S(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.NODE_RULES=void 0;Qt.nodeSupportsStyleProp=QI;Qt.isStyledBoxType=ez;Qt.NODE_RULES={ID_NON_EMPTY:!0,NAME_MAX_LENGTH:256,ALLOWED_TYPES:["container","task","sticky","view","text","template_definition","template_instance","data_wrapper","image","list_data"],MAX_CHILDREN:500,MAX_EDGES_PER_NODE:50,MAX_NODES_PER_PROJECT:5e3,ALLOWED_DATA_API_PATHS:["/notes","/node-assets"],STYLE_CAPABILITIES:{view:["backgroundColor","borderColor","borderWidth","borderStyle","borderRadius","overflow"],container:["backgroundColor","borderRadius"],text:[],sticky:[],image:[],task:[],template_definition:[],template_instance:[],data_wrapper:[],list_data:[]}};function QI(t,e){return!t||!(t in Qt.NODE_RULES.STYLE_CAPABILITIES)?!1:Qt.NODE_RULES.STYLE_CAPABILITIES[t].includes(e)}function ez(t){return!t||!(t in Qt.NODE_RULES.STYLE_CAPABILITIES)?!1:Qt.NODE_RULES.STYLE_CAPABILITIES[t].length>0}});var Fp=S(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.EDGE_RULES=void 0;Zs.canConnectNodes=tz;Zs.EDGE_RULES={ID_NON_EMPTY:!0,NO_SELF_LOOP:!0,NO_EDGE_INTO_TASK:!0,NO_DANGLING_REFERENCES:!0,ALLOWED_PORTS:["top","right","bottom","left"],MAX_EDGES_PER_PROJECT:1e4};function tz(t,e){return e?.type!=="task"}});var Vp=S(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.DIFF_RULES=void 0;Ua.DIFF_RULES={MAX_ADDED:200,MAX_UPDATED:500,MAX_REMOVED:500,NO_ADD_UPDATE_OVERLAP:!0,NO_ADD_REMOVE_OVERLAP:!0,NO_UPDATE_REMOVE_OVERLAP:!0,NO_DUPLICATE_ADDED:!0,NO_DUPLICATE_UPDATED:!0,REMOVED_MUST_EXIST:!0,ADDED_MUST_NOT_EXIST:!0}});var Hp=S(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.PROJECT_RULES=void 0;qa.PROJECT_RULES={NAME_MIN_LENGTH:1,NAME_MAX_LENGTH:128,IS_GENERAL_CLIENT_SETTABLE:!1,IS_TEMPLATE_IMMUTABLE_AFTER_CREATE:!0,MAX_PROJECTS_PER_WORKSPACE:200,MAX_LATEST_DATA_SIZE_BYTES:10*1024*1024}});var Gp=S(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.TASK_RULES=void 0;Fa.TASK_RULES={NAME_MAX_LENGTH:512,DESCRIPTION_MAX_LENGTH:1e4,MAX_ASSIGNED_USERS:20,MAX_TASKS_PER_PROJECT:5e3,PROGRESS_TAG_MUST_EXIST:!0,TASK_TYPE_TAG_MUST_EXIST:!0,ASSIGNED_USERS_MUST_EXIST:!0}});var Ov=S(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.TASK_NODE_RULES=void 0;Va.TASK_NODE_RULES={TASK_ID_REQUIRED:!0,TASK_VERSION_IMMUTABLE_VIA_DIFF:!0,TASK_MUST_EXIST_FOR_NODE:!0,SOFT_DELETE_TASK_ON_NODE_REMOVE:!0,TYPE_CHANGE_FORBIDDEN:!0}});var Nv=S(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.TEMPLATE_RULES=void 0;Ha.TEMPLATE_RULES={MAX_BOUNDED_TEMPLATES:20,UNBIND_BLOCKED_BY_REFERENCES:!0,ONLY_TEMPLATE_PROJECTS_BINDABLE:!0,NO_SELF_BIND:!0,NON_DELETABLE_NODES_PROTECTED:!0,NO_TEMPLATE_ADD_TO_SPECIAL_NODES:!0,NO_NESTED_TEMPLATES_IN_TEMPLATE_PROJECT:!0,TEMPLATE_DEFINITION_ONLY_IN_TEMPLATE:!0,TEMPLATE_DEFINITION_REQUIRED:!0,TEMPLATE_DEFINITION_MAX_CHILDREN:1,GENERAL_TEMPLATE_IMPLICIT_BIND:!0}});var Av=S(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.IMAGE_RULES=void 0;Ga.IMAGE_RULES={ALLOWED_MIME_TYPES:["image/png","image/jpeg","image/webp"],MAX_FILE_SIZE_BYTES:5*1024*1024,IMAGE_PROJECT_MUST_MATCH:!0,NODE_ID_MUST_EXIST:!0,IMAGE_NODE_BINDING_IMMUTABLE:!0,MAX_IMAGES_PER_PROJECT:500}});var Cv=S(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.AUTH_RULES=void 0;Ba.AUTH_RULES={PASSWORD_MIN_LENGTH:8,PASSWORD_MAX_LENGTH:128,EMAIL_MAX_LENGTH:256,NAME_MAX_LENGTH:128,COMPANY_NAME_MAX_LENGTH:128,JWT_SUB_REQUIRED:!0,AUTH_GUARD_REQUIRED:!0,MAX_LOGIN_ATTEMPTS_PER_MINUTE:10}});var Mv=S(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.WORKSPACE_RULES=void 0;Ka.WORKSPACE_RULES={NAME_MIN_LENGTH:1,NAME_MAX_LENGTH:128,MEMBERSHIP_REQUIRED:!0,MAX_WORKSPACES_PER_USER:10,ALLOWED_TEMPLATE_TYPES:["SOFTWARE","MARKETING","DESIGN","CONTENT","PERSONAL"],MAX_PROGRESS_TAGS:50,MAX_TASK_TYPE_TAGS:50,TAG_NAME_MAX_LENGTH:64,TAG_COLOR_FORMAT:/^#[0-9a-fA-F]{6}$/}});var jv=S(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.VIEW_RULES=void 0;Wa.VIEW_RULES={NAME_MAX_LENGTH:128,DESCRIPTION_MAX_LENGTH:1e3,USER_SCOPED:!0,MAX_VIEWS_PER_WORKSPACE:50,ALLOWED_FILTER_KEYS:["status","assigneeIds","tagNames","projectIds","dueDate","sort","groupBy"],ALLOWED_SORT_DIRS:["asc","desc"],ALLOWED_SORT_FIELDS:["createDate","updateDate"],MAX_SORT_SPECS:5,GROUP_BY_STRING_ONLY:!0}});var Bp=S(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.BOUNDS_RULES=void 0;Ja.BOUNDS_RULES={MIN_WIDTH:0,MIN_HEIGHT:0,MAX_WIDTH:5e4,MAX_HEIGHT:5e4,MIN_COORDINATE:-1e5,MAX_COORDINATE:1e5,MUST_BE_FINITE:!0,MUST_BE_NUMBER:!0}});var Kp=S(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.LAYOUT_RULES=void 0;Xa.LAYOUT_RULES={ALLOWED_FLEX_DIRECTIONS:["row","row-reverse","column","column-reverse"],ALLOWED_FLEX_WRAPS:["wrap","wrap-reverse","nowrap","none"],ALLOWED_JUSTIFY_CONTENT:["flex-start","center","flex-end","space-between","space-around","space-evenly"],ALLOWED_ALIGN_ITEMS:["flex-start","center","flex-end","stretch","baseline"],ALLOWED_ALIGN_SELF:["flex-start","center","flex-end","stretch","baseline","auto"],ALLOWED_POSITIONS:["relative","absolute"],MIN_PADDING:0,MAX_PADDING:1e3,MIN_MARGIN:-1e3,MAX_MARGIN:1e3,MIN_GAP:0,MAX_GAP:1e3,MIN_FLEX_GROW:0,MAX_FLEX_GROW:1e3,MIN_FLEX_SHRINK:0,MAX_FLEX_SHRINK:1e3}});var So=S(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.ok=Dv;Us.fail=rz;Us.runValidators=nz;function Dv(){return{valid:!0}}function rz(t,e){return{valid:!1,rule:t,message:e}}function nz(t){for(let e of t){let r=e();if(!r.valid)return r}return Dv()}});var Jp=S(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.validateNode=pz;var Tn=Za(),rt=Bp(),oz=Fp(),Se=Kp(),X=So();function sz(t){return typeof t!="string"||t.trim().length===0?(0,X.fail)("NODE_ID",`Node ID must be a non-empty string. Got: ${String(t)}`):(0,X.ok)()}function iz(t){return t!==void 0&&t.length>Tn.NODE_RULES.NAME_MAX_LENGTH?(0,X.fail)("NODE_NAME_LENGTH",`Node name exceeds maximum length of ${Tn.NODE_RULES.NAME_MAX_LENGTH} characters.`):(0,X.ok)()}function az(t){if(t===void 0)return(0,X.ok)();let e=Tn.NODE_RULES.ALLOWED_TYPES;return e.includes(t)?(0,X.ok)():(0,X.fail)("NODE_TYPE",`Invalid node type "${t}". Allowed: ${e.join(", ")}.`)}function cz(t){return t&&t.length>Tn.NODE_RULES.MAX_CHILDREN?(0,X.fail)("NODE_MAX_CHILDREN",`Node has ${t.length} children, exceeds maximum of ${Tn.NODE_RULES.MAX_CHILDREN}.`):(0,X.ok)()}function uz(t,e){if(!e)return(0,X.ok)();if(e.length>Tn.NODE_RULES.MAX_EDGES_PER_NODE)return(0,X.fail)("NODE_MAX_EDGES",`Node has ${e.length} edges, exceeds maximum of ${Tn.NODE_RULES.MAX_EDGES_PER_NODE}.`);for(let r of e){if(typeof r.id!="string"||r.id.trim().length===0)return(0,X.fail)("EDGE_ID",`Edge ID must be a non-empty string. Got: ${String(r.id)}`);if(r.to===t)return(0,X.fail)("EDGE_SELF_LOOP",`Edge ${r.id} on node ${t} points to itself (self-loop).`);let n=oz.EDGE_RULES.ALLOWED_PORTS;if(r.fromPort!==void 0&&!n.includes(r.fromPort))return(0,X.fail)("EDGE_PORT",`Invalid edge fromPort "${r.fromPort}". Allowed: ${n.join(", ")}.`);if(r.toPort!==void 0&&!n.includes(r.toPort))return(0,X.fail)("EDGE_PORT",`Invalid edge toPort "${r.toPort}". Allowed: ${n.join(", ")}.`)}return(0,X.ok)()}function lz(t){if(!t)return(0,X.ok)();let e=[t.x,t.y,t.width,t.height];for(let r of e)if(typeof r!="number"||!Number.isFinite(r))return(0,X.fail)("BOUNDS_FINITE",`All bounds values must be finite numbers. Got: ${r}`);return t.width<rt.BOUNDS_RULES.MIN_WIDTH?(0,X.fail)("BOUNDS_MIN_WIDTH",`Width must be at least ${rt.BOUNDS_RULES.MIN_WIDTH}. Got: ${t.width}`):t.height<rt.BOUNDS_RULES.MIN_HEIGHT?(0,X.fail)("BOUNDS_MIN_HEIGHT",`Height must be at least ${rt.BOUNDS_RULES.MIN_HEIGHT}. Got: ${t.height}`):t.width>rt.BOUNDS_RULES.MAX_WIDTH?(0,X.fail)("BOUNDS_MAX_WIDTH",`Width exceeds maximum of ${rt.BOUNDS_RULES.MAX_WIDTH}. Got: ${t.width}`):t.height>rt.BOUNDS_RULES.MAX_HEIGHT?(0,X.fail)("BOUNDS_MAX_HEIGHT",`Height exceeds maximum of ${rt.BOUNDS_RULES.MAX_HEIGHT}. Got: ${t.height}`):t.x<rt.BOUNDS_RULES.MIN_COORDINATE||t.x>rt.BOUNDS_RULES.MAX_COORDINATE?(0,X.fail)("BOUNDS_COORDINATE_X",`X coordinate out of range [${rt.BOUNDS_RULES.MIN_COORDINATE}, ${rt.BOUNDS_RULES.MAX_COORDINATE}]. Got: ${t.x}`):t.y<rt.BOUNDS_RULES.MIN_COORDINATE||t.y>rt.BOUNDS_RULES.MAX_COORDINATE?(0,X.fail)("BOUNDS_COORDINATE_Y",`Y coordinate out of range [${rt.BOUNDS_RULES.MIN_COORDINATE}, ${rt.BOUNDS_RULES.MAX_COORDINATE}]. Got: ${t.y}`):(0,X.ok)()}function dz(t){if(!t)return(0,X.ok)();let e=Se.LAYOUT_RULES.ALLOWED_FLEX_DIRECTIONS;if(t.flexDirection!==void 0&&!e.includes(t.flexDirection))return(0,X.fail)("LAYOUT_FLEX_DIRECTION",`Invalid flexDirection "${t.flexDirection}". Allowed: ${e.join(", ")}.`);let r=Se.LAYOUT_RULES.ALLOWED_FLEX_WRAPS;if(t.flexWrap!==void 0&&!r.includes(t.flexWrap))return(0,X.fail)("LAYOUT_FLEX_WRAP",`Invalid flexWrap "${t.flexWrap}". Allowed: ${r.join(", ")}.`);let n=Se.LAYOUT_RULES.ALLOWED_JUSTIFY_CONTENT;if(t.justifyContent!==void 0&&!n.includes(t.justifyContent))return(0,X.fail)("LAYOUT_JUSTIFY_CONTENT",`Invalid justifyContent "${t.justifyContent}". Allowed: ${n.join(", ")}.`);let o=Se.LAYOUT_RULES.ALLOWED_ALIGN_ITEMS;if(t.alignItems!==void 0&&!o.includes(t.alignItems))return(0,X.fail)("LAYOUT_ALIGN_ITEMS",`Invalid alignItems "${t.alignItems}". Allowed: ${o.join(", ")}.`);let s=Se.LAYOUT_RULES.ALLOWED_ALIGN_SELF;if(t.alignSelf!==void 0&&!s.includes(t.alignSelf))return(0,X.fail)("LAYOUT_ALIGN_SELF",`Invalid alignSelf "${t.alignSelf}". Allowed: ${s.join(", ")}.`);let i=Se.LAYOUT_RULES.ALLOWED_POSITIONS;if(t.position!==void 0&&!i.includes(t.position))return(0,X.fail)("LAYOUT_POSITION",`Invalid position "${t.position}". Allowed: ${i.join(", ")}.`);let a=["padding","paddingTop","paddingRight","paddingBottom","paddingLeft"];for(let u of a){let l=t[u];if(l!==void 0&&(l<Se.LAYOUT_RULES.MIN_PADDING||l>Se.LAYOUT_RULES.MAX_PADDING))return(0,X.fail)("LAYOUT_PADDING",`${u} must be between ${Se.LAYOUT_RULES.MIN_PADDING} and ${Se.LAYOUT_RULES.MAX_PADDING}. Got: ${l}`)}let c=["margin","marginTop","marginRight","marginBottom","marginLeft"];for(let u of c){let l=t[u];if(l!==void 0&&(l<Se.LAYOUT_RULES.MIN_MARGIN||l>Se.LAYOUT_RULES.MAX_MARGIN))return(0,X.fail)("LAYOUT_MARGIN",`${u} must be between ${Se.LAYOUT_RULES.MIN_MARGIN} and ${Se.LAYOUT_RULES.MAX_MARGIN}. Got: ${l}`)}return t.gap!==void 0&&(t.gap<Se.LAYOUT_RULES.MIN_GAP||t.gap>Se.LAYOUT_RULES.MAX_GAP)?(0,X.fail)("LAYOUT_GAP",`Gap must be between ${Se.LAYOUT_RULES.MIN_GAP} and ${Se.LAYOUT_RULES.MAX_GAP}. Got: ${t.gap}`):t.flexGrow!==void 0&&(t.flexGrow<Se.LAYOUT_RULES.MIN_FLEX_GROW||t.flexGrow>Se.LAYOUT_RULES.MAX_FLEX_GROW)?(0,X.fail)("LAYOUT_FLEX_GROW",`flexGrow must be between ${Se.LAYOUT_RULES.MIN_FLEX_GROW} and ${Se.LAYOUT_RULES.MAX_FLEX_GROW}. Got: ${t.flexGrow}`):t.flexShrink!==void 0&&(t.flexShrink<Se.LAYOUT_RULES.MIN_FLEX_SHRINK||t.flexShrink>Se.LAYOUT_RULES.MAX_FLEX_SHRINK)?(0,X.fail)("LAYOUT_FLEX_SHRINK",`flexShrink must be between ${Se.LAYOUT_RULES.MIN_FLEX_SHRINK} and ${Se.LAYOUT_RULES.MAX_FLEX_SHRINK}. Got: ${t.flexShrink}`):(0,X.ok)()}function pz(t){return(0,X.runValidators)([()=>sz(t.id),()=>iz(t.name),()=>az(t.type),()=>cz(t.children),()=>uz(t.id,t.edges),()=>lz(t.bounds),()=>dz(t.layout)])}});var Zv=S(Xp=>{"use strict";Object.defineProperty(Xp,"__esModule",{value:!0});Xp.validateDiffPayload=vz;var Eo=Vp(),Lv=Za(),at=So(),fz=Jp();function mz(t){return t.added&&t.added.length>Eo.DIFF_RULES.MAX_ADDED?(0,at.fail)("DIFF_MAX_ADDED",`Diff contains ${t.added.length} added nodes, exceeds maximum of ${Eo.DIFF_RULES.MAX_ADDED}.`):t.updated&&t.updated.length>Eo.DIFF_RULES.MAX_UPDATED?(0,at.fail)("DIFF_MAX_UPDATED",`Diff contains ${t.updated.length} updated nodes, exceeds maximum of ${Eo.DIFF_RULES.MAX_UPDATED}.`):t.removedIds&&t.removedIds.length>Eo.DIFF_RULES.MAX_REMOVED?(0,at.fail)("DIFF_MAX_REMOVED",`Diff contains ${t.removedIds.length} removed nodes, exceeds maximum of ${Eo.DIFF_RULES.MAX_REMOVED}.`):(0,at.ok)()}function hz(t){let e=new Set;if(t.added)for(let n of t.added){if(e.has(n.id))return(0,at.fail)("DIFF_DUPLICATE_ADDED",`Duplicate node ID ${n.id} in diff.added.`);e.add(n.id)}let r=new Set;if(t.updated)for(let n of t.updated){if(r.has(n.id))return(0,at.fail)("DIFF_DUPLICATE_UPDATED",`Duplicate node ID ${n.id} in diff.updated.`);r.add(n.id)}return(0,at.ok)()}function gz(t){let e=(t.added??[]).map(s=>s.id),r=new Set((t.updated??[]).map(s=>s.id)),n=new Set(t.removedIds??[]);for(let s of e){if(r.has(s))return(0,at.fail)("DIFF_ADD_UPDATE_OVERLAP",`Node ID ${s} appears in both diff.added and diff.updated.`);if(n.has(s))return(0,at.fail)("DIFF_ADD_REMOVE_OVERLAP",`Node ID ${s} appears in both diff.added and diff.removedIds.`)}let o=(t.updated??[]).map(s=>s.id);for(let s of o)if(n.has(s))return(0,at.fail)("DIFF_UPDATE_REMOVE_OVERLAP",`Node ID ${s} appears in both diff.updated and diff.removedIds.`);return(0,at.ok)()}function _z(t){let e=[...t.added??[],...t.updated??[]];for(let r of e){let n=(0,fz.validateNode)(r);if(!n.valid)return n}return(0,at.ok)()}function yz(t,e){let r=t.added?.length??0,n=t.removedIds?.length??0,o=e+r-n;return o>Lv.NODE_RULES.MAX_NODES_PER_PROJECT?(0,at.fail)("DIFF_TOTAL_NODES",`After applying this diff, the project would have ${o} nodes, exceeds maximum of ${Lv.NODE_RULES.MAX_NODES_PER_PROJECT}.`):(0,at.ok)()}function vz(t,e){return(0,at.runValidators)([()=>mz(t),()=>hz(t),()=>gz(t),()=>_z(t),()=>yz(t,e)])}});var qv=S(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.validateCreateProject=wz;Qa.validateUpdateProject=xz;var Ya=Hp(),Pn=So();function Uv(t){return t.length<Ya.PROJECT_RULES.NAME_MIN_LENGTH?(0,Pn.fail)("PROJECT_NAME_MIN",`Project name must be at least ${Ya.PROJECT_RULES.NAME_MIN_LENGTH} character(s).`):t.length>Ya.PROJECT_RULES.NAME_MAX_LENGTH?(0,Pn.fail)("PROJECT_NAME_MAX",`Project name exceeds maximum length of ${Ya.PROJECT_RULES.NAME_MAX_LENGTH} characters.`):(0,Pn.ok)()}function bz(t){return t===!0?(0,Pn.fail)("PROJECT_IS_GENERAL","Cannot set isGeneral flag from client. This is a server-controlled field."):(0,Pn.ok)()}function wz(t){return(0,Pn.runValidators)([()=>Uv(t.name),()=>bz(t.isGeneral)])}function xz(t){return t.name!==void 0?Uv(t.name):(0,Pn.ok)()}});var Gv=S(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.validateCreateTask=$z;ec.validateUpdateTask=Sz;var ko=Gp(),Ur=So();function Fv(t){return t!==void 0&&t.length>ko.TASK_RULES.NAME_MAX_LENGTH?(0,Ur.fail)("TASK_NAME_MAX",`Task name exceeds maximum length of ${ko.TASK_RULES.NAME_MAX_LENGTH} characters.`):(0,Ur.ok)()}function Vv(t){return typeof t=="string"&&t.length>ko.TASK_RULES.DESCRIPTION_MAX_LENGTH?(0,Ur.fail)("TASK_DESCRIPTION_MAX",`Task description exceeds maximum length of ${ko.TASK_RULES.DESCRIPTION_MAX_LENGTH} characters.`):(0,Ur.ok)()}function Hv(t){return t&&t.length>ko.TASK_RULES.MAX_ASSIGNED_USERS?(0,Ur.fail)("TASK_MAX_ASSIGNED_USERS",`Task has ${t.length} assigned users, exceeds maximum of ${ko.TASK_RULES.MAX_ASSIGNED_USERS}.`):(0,Ur.ok)()}function $z(t){return(0,Ur.runValidators)([()=>Fv(t.name),()=>Vv(t.description),()=>Hv(t.assignedUserIds)])}function Sz(t){return(0,Ur.runValidators)([()=>Fv(t.name),()=>Vv(t.description),()=>Hv(t.assignedUserIds)])}});var Jv=S(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.validateUpdateTask=U.validateCreateTask=U.validateUpdateProject=U.validateCreateProject=U.validateDiffPayload=U.validateNode=U.runValidators=U.ok=U.LAYOUT_RULES=U.BOUNDS_RULES=U.VIEW_RULES=U.WORKSPACE_RULES=U.AUTH_RULES=U.IMAGE_RULES=U.TEMPLATE_RULES=U.TASK_NODE_RULES=U.TASK_RULES=U.PROJECT_RULES=U.DIFF_RULES=U.canConnectNodes=U.EDGE_RULES=U.isStyledBoxType=U.nodeSupportsStyleProp=U.NODE_RULES=void 0;var Yp=Za();Object.defineProperty(U,"NODE_RULES",{enumerable:!0,get:function(){return Yp.NODE_RULES}});Object.defineProperty(U,"nodeSupportsStyleProp",{enumerable:!0,get:function(){return Yp.nodeSupportsStyleProp}});Object.defineProperty(U,"isStyledBoxType",{enumerable:!0,get:function(){return Yp.isStyledBoxType}});var Bv=Fp();Object.defineProperty(U,"EDGE_RULES",{enumerable:!0,get:function(){return Bv.EDGE_RULES}});Object.defineProperty(U,"canConnectNodes",{enumerable:!0,get:function(){return Bv.canConnectNodes}});var Ez=Vp();Object.defineProperty(U,"DIFF_RULES",{enumerable:!0,get:function(){return Ez.DIFF_RULES}});var kz=Hp();Object.defineProperty(U,"PROJECT_RULES",{enumerable:!0,get:function(){return kz.PROJECT_RULES}});var Tz=Gp();Object.defineProperty(U,"TASK_RULES",{enumerable:!0,get:function(){return Tz.TASK_RULES}});var Pz=Ov();Object.defineProperty(U,"TASK_NODE_RULES",{enumerable:!0,get:function(){return Pz.TASK_NODE_RULES}});var Rz=Nv();Object.defineProperty(U,"TEMPLATE_RULES",{enumerable:!0,get:function(){return Rz.TEMPLATE_RULES}});var Iz=Av();Object.defineProperty(U,"IMAGE_RULES",{enumerable:!0,get:function(){return Iz.IMAGE_RULES}});var zz=Cv();Object.defineProperty(U,"AUTH_RULES",{enumerable:!0,get:function(){return zz.AUTH_RULES}});var Oz=Mv();Object.defineProperty(U,"WORKSPACE_RULES",{enumerable:!0,get:function(){return Oz.WORKSPACE_RULES}});var Nz=jv();Object.defineProperty(U,"VIEW_RULES",{enumerable:!0,get:function(){return Nz.VIEW_RULES}});var Az=Bp();Object.defineProperty(U,"BOUNDS_RULES",{enumerable:!0,get:function(){return Az.BOUNDS_RULES}});var Cz=Kp();Object.defineProperty(U,"LAYOUT_RULES",{enumerable:!0,get:function(){return Cz.LAYOUT_RULES}});var Qp=So();Object.defineProperty(U,"ok",{enumerable:!0,get:function(){return Qp.ok}});Object.defineProperty(U,"fail",{enumerable:!0,get:function(){return Qp.fail}});Object.defineProperty(U,"runValidators",{enumerable:!0,get:function(){return Qp.runValidators}});var Mz=Jp();Object.defineProperty(U,"validateNode",{enumerable:!0,get:function(){return Mz.validateNode}});var jz=Zv();Object.defineProperty(U,"validateDiffPayload",{enumerable:!0,get:function(){return jz.validateDiffPayload}});var Kv=qv();Object.defineProperty(U,"validateCreateProject",{enumerable:!0,get:function(){return Kv.validateCreateProject}});Object.defineProperty(U,"validateUpdateProject",{enumerable:!0,get:function(){return Kv.validateUpdateProject}});var Wv=Gv();Object.defineProperty(U,"validateCreateTask",{enumerable:!0,get:function(){return Wv.validateCreateTask}});Object.defineProperty(U,"validateUpdateTask",{enumerable:!0,get:function(){return Wv.validateUpdateTask}})});var tf=S(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.headlessTextMeasurer=void 0;var ef=1.4,Dz=.55;tc.headlessTextMeasurer={measure(t,e,r){if(!t)return{width:0,height:e*ef};let n=e*Dz;if(r&&r>0){let o=Math.max(1,Math.floor(r/n)),s=Math.ceil(t.length/o);return{width:r,height:s*(e*ef)}}return{width:t.length*n,height:e*ef}}}});var Yv=S(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.layoutContainerChildren=Zz;var Lz=tf();function Nt(t,e){let r=t.layout;return r?e==="top"?r.marginTop??r.margin??0:e==="right"?r.marginRight??r.margin??0:e==="bottom"?r.marginBottom??r.margin??0:r.marginLeft??r.margin??0:0}function Zz(t,e,r=Lz.headlessTextMeasurer){let n=new Set,o=new Map,s=new Map;for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];o.set(f.id,p),s.set(f.id,{x:f.bounds.x,y:f.bounds.y,w:f.bounds.width,h:f.bounds.height,children:f.children.slice()})}let i=()=>{let p=new Set;for(let f of t.nodes){let g=s.get(f.id);if(!g){p.add(f.id);continue}if(g.x!==f.bounds.x||g.y!==f.bounds.y||g.w!==f.bounds.width||g.h!==f.bounds.height){p.add(f.id);continue}if(g.children.length!==f.children.length){p.add(f.id);continue}for(let _=0;_<g.children.length;_++)if(g.children[_]!==f.children[_]){p.add(f.id);break}}return p};if(t.ghostLayout){let{padding:p,gap:f,flexDirection:g}=t.ghostLayout,_=[];for(let v of t.nodes)v.parent===null&&_.push(v);if(_.length>0){_.sort((y,T)=>{if(g==="row"){let F=y.bounds.y-T.bounds.y;return Math.abs(F)>20?F:y.bounds.x-T.bounds.x}else{let F=y.bounds.x-T.bounds.x;return Math.abs(F)>20?F:y.bounds.y-T.bounds.y}});let v=p,$=p;for(let y of _){if(y.layout?.position==="absolute"||y.type==="task")continue;let T=y.bounds.width,F=y.bounds.height;if(g==="row"){if(!e?.has(y.id)&&(y.bounds.x!==v||y.bounds.y!==$)){let te=o.get(y.id);te!==void 0&&te!==-1&&(t.nodes[te].bounds.x=v,t.nodes[te].bounds.y=$,n.add(y.id))}v+=T+f}else{if(!e?.has(y.id)&&(y.bounds.x!==v||y.bounds.y!==$)){let te=o.get(y.id);te!==void 0&&te!==-1&&(t.nodes[te].bounds.x=v,t.nodes[te].bounds.y=$,n.add(y.id))}$+=F+f}}}}let a=new Set;for(let p of t.nodes)(p.type==="container"||p.type==="list_data"||p.type==="template_definition"||p.type==="view"&&p.isAutoLayout)&&a.add(p.id);if(a.size===0)return i();let c=new Map;for(let p of t.nodes)typeof p.parent=="string"&&a.has(p.parent)&&(c.has(p.parent)||c.set(p.parent,[]),c.get(p.parent).push(p));let u=new Map,l=new Set;function d(p){if(u.has(p))return u.get(p);if(l.has(p))return u.set(p,0),0;let f=o.get(p),g=f!==void 0?t.nodes[f]:void 0;if(!g||g.parent===null||g.parent===p||!a.has(g.parent))return u.set(p,0),0;l.add(p);let _=d(g.parent)+1;return l.delete(p),u.set(p,_),_}let h=Array.from(c.keys());for(let p of h)d(p);h.sort((p,f)=>(u.get(f)??0)-(u.get(p)??0));let m=new Map;for(let p of h){let f=c.get(p);if(!f||f.length===0)continue;let g=o.get(p),_=g!==void 0?t.nodes[g]:void 0;if(!_)continue;let v=_.layout||{},$=_.type==="template_definition"?32:_.type==="data_wrapper"?0:10,y=_.type==="data_wrapper"?0:10,T=v.padding??$,F=v.paddingTop??T,te=v.paddingRight??T,Xe=v.paddingBottom??T,q=v.paddingLeft??T,ce=v.gap??y,Ce=v.flexDirection??"row",Q=Ce==="row"||Ce==="row-reverse",er=Ce==="row-reverse"||Ce==="column-reverse",tr=v.flexWrap??"nowrap",_r=tr==="wrap"||tr==="wrap-reverse",Oo=tr==="wrap-reverse",On=Q?q:F,Ft=Q?F:q,yr=_.bounds.width-q-te,Nn=_.bounds.height-F-Xe,Vs=Q?yr:Nn,qr=On,An=Ft,Cn=0,z=new Map;_.children.forEach((j,de)=>z.set(j,de)),f.sort((j,de)=>(z.get(j.id)??Number.MAX_SAFE_INTEGER)-(z.get(de.id)??Number.MAX_SAFE_INTEGER));let D=!!e&&f.some(j=>e.has(j.id));if(er)f.reverse();else{D&&f.sort((me,Le)=>{if(Q){let Ve=me.bounds.y-Le.bounds.y;return Math.abs(Ve)>20?Ve:me.bounds.x-Le.bounds.x}else{let Ve=me.bounds.x-Le.bounds.x;return Math.abs(Ve)>20?Ve:me.bounds.y-Le.bounds.y}});let j=f.map(me=>me.id);if(_.children.length!==j.length||_.children.some((me,Le)=>me!==j[Le])){let me=o.get(p);me!==void 0&&me!==-1&&(t.nodes[me].children=j,n.add(p))}}let ue=_.type==="view"&&_.isAutoLayout,Ae=new Map,$t=0;m.set(p,{parentNode:_,children:f,padTop:F,padRight:te,padBottom:Xe,padLeft:q,gap:ce,isRow:Q,wrapEnabled:_r,justifyContent:v.justifyContent,alignItems:v.alignItems,rowAssignment:Ae});for(let j of f){if(j.layout?.position==="absolute"||j.type==="task")continue;if(ue&&j.type==="text"){let be=o.get(j.id);if(be!==void 0&&be!==-1){let je=j,Vr=je.layout?.widthPinned===!0,Hs=je.layout?.heightPinned===!0,or=je.bounds.width,Gs=je.bounds.height,$b=je.layout?.alignSelf&&je.layout.alignSelf!=="auto"?je.layout.alignSelf:v.alignItems??"stretch",Sb=!Q&&$b==="stretch";if(!Vr){let Bs=r.measure(je.content||"",je.fontSize||14).width+8,vf=_.layout?.widthPinned===!0,bf=Math.max(0,_.bounds.width-q-te-Nt(j,"left")-Nt(j,"right"));!Q&&vf?or=Sb?bf:Math.min(Bs,bf):or=Bs}if(!Hs){let Bs=Math.max(0,or-8);Gs=r.measure(je.content||"",je.fontSize||14,Bs).height+8}let lc=!1;!Vr&&Math.abs(t.nodes[be].bounds.width-or)>.1&&(t.nodes[be].bounds.width=or,lc=!0),!Hs&&Math.abs(t.nodes[be].bounds.height-Gs)>.1&&(t.nodes[be].bounds.height=Gs,lc=!0),lc&&n.add(j.id)}}let de=j.bounds.width,me=j.bounds.height,Le=Q?de:me,Ve=Q?me:de,Me=Nt(j,Q?"left":"top"),_e=Nt(j,Q?"right":"bottom"),_t=Nt(j,Q?"top":"left"),yt=Nt(j,Q?"bottom":"right"),vt=Me+Le+_e,vr=_t+Ve+yt;Q&&_r&&qr+vt>On+Vs&&qr!==On&&(qr=On,An+=Cn+ce,Cn=0,$t++);let Fr=qr+Me,Mn=An+_t,rr=Q?Fr:Mn,nr=Q?Mn:Fr;if(!e?.has(j.id)&&(j.bounds.x!==rr||j.bounds.y!==nr)){let be=o.get(j.id);be!==void 0&&be!==-1&&(t.nodes[be].bounds.x=rr,t.nodes[be].bounds.y=nr,n.add(j.id))}Ae.set(j.id,$t),qr+=vt+ce,vr>Cn&&(Cn=vr)}if(_.type==="view"&&_.isAutoLayout){let j=f.filter(de=>de.layout?.position!=="absolute"&&de.type!=="task"&&!e?.has(de.id));if(j.length>0){let de=0,me=0;for(let _e of j){let _t=_e.bounds.x+_e.bounds.width+Nt(_e,"right"),yt=_e.bounds.y+_e.bounds.height+Nt(_e,"bottom");_t>de&&(de=_t),yt>me&&(me=yt)}let Le=de+te,Ve=me+Xe,Me=o.get(p);if(Me!==void 0){let _e=_.parent===null,_t=_.layout?.widthPinned===!0,yt=_.layout?.heightPinned===!0,vt=null;if(!_e&&_.parent!==null){let be=o.get(_.parent),je=be!==void 0?t.nodes[be]:void 0;if(je&&a.has(je.id)){let Vr=je.layout?.flexDirection??"row",Hs=Vr==="row"||Vr==="row-reverse",or=_.layout?.alignSelf;(or&&or!=="auto"?or:je.layout?.alignItems??"stretch")==="stretch"&&(vt=Hs?"height":"width")}}let Mn=(v.alignItems??"stretch")==="stretch"&&!(Q&&_r)?Q?"height":"width":null,rr=be=>!_e&&vt!==be&&Mn!==be,nr=(be,je,Vr)=>be<je||rr(Vr)&&be>je?je:null;if(!_t){let be=nr(_.bounds.width,Le,"width");be!==null&&(t.nodes[Me].bounds.width=be,n.add(p))}if(!yt){let be=nr(_.bounds.height,Ve,"height");be!==null&&(t.nodes[Me].bounds.height=be,n.add(p))}}}}if(Q&&_r&&Oo&&Ae.size>0){let j=new Map;for(let Me of f){let _e=Ae.get(Me.id);_e!==void 0&&(j.has(_e)||j.set(_e,[]),j.get(_e).push(Me))}let de=Array.from(j.keys()).sort((Me,_e)=>Me-_e),me=[];for(let Me of de){let _e=j.get(Me),_t=1/0,yt=-1/0;for(let vt of _e){let vr=vt.bounds.y-Nt(vt,"top"),Fr=vt.bounds.y+vt.bounds.height+Nt(vt,"bottom");vr<_t&&(_t=vr),Fr>yt&&(yt=Fr)}me.push({top:_t,bottom:yt})}let Le=_.bounds.height-F-Xe,Ve=Array.from(j.keys()).sort((Me,_e)=>Me-_e);for(let Me=0;Me<Ve.length;Me++){let _e=Ve[Me],_t=j.get(_e),yt=me[Me],vt=yt.top-Ft,vr=yt.bottom-Ft,Mn=Le-vr-vt;for(let rr of _t){if(e?.has(rr.id))continue;let nr=o.get(rr.id);nr===void 0||nr===-1||(t.nodes[nr].bounds.y=rr.bounds.y+Mn,n.add(rr.id))}}}Xv({document:t,parentNode:_,children:f,padTop:F,padRight:te,padBottom:Xe,padLeft:q,gap:ce,isRow:Q,wrapEnabled:_r,justifyContent:v.justifyContent,alignItems:v.alignItems,rowAssignment:Ae,nodeIndexById:o,modifiedNodeIds:n,draggedNodeIds:e,marginOf:Nt})}for(let p=h.length-1;p>=0;p--){let f=h[p],g=m.get(f);g&&Xv({document:t,parentNode:g.parentNode,children:g.children,padTop:g.padTop,padRight:g.padRight,padBottom:g.padBottom,padLeft:g.padLeft,gap:g.gap,isRow:g.isRow,wrapEnabled:g.wrapEnabled,justifyContent:g.justifyContent,alignItems:g.alignItems,rowAssignment:g.rowAssignment,nodeIndexById:o,modifiedNodeIds:n,draggedNodeIds:e,marginOf:Nt})}return i()}function Xv(t){let{document:e,parentNode:r,children:n,padTop:o,padRight:s,padBottom:i,padLeft:a,gap:c,isRow:u,wrapEnabled:l,justifyContent:d,alignItems:h,rowAssignment:m,nodeIndexById:p,modifiedNodeIds:f,draggedNodeIds:g,marginOf:_}=t,v=n.filter(q=>q.layout?.position!=="absolute"&&q.type!=="task");if(v.length===0)return;let $=[];if(u&&l){let q=new Map;for(let ce of v){let Ce=m.get(ce.id)??0;q.has(Ce)||q.set(Ce,[]),q.get(Ce).push(ce)}for(let ce of Array.from(q.keys()).sort((Ce,Q)=>Ce-Q))$.push(q.get(ce))}else $.push(v);let y=u?a:o,T=u?r.bounds.width-a-s:r.bounds.height-o-i,F=u?r.bounds.height-o-i:r.bounds.width-a-s,te=q=>q&&q!=="auto"?q:h,Xe=q=>q==="baseline"?"flex-start":q;for(let q of $){if(q.length===0)continue;let ce=q.map(z=>u?z.bounds.width:z.bounds.height),Ce=q.map(z=>_(z,u?"left":"top")+_(z,u?"right":"bottom")),Q=ce.reduce((z,D)=>z+D,0)+Ce.reduce((z,D)=>z+D,0)+(q.length-1)*c,er=Math.max(0,T-Q),tr=q.filter(z=>{let D=z.layout?.flexGrow;return!D||D<=0||g?.has(z.id)?!1:!(u?z.layout?.widthPinned===!0:z.layout?.heightPinned===!0)});if(er>.5&&tr.length>0){let z=tr.reduce((D,ue)=>D+(ue.layout?.flexGrow||0),0);for(let D of tr){let ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=q.indexOf(D),$t=er*((D.layout?.flexGrow||0)/z),j=ce[Ae]+$t;ce[Ae]=j,u?Math.abs(e.nodes[ue].bounds.width-j)>.1&&(e.nodes[ue].bounds.width=j,f.add(D.id)):Math.abs(e.nodes[ue].bounds.height-j)>.1&&(e.nodes[ue].bounds.height=j,f.add(D.id))}}let _r=Q-T,Oo=q.filter(z=>(z.layout?.flexShrink??1)<=0||g?.has(z.id)?!1:!(u?z.layout?.widthPinned===!0:z.layout?.heightPinned===!0));if(_r>.5&&Oo.length>0){let z=Oo.reduce((D,ue)=>{let Ae=q.indexOf(ue);return D+(ue.layout?.flexShrink??1)*ce[Ae]},0);if(z>0)for(let D of Oo){let ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=q.indexOf(D),$t=(D.layout?.flexShrink??1)*ce[Ae],j=_r*($t/z),de=Math.max(0,ce[Ae]-j);ce[Ae]=de,u?Math.abs(e.nodes[ue].bounds.width-de)>.1&&(e.nodes[ue].bounds.width=de,f.add(D.id)):Math.abs(e.nodes[ue].bounds.height-de)>.1&&(e.nodes[ue].bounds.height=de,f.add(D.id))}}let On=ce.reduce((z,D)=>z+D,0)+Ce.reduce((z,D)=>z+D,0)+(q.length-1)*c,Ft=Math.max(0,T-On),yr=0,Nn=c;switch(d){case"center":yr=Ft/2;break;case"flex-end":yr=Ft;break;case"space-between":q.length>1?Nn=c+Ft/(q.length-1):yr=Ft/2;break;case"space-around":if(q.length>0){let z=Ft/q.length;yr=z/2,Nn=c+z}break;case"space-evenly":if(q.length>0){let z=Ft/(q.length+1);yr=z,Nn=c+z}break;default:break}let Vs=y+yr;for(let z=0;z<q.length;z++){let D=q[z],ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=_(D,u?"left":"top"),$t=_(D,u?"right":"bottom"),j=ce[z],de=Vs+Ae;g?.has(D.id)||(u?e.nodes[ue].bounds.x!==de&&(e.nodes[ue].bounds.x=de,f.add(D.id)):e.nodes[ue].bounds.y!==de&&(e.nodes[ue].bounds.y=de,f.add(D.id))),Vs+=Ae+j+$t+Nn}let qr=q.reduce((z,D)=>{let ue=u?D.bounds.height:D.bounds.width,Ae=_(D,u?"top":"left")+_(D,u?"bottom":"right");return Math.max(z,ue+Ae)},0),An=u&&l?qr:F,Cn=u?Math.min(...q.map(z=>z.bounds.y-_(z,"top"))):a;for(let z of q){let D=p.get(z.id);if(D===void 0||D===-1)continue;let ue=Xe(te(z.layout?.alignSelf))??"stretch",Ae=u?z.bounds.height:z.bounds.width,$t=_(z,u?"top":"left"),j=_(z,u?"bottom":"right"),de=$t+Ae+j,me=0,Le=null;switch(ue){case"center":me=(An-de)/2;break;case"flex-end":me=An-de;break;case"stretch":{if(!(u?z.layout?.heightPinned===!0:z.layout?.widthPinned===!0)){let _e=An-$t-j;Ae<_e&&(Le=_e)}break}case"flex-start":case"baseline":break;default:break}me<0&&(me=0);let Ve=Cn+me+$t;g?.has(z.id)||(u?(e.nodes[D].bounds.y!==Ve&&(e.nodes[D].bounds.y=Ve,f.add(z.id)),Le!==null&&e.nodes[D].bounds.height!==Le&&(e.nodes[D].bounds.height=Le,f.add(z.id))):(e.nodes[D].bounds.x!==Ve&&(e.nodes[D].bounds.x=Ve,f.add(z.id)),Le!==null&&e.nodes[D].bounds.width!==Le&&(e.nodes[D].bounds.width=Le,f.add(z.id))))}}}});var Qv=S(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.detectLayoutOverflows=Uz;function Uz(t){let n=new Map;for(let s of t)if(s.parent!=null){let i=n.get(s.parent);i?i.push(s):n.set(s.parent,[s])}let o=[];for(let s of t){let i=s.layout,a=i?.flexDirection;if(!a)continue;let c=n.get(s.id);if(!c||c.length===0)continue;let u=c.filter(ce=>ce.layout?.position!=="absolute");if(u.length===0)continue;let l=a==="row"||a==="row-reverse";if(u.some(ce=>(ce.layout?.flexGrow??0)>0))continue;let d=l?s.bounds?.width:s.bounds?.height;if(typeof d!="number"||!Number.isFinite(d)||d<=0)continue;let h=i?.padding??0,m=l?(i?.paddingLeft??h)+(i?.paddingRight??h):(i?.paddingTop??h)+(i?.paddingBottom??h),p=i?.gap??0,f=0,g=!0;for(let ce of u){let Ce=l?ce.bounds?.width:ce.bounds?.height;if(typeof Ce!="number"||!Number.isFinite(Ce)){g=!1;break}let Q=ce.layout,er=l?(Q?.marginLeft??Q?.margin??0)+(Q?.marginRight??Q?.margin??0):(Q?.marginTop??Q?.margin??0)+(Q?.marginBottom??Q?.margin??0);f+=Ce+er}if(!g)continue;let _=f+(u.length-1)*p+m,v=_-d;if(v<=1)continue;let $=l?"width":"height",y=s.name??"(unnamed)",T=i?.flexWrap,F=T==="wrap"||T==="wrap-reverse",te=Math.round(_),Xe=`${u.length} children need ${te}px on the main axis (\u03A3 children ${Math.round(f)} + ${u.length-1}\xD7gap ${p} + padding ${m}) but ${$} is only ${Math.round(d)}px`,q=F?`children WRAP onto a new line (flexWrap=${T}). To keep them inline: widen ${$} to \u2265${te}, set flexWrap=nowrap, or give the children flexGrow so they shrink to share the ${$}.`:`children OVERFLOW / get clipped (flexWrap=${T??"nowrap"}). Widen ${$} to \u2265${te}, reduce child sizes, or give the children flexGrow.`;o.push({overage:v,line:`\u26A0 #${s.id} "${y}" (${a}): ${Xe} \u2192 ${q}`})}return o.sort((s,i)=>i.overage-s.overage),o.slice(0,8).map(s=>s.line)}});var of=S(gt=>{"use strict";var qz=gt&&gt.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),eb=gt&&gt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&qz(e,t,r)};Object.defineProperty(gt,"__esModule",{value:!0});gt.detectLayoutOverflows=gt.headlessTextMeasurer=gt.layoutContainerChildren=void 0;eb(zv(),gt);eb(Jv(),gt);var Fz=Yv();Object.defineProperty(gt,"layoutContainerChildren",{enumerable:!0,get:function(){return Fz.layoutContainerChildren}});var Vz=tf();Object.defineProperty(gt,"headlessTextMeasurer",{enumerable:!0,get:function(){return Vz.headlessTextMeasurer}});var Hz=Qv();Object.defineProperty(gt,"detectLayoutOverflows",{enumerable:!0,get:function(){return Hz.detectLayoutOverflows}})});(function(){kf().config(Object.assign({},Pf(),If()(process.argv)))})();import Oh from"node:process";var Bb=Object.freeze({status:"aborted"});function x(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var ir=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Xs={};function bt(t){return t&&Object.assign(Xs,t),Xs}var re={};pc(re,{BIGINT_FORMAT_RANGES:()=>Of,Class:()=>hc,NUMBER_FORMAT_RANGES:()=>xc,aborted:()=>Br,allowsEval:()=>vc,assert:()=>Yb,assertEqual:()=>Kb,assertIs:()=>Jb,assertNever:()=>Xb,assertNotEqual:()=>Wb,assignProp:()=>yc,cached:()=>Mo,captureStackTrace:()=>Qs,cleanEnum:()=>dw,cleanRegex:()=>Do,clone:()=>wt,createTransparentProxy:()=>ow,defineLazy:()=>we,esc:()=>Gr,escapeRegex:()=>br,extend:()=>aw,finalizeIssue:()=>At,floatSafeRemainder:()=>_c,getElementAtPath:()=>Qb,getEnumValues:()=>Co,getLengthableOrigin:()=>Lo,getParsedType:()=>nw,getSizableOrigin:()=>Nf,isObject:()=>Dn,isPlainObject:()=>Ln,issue:()=>$c,joinValues:()=>Ys,jsonStringifyReplacer:()=>gc,merge:()=>cw,normalizeParams:()=>L,nullish:()=>jo,numKeys:()=>rw,omit:()=>iw,optionalKeys:()=>wc,partial:()=>uw,pick:()=>sw,prefixIssues:()=>Vt,primitiveTypes:()=>zf,promiseAllObject:()=>ew,propertyKeyTypes:()=>bc,randomString:()=>tw,required:()=>lw,stringifyPrimitive:()=>ei,unwrapMessage:()=>Ao});function Kb(t){return t}function Wb(t){return t}function Jb(t){}function Xb(t){throw new Error}function Yb(t){}function Co(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Ys(t,e="|"){return t.map(r=>ei(r)).join(e)}function gc(t,e){return typeof e=="bigint"?e.toString():e}function Mo(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function jo(t){return t==null}function Do(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function _c(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function we(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function yc(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Qb(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function ew(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function tw(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Gr(t){return JSON.stringify(t)}var Qs=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Dn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var vc=Mo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Ln(t){if(Dn(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Dn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function rw(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var nw=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},bc=new Set(["string","number","symbol"]),zf=new Set(["string","number","bigint","boolean","symbol","undefined"]);function br(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function L(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function ow(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function ei(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function wc(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var xc={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]},Of={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function sw(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return wt(t,{...t._zod.def,shape:r,checks:[]})}function iw(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return wt(t,{...t._zod.def,shape:r,checks:[]})}function aw(t,e){if(!Ln(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return yc(this,"shape",n),n},checks:[]};return wt(t,r)}function cw(t,e){return wt(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return yc(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function uw(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return wt(e,{...e._zod.def,shape:o,checks:[]})}function lw(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return wt(e,{...e._zod.def,shape:o,checks:[]})}function Br(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Vt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Ao(t){return typeof t=="string"?t:t?.message}function At(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Ao(t.inst?._zod.def?.error?.(t))??Ao(e?.error?.(t))??Ao(r.customError?.(t))??Ao(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Nf(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Lo(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function $c(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function dw(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var hc=class{constructor(...e){}};var Af=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,gc,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},ti=x("$ZodError",Af),Zo=x("$ZodError",Af,{Parent:Error});function Sc(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function Ec(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var kc=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ir;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>At(c,s,bt())));throw Qs(a,o?.callee),a}return i.value},Tc=kc(Zo),Pc=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>At(c,s,bt())));throw Qs(a,o?.callee),a}return i.value},Rc=Pc(Zo),Ic=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ir;return s.issues.length?{success:!1,error:new(t??ti)(s.issues.map(i=>At(i,o,bt())))}:{success:!0,data:s.value}},Kr=Ic(Zo),zc=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>At(i,o,bt())))}:{success:!0,data:s.value}},Wr=zc(Zo);var Cf=/^[cC][^\s-]{8,}$/,Mf=/^[0-9a-z]+$/,jf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Df=/^[0-9a-vA-V]{20}$/,Lf=/^[A-Za-z0-9]{27}$/,Zf=/^[a-zA-Z0-9_-]{21}$/,Uf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var qf=/^([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})$/,Oc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Ff=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var fw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vf(){return new RegExp(fw,"u")}var Hf=/^(?:(?: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])$/,Gf=/^(([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})$/,Bf=/^((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])$/,Kf=/^(([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])$/,Wf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nc=/^[A-Za-z0-9_-]*$/,Jf=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Xf=/^\+(?:[0-9]){6,14}[0-9]$/,Yf="(?:(?:\\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])))",Qf=new RegExp(`^${Yf}$`);function em(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tm(t){return new RegExp(`^${em(t)}$`)}function rm(t){let e=em({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Yf}T(?:${n})$`)}var nm=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var om=/^\d+$/,sm=/^-?\d+(?:\.\d+)?/i,im=/true|false/i,am=/null/i;var cm=/^[^A-Z]*$/,um=/^[^a-z]*$/;var He=x("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),lm={number:"number",bigint:"bigint",object:"date"},Ac=x("$ZodCheckLessThan",(t,e)=>{He.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Cc=x("$ZodCheckGreaterThan",(t,e)=>{He.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),dm=x("$ZodCheckMultipleOf",(t,e)=>{He.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):_c(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),pm=x("$ZodCheckNumberFormat",(t,e)=>{He.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=xc[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=om)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var fm=x("$ZodCheckMaxLength",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Lo(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),mm=x("$ZodCheckMinLength",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Lo(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),hm=x("$ZodCheckLengthEquals",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Lo(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Uo=x("$ZodCheckStringFormat",(t,e)=>{var r,n;He.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),gm=x("$ZodCheckRegex",(t,e)=>{Uo.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),_m=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=cm),Uo.init(t,e)}),ym=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=um),Uo.init(t,e)}),vm=x("$ZodCheckIncludes",(t,e)=>{He.init(t,e);let r=br(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),bm=x("$ZodCheckStartsWith",(t,e)=>{He.init(t,e);let r=new RegExp(`^${br(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),wm=x("$ZodCheckEndsWith",(t,e)=>{He.init(t,e);let r=new RegExp(`.*${br(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var xm=x("$ZodCheckOverwrite",(t,e)=>{He.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var ni=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
11
+ deps: ${r}}`};var kR={keyword:"dependencies",type:"object",schemaType:"object",error:Xt.error,code(t){let[e,r]=TR(t);Iy(t,e),zy(t,r)}};function TR({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Iy(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,js.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,js.checkReportMissingProp)(t,u)}):(r.if((0,dp._)`${c} && (${(0,js.checkMissingProp)(t,a,s)})`),(0,js.reportMissingProp)(t,s),r.else())}}Xt.validatePropertyDeps=Iy;function zy(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,ER.alwaysValidSchema)(s,e[a])||(r.if((0,js.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Xt.validateSchemaDeps=zy;Xt.default=kR});var Ay=$(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var Ny=W(),PR=ie(),RR={message:"property name must be valid",params:({params:t})=>(0,Ny._)`{propertyName: ${t.propertyName}}`},IR={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:RR,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,PR.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Ny.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};pp.default=IR});var mp=$(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});var ka=It(),Ut=W(),zR=hr(),Ta=ie(),OR={message:"must NOT have additional properties",params:({params:t})=>(0,Ut._)`{additionalProperty: ${t.additionalProperty}}`},NR={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:OR,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Ta.alwaysValidSchema)(i,r))return;let u=(0,ka.allSchemaProperties)(n.properties),l=(0,ka.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Ut._)`${s} === ${zR.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?p(g):e.if(h(g),()=>p(g))})}function h(g){let _;if(u.length>8){let v=(0,Ta.schemaRefOrVal)(i,n.properties,"properties");_=(0,ka.isOwnProperty)(e,v,g)}else u.length?_=(0,Ut.or)(...u.map(v=>(0,Ut._)`${g} === ${v}`)):_=Ut.nil;return l.length&&(_=(0,Ut.or)(_,...l.map(v=>(0,Ut._)`${(0,ka.usePattern)(t,v)}.test(${g})`))),(0,Ut.not)(_)}function m(g){e.code((0,Ut._)`delete ${o}[${g}]`)}function p(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Ta.alwaysValidSchema)(i,r)){let _=e.name("valid");c.removeAdditional==="failing"?(f(g,_,!1),e.if((0,Ut.not)(_),()=>{t.reset(),m(g)})):(f(g,_),a||e.if((0,Ut.not)(_),()=>e.break()))}}function f(g,_,v){let S={keyword:"additionalProperties",dataProp:g,dataPropType:Ta.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(S,_)}}};fp.default=NR});var jy=$(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});var AR=Ss(),Cy=It(),hp=ie(),My=mp(),CR={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&My.default.code(new AR.KeywordCxt(s,My.default,"additionalProperties"));let i=(0,Cy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=hp.mergeEvaluated.props(e,(0,hp.toHash)(i),s.props));let a=i.filter(d=>!(0,hp.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Cy.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};gp.default=CR});var Uy=$(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var Dy=It(),Pa=W(),Ly=ie(),Zy=ie(),MR={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,Dy.allSchemaProperties)(r),c=a.filter(f=>(0,Ly.alwaysValidSchema)(s,r[f]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof Pa.Name)&&(s.props=(0,Zy.evaluatedPropsToName)(e,s.props));let{props:d}=s;h();function h(){for(let f of a)u&&m(f),s.allErrors?p(f):(e.var(l,!0),p(f),e.if(l))}function m(f){for(let g in u)new RegExp(f).test(g)&&(0,Ly.checkStrictMode)(s,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function p(f){e.forIn("key",n,g=>{e.if((0,Pa._)`${(0,Dy.usePattern)(t,f)}.test(${g})`,()=>{let _=c.includes(f);_||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:Zy.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,Pa._)`${d}[${g}]`,!0):!_&&!s.allErrors&&e.if((0,Pa.not)(l),()=>e.break())})})}}};_p.default=MR});var qy=$(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var jR=ie(),DR={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,jR.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};yp.default=DR});var Fy=$(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var LR=It(),ZR={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:LR.validateUnion,error:{message:"must match a schema in anyOf"}};vp.default=ZR});var Vy=$(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});var Ra=W(),UR=ie(),qR={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ra._)`{passingSchemas: ${t.passing}}`},FR={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:qR,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let h;(0,UR.alwaysValidSchema)(o,l)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ra._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ra._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),h&&t.mergeEvaluated(h,Ra.Name)})})}}};bp.default=FR});var Hy=$(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var VR=ie(),HR={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,VR.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};wp.default=HR});var Ky=$(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});var Ia=W(),By=ie(),GR={message:({params:t})=>(0,Ia.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ia._)`{failingKeyword: ${t.ifClause}}`},BR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:GR,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,By.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Gy(n,"then"),s=Gy(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Ia.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let h=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(h,i),d?e.assign(d,(0,Ia._)`${l}`):t.setParams({ifClause:l})}}}};function Gy(t,e){let r=t.schema[e];return r!==void 0&&!(0,By.alwaysValidSchema)(t,r)}xp.default=BR});var Wy=$(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});var KR=ie(),WR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,KR.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Sp.default=WR});var Jy=$($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});var JR=ip(),XR=ky(),YR=ap(),QR=Py(),eI=Ry(),tI=Oy(),rI=Ay(),nI=mp(),oI=jy(),sI=Uy(),iI=qy(),aI=Fy(),cI=Vy(),uI=Hy(),lI=Ky(),dI=Wy();function pI(t=!1){let e=[iI.default,aI.default,cI.default,uI.default,lI.default,dI.default,rI.default,nI.default,tI.default,oI.default,sI.default];return t?e.push(XR.default,QR.default):e.push(JR.default,YR.default),e.push(eI.default),e}$p.default=pI});var Xy=$(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});var De=W(),fI={message:({schemaCode:t})=>(0,De.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,De._)`{format: ${t}}`},mI={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:fI,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?h():m();function h(){let p=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,De._)`${p}[${i}]`),g=r.let("fType"),_=r.let("format");r.if((0,De._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,De._)`${f}.type || "string"`).assign(_,(0,De._)`${f}.validate`),()=>r.assign(g,(0,De._)`"string"`).assign(_,f)),t.fail$data((0,De.or)(v(),S()));function v(){return c.strictSchema===!1?De.nil:(0,De._)`${i} && !${_}`}function S(){let y=l.$async?(0,De._)`(${f}.async ? await ${_}(${n}) : ${_}(${n}))`:(0,De._)`${_}(${n})`,T=(0,De._)`(typeof ${_} == "function" ? ${y} : ${_}.test(${n}))`;return(0,De._)`${_} && ${_} !== true && ${g} === ${e} && !${T}`}}function m(){let p=d.formats[s];if(!p){v();return}if(p===!0)return;let[f,g,_]=S(p);f===e&&t.pass(y());function v(){if(c.strictSchema===!1){d.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function S(T){let L=T instanceof RegExp?(0,De.regexpCode)(T):c.code.formats?(0,De._)`${c.code.formats}${(0,De.getProperty)(s)}`:void 0,te=r.scopeValue("formats",{key:s,ref:T,code:L});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,De._)`${te}.validate`]:["string",T,te]}function y(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,De._)`await ${_}(${n})`}return typeof g=="function"?(0,De._)`${_}(${n})`:(0,De._)`${_}.test(${n})`}}}};Ep.default=mI});var Yy=$(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});var hI=Xy(),gI=[hI.default];kp.default=gI});var Qy=$(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 tv=$(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});var _I=cy(),yI=xy(),vI=Jy(),bI=Yy(),ev=Qy(),wI=[_I.default,yI.default,(0,vI.default)(),bI.default,ev.metadataVocabulary,ev.contentVocabulary];Tp.default=wI});var nv=$(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.DiscrError=void 0;var rv;(function(t){t.Tag="tag",t.Mapping="mapping"})(rv||(za.DiscrError=rv={}))});var sv=$(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var bo=W(),Pp=nv(),ov=ma(),xI=$s(),SI=ie(),$I={message:({params:{discrError:t,tagName:e}})=>t===Pp.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,bo._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},EI={keyword:"discriminator",type:"object",schemaType:"object",error:$I,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.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(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,bo._)`${r}${(0,bo.getProperty)(a)}`);e.if((0,bo._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Pp.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=h();e.if(!1);for(let p in m)e.elseIf((0,bo._)`${u} === ${p}`),e.assign(c,d(m[p]));e.else(),t.error(!1,{discrError:Pp.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let p=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},p);return t.mergeEvaluated(f,bo.Name),p}function h(){var m;let p={},f=_(o),g=!0;for(let y=0;y<i.length;y++){let T=i[y];if(T?.$ref&&!(0,SI.schemaHasRulesButRef)(T,s.self.RULES)){let te=T.$ref;if(T=ov.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,te),T instanceof ov.SchemaEnv&&(T=T.schema),T===void 0)throw new xI.default(s.opts.uriResolver,s.baseId,te)}let L=(m=T?.properties)===null||m===void 0?void 0:m[a];if(typeof L!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||_(T)),v(L,y)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return p;function _({required:y}){return Array.isArray(y)&&y.includes(a)}function v(y,T){if(y.const)S(y.const,T);else if(y.enum)for(let L of y.enum)S(L,T);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(y,T){if(typeof y!="string"||y in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[y]=T}}}};Rp.default=EI});var iv=$((s1,kI)=>{kI.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 zp=$((Te,Ip)=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.MissingRefError=Te.ValidationError=Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=Te.Ajv=void 0;var TI=ry(),PI=tv(),RI=sv(),av=iv(),II=["/properties"],Oa="http://json-schema.org/draft-07/schema",wo=class extends TI.default{_addVocabularies(){super._addVocabularies(),PI.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(RI.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(av,II):av;this.addMetaSchema(e,Oa,!1),this.refs["http://json-schema.org/schema"]=Oa}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Oa)?Oa:void 0)}};Te.Ajv=wo;Ip.exports=Te=wo;Ip.exports.Ajv=wo;Object.defineProperty(Te,"__esModule",{value:!0});Te.default=wo;var zI=Ss();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return zI.KeywordCxt}});var xo=W();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return xo._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return xo.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return xo.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return xo.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return xo.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return xo.CodeGen}});var OI=pa();Object.defineProperty(Te,"ValidationError",{enumerable:!0,get:function(){return OI.default}});var NI=$s();Object.defineProperty(Te,"MissingRefError",{enumerable:!0,get:function(){return NI.default}})});var hv=$(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.formatNames=Qt.fastFormats=Qt.fullFormats=void 0;function Yt(t,e){return{validate:t,compare:e}}Qt.fullFormats={date:Yt(dv,Cp),time:Yt(Np(!0),Mp),"date-time":Yt(cv(!0),fv),"iso-time":Yt(Np(),pv),"iso-date-time":Yt(cv(),mv),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:LI,"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:GI,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:ZI,int32:{type:"number",validate:FI},int64:{type:"number",validate:VI},float:{type:"number",validate:lv},double:{type:"number",validate:lv},password:!0,binary:!0};Qt.fastFormats={...Qt.fullFormats,date:Yt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Cp),time:Yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Mp),"date-time":Yt(/^\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,fv),"iso-time":Yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,pv),"iso-date-time":Yt(/^\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,mv),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};Qt.formatNames=Object.keys(Qt.fullFormats);function AI(t){return t%4===0&&(t%100!==0||t%400===0)}var CI=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,MI=[0,31,28,31,30,31,30,31,31,30,31,30,31];function dv(t){let e=CI.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&AI(r)?29:MI[n])}function Cp(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Op=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Np(t){return function(r){let n=Op.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,h=o-u*c-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&i<61}}function Mp(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function pv(t,e){if(!(t&&e))return;let r=Op.exec(t),n=Op.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Ap=/t|\s/i;function cv(t){let e=Np(t);return function(n){let o=n.split(Ap);return o.length===2&&dv(o[0])&&e(o[1])}}function fv(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function mv(t,e){if(!(t&&e))return;let[r,n]=t.split(Ap),[o,s]=e.split(Ap),i=Cp(r,o);if(i!==void 0)return i||Mp(n,s)}var jI=/\/|:/,DI=/^(?:[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 LI(t){return jI.test(t)&&DI.test(t)}var uv=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function ZI(t){return uv.lastIndex=0,uv.test(t)}var UI=-(2**31),qI=2**31-1;function FI(t){return Number.isInteger(t)&&t<=qI&&t>=UI}function VI(t){return Number.isInteger(t)}function lv(){return!0}var HI=/[^\\]\\Z/;function GI(t){if(HI.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var gv=$(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.formatLimitDefinition=void 0;var BI=zp(),qt=W(),Dr=qt.operators,Na={formatMaximum:{okStr:"<=",ok:Dr.LTE,fail:Dr.GT},formatMinimum:{okStr:">=",ok:Dr.GTE,fail:Dr.LT},formatExclusiveMaximum:{okStr:"<",ok:Dr.LT,fail:Dr.GTE},formatExclusiveMinimum:{okStr:">",ok:Dr.GT,fail:Dr.LTE}},KI={message:({keyword:t,schemaCode:e})=>(0,qt.str)`should be ${Na[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,qt._)`{comparison: ${Na[t].okStr}, limit: ${e}}`};So.formatLimitDefinition={keyword:Object.keys(Na),type:"string",schemaType:"string",$data:!0,error:KI,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new BI.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,qt._)`${h}[${c.schemaCode}]`);t.fail$data((0,qt.or)((0,qt._)`typeof ${m} != "object"`,(0,qt._)`${m} instanceof RegExp`,(0,qt._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let h=c.schema,m=a.formats[h];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${h}" does not define "compare" function`);let p=e.scopeValue("formats",{key:h,ref:m,code:i.code.formats?(0,qt._)`${i.code.formats}${(0,qt.getProperty)(h)}`:void 0});t.fail$data(d(p))}function d(h){return(0,qt._)`${h}.compare(${r}, ${n}) ${Na[o].fail} 0`}},dependencies:["format"]};var WI=t=>(t.addKeyword(So.formatLimitDefinition),t);So.default=WI});var bv=$((Ds,vv)=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});var $o=hv(),JI=gv(),jp=W(),_v=new jp.Name("fullFormats"),XI=new jp.Name("fastFormats"),Dp=(t,e={keywords:!0})=>{if(Array.isArray(e))return yv(t,e,$o.fullFormats,_v),t;let[r,n]=e.mode==="fast"?[$o.fastFormats,XI]:[$o.fullFormats,_v],o=e.formats||$o.formatNames;return yv(t,o,r,n),e.keywords&&(0,JI.default)(t),t};Dp.get=(t,e="full")=>{let n=(e==="fast"?$o.fastFormats:$o.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function yv(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,jp._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}vv.exports=Ds=Dp;Object.defineProperty(Ds,"__esModule",{value:!0});Ds.default=Dp});var Cv=$(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.EdgePort=void 0;var Av;(function(t){t.Top="top",t.Right="right",t.Bottom="bottom",t.Left="left"})(Av||(La.EdgePort=Av={}))});var Za=$(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.NODE_RULES=void 0;er.nodeSupportsStyleProp=sz;er.isStyledBoxType=iz;er.NODE_RULES={ID_NON_EMPTY:!0,NAME_MAX_LENGTH:256,ALLOWED_TYPES:["container","task","sticky","view","text","template_definition","template_instance","data_wrapper","image","list_data"],MAX_CHILDREN:500,MAX_EDGES_PER_NODE:50,MAX_NODES_PER_PROJECT:5e3,ALLOWED_DATA_API_PATHS:["/notes","/node-assets"],STYLE_CAPABILITIES:{view:["backgroundColor","borderColor","borderWidth","borderStyle","borderRadius","overflow"],container:["backgroundColor","borderRadius"],text:[],sticky:[],image:[],task:[],template_definition:[],template_instance:[],data_wrapper:[],list_data:[]}};function sz(t,e){return!t||!(t in er.NODE_RULES.STYLE_CAPABILITIES)?!1:er.NODE_RULES.STYLE_CAPABILITIES[t].includes(e)}function iz(t){return!t||!(t in er.NODE_RULES.STYLE_CAPABILITIES)?!1:er.NODE_RULES.STYLE_CAPABILITIES[t].length>0}});var Fp=$(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.EDGE_RULES=void 0;Zs.canConnectNodes=az;Zs.EDGE_RULES={ID_NON_EMPTY:!0,NO_SELF_LOOP:!0,NO_EDGE_INTO_TASK:!0,NO_DANGLING_REFERENCES:!0,ALLOWED_PORTS:["top","right","bottom","left"],MAX_EDGES_PER_PROJECT:1e4};function az(t,e){return e?.type!=="task"}});var Vp=$(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.DIFF_RULES=void 0;Ua.DIFF_RULES={MAX_ADDED:200,MAX_UPDATED:500,MAX_REMOVED:500,NO_ADD_UPDATE_OVERLAP:!0,NO_ADD_REMOVE_OVERLAP:!0,NO_UPDATE_REMOVE_OVERLAP:!0,NO_DUPLICATE_ADDED:!0,NO_DUPLICATE_UPDATED:!0,REMOVED_MUST_EXIST:!0,ADDED_MUST_NOT_EXIST:!0}});var Hp=$(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.PROJECT_RULES=void 0;qa.PROJECT_RULES={NAME_MIN_LENGTH:1,NAME_MAX_LENGTH:128,IS_GENERAL_CLIENT_SETTABLE:!1,IS_TEMPLATE_IMMUTABLE_AFTER_CREATE:!0,MAX_PROJECTS_PER_WORKSPACE:200,MAX_LATEST_DATA_SIZE_BYTES:10*1024*1024}});var Gp=$(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.TASK_RULES=void 0;Fa.TASK_RULES={NAME_MAX_LENGTH:512,DESCRIPTION_MAX_LENGTH:1e4,MAX_ASSIGNED_USERS:20,MAX_TASKS_PER_PROJECT:5e3,PROGRESS_TAG_MUST_EXIST:!0,TASK_TYPE_TAG_MUST_EXIST:!0,ASSIGNED_USERS_MUST_EXIST:!0}});var Mv=$(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.TASK_NODE_RULES=void 0;Va.TASK_NODE_RULES={TASK_ID_REQUIRED:!0,TASK_VERSION_IMMUTABLE_VIA_DIFF:!0,TASK_MUST_EXIST_FOR_NODE:!0,SOFT_DELETE_TASK_ON_NODE_REMOVE:!0,TYPE_CHANGE_FORBIDDEN:!0}});var jv=$(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.TEMPLATE_RULES=void 0;Ha.TEMPLATE_RULES={MAX_BOUNDED_TEMPLATES:20,UNBIND_BLOCKED_BY_REFERENCES:!0,ONLY_TEMPLATE_PROJECTS_BINDABLE:!0,NO_SELF_BIND:!0,NON_DELETABLE_NODES_PROTECTED:!0,NO_TEMPLATE_ADD_TO_SPECIAL_NODES:!0,NO_NESTED_TEMPLATES_IN_TEMPLATE_PROJECT:!0,TEMPLATE_DEFINITION_ONLY_IN_TEMPLATE:!0,TEMPLATE_DEFINITION_REQUIRED:!0,TEMPLATE_DEFINITION_MAX_CHILDREN:1,GENERAL_TEMPLATE_IMPLICIT_BIND:!0}});var Dv=$(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.IMAGE_RULES=void 0;Ga.IMAGE_RULES={ALLOWED_MIME_TYPES:["image/png","image/jpeg","image/webp"],MAX_FILE_SIZE_BYTES:5*1024*1024,IMAGE_PROJECT_MUST_MATCH:!0,NODE_ID_MUST_EXIST:!0,IMAGE_NODE_BINDING_IMMUTABLE:!0,MAX_IMAGES_PER_PROJECT:500}});var Lv=$(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.AUTH_RULES=void 0;Ba.AUTH_RULES={PASSWORD_MIN_LENGTH:8,PASSWORD_MAX_LENGTH:128,EMAIL_MAX_LENGTH:256,NAME_MAX_LENGTH:128,COMPANY_NAME_MAX_LENGTH:128,JWT_SUB_REQUIRED:!0,AUTH_GUARD_REQUIRED:!0,MAX_LOGIN_ATTEMPTS_PER_MINUTE:10}});var Zv=$(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.WORKSPACE_RULES=void 0;Ka.WORKSPACE_RULES={NAME_MIN_LENGTH:1,NAME_MAX_LENGTH:128,MEMBERSHIP_REQUIRED:!0,MAX_WORKSPACES_PER_USER:10,ALLOWED_TEMPLATE_TYPES:["SOFTWARE","MARKETING","DESIGN","CONTENT","PERSONAL"],MAX_PROGRESS_TAGS:50,MAX_TASK_TYPE_TAGS:50,TAG_NAME_MAX_LENGTH:64,TAG_COLOR_FORMAT:/^#[0-9a-fA-F]{6}$/}});var Uv=$(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.VIEW_RULES=void 0;Wa.VIEW_RULES={NAME_MAX_LENGTH:128,DESCRIPTION_MAX_LENGTH:1e3,USER_SCOPED:!0,MAX_VIEWS_PER_WORKSPACE:50,ALLOWED_FILTER_KEYS:["status","assigneeIds","tagNames","projectIds","dueDate","sort","groupBy"],ALLOWED_SORT_DIRS:["asc","desc"],ALLOWED_SORT_FIELDS:["createDate","updateDate"],MAX_SORT_SPECS:5,GROUP_BY_STRING_ONLY:!0}});var Bp=$(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.BOUNDS_RULES=void 0;Ja.BOUNDS_RULES={MIN_WIDTH:0,MIN_HEIGHT:0,MAX_WIDTH:5e4,MAX_HEIGHT:5e4,MIN_COORDINATE:-1e5,MAX_COORDINATE:1e5,MUST_BE_FINITE:!0,MUST_BE_NUMBER:!0}});var Kp=$(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.LAYOUT_RULES=void 0;Xa.LAYOUT_RULES={ALLOWED_FLEX_DIRECTIONS:["row","row-reverse","column","column-reverse"],ALLOWED_FLEX_WRAPS:["wrap","wrap-reverse","nowrap","none"],ALLOWED_JUSTIFY_CONTENT:["flex-start","center","flex-end","space-between","space-around","space-evenly"],ALLOWED_ALIGN_ITEMS:["flex-start","center","flex-end","stretch","baseline"],ALLOWED_ALIGN_SELF:["flex-start","center","flex-end","stretch","baseline","auto"],ALLOWED_POSITIONS:["relative","absolute"],MIN_PADDING:0,MAX_PADDING:1e3,MIN_MARGIN:-1e3,MAX_MARGIN:1e3,MIN_GAP:0,MAX_GAP:1e3,MIN_FLEX_GROW:0,MAX_FLEX_GROW:1e3,MIN_FLEX_SHRINK:0,MAX_FLEX_SHRINK:1e3}});var Eo=$(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.ok=qv;Us.fail=cz;Us.runValidators=uz;function qv(){return{valid:!0}}function cz(t,e){return{valid:!1,rule:t,message:e}}function uz(t){for(let e of t){let r=e();if(!r.valid)return r}return qv()}});var Jp=$(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.validateNode=yz;var Tn=Za(),rt=Bp(),lz=Fp(),$e=Kp(),X=Eo();function dz(t){return typeof t!="string"||t.trim().length===0?(0,X.fail)("NODE_ID",`Node ID must be a non-empty string. Got: ${String(t)}`):(0,X.ok)()}function pz(t){return t!==void 0&&t.length>Tn.NODE_RULES.NAME_MAX_LENGTH?(0,X.fail)("NODE_NAME_LENGTH",`Node name exceeds maximum length of ${Tn.NODE_RULES.NAME_MAX_LENGTH} characters.`):(0,X.ok)()}function fz(t){if(t===void 0)return(0,X.ok)();let e=Tn.NODE_RULES.ALLOWED_TYPES;return e.includes(t)?(0,X.ok)():(0,X.fail)("NODE_TYPE",`Invalid node type "${t}". Allowed: ${e.join(", ")}.`)}function mz(t){return t&&t.length>Tn.NODE_RULES.MAX_CHILDREN?(0,X.fail)("NODE_MAX_CHILDREN",`Node has ${t.length} children, exceeds maximum of ${Tn.NODE_RULES.MAX_CHILDREN}.`):(0,X.ok)()}function hz(t,e){if(!e)return(0,X.ok)();if(e.length>Tn.NODE_RULES.MAX_EDGES_PER_NODE)return(0,X.fail)("NODE_MAX_EDGES",`Node has ${e.length} edges, exceeds maximum of ${Tn.NODE_RULES.MAX_EDGES_PER_NODE}.`);for(let r of e){if(typeof r.id!="string"||r.id.trim().length===0)return(0,X.fail)("EDGE_ID",`Edge ID must be a non-empty string. Got: ${String(r.id)}`);if(r.to===t)return(0,X.fail)("EDGE_SELF_LOOP",`Edge ${r.id} on node ${t} points to itself (self-loop).`);let n=lz.EDGE_RULES.ALLOWED_PORTS;if(r.fromPort!==void 0&&!n.includes(r.fromPort))return(0,X.fail)("EDGE_PORT",`Invalid edge fromPort "${r.fromPort}". Allowed: ${n.join(", ")}.`);if(r.toPort!==void 0&&!n.includes(r.toPort))return(0,X.fail)("EDGE_PORT",`Invalid edge toPort "${r.toPort}". Allowed: ${n.join(", ")}.`)}return(0,X.ok)()}function gz(t){if(!t)return(0,X.ok)();let e=[t.x,t.y,t.width,t.height];for(let r of e)if(typeof r!="number"||!Number.isFinite(r))return(0,X.fail)("BOUNDS_FINITE",`All bounds values must be finite numbers. Got: ${r}`);return t.width<rt.BOUNDS_RULES.MIN_WIDTH?(0,X.fail)("BOUNDS_MIN_WIDTH",`Width must be at least ${rt.BOUNDS_RULES.MIN_WIDTH}. Got: ${t.width}`):t.height<rt.BOUNDS_RULES.MIN_HEIGHT?(0,X.fail)("BOUNDS_MIN_HEIGHT",`Height must be at least ${rt.BOUNDS_RULES.MIN_HEIGHT}. Got: ${t.height}`):t.width>rt.BOUNDS_RULES.MAX_WIDTH?(0,X.fail)("BOUNDS_MAX_WIDTH",`Width exceeds maximum of ${rt.BOUNDS_RULES.MAX_WIDTH}. Got: ${t.width}`):t.height>rt.BOUNDS_RULES.MAX_HEIGHT?(0,X.fail)("BOUNDS_MAX_HEIGHT",`Height exceeds maximum of ${rt.BOUNDS_RULES.MAX_HEIGHT}. Got: ${t.height}`):t.x<rt.BOUNDS_RULES.MIN_COORDINATE||t.x>rt.BOUNDS_RULES.MAX_COORDINATE?(0,X.fail)("BOUNDS_COORDINATE_X",`X coordinate out of range [${rt.BOUNDS_RULES.MIN_COORDINATE}, ${rt.BOUNDS_RULES.MAX_COORDINATE}]. Got: ${t.x}`):t.y<rt.BOUNDS_RULES.MIN_COORDINATE||t.y>rt.BOUNDS_RULES.MAX_COORDINATE?(0,X.fail)("BOUNDS_COORDINATE_Y",`Y coordinate out of range [${rt.BOUNDS_RULES.MIN_COORDINATE}, ${rt.BOUNDS_RULES.MAX_COORDINATE}]. Got: ${t.y}`):(0,X.ok)()}function _z(t){if(!t)return(0,X.ok)();let e=$e.LAYOUT_RULES.ALLOWED_FLEX_DIRECTIONS;if(t.flexDirection!==void 0&&!e.includes(t.flexDirection))return(0,X.fail)("LAYOUT_FLEX_DIRECTION",`Invalid flexDirection "${t.flexDirection}". Allowed: ${e.join(", ")}.`);let r=$e.LAYOUT_RULES.ALLOWED_FLEX_WRAPS;if(t.flexWrap!==void 0&&!r.includes(t.flexWrap))return(0,X.fail)("LAYOUT_FLEX_WRAP",`Invalid flexWrap "${t.flexWrap}". Allowed: ${r.join(", ")}.`);let n=$e.LAYOUT_RULES.ALLOWED_JUSTIFY_CONTENT;if(t.justifyContent!==void 0&&!n.includes(t.justifyContent))return(0,X.fail)("LAYOUT_JUSTIFY_CONTENT",`Invalid justifyContent "${t.justifyContent}". Allowed: ${n.join(", ")}.`);let o=$e.LAYOUT_RULES.ALLOWED_ALIGN_ITEMS;if(t.alignItems!==void 0&&!o.includes(t.alignItems))return(0,X.fail)("LAYOUT_ALIGN_ITEMS",`Invalid alignItems "${t.alignItems}". Allowed: ${o.join(", ")}.`);let s=$e.LAYOUT_RULES.ALLOWED_ALIGN_SELF;if(t.alignSelf!==void 0&&!s.includes(t.alignSelf))return(0,X.fail)("LAYOUT_ALIGN_SELF",`Invalid alignSelf "${t.alignSelf}". Allowed: ${s.join(", ")}.`);let i=$e.LAYOUT_RULES.ALLOWED_POSITIONS;if(t.position!==void 0&&!i.includes(t.position))return(0,X.fail)("LAYOUT_POSITION",`Invalid position "${t.position}". Allowed: ${i.join(", ")}.`);let a=["padding","paddingTop","paddingRight","paddingBottom","paddingLeft"];for(let u of a){let l=t[u];if(l!==void 0&&(l<$e.LAYOUT_RULES.MIN_PADDING||l>$e.LAYOUT_RULES.MAX_PADDING))return(0,X.fail)("LAYOUT_PADDING",`${u} must be between ${$e.LAYOUT_RULES.MIN_PADDING} and ${$e.LAYOUT_RULES.MAX_PADDING}. Got: ${l}`)}let c=["margin","marginTop","marginRight","marginBottom","marginLeft"];for(let u of c){let l=t[u];if(l!==void 0&&(l<$e.LAYOUT_RULES.MIN_MARGIN||l>$e.LAYOUT_RULES.MAX_MARGIN))return(0,X.fail)("LAYOUT_MARGIN",`${u} must be between ${$e.LAYOUT_RULES.MIN_MARGIN} and ${$e.LAYOUT_RULES.MAX_MARGIN}. Got: ${l}`)}return t.gap!==void 0&&(t.gap<$e.LAYOUT_RULES.MIN_GAP||t.gap>$e.LAYOUT_RULES.MAX_GAP)?(0,X.fail)("LAYOUT_GAP",`Gap must be between ${$e.LAYOUT_RULES.MIN_GAP} and ${$e.LAYOUT_RULES.MAX_GAP}. Got: ${t.gap}`):t.flexGrow!==void 0&&(t.flexGrow<$e.LAYOUT_RULES.MIN_FLEX_GROW||t.flexGrow>$e.LAYOUT_RULES.MAX_FLEX_GROW)?(0,X.fail)("LAYOUT_FLEX_GROW",`flexGrow must be between ${$e.LAYOUT_RULES.MIN_FLEX_GROW} and ${$e.LAYOUT_RULES.MAX_FLEX_GROW}. Got: ${t.flexGrow}`):t.flexShrink!==void 0&&(t.flexShrink<$e.LAYOUT_RULES.MIN_FLEX_SHRINK||t.flexShrink>$e.LAYOUT_RULES.MAX_FLEX_SHRINK)?(0,X.fail)("LAYOUT_FLEX_SHRINK",`flexShrink must be between ${$e.LAYOUT_RULES.MIN_FLEX_SHRINK} and ${$e.LAYOUT_RULES.MAX_FLEX_SHRINK}. Got: ${t.flexShrink}`):(0,X.ok)()}function yz(t){return(0,X.runValidators)([()=>dz(t.id),()=>pz(t.name),()=>fz(t.type),()=>mz(t.children),()=>hz(t.id,t.edges),()=>gz(t.bounds),()=>_z(t.layout)])}});var Vv=$(Xp=>{"use strict";Object.defineProperty(Xp,"__esModule",{value:!0});Xp.validateDiffPayload=Ez;var ko=Vp(),Fv=Za(),at=Eo(),vz=Jp();function bz(t){return t.added&&t.added.length>ko.DIFF_RULES.MAX_ADDED?(0,at.fail)("DIFF_MAX_ADDED",`Diff contains ${t.added.length} added nodes, exceeds maximum of ${ko.DIFF_RULES.MAX_ADDED}.`):t.updated&&t.updated.length>ko.DIFF_RULES.MAX_UPDATED?(0,at.fail)("DIFF_MAX_UPDATED",`Diff contains ${t.updated.length} updated nodes, exceeds maximum of ${ko.DIFF_RULES.MAX_UPDATED}.`):t.removedIds&&t.removedIds.length>ko.DIFF_RULES.MAX_REMOVED?(0,at.fail)("DIFF_MAX_REMOVED",`Diff contains ${t.removedIds.length} removed nodes, exceeds maximum of ${ko.DIFF_RULES.MAX_REMOVED}.`):(0,at.ok)()}function wz(t){let e=new Set;if(t.added)for(let n of t.added){if(e.has(n.id))return(0,at.fail)("DIFF_DUPLICATE_ADDED",`Duplicate node ID ${n.id} in diff.added.`);e.add(n.id)}let r=new Set;if(t.updated)for(let n of t.updated){if(r.has(n.id))return(0,at.fail)("DIFF_DUPLICATE_UPDATED",`Duplicate node ID ${n.id} in diff.updated.`);r.add(n.id)}return(0,at.ok)()}function xz(t){let e=(t.added??[]).map(s=>s.id),r=new Set((t.updated??[]).map(s=>s.id)),n=new Set(t.removedIds??[]);for(let s of e){if(r.has(s))return(0,at.fail)("DIFF_ADD_UPDATE_OVERLAP",`Node ID ${s} appears in both diff.added and diff.updated.`);if(n.has(s))return(0,at.fail)("DIFF_ADD_REMOVE_OVERLAP",`Node ID ${s} appears in both diff.added and diff.removedIds.`)}let o=(t.updated??[]).map(s=>s.id);for(let s of o)if(n.has(s))return(0,at.fail)("DIFF_UPDATE_REMOVE_OVERLAP",`Node ID ${s} appears in both diff.updated and diff.removedIds.`);return(0,at.ok)()}function Sz(t){let e=[...t.added??[],...t.updated??[]];for(let r of e){let n=(0,vz.validateNode)(r);if(!n.valid)return n}return(0,at.ok)()}function $z(t,e){let r=t.added?.length??0,n=t.removedIds?.length??0,o=e+r-n;return o>Fv.NODE_RULES.MAX_NODES_PER_PROJECT?(0,at.fail)("DIFF_TOTAL_NODES",`After applying this diff, the project would have ${o} nodes, exceeds maximum of ${Fv.NODE_RULES.MAX_NODES_PER_PROJECT}.`):(0,at.ok)()}function Ez(t,e){return(0,at.runValidators)([()=>bz(t),()=>wz(t),()=>xz(t),()=>Sz(t),()=>$z(t,e)])}});var Gv=$(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.validateCreateProject=Tz;Qa.validateUpdateProject=Pz;var Ya=Hp(),Pn=Eo();function Hv(t){return t.length<Ya.PROJECT_RULES.NAME_MIN_LENGTH?(0,Pn.fail)("PROJECT_NAME_MIN",`Project name must be at least ${Ya.PROJECT_RULES.NAME_MIN_LENGTH} character(s).`):t.length>Ya.PROJECT_RULES.NAME_MAX_LENGTH?(0,Pn.fail)("PROJECT_NAME_MAX",`Project name exceeds maximum length of ${Ya.PROJECT_RULES.NAME_MAX_LENGTH} characters.`):(0,Pn.ok)()}function kz(t){return t===!0?(0,Pn.fail)("PROJECT_IS_GENERAL","Cannot set isGeneral flag from client. This is a server-controlled field."):(0,Pn.ok)()}function Tz(t){return(0,Pn.runValidators)([()=>Hv(t.name),()=>kz(t.isGeneral)])}function Pz(t){return t.name!==void 0?Hv(t.name):(0,Pn.ok)()}});var Jv=$(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.validateCreateTask=Rz;ec.validateUpdateTask=Iz;var To=Gp(),Ur=Eo();function Bv(t){return t!==void 0&&t.length>To.TASK_RULES.NAME_MAX_LENGTH?(0,Ur.fail)("TASK_NAME_MAX",`Task name exceeds maximum length of ${To.TASK_RULES.NAME_MAX_LENGTH} characters.`):(0,Ur.ok)()}function Kv(t){return typeof t=="string"&&t.length>To.TASK_RULES.DESCRIPTION_MAX_LENGTH?(0,Ur.fail)("TASK_DESCRIPTION_MAX",`Task description exceeds maximum length of ${To.TASK_RULES.DESCRIPTION_MAX_LENGTH} characters.`):(0,Ur.ok)()}function Wv(t){return t&&t.length>To.TASK_RULES.MAX_ASSIGNED_USERS?(0,Ur.fail)("TASK_MAX_ASSIGNED_USERS",`Task has ${t.length} assigned users, exceeds maximum of ${To.TASK_RULES.MAX_ASSIGNED_USERS}.`):(0,Ur.ok)()}function Rz(t){return(0,Ur.runValidators)([()=>Bv(t.name),()=>Kv(t.description),()=>Wv(t.assignedUserIds)])}function Iz(t){return(0,Ur.runValidators)([()=>Bv(t.name),()=>Kv(t.description),()=>Wv(t.assignedUserIds)])}});var eb=$(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.validateUpdateTask=q.validateCreateTask=q.validateUpdateProject=q.validateCreateProject=q.validateDiffPayload=q.validateNode=q.runValidators=q.ok=q.LAYOUT_RULES=q.BOUNDS_RULES=q.VIEW_RULES=q.WORKSPACE_RULES=q.AUTH_RULES=q.IMAGE_RULES=q.TEMPLATE_RULES=q.TASK_NODE_RULES=q.TASK_RULES=q.PROJECT_RULES=q.DIFF_RULES=q.canConnectNodes=q.EDGE_RULES=q.isStyledBoxType=q.nodeSupportsStyleProp=q.NODE_RULES=void 0;var Yp=Za();Object.defineProperty(q,"NODE_RULES",{enumerable:!0,get:function(){return Yp.NODE_RULES}});Object.defineProperty(q,"nodeSupportsStyleProp",{enumerable:!0,get:function(){return Yp.nodeSupportsStyleProp}});Object.defineProperty(q,"isStyledBoxType",{enumerable:!0,get:function(){return Yp.isStyledBoxType}});var Xv=Fp();Object.defineProperty(q,"EDGE_RULES",{enumerable:!0,get:function(){return Xv.EDGE_RULES}});Object.defineProperty(q,"canConnectNodes",{enumerable:!0,get:function(){return Xv.canConnectNodes}});var zz=Vp();Object.defineProperty(q,"DIFF_RULES",{enumerable:!0,get:function(){return zz.DIFF_RULES}});var Oz=Hp();Object.defineProperty(q,"PROJECT_RULES",{enumerable:!0,get:function(){return Oz.PROJECT_RULES}});var Nz=Gp();Object.defineProperty(q,"TASK_RULES",{enumerable:!0,get:function(){return Nz.TASK_RULES}});var Az=Mv();Object.defineProperty(q,"TASK_NODE_RULES",{enumerable:!0,get:function(){return Az.TASK_NODE_RULES}});var Cz=jv();Object.defineProperty(q,"TEMPLATE_RULES",{enumerable:!0,get:function(){return Cz.TEMPLATE_RULES}});var Mz=Dv();Object.defineProperty(q,"IMAGE_RULES",{enumerable:!0,get:function(){return Mz.IMAGE_RULES}});var jz=Lv();Object.defineProperty(q,"AUTH_RULES",{enumerable:!0,get:function(){return jz.AUTH_RULES}});var Dz=Zv();Object.defineProperty(q,"WORKSPACE_RULES",{enumerable:!0,get:function(){return Dz.WORKSPACE_RULES}});var Lz=Uv();Object.defineProperty(q,"VIEW_RULES",{enumerable:!0,get:function(){return Lz.VIEW_RULES}});var Zz=Bp();Object.defineProperty(q,"BOUNDS_RULES",{enumerable:!0,get:function(){return Zz.BOUNDS_RULES}});var Uz=Kp();Object.defineProperty(q,"LAYOUT_RULES",{enumerable:!0,get:function(){return Uz.LAYOUT_RULES}});var Qp=Eo();Object.defineProperty(q,"ok",{enumerable:!0,get:function(){return Qp.ok}});Object.defineProperty(q,"fail",{enumerable:!0,get:function(){return Qp.fail}});Object.defineProperty(q,"runValidators",{enumerable:!0,get:function(){return Qp.runValidators}});var qz=Jp();Object.defineProperty(q,"validateNode",{enumerable:!0,get:function(){return qz.validateNode}});var Fz=Vv();Object.defineProperty(q,"validateDiffPayload",{enumerable:!0,get:function(){return Fz.validateDiffPayload}});var Yv=Gv();Object.defineProperty(q,"validateCreateProject",{enumerable:!0,get:function(){return Yv.validateCreateProject}});Object.defineProperty(q,"validateUpdateProject",{enumerable:!0,get:function(){return Yv.validateUpdateProject}});var Qv=Jv();Object.defineProperty(q,"validateCreateTask",{enumerable:!0,get:function(){return Qv.validateCreateTask}});Object.defineProperty(q,"validateUpdateTask",{enumerable:!0,get:function(){return Qv.validateUpdateTask}})});var tf=$(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.headlessTextMeasurer=void 0;var ef=1.4,Vz=.55;tc.headlessTextMeasurer={measure(t,e,r){if(!t)return{width:0,height:e*ef};let n=e*Vz;if(r&&r>0){let o=Math.max(1,Math.floor(r/n)),s=Math.ceil(t.length/o);return{width:r,height:s*(e*ef)}}return{width:t.length*n,height:e*ef}}}});var rb=$(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.layoutContainerChildren=Gz;var Hz=tf();function Nt(t,e){let r=t.layout;return r?e==="top"?r.marginTop??r.margin??0:e==="right"?r.marginRight??r.margin??0:e==="bottom"?r.marginBottom??r.margin??0:r.marginLeft??r.margin??0:0}function Gz(t,e,r=Hz.headlessTextMeasurer){let n=new Set,o=new Map,s=new Map;for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];o.set(f.id,p),s.set(f.id,{x:f.bounds.x,y:f.bounds.y,w:f.bounds.width,h:f.bounds.height,children:f.children.slice()})}let i=()=>{let p=new Set;for(let f of t.nodes){let g=s.get(f.id);if(!g){p.add(f.id);continue}if(g.x!==f.bounds.x||g.y!==f.bounds.y||g.w!==f.bounds.width||g.h!==f.bounds.height){p.add(f.id);continue}if(g.children.length!==f.children.length){p.add(f.id);continue}for(let _=0;_<g.children.length;_++)if(g.children[_]!==f.children[_]){p.add(f.id);break}}return p};if(t.ghostLayout){let{padding:p,gap:f,flexDirection:g}=t.ghostLayout,_=[];for(let v of t.nodes)v.parent===null&&_.push(v);if(_.length>0){_.sort((y,T)=>{if(g==="row"){let L=y.bounds.y-T.bounds.y;return Math.abs(L)>20?L:y.bounds.x-T.bounds.x}else{let L=y.bounds.x-T.bounds.x;return Math.abs(L)>20?L:y.bounds.y-T.bounds.y}});let v=p,S=p;for(let y of _){if(y.layout?.position==="absolute"||y.type==="task")continue;let T=y.bounds.width,L=y.bounds.height;if(g==="row"){if(!e?.has(y.id)&&(y.bounds.x!==v||y.bounds.y!==S)){let te=o.get(y.id);te!==void 0&&te!==-1&&(t.nodes[te].bounds.x=v,t.nodes[te].bounds.y=S,n.add(y.id))}v+=T+f}else{if(!e?.has(y.id)&&(y.bounds.x!==v||y.bounds.y!==S)){let te=o.get(y.id);te!==void 0&&te!==-1&&(t.nodes[te].bounds.x=v,t.nodes[te].bounds.y=S,n.add(y.id))}S+=L+f}}}}let a=new Set;for(let p of t.nodes)(p.type==="container"||p.type==="list_data"||p.type==="template_definition"||p.type==="view"&&p.isAutoLayout)&&a.add(p.id);if(a.size===0)return i();let c=new Map;for(let p of t.nodes)typeof p.parent=="string"&&a.has(p.parent)&&(c.has(p.parent)||c.set(p.parent,[]),c.get(p.parent).push(p));let u=new Map,l=new Set;function d(p){if(u.has(p))return u.get(p);if(l.has(p))return u.set(p,0),0;let f=o.get(p),g=f!==void 0?t.nodes[f]:void 0;if(!g||g.parent===null||g.parent===p||!a.has(g.parent))return u.set(p,0),0;l.add(p);let _=d(g.parent)+1;return l.delete(p),u.set(p,_),_}let h=Array.from(c.keys());for(let p of h)d(p);h.sort((p,f)=>(u.get(f)??0)-(u.get(p)??0));let m=new Map;for(let p of h){let f=c.get(p);if(!f||f.length===0)continue;let g=o.get(p),_=g!==void 0?t.nodes[g]:void 0;if(!_)continue;let v=_.layout||{},S=_.type==="template_definition"?32:_.type==="data_wrapper"?0:10,y=_.type==="data_wrapper"?0:10,T=v.padding??S,L=v.paddingTop??T,te=v.paddingRight??T,Xe=v.paddingBottom??T,F=v.paddingLeft??T,ce=v.gap??y,Ce=v.flexDirection??"row",Q=Ce==="row"||Ce==="row-reverse",tr=Ce==="row-reverse"||Ce==="column-reverse",rr=v.flexWrap??"nowrap",_r=rr==="wrap"||rr==="wrap-reverse",Oo=rr==="wrap-reverse",Nn=Q?F:L,Ft=Q?L:F,yr=_.bounds.width-F-te,An=_.bounds.height-L-Xe,Vs=Q?yr:An,qr=Nn,Cn=Ft,Mn=0,z=new Map;_.children.forEach((j,de)=>z.set(j,de)),f.sort((j,de)=>(z.get(j.id)??Number.MAX_SAFE_INTEGER)-(z.get(de.id)??Number.MAX_SAFE_INTEGER));let D=!!e&&f.some(j=>e.has(j.id));if(tr)f.reverse();else{D&&f.sort((me,Le)=>{if(Q){let Ve=me.bounds.y-Le.bounds.y;return Math.abs(Ve)>20?Ve:me.bounds.x-Le.bounds.x}else{let Ve=me.bounds.x-Le.bounds.x;return Math.abs(Ve)>20?Ve:me.bounds.y-Le.bounds.y}});let j=f.map(me=>me.id);if(_.children.length!==j.length||_.children.some((me,Le)=>me!==j[Le])){let me=o.get(p);me!==void 0&&me!==-1&&(t.nodes[me].children=j,n.add(p))}}let ue=_.type==="view"&&_.isAutoLayout,Ae=new Map,St=0;m.set(p,{parentNode:_,children:f,padTop:L,padRight:te,padBottom:Xe,padLeft:F,gap:ce,isRow:Q,wrapEnabled:_r,justifyContent:v.justifyContent,alignItems:v.alignItems,rowAssignment:Ae});for(let j of f){if(j.layout?.position==="absolute"||j.type==="task")continue;if(ue&&j.type==="text"){let be=o.get(j.id);if(be!==void 0&&be!==-1){let je=j,Vr=je.layout?.widthPinned===!0,Hs=je.layout?.heightPinned===!0,sr=je.bounds.width,Gs=je.bounds.height,Rb=je.layout?.alignSelf&&je.layout.alignSelf!=="auto"?je.layout.alignSelf:v.alignItems??"stretch",Ib=!Q&&Rb==="stretch";if(!Vr){let Bs=r.measure(je.content||"",je.fontSize||14).width+8,vf=_.layout?.widthPinned===!0,bf=Math.max(0,_.bounds.width-F-te-Nt(j,"left")-Nt(j,"right"));!Q&&vf?sr=Ib?bf:Math.min(Bs,bf):sr=Bs}if(!Hs){let Bs=Math.max(0,sr-8);Gs=r.measure(je.content||"",je.fontSize||14,Bs).height+8}let lc=!1;!Vr&&Math.abs(t.nodes[be].bounds.width-sr)>.1&&(t.nodes[be].bounds.width=sr,lc=!0),!Hs&&Math.abs(t.nodes[be].bounds.height-Gs)>.1&&(t.nodes[be].bounds.height=Gs,lc=!0),lc&&n.add(j.id)}}let de=j.bounds.width,me=j.bounds.height,Le=Q?de:me,Ve=Q?me:de,Me=Nt(j,Q?"left":"top"),_e=Nt(j,Q?"right":"bottom"),_t=Nt(j,Q?"top":"left"),yt=Nt(j,Q?"bottom":"right"),vt=Me+Le+_e,vr=_t+Ve+yt;Q&&_r&&qr+vt>Nn+Vs&&qr!==Nn&&(qr=Nn,Cn+=Mn+ce,Mn=0,St++);let Fr=qr+Me,jn=Cn+_t,nr=Q?Fr:jn,or=Q?jn:Fr;if(!e?.has(j.id)&&(j.bounds.x!==nr||j.bounds.y!==or)){let be=o.get(j.id);be!==void 0&&be!==-1&&(t.nodes[be].bounds.x=nr,t.nodes[be].bounds.y=or,n.add(j.id))}Ae.set(j.id,St),qr+=vt+ce,vr>Mn&&(Mn=vr)}if(_.type==="view"&&_.isAutoLayout){let j=f.filter(de=>de.layout?.position!=="absolute"&&de.type!=="task"&&!e?.has(de.id));if(j.length>0){let de=0,me=0;for(let _e of j){let _t=_e.bounds.x+_e.bounds.width+Nt(_e,"right"),yt=_e.bounds.y+_e.bounds.height+Nt(_e,"bottom");_t>de&&(de=_t),yt>me&&(me=yt)}let Le=de+te,Ve=me+Xe,Me=o.get(p);if(Me!==void 0){let _e=_.parent===null,_t=_.layout?.widthPinned===!0,yt=_.layout?.heightPinned===!0,vt=null;if(!_e&&_.parent!==null){let be=o.get(_.parent),je=be!==void 0?t.nodes[be]:void 0;if(je&&a.has(je.id)){let Vr=je.layout?.flexDirection??"row",Hs=Vr==="row"||Vr==="row-reverse",sr=_.layout?.alignSelf;(sr&&sr!=="auto"?sr:je.layout?.alignItems??"stretch")==="stretch"&&(vt=Hs?"height":"width")}}let jn=(v.alignItems??"stretch")==="stretch"&&!(Q&&_r)?Q?"height":"width":null,nr=be=>!_e&&vt!==be&&jn!==be,or=(be,je,Vr)=>be<je||nr(Vr)&&be>je?je:null;if(!_t){let be=or(_.bounds.width,Le,"width");be!==null&&(t.nodes[Me].bounds.width=be,n.add(p))}if(!yt){let be=or(_.bounds.height,Ve,"height");be!==null&&(t.nodes[Me].bounds.height=be,n.add(p))}}}}if(Q&&_r&&Oo&&Ae.size>0){let j=new Map;for(let Me of f){let _e=Ae.get(Me.id);_e!==void 0&&(j.has(_e)||j.set(_e,[]),j.get(_e).push(Me))}let de=Array.from(j.keys()).sort((Me,_e)=>Me-_e),me=[];for(let Me of de){let _e=j.get(Me),_t=1/0,yt=-1/0;for(let vt of _e){let vr=vt.bounds.y-Nt(vt,"top"),Fr=vt.bounds.y+vt.bounds.height+Nt(vt,"bottom");vr<_t&&(_t=vr),Fr>yt&&(yt=Fr)}me.push({top:_t,bottom:yt})}let Le=_.bounds.height-L-Xe,Ve=Array.from(j.keys()).sort((Me,_e)=>Me-_e);for(let Me=0;Me<Ve.length;Me++){let _e=Ve[Me],_t=j.get(_e),yt=me[Me],vt=yt.top-Ft,vr=yt.bottom-Ft,jn=Le-vr-vt;for(let nr of _t){if(e?.has(nr.id))continue;let or=o.get(nr.id);or===void 0||or===-1||(t.nodes[or].bounds.y=nr.bounds.y+jn,n.add(nr.id))}}}tb({document:t,parentNode:_,children:f,padTop:L,padRight:te,padBottom:Xe,padLeft:F,gap:ce,isRow:Q,wrapEnabled:_r,justifyContent:v.justifyContent,alignItems:v.alignItems,rowAssignment:Ae,nodeIndexById:o,modifiedNodeIds:n,draggedNodeIds:e,marginOf:Nt})}for(let p=h.length-1;p>=0;p--){let f=h[p],g=m.get(f);g&&tb({document:t,parentNode:g.parentNode,children:g.children,padTop:g.padTop,padRight:g.padRight,padBottom:g.padBottom,padLeft:g.padLeft,gap:g.gap,isRow:g.isRow,wrapEnabled:g.wrapEnabled,justifyContent:g.justifyContent,alignItems:g.alignItems,rowAssignment:g.rowAssignment,nodeIndexById:o,modifiedNodeIds:n,draggedNodeIds:e,marginOf:Nt})}return i()}function tb(t){let{document:e,parentNode:r,children:n,padTop:o,padRight:s,padBottom:i,padLeft:a,gap:c,isRow:u,wrapEnabled:l,justifyContent:d,alignItems:h,rowAssignment:m,nodeIndexById:p,modifiedNodeIds:f,draggedNodeIds:g,marginOf:_}=t,v=n.filter(F=>F.layout?.position!=="absolute"&&F.type!=="task");if(v.length===0)return;let S=[];if(u&&l){let F=new Map;for(let ce of v){let Ce=m.get(ce.id)??0;F.has(Ce)||F.set(Ce,[]),F.get(Ce).push(ce)}for(let ce of Array.from(F.keys()).sort((Ce,Q)=>Ce-Q))S.push(F.get(ce))}else S.push(v);let y=u?a:o,T=u?r.bounds.width-a-s:r.bounds.height-o-i,L=u?r.bounds.height-o-i:r.bounds.width-a-s,te=F=>F&&F!=="auto"?F:h,Xe=F=>F==="baseline"?"flex-start":F;for(let F of S){if(F.length===0)continue;let ce=F.map(z=>u?z.bounds.width:z.bounds.height),Ce=F.map(z=>_(z,u?"left":"top")+_(z,u?"right":"bottom")),Q=ce.reduce((z,D)=>z+D,0)+Ce.reduce((z,D)=>z+D,0)+(F.length-1)*c,tr=Math.max(0,T-Q),rr=F.filter(z=>{let D=z.layout?.flexGrow;return!D||D<=0||g?.has(z.id)?!1:!(u?z.layout?.widthPinned===!0:z.layout?.heightPinned===!0)});if(tr>.5&&rr.length>0){let z=rr.reduce((D,ue)=>D+(ue.layout?.flexGrow||0),0);for(let D of rr){let ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=F.indexOf(D),St=tr*((D.layout?.flexGrow||0)/z),j=ce[Ae]+St;ce[Ae]=j,u?Math.abs(e.nodes[ue].bounds.width-j)>.1&&(e.nodes[ue].bounds.width=j,f.add(D.id)):Math.abs(e.nodes[ue].bounds.height-j)>.1&&(e.nodes[ue].bounds.height=j,f.add(D.id))}}let _r=Q-T,Oo=F.filter(z=>(z.layout?.flexShrink??1)<=0||g?.has(z.id)?!1:!(u?z.layout?.widthPinned===!0:z.layout?.heightPinned===!0));if(_r>.5&&Oo.length>0){let z=Oo.reduce((D,ue)=>{let Ae=F.indexOf(ue);return D+(ue.layout?.flexShrink??1)*ce[Ae]},0);if(z>0)for(let D of Oo){let ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=F.indexOf(D),St=(D.layout?.flexShrink??1)*ce[Ae],j=_r*(St/z),de=Math.max(0,ce[Ae]-j);ce[Ae]=de,u?Math.abs(e.nodes[ue].bounds.width-de)>.1&&(e.nodes[ue].bounds.width=de,f.add(D.id)):Math.abs(e.nodes[ue].bounds.height-de)>.1&&(e.nodes[ue].bounds.height=de,f.add(D.id))}}let Nn=ce.reduce((z,D)=>z+D,0)+Ce.reduce((z,D)=>z+D,0)+(F.length-1)*c,Ft=Math.max(0,T-Nn),yr=0,An=c;switch(d){case"center":yr=Ft/2;break;case"flex-end":yr=Ft;break;case"space-between":F.length>1?An=c+Ft/(F.length-1):yr=Ft/2;break;case"space-around":if(F.length>0){let z=Ft/F.length;yr=z/2,An=c+z}break;case"space-evenly":if(F.length>0){let z=Ft/(F.length+1);yr=z,An=c+z}break;default:break}let Vs=y+yr;for(let z=0;z<F.length;z++){let D=F[z],ue=p.get(D.id);if(ue===void 0||ue===-1)continue;let Ae=_(D,u?"left":"top"),St=_(D,u?"right":"bottom"),j=ce[z],de=Vs+Ae;g?.has(D.id)||(u?e.nodes[ue].bounds.x!==de&&(e.nodes[ue].bounds.x=de,f.add(D.id)):e.nodes[ue].bounds.y!==de&&(e.nodes[ue].bounds.y=de,f.add(D.id))),Vs+=Ae+j+St+An}let qr=F.reduce((z,D)=>{let ue=u?D.bounds.height:D.bounds.width,Ae=_(D,u?"top":"left")+_(D,u?"bottom":"right");return Math.max(z,ue+Ae)},0),Cn=u&&l?qr:L,Mn=u?Math.min(...F.map(z=>z.bounds.y-_(z,"top"))):a;for(let z of F){let D=p.get(z.id);if(D===void 0||D===-1)continue;let ue=Xe(te(z.layout?.alignSelf))??"stretch",Ae=u?z.bounds.height:z.bounds.width,St=_(z,u?"top":"left"),j=_(z,u?"bottom":"right"),de=St+Ae+j,me=0,Le=null;switch(ue){case"center":me=(Cn-de)/2;break;case"flex-end":me=Cn-de;break;case"stretch":{if(!(u?z.layout?.heightPinned===!0:z.layout?.widthPinned===!0)){let _e=Cn-St-j;Ae<_e&&(Le=_e)}break}case"flex-start":case"baseline":break;default:break}me<0&&(me=0);let Ve=Mn+me+St;g?.has(z.id)||(u?(e.nodes[D].bounds.y!==Ve&&(e.nodes[D].bounds.y=Ve,f.add(z.id)),Le!==null&&e.nodes[D].bounds.height!==Le&&(e.nodes[D].bounds.height=Le,f.add(z.id))):(e.nodes[D].bounds.x!==Ve&&(e.nodes[D].bounds.x=Ve,f.add(z.id)),Le!==null&&e.nodes[D].bounds.width!==Le&&(e.nodes[D].bounds.width=Le,f.add(z.id))))}}}});var nb=$(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.detectLayoutOverflows=Bz;function Bz(t){let n=new Map;for(let s of t)if(s.parent!=null){let i=n.get(s.parent);i?i.push(s):n.set(s.parent,[s])}let o=[];for(let s of t){let i=s.layout,a=i?.flexDirection;if(!a)continue;let c=n.get(s.id);if(!c||c.length===0)continue;let u=c.filter(ce=>ce.layout?.position!=="absolute");if(u.length===0)continue;let l=a==="row"||a==="row-reverse";if(u.some(ce=>(ce.layout?.flexGrow??0)>0))continue;let d=l?s.bounds?.width:s.bounds?.height;if(typeof d!="number"||!Number.isFinite(d)||d<=0)continue;let h=i?.padding??0,m=l?(i?.paddingLeft??h)+(i?.paddingRight??h):(i?.paddingTop??h)+(i?.paddingBottom??h),p=i?.gap??0,f=0,g=!0;for(let ce of u){let Ce=l?ce.bounds?.width:ce.bounds?.height;if(typeof Ce!="number"||!Number.isFinite(Ce)){g=!1;break}let Q=ce.layout,tr=l?(Q?.marginLeft??Q?.margin??0)+(Q?.marginRight??Q?.margin??0):(Q?.marginTop??Q?.margin??0)+(Q?.marginBottom??Q?.margin??0);f+=Ce+tr}if(!g)continue;let _=f+(u.length-1)*p+m,v=_-d;if(v<=1)continue;let S=l?"width":"height",y=s.name??"(unnamed)",T=i?.flexWrap,L=T==="wrap"||T==="wrap-reverse",te=Math.round(_),Xe=`${u.length} children need ${te}px on the main axis (\u03A3 children ${Math.round(f)} + ${u.length-1}\xD7gap ${p} + padding ${m}) but ${S} is only ${Math.round(d)}px`,F=L?`children WRAP onto a new line (flexWrap=${T}). To keep them inline: widen ${S} to \u2265${te}, set flexWrap=nowrap, or give the children flexGrow so they shrink to share the ${S}.`:`children OVERFLOW / get clipped (flexWrap=${T??"nowrap"}). Widen ${S} to \u2265${te}, reduce child sizes, or give the children flexGrow.`;o.push({overage:v,line:`\u26A0 #${s.id} "${y}" (${a}): ${Xe} \u2192 ${F}`})}return o.sort((s,i)=>i.overage-s.overage),o.slice(0,8).map(s=>s.line)}});var of=$(gt=>{"use strict";var Kz=gt&&gt.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),ob=gt&&gt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Kz(e,t,r)};Object.defineProperty(gt,"__esModule",{value:!0});gt.detectLayoutOverflows=gt.headlessTextMeasurer=gt.layoutContainerChildren=void 0;ob(Cv(),gt);ob(eb(),gt);var Wz=rb();Object.defineProperty(gt,"layoutContainerChildren",{enumerable:!0,get:function(){return Wz.layoutContainerChildren}});var Jz=tf();Object.defineProperty(gt,"headlessTextMeasurer",{enumerable:!0,get:function(){return Jz.headlessTextMeasurer}});var Xz=nb();Object.defineProperty(gt,"detectLayoutOverflows",{enumerable:!0,get:function(){return Xz.detectLayoutOverflows}})});(function(){kf().config(Object.assign({},Pf(),If()(process.argv)))})();import Oh from"node:process";var Qb=Object.freeze({status:"aborted"});function x(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var ar=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Xs={};function bt(t){return t&&Object.assign(Xs,t),Xs}var re={};pc(re,{BIGINT_FORMAT_RANGES:()=>Of,Class:()=>hc,NUMBER_FORMAT_RANGES:()=>xc,aborted:()=>Br,allowsEval:()=>vc,assert:()=>ow,assertEqual:()=>ew,assertIs:()=>rw,assertNever:()=>nw,assertNotEqual:()=>tw,assignProp:()=>yc,cached:()=>Mo,captureStackTrace:()=>Qs,cleanEnum:()=>_w,cleanRegex:()=>Do,clone:()=>wt,createTransparentProxy:()=>lw,defineLazy:()=>we,esc:()=>Gr,escapeRegex:()=>br,extend:()=>fw,finalizeIssue:()=>At,floatSafeRemainder:()=>_c,getElementAtPath:()=>sw,getEnumValues:()=>Co,getLengthableOrigin:()=>Lo,getParsedType:()=>uw,getSizableOrigin:()=>Nf,isObject:()=>Ln,isPlainObject:()=>Zn,issue:()=>Sc,joinValues:()=>Ys,jsonStringifyReplacer:()=>gc,merge:()=>mw,normalizeParams:()=>Z,nullish:()=>jo,numKeys:()=>cw,omit:()=>pw,optionalKeys:()=>wc,partial:()=>hw,pick:()=>dw,prefixIssues:()=>Vt,primitiveTypes:()=>zf,promiseAllObject:()=>iw,propertyKeyTypes:()=>bc,randomString:()=>aw,required:()=>gw,stringifyPrimitive:()=>ei,unwrapMessage:()=>Ao});function ew(t){return t}function tw(t){return t}function rw(t){}function nw(t){throw new Error}function ow(t){}function Co(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Ys(t,e="|"){return t.map(r=>ei(r)).join(e)}function gc(t,e){return typeof e=="bigint"?e.toString():e}function Mo(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function jo(t){return t==null}function Do(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function _c(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function we(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function yc(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function sw(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function iw(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function aw(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Gr(t){return JSON.stringify(t)}var Qs=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var vc=Mo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Zn(t){if(Ln(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function cw(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var uw=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},bc=new Set(["string","number","symbol"]),zf=new Set(["string","number","bigint","boolean","symbol","undefined"]);function br(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function lw(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function ei(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function wc(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var xc={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]},Of={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function dw(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return wt(t,{...t._zod.def,shape:r,checks:[]})}function pw(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return wt(t,{...t._zod.def,shape:r,checks:[]})}function fw(t,e){if(!Zn(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return yc(this,"shape",n),n},checks:[]};return wt(t,r)}function mw(t,e){return wt(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return yc(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function hw(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return wt(e,{...e._zod.def,shape:o,checks:[]})}function gw(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return wt(e,{...e._zod.def,shape:o,checks:[]})}function Br(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Vt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Ao(t){return typeof t=="string"?t:t?.message}function At(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Ao(t.inst?._zod.def?.error?.(t))??Ao(e?.error?.(t))??Ao(r.customError?.(t))??Ao(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Nf(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Lo(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Sc(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function _w(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var hc=class{constructor(...e){}};var Af=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,gc,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},ti=x("$ZodError",Af),Zo=x("$ZodError",Af,{Parent:Error});function $c(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function Ec(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var kc=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ar;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>At(c,s,bt())));throw Qs(a,o?.callee),a}return i.value},Tc=kc(Zo),Pc=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>At(c,s,bt())));throw Qs(a,o?.callee),a}return i.value},Rc=Pc(Zo),Ic=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ar;return s.issues.length?{success:!1,error:new(t??ti)(s.issues.map(i=>At(i,o,bt())))}:{success:!0,data:s.value}},Kr=Ic(Zo),zc=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>At(i,o,bt())))}:{success:!0,data:s.value}},Wr=zc(Zo);var Cf=/^[cC][^\s-]{8,}$/,Mf=/^[0-9a-z]+$/,jf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Df=/^[0-9a-vA-V]{20}$/,Lf=/^[A-Za-z0-9]{27}$/,Zf=/^[a-zA-Z0-9_-]{21}$/,Uf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var qf=/^([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})$/,Oc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Ff=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var vw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vf(){return new RegExp(vw,"u")}var Hf=/^(?:(?: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])$/,Gf=/^(([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})$/,Bf=/^((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])$/,Kf=/^(([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])$/,Wf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nc=/^[A-Za-z0-9_-]*$/,Jf=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Xf=/^\+(?:[0-9]){6,14}[0-9]$/,Yf="(?:(?:\\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])))",Qf=new RegExp(`^${Yf}$`);function em(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tm(t){return new RegExp(`^${em(t)}$`)}function rm(t){let e=em({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Yf}T(?:${n})$`)}var nm=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var om=/^\d+$/,sm=/^-?\d+(?:\.\d+)?/i,im=/true|false/i,am=/null/i;var cm=/^[^A-Z]*$/,um=/^[^a-z]*$/;var He=x("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),lm={number:"number",bigint:"bigint",object:"date"},Ac=x("$ZodCheckLessThan",(t,e)=>{He.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Cc=x("$ZodCheckGreaterThan",(t,e)=>{He.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),dm=x("$ZodCheckMultipleOf",(t,e)=>{He.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):_c(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),pm=x("$ZodCheckNumberFormat",(t,e)=>{He.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=xc[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=om)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var fm=x("$ZodCheckMaxLength",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Lo(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),mm=x("$ZodCheckMinLength",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Lo(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),hm=x("$ZodCheckLengthEquals",(t,e)=>{var r;He.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jo(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Lo(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Uo=x("$ZodCheckStringFormat",(t,e)=>{var r,n;He.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),gm=x("$ZodCheckRegex",(t,e)=>{Uo.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),_m=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=cm),Uo.init(t,e)}),ym=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=um),Uo.init(t,e)}),vm=x("$ZodCheckIncludes",(t,e)=>{He.init(t,e);let r=br(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),bm=x("$ZodCheckStartsWith",(t,e)=>{He.init(t,e);let r=new RegExp(`^${br(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),wm=x("$ZodCheckEndsWith",(t,e)=>{He.init(t,e);let r=new RegExp(`.*${br(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var xm=x("$ZodCheckOverwrite",(t,e)=>{He.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var ni=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
12
12
  `).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
13
- `))}};var Sm={major:4,minor:0,patch:0};var he=x("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Sm;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(s,i,a)=>{let c=Br(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,h=l._zod.check(s);if(h instanceof Promise&&a?.async===!1)throw new ir;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==d&&(c||(c=Br(s,d)))});else{if(s.issues.length===d)continue;c||(c=Br(s,d))}}return u?u.then(()=>s):s};t._zod.run=(s,i)=>{let a=t._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new ir;return a.then(c=>o(c,n,i))}return o(a,n,i)}}t["~standard"]={validate:o=>{try{let s=Kr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Wr(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),qo=x("$ZodString",(t,e)=>{he.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??nm(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),xe=x("$ZodStringFormat",(t,e)=>{Uo.init(t,e),qo.init(t,e)}),jc=x("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=qf),xe.init(t,e)}),Dc=x("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Oc(n))}else e.pattern??(e.pattern=Oc());xe.init(t,e)}),Lc=x("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Ff),xe.init(t,e)}),Zc=x("$ZodURL",(t,e)=>{xe.init(t,e),t._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Jf.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Uc=x("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Vf()),xe.init(t,e)}),qc=x("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Zf),xe.init(t,e)}),Fc=x("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Cf),xe.init(t,e)}),Vc=x("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Mf),xe.init(t,e)}),Hc=x("$ZodULID",(t,e)=>{e.pattern??(e.pattern=jf),xe.init(t,e)}),Gc=x("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Df),xe.init(t,e)}),Bc=x("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Lf),xe.init(t,e)}),Am=x("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=rm(e)),xe.init(t,e)}),Cm=x("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Qf),xe.init(t,e)}),Mm=x("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=tm(e)),xe.init(t,e)}),jm=x("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Uf),xe.init(t,e)}),Kc=x("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Hf),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Wc=x("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Gf),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Jc=x("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Bf),xe.init(t,e)}),Xc=x("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Kf),xe.init(t,e),t._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function Dm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Yc=x("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Wf),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Dm(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function mw(t){if(!Nc.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Dm(r)}var Qc=x("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Nc),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{mw(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),eu=x("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Xf),xe.init(t,e)});function hw(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var tu=x("$ZodJWT",(t,e)=>{xe.init(t,e),t._zod.check=r=>{hw(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var si=x("$ZodNumber",(t,e)=>{he.init(t,e),t._zod.pattern=t._zod.bag.pattern??sm,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),ru=x("$ZodNumber",(t,e)=>{pm.init(t,e),si.init(t,e)}),nu=x("$ZodBoolean",(t,e)=>{he.init(t,e),t._zod.pattern=im,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var ou=x("$ZodNull",(t,e)=>{he.init(t,e),t._zod.pattern=am,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var su=x("$ZodUnknown",(t,e)=>{he.init(t,e),t._zod.parse=r=>r}),iu=x("$ZodNever",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Em(t,e,r){t.issues.length&&e.issues.push(...Vt(r,t.issues)),e.value[r]=t.value}var au=x("$ZodArray",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>Em(u,r,i))):Em(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function oi(t,e,r){t.issues.length&&e.issues.push(...Vt(r,t.issues)),e.value[r]=t.value}function km(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...Vt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var ii=x("$ZodObject",(t,e)=>{he.init(t,e);let r=Mo(()=>{let d=Object.keys(e.shape);for(let m of d)if(!(e.shape[m]instanceof he))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let h=wc(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(h)}});we(t._zod,"propValues",()=>{let d=e.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 ni(["shape","payload","ctx"]),m=r.value,p=v=>{let $=Gr(v);return`shape[${$}]._zod.run({ value: input[${$}], 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 $=f[v];h.write(`const ${$} = ${p(v)};`);let y=Gr(v);h.write(`
14
- if (${$}.issues.length) {
13
+ `))}};var $m={major:4,minor:0,patch:0};var he=x("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=$m;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(s,i,a)=>{let c=Br(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,h=l._zod.check(s);if(h instanceof Promise&&a?.async===!1)throw new ar;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==d&&(c||(c=Br(s,d)))});else{if(s.issues.length===d)continue;c||(c=Br(s,d))}}return u?u.then(()=>s):s};t._zod.run=(s,i)=>{let a=t._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new ar;return a.then(c=>o(c,n,i))}return o(a,n,i)}}t["~standard"]={validate:o=>{try{let s=Kr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Wr(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),qo=x("$ZodString",(t,e)=>{he.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??nm(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),xe=x("$ZodStringFormat",(t,e)=>{Uo.init(t,e),qo.init(t,e)}),jc=x("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=qf),xe.init(t,e)}),Dc=x("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Oc(n))}else e.pattern??(e.pattern=Oc());xe.init(t,e)}),Lc=x("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Ff),xe.init(t,e)}),Zc=x("$ZodURL",(t,e)=>{xe.init(t,e),t._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Jf.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Uc=x("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Vf()),xe.init(t,e)}),qc=x("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Zf),xe.init(t,e)}),Fc=x("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Cf),xe.init(t,e)}),Vc=x("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Mf),xe.init(t,e)}),Hc=x("$ZodULID",(t,e)=>{e.pattern??(e.pattern=jf),xe.init(t,e)}),Gc=x("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Df),xe.init(t,e)}),Bc=x("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Lf),xe.init(t,e)}),Am=x("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=rm(e)),xe.init(t,e)}),Cm=x("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Qf),xe.init(t,e)}),Mm=x("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=tm(e)),xe.init(t,e)}),jm=x("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Uf),xe.init(t,e)}),Kc=x("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Hf),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Wc=x("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Gf),xe.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Jc=x("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Bf),xe.init(t,e)}),Xc=x("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Kf),xe.init(t,e),t._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function Dm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Yc=x("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Wf),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Dm(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function bw(t){if(!Nc.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Dm(r)}var Qc=x("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Nc),xe.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{bw(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),eu=x("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Xf),xe.init(t,e)});function ww(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var tu=x("$ZodJWT",(t,e)=>{xe.init(t,e),t._zod.check=r=>{ww(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var si=x("$ZodNumber",(t,e)=>{he.init(t,e),t._zod.pattern=t._zod.bag.pattern??sm,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),ru=x("$ZodNumber",(t,e)=>{pm.init(t,e),si.init(t,e)}),nu=x("$ZodBoolean",(t,e)=>{he.init(t,e),t._zod.pattern=im,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var ou=x("$ZodNull",(t,e)=>{he.init(t,e),t._zod.pattern=am,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var su=x("$ZodUnknown",(t,e)=>{he.init(t,e),t._zod.parse=r=>r}),iu=x("$ZodNever",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Em(t,e,r){t.issues.length&&e.issues.push(...Vt(r,t.issues)),e.value[r]=t.value}var au=x("$ZodArray",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>Em(u,r,i))):Em(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function oi(t,e,r){t.issues.length&&e.issues.push(...Vt(r,t.issues)),e.value[r]=t.value}function km(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...Vt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var ii=x("$ZodObject",(t,e)=>{he.init(t,e);let r=Mo(()=>{let d=Object.keys(e.shape);for(let m of d)if(!(e.shape[m]instanceof he))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let h=wc(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(h)}});we(t._zod,"propValues",()=>{let d=e.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 ni(["shape","payload","ctx"]),m=r.value,p=v=>{let S=Gr(v);return`shape[${S}]._zod.run({ value: input[${S}], 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 S=f[v];h.write(`const ${S} = ${p(v)};`);let y=Gr(v);h.write(`
14
+ if (${S}.issues.length) {
15
15
  if (input[${y}] === undefined) {
16
16
  if (${y} in input) {
17
17
  newResult[${y}] = undefined;
18
18
  }
19
19
  } else {
20
20
  payload.issues = payload.issues.concat(
21
- ${$}.issues.map((iss) => ({
21
+ ${S}.issues.map((iss) => ({
22
22
  ...iss,
23
23
  path: iss.path ? [${y}, ...iss.path] : [${y}],
24
24
  }))
25
25
  );
26
26
  }
27
- } else if (${$}.value === undefined) {
27
+ } else if (${S}.value === undefined) {
28
28
  if (${y} in input) newResult[${y}] = undefined;
29
29
  } else {
30
- newResult[${y}] = ${$}.value;
30
+ newResult[${y}] = ${S}.value;
31
31
  }
32
- `)}else{let $=f[v];h.write(`const ${$} = ${p(v)};`),h.write(`
33
- if (${$}.issues.length) payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
32
+ `)}else{let S=f[v];h.write(`const ${S} = ${p(v)};`),h.write(`
33
+ if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
34
34
  ...iss,
35
35
  path: iss.path ? [${Gr(v)}, ...iss.path] : [${Gr(v)}]
36
- })));`),h.write(`newResult[${Gr(v)}] = ${$}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let _=h.compile();return(v,$)=>_(d,v,$)},o,s=Dn,i=!Xs.jitless,c=i&&vc.value,u=e.catchall,l;t._zod.parse=(d,h)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let p=[];if(i&&c&&h?.async===!1&&h.jitless!==!0)o||(o=n(e.shape)),d=o(d,h);else{d.value={};let $=l.shape;for(let y of l.keys){let T=$[y],F=T._zod.run({value:m[y],issues:[]},h),te=T._zod.optin==="optional"&&T._zod.optout==="optional";F instanceof Promise?p.push(F.then(Xe=>te?km(Xe,d,y,m):oi(Xe,d,y))):te?km(F,d,y,m):oi(F,d,y)}}if(!u)return p.length?Promise.all(p).then(()=>d):d;let f=[],g=l.keySet,_=u._zod,v=_.def.type;for(let $ of Object.keys(m)){if(g.has($))continue;if(v==="never"){f.push($);continue}let y=_.run({value:m[$],issues:[]},h);y instanceof Promise?p.push(y.then(T=>oi(T,d,$))):oi(y,d,$)}return f.length&&d.issues.push({code:"unrecognized_keys",keys:f,input:m,inst:t}),p.length?Promise.all(p).then(()=>d):d}});function Tm(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>At(s,n,bt())))}),e}var ai=x("$ZodUnion",(t,e)=>{he.init(t,e),we(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),we(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),we(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),we(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Do(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Tm(i,r,t,n)):Tm(s,r,t,n)}}),cu=x("$ZodDiscriminatedUnion",(t,e)=>{ai.init(t,e);let r=t._zod.parse;we(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=Mo(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Dn(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),uu=x("$ZodIntersection",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Pm(r,c,u)):Pm(r,s,i)}});function Mc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Ln(t)&&Ln(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=Mc(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=Mc(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Pm(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Br(t))return t;let n=Mc(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var lu=x("$ZodRecord",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Ln(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...Vt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Vt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>At(u,n,bt())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...Vt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Vt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var du=x("$ZodEnum",(t,e)=>{he.init(t,e);let r=Co(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>bc.has(typeof n)).map(n=>typeof n=="string"?br(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),pu=x("$ZodLiteral",(t,e)=>{he.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?br(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var fu=x("$ZodTransform",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ir;return r.value=o,r}}),mu=x("$ZodOptional",(t,e)=>{he.init(t,e),t._zod.optin="optional",t._zod.optout="optional",we(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),we(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Do(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),hu=x("$ZodNullable",(t,e)=>{he.init(t,e),we(t._zod,"optin",()=>e.innerType._zod.optin),we(t._zod,"optout",()=>e.innerType._zod.optout),we(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Do(r.source)}|null)$`):void 0}),we(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),gu=x("$ZodDefault",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Rm(s,e)):Rm(o,e)}});function Rm(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var _u=x("$ZodPrefault",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),yu=x("$ZodNonOptional",(t,e)=>{he.init(t,e),we(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Im(s,t)):Im(o,t)}});function Im(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var vu=x("$ZodCatch",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"optout",()=>e.innerType._zod.optout),we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>At(i,n,bt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>At(s,n,bt()))},input:r.value}),r.issues=[]),r)}});var bu=x("$ZodPipe",(t,e)=>{he.init(t,e),we(t._zod,"values",()=>e.in._zod.values),we(t._zod,"optin",()=>e.in._zod.optin),we(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>zm(s,e,n)):zm(o,e,n)}});function zm(t,e,r){return Br(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var wu=x("$ZodReadonly",(t,e)=>{he.init(t,e),we(t._zod,"propValues",()=>e.innerType._zod.propValues),we(t._zod,"values",()=>e.innerType._zod.values),we(t._zod,"optin",()=>e.innerType._zod.optin),we(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Om):Om(o)}});function Om(t){return t.value=Object.freeze(t.value),t}var xu=x("$ZodCustom",(t,e)=>{He.init(t,e),he.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Nm(s,r,n,t));Nm(o,r,n,t)}});function Nm(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push($c(o))}}var gw=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},_w=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${gw(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${ei(n.values[0])}`:`Invalid option: expected one of ${Ys(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.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":""}: ${Ys(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 Lm(){return{localeError:_w()}}var Fo=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Zm(){return new Fo}var wr=Zm();function $u(t,e){return new t({type:"string",...L(e)})}function Su(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...L(e)})}function ci(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...L(e)})}function Eu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...L(e)})}function ku(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...L(e)})}function Tu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...L(e)})}function Pu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...L(e)})}function Ru(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...L(e)})}function Iu(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...L(e)})}function zu(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...L(e)})}function Ou(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...L(e)})}function Nu(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...L(e)})}function Au(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...L(e)})}function Cu(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...L(e)})}function Mu(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...L(e)})}function ju(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...L(e)})}function Du(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...L(e)})}function Lu(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...L(e)})}function Zu(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...L(e)})}function Uu(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...L(e)})}function qu(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...L(e)})}function Fu(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...L(e)})}function Vu(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...L(e)})}function Um(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...L(e)})}function qm(t,e){return new t({type:"string",format:"date",check:"string_format",...L(e)})}function Fm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...L(e)})}function Vm(t,e){return new t({type:"string",format:"duration",check:"string_format",...L(e)})}function Hu(t,e){return new t({type:"number",checks:[],...L(e)})}function Gu(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...L(e)})}function Bu(t,e){return new t({type:"boolean",...L(e)})}function Ku(t,e){return new t({type:"null",...L(e)})}function Wu(t){return new t({type:"unknown"})}function Ju(t,e){return new t({type:"never",...L(e)})}function ui(t,e){return new Ac({check:"less_than",...L(e),value:t,inclusive:!1})}function Vo(t,e){return new Ac({check:"less_than",...L(e),value:t,inclusive:!0})}function li(t,e){return new Cc({check:"greater_than",...L(e),value:t,inclusive:!1})}function Ho(t,e){return new Cc({check:"greater_than",...L(e),value:t,inclusive:!0})}function di(t,e){return new dm({check:"multiple_of",...L(e),value:t})}function pi(t,e){return new fm({check:"max_length",...L(e),maximum:t})}function Zn(t,e){return new mm({check:"min_length",...L(e),minimum:t})}function fi(t,e){return new hm({check:"length_equals",...L(e),length:t})}function Xu(t,e){return new gm({check:"string_format",format:"regex",...L(e),pattern:t})}function Yu(t){return new _m({check:"string_format",format:"lowercase",...L(t)})}function Qu(t){return new ym({check:"string_format",format:"uppercase",...L(t)})}function el(t,e){return new vm({check:"string_format",format:"includes",...L(e),includes:t})}function tl(t,e){return new bm({check:"string_format",format:"starts_with",...L(e),prefix:t})}function rl(t,e){return new wm({check:"string_format",format:"ends_with",...L(e),suffix:t})}function Jr(t){return new xm({check:"overwrite",tx:t})}function nl(t){return Jr(e=>e.normalize(t))}function ol(){return Jr(t=>t.trim())}function sl(){return Jr(t=>t.toLowerCase())}function il(){return Jr(t=>t.toUpperCase())}function Hm(t,e,r){return new t({type:"array",element:e,...L(r)})}function al(t,e,r){let n=L(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function cl(t,e,r){return new t({type:"custom",check:"custom",fn:e,...L(r)})}var mi=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??wr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},h=e._zod.parent;if(h)a.ref=h,this.process(h,d),this.seen.get(h).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let p=m;p.type="string";let{minimum:f,maximum:g,format:_,patterns:v,contentEncoding:$}=e._zod.bag;if(typeof f=="number"&&(p.minLength=f),typeof g=="number"&&(p.maxLength=g),_&&(p.format=s[_]??_,p.format===""&&delete p.format),$&&(p.contentEncoding=$),v&&v.size>0){let y=[...v];y.length===1?p.pattern=y[0].source:y.length>1&&(a.schema.allOf=[...y.map(T=>({...this.target==="draft-7"?{type:"string"}:{},pattern:T.source}))])}break}case"number":{let p=m,{minimum:f,maximum:g,format:_,multipleOf:v,exclusiveMaximum:$,exclusiveMinimum:y}=e._zod.bag;typeof _=="string"&&_.includes("int")?p.type="integer":p.type="number",typeof y=="number"&&(p.exclusiveMinimum=y),typeof f=="number"&&(p.minimum=f,typeof y=="number"&&(y>=f?delete p.minimum:delete p.exclusiveMinimum)),typeof $=="number"&&(p.exclusiveMaximum=$),typeof g=="number"&&(p.maximum=g,typeof $=="number"&&($<=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}=e._zod.bag;typeof f=="number"&&(p.minItems=f),typeof g=="number"&&(p.maxItems=g),p.type="array",p.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let p=m;p.type="object",p.properties={};let f=o.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)),_=new Set([...g].filter(v=>{let $=o.shape[v]._zod;return this.io==="input"?$.optin===void 0:$.optout===void 0}));_.size>0&&(p.required=Array.from(_)),o.catchall?._zod.def.type==="never"?p.additionalProperties=!1:o.catchall?o.catchall&&(p.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=m;p.anyOf=o.options.map((f,g)=>this.process(f,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let p=m,f=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),_=$=>"allOf"in $&&Object.keys($).length===1,v=[..._(f)?f.allOf:[f],..._(g)?g.allOf:[g]];p.allOf=v;break}case"tuple":{let p=m;p.type="array";let f=o.items.map((v,$)=>this.process(v,{...d,path:[...d.path,"prefixItems",$]}));if(this.target==="draft-2020-12"?p.prefixItems=f:p.items=f,o.rest){let v=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=v:p.additionalItems=v}o.rest&&(p.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:_}=e._zod.bag;typeof g=="number"&&(p.minItems=g),typeof _=="number"&&(p.maxItems=_);break}case"record":{let p=m;p.type="object",p.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(o.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=Co(o.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 o.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:_,mime:v}=e._zod.bag;g!==void 0&&(f.minLength=g),_!==void 0&&(f.maxLength=_),v?v.length===1?(f.contentMediaType=v[0],Object.assign(p,f)):p.anyOf=v.map($=>({...f,contentMediaType:$})):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(o.innerType,d);m.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let p=m;p.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),a.ref=o.innerType;let p;try{p=o.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=e._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"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(p,d),a.ref=p;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let p=e._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 u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&Ue(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=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 _=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=_,{defId:_,ref:`${g("__shared")}#/${d}/${_}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:m+p}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:h,defId:m}=s(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>
36
+ })));`),h.write(`newResult[${Gr(v)}] = ${S}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let _=h.compile();return(v,S)=>_(d,v,S)},o,s=Ln,i=!Xs.jitless,c=i&&vc.value,u=e.catchall,l;t._zod.parse=(d,h)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let p=[];if(i&&c&&h?.async===!1&&h.jitless!==!0)o||(o=n(e.shape)),d=o(d,h);else{d.value={};let S=l.shape;for(let y of l.keys){let T=S[y],L=T._zod.run({value:m[y],issues:[]},h),te=T._zod.optin==="optional"&&T._zod.optout==="optional";L instanceof Promise?p.push(L.then(Xe=>te?km(Xe,d,y,m):oi(Xe,d,y))):te?km(L,d,y,m):oi(L,d,y)}}if(!u)return p.length?Promise.all(p).then(()=>d):d;let f=[],g=l.keySet,_=u._zod,v=_.def.type;for(let S of Object.keys(m)){if(g.has(S))continue;if(v==="never"){f.push(S);continue}let y=_.run({value:m[S],issues:[]},h);y instanceof Promise?p.push(y.then(T=>oi(T,d,S))):oi(y,d,S)}return f.length&&d.issues.push({code:"unrecognized_keys",keys:f,input:m,inst:t}),p.length?Promise.all(p).then(()=>d):d}});function Tm(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>At(s,n,bt())))}),e}var ai=x("$ZodUnion",(t,e)=>{he.init(t,e),we(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),we(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),we(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),we(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Do(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Tm(i,r,t,n)):Tm(s,r,t,n)}}),cu=x("$ZodDiscriminatedUnion",(t,e)=>{ai.init(t,e);let r=t._zod.parse;we(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=Mo(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Ln(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),uu=x("$ZodIntersection",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Pm(r,c,u)):Pm(r,s,i)}});function Mc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Zn(t)&&Zn(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=Mc(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=Mc(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Pm(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Br(t))return t;let n=Mc(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var lu=x("$ZodRecord",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Zn(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...Vt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Vt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>At(u,n,bt())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...Vt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Vt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var du=x("$ZodEnum",(t,e)=>{he.init(t,e);let r=Co(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>bc.has(typeof n)).map(n=>typeof n=="string"?br(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),pu=x("$ZodLiteral",(t,e)=>{he.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?br(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var fu=x("$ZodTransform",(t,e)=>{he.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ar;return r.value=o,r}}),mu=x("$ZodOptional",(t,e)=>{he.init(t,e),t._zod.optin="optional",t._zod.optout="optional",we(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),we(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Do(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),hu=x("$ZodNullable",(t,e)=>{he.init(t,e),we(t._zod,"optin",()=>e.innerType._zod.optin),we(t._zod,"optout",()=>e.innerType._zod.optout),we(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Do(r.source)}|null)$`):void 0}),we(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),gu=x("$ZodDefault",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Rm(s,e)):Rm(o,e)}});function Rm(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var _u=x("$ZodPrefault",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),yu=x("$ZodNonOptional",(t,e)=>{he.init(t,e),we(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Im(s,t)):Im(o,t)}});function Im(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var vu=x("$ZodCatch",(t,e)=>{he.init(t,e),t._zod.optin="optional",we(t._zod,"optout",()=>e.innerType._zod.optout),we(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>At(i,n,bt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>At(s,n,bt()))},input:r.value}),r.issues=[]),r)}});var bu=x("$ZodPipe",(t,e)=>{he.init(t,e),we(t._zod,"values",()=>e.in._zod.values),we(t._zod,"optin",()=>e.in._zod.optin),we(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>zm(s,e,n)):zm(o,e,n)}});function zm(t,e,r){return Br(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var wu=x("$ZodReadonly",(t,e)=>{he.init(t,e),we(t._zod,"propValues",()=>e.innerType._zod.propValues),we(t._zod,"values",()=>e.innerType._zod.values),we(t._zod,"optin",()=>e.innerType._zod.optin),we(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Om):Om(o)}});function Om(t){return t.value=Object.freeze(t.value),t}var xu=x("$ZodCustom",(t,e)=>{He.init(t,e),he.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Nm(s,r,n,t));Nm(o,r,n,t)}});function Nm(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(Sc(o))}}var xw=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},Sw=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${xw(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${ei(n.values[0])}`:`Invalid option: expected one of ${Ys(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.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":""}: ${Ys(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 Lm(){return{localeError:Sw()}}var Fo=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Zm(){return new Fo}var wr=Zm();function Su(t,e){return new t({type:"string",...Z(e)})}function $u(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Z(e)})}function ci(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Z(e)})}function Eu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Z(e)})}function ku(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Z(e)})}function Tu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Z(e)})}function Pu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Z(e)})}function Ru(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Z(e)})}function Iu(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Z(e)})}function zu(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Z(e)})}function Ou(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Z(e)})}function Nu(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Z(e)})}function Au(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Z(e)})}function Cu(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Z(e)})}function Mu(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Z(e)})}function ju(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Z(e)})}function Du(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Z(e)})}function Lu(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Z(e)})}function Zu(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Z(e)})}function Uu(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Z(e)})}function qu(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Z(e)})}function Fu(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Z(e)})}function Vu(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Z(e)})}function Um(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Z(e)})}function qm(t,e){return new t({type:"string",format:"date",check:"string_format",...Z(e)})}function Fm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Z(e)})}function Vm(t,e){return new t({type:"string",format:"duration",check:"string_format",...Z(e)})}function Hu(t,e){return new t({type:"number",checks:[],...Z(e)})}function Gu(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Z(e)})}function Bu(t,e){return new t({type:"boolean",...Z(e)})}function Ku(t,e){return new t({type:"null",...Z(e)})}function Wu(t){return new t({type:"unknown"})}function Ju(t,e){return new t({type:"never",...Z(e)})}function ui(t,e){return new Ac({check:"less_than",...Z(e),value:t,inclusive:!1})}function Vo(t,e){return new Ac({check:"less_than",...Z(e),value:t,inclusive:!0})}function li(t,e){return new Cc({check:"greater_than",...Z(e),value:t,inclusive:!1})}function Ho(t,e){return new Cc({check:"greater_than",...Z(e),value:t,inclusive:!0})}function di(t,e){return new dm({check:"multiple_of",...Z(e),value:t})}function pi(t,e){return new fm({check:"max_length",...Z(e),maximum:t})}function Un(t,e){return new mm({check:"min_length",...Z(e),minimum:t})}function fi(t,e){return new hm({check:"length_equals",...Z(e),length:t})}function Xu(t,e){return new gm({check:"string_format",format:"regex",...Z(e),pattern:t})}function Yu(t){return new _m({check:"string_format",format:"lowercase",...Z(t)})}function Qu(t){return new ym({check:"string_format",format:"uppercase",...Z(t)})}function el(t,e){return new vm({check:"string_format",format:"includes",...Z(e),includes:t})}function tl(t,e){return new bm({check:"string_format",format:"starts_with",...Z(e),prefix:t})}function rl(t,e){return new wm({check:"string_format",format:"ends_with",...Z(e),suffix:t})}function Jr(t){return new xm({check:"overwrite",tx:t})}function nl(t){return Jr(e=>e.normalize(t))}function ol(){return Jr(t=>t.trim())}function sl(){return Jr(t=>t.toLowerCase())}function il(){return Jr(t=>t.toUpperCase())}function Hm(t,e,r){return new t({type:"array",element:e,...Z(r)})}function al(t,e,r){let n=Z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function cl(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Z(r)})}var mi=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??wr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},h=e._zod.parent;if(h)a.ref=h,this.process(h,d),this.seen.get(h).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let p=m;p.type="string";let{minimum:f,maximum:g,format:_,patterns:v,contentEncoding:S}=e._zod.bag;if(typeof f=="number"&&(p.minLength=f),typeof g=="number"&&(p.maxLength=g),_&&(p.format=s[_]??_,p.format===""&&delete p.format),S&&(p.contentEncoding=S),v&&v.size>0){let y=[...v];y.length===1?p.pattern=y[0].source:y.length>1&&(a.schema.allOf=[...y.map(T=>({...this.target==="draft-7"?{type:"string"}:{},pattern:T.source}))])}break}case"number":{let p=m,{minimum:f,maximum:g,format:_,multipleOf:v,exclusiveMaximum:S,exclusiveMinimum:y}=e._zod.bag;typeof _=="string"&&_.includes("int")?p.type="integer":p.type="number",typeof y=="number"&&(p.exclusiveMinimum=y),typeof f=="number"&&(p.minimum=f,typeof y=="number"&&(y>=f?delete p.minimum:delete p.exclusiveMinimum)),typeof S=="number"&&(p.exclusiveMaximum=S),typeof g=="number"&&(p.maximum=g,typeof S=="number"&&(S<=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}=e._zod.bag;typeof f=="number"&&(p.minItems=f),typeof g=="number"&&(p.maxItems=g),p.type="array",p.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let p=m;p.type="object",p.properties={};let f=o.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)),_=new Set([...g].filter(v=>{let S=o.shape[v]._zod;return this.io==="input"?S.optin===void 0:S.optout===void 0}));_.size>0&&(p.required=Array.from(_)),o.catchall?._zod.def.type==="never"?p.additionalProperties=!1:o.catchall?o.catchall&&(p.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=m;p.anyOf=o.options.map((f,g)=>this.process(f,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let p=m,f=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),_=S=>"allOf"in S&&Object.keys(S).length===1,v=[..._(f)?f.allOf:[f],..._(g)?g.allOf:[g]];p.allOf=v;break}case"tuple":{let p=m;p.type="array";let f=o.items.map((v,S)=>this.process(v,{...d,path:[...d.path,"prefixItems",S]}));if(this.target==="draft-2020-12"?p.prefixItems=f:p.items=f,o.rest){let v=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=v:p.additionalItems=v}o.rest&&(p.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:_}=e._zod.bag;typeof g=="number"&&(p.minItems=g),typeof _=="number"&&(p.maxItems=_);break}case"record":{let p=m;p.type="object",p.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(o.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=Co(o.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 o.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:_,mime:v}=e._zod.bag;g!==void 0&&(f.minLength=g),_!==void 0&&(f.maxLength=_),v?v.length===1?(f.contentMediaType=v[0],Object.assign(p,f)):p.anyOf=v.map(S=>({...f,contentMediaType:S})):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(o.innerType,d);m.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let p=m;p.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),a.ref=o.innerType;let p;try{p=o.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=e._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"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(p,d),a.ref=p;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let p=e._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 u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&Ue(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=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 _=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=_,{defId:_,ref:`${g("__shared")}#/${d}/${_}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:m+p}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:h,defId:m}=s(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>
37
37
 
38
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(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 c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function ul(t,e){if(t instanceof Fo){let n=new mi(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new mi(e);return r.process(t),r.emit(t,e)}function Ue(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.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 Ue(o.element,r);case"object":{for(let s in o.shape)if(Ue(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Ue(s,r))return!0;return!1}case"intersection":return Ue(o.left,r)||Ue(o.right,r);case"tuple":{for(let s of o.items)if(Ue(s,r))return!0;return!!(o.rest&&Ue(o.rest,r))}case"record":return Ue(o.keyType,r)||Ue(o.valueType,r);case"map":return Ue(o.keyType,r)||Ue(o.valueType,r);case"set":return Ue(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ue(o.innerType,r);case"lazy":return Ue(o.getter(),r);case"default":return Ue(o.innerType,r);case"prefault":return Ue(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ue(o.in,r)||Ue(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var Go={};pc(Go,{ZodISODate:()=>Km,ZodISODateTime:()=>Bm,ZodISODuration:()=>Jm,ZodISOTime:()=>Wm,date:()=>dl,datetime:()=>ll,duration:()=>fl,time:()=>pl});var Bm=x("ZodISODateTime",(t,e)=>{Am.init(t,e),Pe.init(t,e)});function ll(t){return Um(Bm,t)}var Km=x("ZodISODate",(t,e)=>{Cm.init(t,e),Pe.init(t,e)});function dl(t){return qm(Km,t)}var Wm=x("ZodISOTime",(t,e)=>{Mm.init(t,e),Pe.init(t,e)});function pl(t){return Fm(Wm,t)}var Jm=x("ZodISODuration",(t,e)=>{jm.init(t,e),Pe.init(t,e)});function fl(t){return Vm(Jm,t)}var Xm=(t,e)=>{ti.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Ec(t,r)},flatten:{value:r=>Sc(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},dN=x("ZodError",Xm),Bo=x("ZodError",Xm,{Parent:Error});var Ym=kc(Bo),Qm=Pc(Bo),eh=Ic(Bo),th=zc(Bo);var Ne=x("ZodType",(t,e)=>(he.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>wt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Ym(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>eh(t,r,n),t.parseAsync=async(r,n)=>Qm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>th(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Gx(r,n)),t.superRefine=r=>t.check(Bx(r)),t.overwrite=r=>t.check(Jr(r)),t.optional=()=>Ie(t),t.nullable=()=>oh(t),t.nullish=()=>Ie(oh(t)),t.nonoptional=r=>Lx(t,r),t.array=()=>ne(t),t.or=r=>Ee([t,r]),t.and=r=>gi(t,r),t.transform=r=>hl(t,lh(r)),t.default=r=>Mx(t,r),t.prefault=r=>Dx(t,r),t.catch=r=>Ux(t,r),t.pipe=r=>hl(t,r),t.readonly=()=>Vx(t),t.describe=r=>{let n=t.clone();return wr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return wr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return wr.get(t);let n=t.clone();return wr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),sh=x("_ZodString",(t,e)=>{qo.init(t,e),Ne.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Xu(...n)),t.includes=(...n)=>t.check(el(...n)),t.startsWith=(...n)=>t.check(tl(...n)),t.endsWith=(...n)=>t.check(rl(...n)),t.min=(...n)=>t.check(Zn(...n)),t.max=(...n)=>t.check(pi(...n)),t.length=(...n)=>t.check(fi(...n)),t.nonempty=(...n)=>t.check(Zn(1,...n)),t.lowercase=n=>t.check(Yu(n)),t.uppercase=n=>t.check(Qu(n)),t.trim=()=>t.check(ol()),t.normalize=(...n)=>t.check(nl(...n)),t.toLowerCase=()=>t.check(sl()),t.toUpperCase=()=>t.check(il())}),ox=x("ZodString",(t,e)=>{qo.init(t,e),sh.init(t,e),t.email=r=>t.check(Su(sx,r)),t.url=r=>t.check(Ru(ix,r)),t.jwt=r=>t.check(Vu(wx,r)),t.emoji=r=>t.check(Iu(ax,r)),t.guid=r=>t.check(ci(rh,r)),t.uuid=r=>t.check(Eu(hi,r)),t.uuidv4=r=>t.check(ku(hi,r)),t.uuidv6=r=>t.check(Tu(hi,r)),t.uuidv7=r=>t.check(Pu(hi,r)),t.nanoid=r=>t.check(zu(cx,r)),t.guid=r=>t.check(ci(rh,r)),t.cuid=r=>t.check(Ou(ux,r)),t.cuid2=r=>t.check(Nu(lx,r)),t.ulid=r=>t.check(Au(dx,r)),t.base64=r=>t.check(Uu(yx,r)),t.base64url=r=>t.check(qu(vx,r)),t.xid=r=>t.check(Cu(px,r)),t.ksuid=r=>t.check(Mu(fx,r)),t.ipv4=r=>t.check(ju(mx,r)),t.ipv6=r=>t.check(Du(hx,r)),t.cidrv4=r=>t.check(Lu(gx,r)),t.cidrv6=r=>t.check(Zu(_x,r)),t.e164=r=>t.check(Fu(bx,r)),t.datetime=r=>t.check(ll(r)),t.date=r=>t.check(dl(r)),t.time=r=>t.check(pl(r)),t.duration=r=>t.check(fl(r))});function b(t){return $u(ox,t)}var Pe=x("ZodStringFormat",(t,e)=>{xe.init(t,e),sh.init(t,e)}),sx=x("ZodEmail",(t,e)=>{Lc.init(t,e),Pe.init(t,e)});var rh=x("ZodGUID",(t,e)=>{jc.init(t,e),Pe.init(t,e)});var hi=x("ZodUUID",(t,e)=>{Dc.init(t,e),Pe.init(t,e)});var ix=x("ZodURL",(t,e)=>{Zc.init(t,e),Pe.init(t,e)});var ax=x("ZodEmoji",(t,e)=>{Uc.init(t,e),Pe.init(t,e)});var cx=x("ZodNanoID",(t,e)=>{qc.init(t,e),Pe.init(t,e)});var ux=x("ZodCUID",(t,e)=>{Fc.init(t,e),Pe.init(t,e)});var lx=x("ZodCUID2",(t,e)=>{Vc.init(t,e),Pe.init(t,e)});var dx=x("ZodULID",(t,e)=>{Hc.init(t,e),Pe.init(t,e)});var px=x("ZodXID",(t,e)=>{Gc.init(t,e),Pe.init(t,e)});var fx=x("ZodKSUID",(t,e)=>{Bc.init(t,e),Pe.init(t,e)});var mx=x("ZodIPv4",(t,e)=>{Kc.init(t,e),Pe.init(t,e)});var hx=x("ZodIPv6",(t,e)=>{Wc.init(t,e),Pe.init(t,e)});var gx=x("ZodCIDRv4",(t,e)=>{Jc.init(t,e),Pe.init(t,e)});var _x=x("ZodCIDRv6",(t,e)=>{Xc.init(t,e),Pe.init(t,e)});var yx=x("ZodBase64",(t,e)=>{Yc.init(t,e),Pe.init(t,e)});var vx=x("ZodBase64URL",(t,e)=>{Qc.init(t,e),Pe.init(t,e)});var bx=x("ZodE164",(t,e)=>{eu.init(t,e),Pe.init(t,e)});var wx=x("ZodJWT",(t,e)=>{tu.init(t,e),Pe.init(t,e)});var ih=x("ZodNumber",(t,e)=>{si.init(t,e),Ne.init(t,e),t.gt=(n,o)=>t.check(li(n,o)),t.gte=(n,o)=>t.check(Ho(n,o)),t.min=(n,o)=>t.check(Ho(n,o)),t.lt=(n,o)=>t.check(ui(n,o)),t.lte=(n,o)=>t.check(Vo(n,o)),t.max=(n,o)=>t.check(Vo(n,o)),t.int=n=>t.check(nh(n)),t.safe=n=>t.check(nh(n)),t.positive=n=>t.check(li(0,n)),t.nonnegative=n=>t.check(Ho(0,n)),t.negative=n=>t.check(ui(0,n)),t.nonpositive=n=>t.check(Vo(0,n)),t.multipleOf=(n,o)=>t.check(di(n,o)),t.step=(n,o)=>t.check(di(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function fe(t){return Hu(ih,t)}var xx=x("ZodNumberFormat",(t,e)=>{ru.init(t,e),ih.init(t,e)});function nh(t){return Gu(xx,t)}var $x=x("ZodBoolean",(t,e)=>{nu.init(t,e),Ne.init(t,e)});function Fe(t){return Bu($x,t)}var Sx=x("ZodNull",(t,e)=>{ou.init(t,e),Ne.init(t,e)});function ah(t){return Ku(Sx,t)}var Ex=x("ZodUnknown",(t,e)=>{su.init(t,e),Ne.init(t,e)});function Re(){return Wu(Ex)}var kx=x("ZodNever",(t,e)=>{iu.init(t,e),Ne.init(t,e)});function Tx(t){return Ju(kx,t)}var Px=x("ZodArray",(t,e)=>{au.init(t,e),Ne.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Zn(r,n)),t.nonempty=r=>t.check(Zn(1,r)),t.max=(r,n)=>t.check(pi(r,n)),t.length=(r,n)=>t.check(fi(r,n)),t.unwrap=()=>t.element});function ne(t,e){return Hm(Px,t,e)}var ch=x("ZodObject",(t,e)=>{ii.init(t,e),Ne.init(t,e),re.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>ct(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Re()}),t.loose=()=>t.clone({...t._zod.def,catchall:Re()}),t.strict=()=>t.clone({...t._zod.def,catchall:Tx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>re.extend(t,r),t.merge=r=>re.merge(t,r),t.pick=r=>re.pick(t,r),t.omit=r=>re.omit(t,r),t.partial=(...r)=>re.partial(dh,t,r[0]),t.required=(...r)=>re.required(ph,t,r[0])});function I(t,e){let r={type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},...re.normalizeParams(e)};return new ch(r)}function nt(t,e){return new ch({type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},catchall:Re(),...re.normalizeParams(e)})}var uh=x("ZodUnion",(t,e)=>{ai.init(t,e),Ne.init(t,e),t.options=e.options});function Ee(t,e){return new uh({type:"union",options:t,...re.normalizeParams(e)})}var Rx=x("ZodDiscriminatedUnion",(t,e)=>{uh.init(t,e),cu.init(t,e)});function gl(t,e,r){return new Rx({type:"union",options:e,discriminator:t,...re.normalizeParams(r)})}var Ix=x("ZodIntersection",(t,e)=>{uu.init(t,e),Ne.init(t,e)});function gi(t,e){return new Ix({type:"intersection",left:t,right:e})}var zx=x("ZodRecord",(t,e)=>{lu.init(t,e),Ne.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function $e(t,e,r){return new zx({type:"record",keyType:t,valueType:e,...re.normalizeParams(r)})}var ml=x("ZodEnum",(t,e)=>{du.init(t,e),Ne.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ml({...e,checks:[],...re.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ml({...e,checks:[],...re.normalizeParams(o),entries:s})}});function ct(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ml({type:"enum",entries:r,...re.normalizeParams(e)})}var Ox=x("ZodLiteral",(t,e)=>{pu.init(t,e),Ne.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new Ox({type:"literal",values:Array.isArray(t)?t:[t],...re.normalizeParams(e)})}var Nx=x("ZodTransform",(t,e)=>{fu.init(t,e),Ne.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(re.issue(s,r.value,e));else{let i=s;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=!0),r.issues.push(re.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function lh(t){return new Nx({type:"transform",transform:t})}var dh=x("ZodOptional",(t,e)=>{mu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ie(t){return new dh({type:"optional",innerType:t})}var Ax=x("ZodNullable",(t,e)=>{hu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function oh(t){return new Ax({type:"nullable",innerType:t})}var Cx=x("ZodDefault",(t,e)=>{gu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Mx(t,e){return new Cx({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var jx=x("ZodPrefault",(t,e)=>{_u.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dx(t,e){return new jx({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var ph=x("ZodNonOptional",(t,e)=>{yu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Lx(t,e){return new ph({type:"nonoptional",innerType:t,...re.normalizeParams(e)})}var Zx=x("ZodCatch",(t,e)=>{vu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Ux(t,e){return new Zx({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var qx=x("ZodPipe",(t,e)=>{bu.init(t,e),Ne.init(t,e),t.in=e.in,t.out=e.out});function hl(t,e){return new qx({type:"pipe",in:t,out:e})}var Fx=x("ZodReadonly",(t,e)=>{wu.init(t,e),Ne.init(t,e)});function Vx(t){return new Fx({type:"readonly",innerType:t})}var fh=x("ZodCustom",(t,e)=>{xu.init(t,e),Ne.init(t,e)});function Hx(t){let e=new He({check:"custom"});return e._zod.check=t,e}function mh(t,e){return al(fh,t??(()=>!0),e)}function Gx(t,e={}){return cl(fh,t,e)}function Bx(t){let e=Hx(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(re.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(re.issue(o))}},t(r.value,r)));return e}function _l(t,e){return hl(lh(t),e)}bt(Lm());var vl="2025-11-25",hh="2025-03-26",qn=[vl,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],xr="io.modelcontextprotocol/related-task",yi="2.0",qe=mh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),gh=Ee([b(),fe().int()]),_h=b(),EN=nt({ttl:fe().optional(),pollInterval:fe().optional()}),Kx=I({ttl:fe().optional()}),Wx=I({taskId:b()}),bl=nt({progressToken:gh.optional(),[xr]:Wx.optional()}),xt=I({_meta:bl.optional()}),Ko=xt.extend({task:Kx.optional()}),yh=t=>Ko.safeParse(t).success,Ge=I({method:b(),params:xt.loose().optional()}),St=I({_meta:bl.optional()}),Et=I({method:b(),params:St.loose().optional()}),Be=nt({_meta:bl.optional()}),vi=Ee([b(),fe().int()]),vh=I({jsonrpc:A(yi),id:vi,...Ge.shape}).strict(),$r=t=>vh.safeParse(t).success,bh=I({jsonrpc:A(yi),...Et.shape}).strict(),wh=t=>bh.safeParse(t).success,wl=I({jsonrpc:A(yi),id:vi,result:Be}).strict(),ar=t=>wl.safeParse(t).success;var M;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(M||(M={}));var xl=I({jsonrpc:A(yi),id:vi.optional(),error:I({code:fe().int(),message:b(),data:Re().optional()})}).strict();var Fn=t=>xl.safeParse(t).success;var Wo=Ee([vh,bh,wl,xl]),kN=Ee([wl,xl]),bi=Be.strict(),Jx=St.extend({requestId:vi.optional(),reason:b().optional()}),wi=Et.extend({method:A("notifications/cancelled"),params:Jx}),Xx=I({src:b(),mimeType:b().optional(),sizes:ne(b()).optional(),theme:ct(["light","dark"]).optional()}),Jo=I({icons:ne(Xx).optional()}),Un=I({name:b(),title:b().optional()}),xh=Un.extend({...Un.shape,...Jo.shape,version:b(),websiteUrl:b().optional(),description:b().optional()}),Yx=gi(I({applyDefaults:Fe().optional()}),$e(b(),Re())),Qx=_l(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,gi(I({form:Yx.optional(),url:qe.optional()}),$e(b(),Re()).optional())),e0=nt({list:qe.optional(),cancel:qe.optional(),requests:nt({sampling:nt({createMessage:qe.optional()}).optional(),elicitation:nt({create:qe.optional()}).optional()}).optional()}),t0=nt({list:qe.optional(),cancel:qe.optional(),requests:nt({tools:nt({call:qe.optional()}).optional()}).optional()}),r0=I({experimental:$e(b(),qe).optional(),sampling:I({context:qe.optional(),tools:qe.optional()}).optional(),elicitation:Qx.optional(),roots:I({listChanged:Fe().optional()}).optional(),tasks:e0.optional(),extensions:$e(b(),qe).optional()}),n0=xt.extend({protocolVersion:b(),capabilities:r0,clientInfo:xh}),xi=Ge.extend({method:A("initialize"),params:n0}),Xo=t=>xi.safeParse(t).success,o0=I({experimental:$e(b(),qe).optional(),logging:qe.optional(),completions:qe.optional(),prompts:I({listChanged:Fe().optional()}).optional(),resources:I({subscribe:Fe().optional(),listChanged:Fe().optional()}).optional(),tools:I({listChanged:Fe().optional()}).optional(),tasks:t0.optional(),extensions:$e(b(),qe).optional()}),s0=Be.extend({protocolVersion:b(),capabilities:o0,serverInfo:xh,instructions:b().optional()}),$l=Et.extend({method:A("notifications/initialized"),params:St.optional()});var $i=Ge.extend({method:A("ping"),params:xt.optional()}),i0=I({progress:fe(),total:Ie(fe()),message:Ie(b())}),a0=I({...St.shape,...i0.shape,progressToken:gh}),Si=Et.extend({method:A("notifications/progress"),params:a0}),c0=xt.extend({cursor:_h.optional()}),Yo=Ge.extend({params:c0.optional()}),Qo=Be.extend({nextCursor:_h.optional()}),u0=ct(["working","input_required","completed","failed","cancelled"]),es=I({taskId:b(),status:u0,ttl:Ee([fe(),ah()]),createdAt:b(),lastUpdatedAt:b(),pollInterval:Ie(fe()),statusMessage:Ie(b())}),Vn=Be.extend({task:es}),l0=St.merge(es),ts=Et.extend({method:A("notifications/tasks/status"),params:l0}),Ei=Ge.extend({method:A("tasks/get"),params:xt.extend({taskId:b()})}),ki=Be.merge(es),Ti=Ge.extend({method:A("tasks/result"),params:xt.extend({taskId:b()})}),TN=Be.loose(),Pi=Yo.extend({method:A("tasks/list")}),Ri=Qo.extend({tasks:ne(es)}),Ii=Ge.extend({method:A("tasks/cancel"),params:xt.extend({taskId:b()})}),$h=Be.merge(es),Sh=I({uri:b(),mimeType:Ie(b()),_meta:$e(b(),Re()).optional()}),Eh=Sh.extend({text:b()}),Sl=b().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),kh=Sh.extend({blob:Sl}),rs=ct(["user","assistant"]),Hn=I({audience:ne(rs).optional(),priority:fe().min(0).max(1).optional(),lastModified:Go.datetime({offset:!0}).optional()}),Th=I({...Un.shape,...Jo.shape,uri:b(),description:Ie(b()),mimeType:Ie(b()),size:Ie(fe()),annotations:Hn.optional(),_meta:Ie(nt({}))}),d0=I({...Un.shape,...Jo.shape,uriTemplate:b(),description:Ie(b()),mimeType:Ie(b()),annotations:Hn.optional(),_meta:Ie(nt({}))}),zi=Yo.extend({method:A("resources/list")}),p0=Qo.extend({resources:ne(Th)}),Oi=Yo.extend({method:A("resources/templates/list")}),f0=Qo.extend({resourceTemplates:ne(d0)}),El=xt.extend({uri:b()}),m0=El,Ni=Ge.extend({method:A("resources/read"),params:m0}),h0=Be.extend({contents:ne(Ee([Eh,kh]))}),g0=Et.extend({method:A("notifications/resources/list_changed"),params:St.optional()}),_0=El,y0=Ge.extend({method:A("resources/subscribe"),params:_0}),v0=El,b0=Ge.extend({method:A("resources/unsubscribe"),params:v0}),w0=St.extend({uri:b()}),x0=Et.extend({method:A("notifications/resources/updated"),params:w0}),$0=I({name:b(),description:Ie(b()),required:Ie(Fe())}),S0=I({...Un.shape,...Jo.shape,description:Ie(b()),arguments:Ie(ne($0)),_meta:Ie(nt({}))}),Ai=Yo.extend({method:A("prompts/list")}),E0=Qo.extend({prompts:ne(S0)}),k0=xt.extend({name:b(),arguments:$e(b(),b()).optional()}),Ci=Ge.extend({method:A("prompts/get"),params:k0}),kl=I({type:A("text"),text:b(),annotations:Hn.optional(),_meta:$e(b(),Re()).optional()}),Tl=I({type:A("image"),data:Sl,mimeType:b(),annotations:Hn.optional(),_meta:$e(b(),Re()).optional()}),Pl=I({type:A("audio"),data:Sl,mimeType:b(),annotations:Hn.optional(),_meta:$e(b(),Re()).optional()}),T0=I({type:A("tool_use"),name:b(),id:b(),input:$e(b(),Re()),_meta:$e(b(),Re()).optional()}),P0=I({type:A("resource"),resource:Ee([Eh,kh]),annotations:Hn.optional(),_meta:$e(b(),Re()).optional()}),R0=Th.extend({type:A("resource_link")}),Rl=Ee([kl,Tl,Pl,R0,P0]),I0=I({role:rs,content:Rl}),z0=Be.extend({description:b().optional(),messages:ne(I0)}),O0=Et.extend({method:A("notifications/prompts/list_changed"),params:St.optional()}),N0=I({title:b().optional(),readOnlyHint:Fe().optional(),destructiveHint:Fe().optional(),idempotentHint:Fe().optional(),openWorldHint:Fe().optional()}),A0=I({taskSupport:ct(["required","optional","forbidden"]).optional()}),Ph=I({...Un.shape,...Jo.shape,description:b().optional(),inputSchema:I({type:A("object"),properties:$e(b(),qe).optional(),required:ne(b()).optional()}).catchall(Re()),outputSchema:I({type:A("object"),properties:$e(b(),qe).optional(),required:ne(b()).optional()}).catchall(Re()).optional(),annotations:N0.optional(),execution:A0.optional(),_meta:$e(b(),Re()).optional()}),Mi=Yo.extend({method:A("tools/list")}),C0=Qo.extend({tools:ne(Ph)}),ji=Be.extend({content:ne(Rl).default([]),structuredContent:$e(b(),Re()).optional(),isError:Fe().optional()}),PN=ji.or(Be.extend({toolResult:Re()})),M0=Ko.extend({name:b(),arguments:$e(b(),Re()).optional()}),Gn=Ge.extend({method:A("tools/call"),params:M0}),j0=Et.extend({method:A("notifications/tools/list_changed"),params:St.optional()}),RN=I({autoRefresh:Fe().default(!0),debounceMs:fe().int().nonnegative().default(300)}),ns=ct(["debug","info","notice","warning","error","critical","alert","emergency"]),D0=xt.extend({level:ns}),Il=Ge.extend({method:A("logging/setLevel"),params:D0}),L0=St.extend({level:ns,logger:b().optional(),data:Re()}),Z0=Et.extend({method:A("notifications/message"),params:L0}),U0=I({name:b().optional()}),q0=I({hints:ne(U0).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),F0=I({mode:ct(["auto","required","none"]).optional()}),V0=I({type:A("tool_result"),toolUseId:b().describe("The unique identifier for the corresponding tool call."),content:ne(Rl).default([]),structuredContent:I({}).loose().optional(),isError:Fe().optional(),_meta:$e(b(),Re()).optional()}),H0=gl("type",[kl,Tl,Pl]),_i=gl("type",[kl,Tl,Pl,T0,V0]),G0=I({role:rs,content:Ee([_i,ne(_i)]),_meta:$e(b(),Re()).optional()}),B0=Ko.extend({messages:ne(G0),modelPreferences:q0.optional(),systemPrompt:b().optional(),includeContext:ct(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:ne(b()).optional(),metadata:qe.optional(),tools:ne(Ph).optional(),toolChoice:F0.optional()}),K0=Ge.extend({method:A("sampling/createMessage"),params:B0}),os=Be.extend({model:b(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens"]).or(b())),role:rs,content:H0}),zl=Be.extend({model:b(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens","toolUse"]).or(b())),role:rs,content:Ee([_i,ne(_i)])}),W0=I({type:A("boolean"),title:b().optional(),description:b().optional(),default:Fe().optional()}),J0=I({type:A("string"),title:b().optional(),description:b().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:ct(["email","uri","date","date-time"]).optional(),default:b().optional()}),X0=I({type:ct(["number","integer"]),title:b().optional(),description:b().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),Y0=I({type:A("string"),title:b().optional(),description:b().optional(),enum:ne(b()),default:b().optional()}),Q0=I({type:A("string"),title:b().optional(),description:b().optional(),oneOf:ne(I({const:b(),title:b()})),default:b().optional()}),e$=I({type:A("string"),title:b().optional(),description:b().optional(),enum:ne(b()),enumNames:ne(b()).optional(),default:b().optional()}),t$=Ee([Y0,Q0]),r$=I({type:A("array"),title:b().optional(),description:b().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:I({type:A("string"),enum:ne(b())}),default:ne(b()).optional()}),n$=I({type:A("array"),title:b().optional(),description:b().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:I({anyOf:ne(I({const:b(),title:b()}))}),default:ne(b()).optional()}),o$=Ee([r$,n$]),s$=Ee([e$,t$,o$]),i$=Ee([s$,W0,J0,X0]),a$=Ko.extend({mode:A("form").optional(),message:b(),requestedSchema:I({type:A("object"),properties:$e(b(),i$),required:ne(b()).optional()})}),c$=Ko.extend({mode:A("url"),message:b(),elicitationId:b(),url:b().url()}),u$=Ee([a$,c$]),l$=Ge.extend({method:A("elicitation/create"),params:u$}),d$=St.extend({elicitationId:b()}),p$=Et.extend({method:A("notifications/elicitation/complete"),params:d$}),Bn=Be.extend({action:ct(["accept","decline","cancel"]),content:_l(t=>t===null?void 0:t,$e(b(),Ee([b(),fe(),Fe(),ne(b())])).optional())}),f$=I({type:A("ref/resource"),uri:b()});var m$=I({type:A("ref/prompt"),name:b()}),h$=xt.extend({ref:Ee([m$,f$]),argument:I({name:b(),value:b()}),context:I({arguments:$e(b(),b()).optional()}).optional()}),Di=Ge.extend({method:A("completion/complete"),params:h$});function Rh(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Ih(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var g$=Be.extend({completion:nt({values:ne(b()).max(100),total:Ie(fe().int()),hasMore:Ie(Fe())})}),_$=I({uri:b().startsWith("file://"),name:b().optional(),_meta:$e(b(),Re()).optional()}),y$=Ge.extend({method:A("roots/list"),params:xt.optional()}),Ol=Be.extend({roots:ne(_$)}),v$=Et.extend({method:A("notifications/roots/list_changed"),params:St.optional()}),IN=Ee([$i,xi,Di,Il,Ci,Ai,zi,Oi,Ni,y0,b0,Gn,Mi,Ei,Ti,Pi,Ii]),zN=Ee([wi,Si,$l,v$,ts]),ON=Ee([bi,os,zl,Bn,Ol,ki,Ri,Vn]),NN=Ee([$i,K0,l$,y$,Ei,Ti,Pi,Ii]),AN=Ee([wi,Si,Z0,x0,g0,j0,O0,ts,p$]),CN=Ee([bi,s0,g$,z0,E0,p0,f0,h0,ji,C0,ki,Ri,Vn]),N=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===M.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new yl(o.elicitations,r)}return new t(e,r,n)}},yl=class extends N{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(M.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};var Li=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
39
- `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),b$(r)}clear(){this._buffer=void 0}};function b$(t){return Wo.parse(JSON.parse(t))}function zh(t){return JSON.stringify(t)+`
40
- `}var Zi=class{constructor(e=Oh.stdin,r=Oh.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Li,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=zh(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var ss="0.1.0";var Nh=3e4;function Wn(t){return t?.proposed===!0}var cr=class extends Error{status;constructor(e,r){super(e),this.name="FlowpadError",this.status=r}},Kn=class{constructor(e){this.cfg=e;if(e.token)this.token=e.token;else if(!e.mcpKey)throw new cr("Missing credential: provide an OAuth access token, or a FLOWPAD_API_KEY (Settings \u2192 Integrations) for the MCP server env.")}cfg;token;cache=new Map;clientName;updateAdvisory;url(e){return`${this.cfg.baseUrl.replace(/\/$/,"")}${e}`}setClientName(e){let r=e?.trim();this.clientName=r?r.slice(0,64):void 0}getUpdateAdvisory(){return this.updateAdvisory}async login(){if(!this.cfg.mcpKey)throw new cr("Access token rejected and no MCP key to re-authenticate \u2014 the OAuth token is likely expired; reconnect the connector.",401);let e;try{e=await fetch(this.url("/mcp/auth/login"),{method:"POST",headers:{"Content-Type":"application/json","x-mcp-key":this.cfg.mcpKey,"X-Flowpad-MCP-Version":ss},signal:AbortSignal.timeout(Nh)})}catch(n){throw n instanceof Error&&n.name==="TimeoutError"?new cr("Backend timed out \u2014 retry"):n}if(!e.ok)throw new cr(`MCP login failed (${e.status}): ${await e.text()}. Check FLOWPAD_API_KEY is a valid, non-revoked key and FLOWPAD_API_URL points at the right backend.`,e.status);let r=await e.json();if(!r.access_token)throw new cr("MCP login response did not contain access_token.");this.token=r.access_token}async guidance(){return(await this.request("/mcp/guidance")).instructions}async request(e,r={},n=!0){this.token||await this.login();let o;try{o=await fetch(this.url(e),{...r,headers:{"Content-Type":"application/json","X-Flowpad-MCP-Version":ss,...this.clientName?{"x-mcp-client":this.clientName}:{},...r.headers??{},Authorization:`Bearer ${this.token}`},signal:AbortSignal.timeout(Nh)})}catch(s){throw s instanceof Error&&s.name==="TimeoutError"?new cr("Backend timed out \u2014 retry"):s}if(o.headers.get("x-flowpad-mcp-update")==="available"&&(this.updateAdvisory=o.headers.get("x-flowpad-mcp-latest")??"newer"),o.status===401&&n&&this.cfg.mcpKey)return this.token=void 0,await this.login(),this.request(e,r,!1);if(!o.ok)throw new cr(`${r.method??"GET"} ${e} failed (${o.status}): ${await o.text()}`,o.status);if(o.status!==204)return await o.json()}async listProjects(e){let r=e?`?query=${encodeURIComponent(e)}`:"";return this.request(`/mcp/projects${r}`)}async getProjectRaw(e){return this.request(`/mcp/projects/${e}/raw`)}async getRevision(e){return this.request(`/mcp/projects/${e}/revision`)}async getProjectRawCached(e){let r=this.cache.get(e);if(r)try{let{revision:o}=await this.getRevision(e);if(o===r.version)return r.project}catch{}let n=await this.getProjectRaw(e);return this.cache.set(e,{version:n.version,project:n}),n}invalidate(e){this.cache.delete(e)}async outline(e,r){let n=r!==void 0?`?maxDepth=${r}`:"",{text:o}=await this.request(`/mcp/projects/${e}/outline${n}`);return o}async searchNodes(e,r){let n=new URLSearchParams;for(let[i,a]of Object.entries(r))a!==void 0&&a!==""&&n.set(i,String(a));let o=n.toString()?`?${n.toString()}`:"",{text:s}=await this.request(`/mcp/projects/${e}/search${o}`);return s}async getNode(e,r,n){let o=n!==void 0?`?depth=${n}`:"",{text:s}=await this.request(`/mcp/projects/${e}/nodes/${encodeURIComponent(r)}${o}`);return s}async analyze(e){let{text:r}=await this.request(`/mcp/projects/${e}/analyze`);return r}async connections(e,r={}){let n=new URLSearchParams;r.nodeId&&n.set("nodeId",r.nodeId),r.nodeName&&n.set("nodeName",r.nodeName);let o=n.toString()?`?${n.toString()}`:"",{text:s}=await this.request(`/mcp/projects/${e}/connections${o}`);return s}async updateProject(e,r){let n=await this.request(`/mcp/projects/${e}`,{method:"PUT",body:JSON.stringify(r)});return Wn(n)?this.invalidate(e):n&&typeof n.version=="number"&&n.latestData?this.cache.set(e,{version:n.version,project:n}):this.invalidate(e),n}async createProject(e){return this.request("/mcp/projects",{method:"POST",body:JSON.stringify(e)})}async deleteProject(e){return this.request(`/mcp/projects/${e}`,{method:"DELETE"})}async bindTemplate(e,r){return this.request(`/mcp/projects/${e}/bind-template`,{method:"POST",body:JSON.stringify({templateProjectId:r})})}async listTemplates(){return this.request("/mcp/templates")}};var w={};pc(w,{BRAND:()=>G$,DIRTY:()=>Yr,EMPTY_PATH:()=>S$,INVALID:()=>Z,NEVER:()=>RS,OK:()=>Ye,ParseStatus:()=>Ke,Schema:()=>K,ZodAny:()=>kr,ZodArray:()=>pr,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>as,ZodCatch:()=>fn,ZodDate:()=>rn,ZodDefault:()=>pn,ZodDiscriminatedUnion:()=>Fi,ZodEffects:()=>Tt,ZodEnum:()=>ln,ZodError:()=>ut,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Hi,ZodIntersection:()=>an,ZodIssueCode:()=>E,ZodLazy:()=>cn,ZodLiteral:()=>un,ZodMap:()=>to,ZodNaN:()=>no,ZodNativeEnum:()=>dn,ZodNever:()=>Ct,ZodNull:()=>on,ZodNullable:()=>Bt,ZodNumber:()=>Qr,ZodObject:()=>dt,ZodOptional:()=>lt,ZodParsedType:()=>R,ZodPipeline:()=>cs,ZodPromise:()=>Tr,ZodReadonly:()=>mn,ZodRecord:()=>Vi,ZodSchema:()=>K,ZodSet:()=>ro,ZodString:()=>Er,ZodSymbol:()=>Qn,ZodTransformer:()=>Tt,ZodTuple:()=>Gt,ZodType:()=>K,ZodUndefined:()=>nn,ZodUnion:()=>sn,ZodUnknown:()=>dr,ZodVoid:()=>eo,addIssueToContext:()=>P,any:()=>tS,array:()=>sS,bigint:()=>J$,boolean:()=>Vh,coerce:()=>PS,custom:()=>Uh,date:()=>X$,datetimeRegex:()=>Lh,defaultErrorMap:()=>ur,discriminatedUnion:()=>cS,effect:()=>bS,enum:()=>_S,function:()=>mS,getErrorMap:()=>Jn,getParsedType:()=>Ht,instanceof:()=>K$,intersection:()=>uS,isAborted:()=>Ui,isAsync:()=>Xn,isDirty:()=>qi,isValid:()=>Sr,late:()=>B$,lazy:()=>hS,literal:()=>gS,makeIssue:()=>is,map:()=>pS,nan:()=>W$,nativeEnum:()=>yS,never:()=>nS,null:()=>eS,nullable:()=>xS,number:()=>Fh,object:()=>Ml,objectUtil:()=>Nl,oboolean:()=>TS,onumber:()=>kS,optional:()=>wS,ostring:()=>ES,pipeline:()=>SS,preprocess:()=>$S,promise:()=>vS,quotelessJson:()=>w$,record:()=>dS,set:()=>fS,setErrorMap:()=>$$,strictObject:()=>iS,string:()=>qh,symbol:()=>Y$,transformer:()=>bS,tuple:()=>lS,undefined:()=>Q$,union:()=>aS,unknown:()=>rS,util:()=>ee,void:()=>oS});var ee;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(ee||(ee={}));var Nl;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Nl||(Nl={}));var R=ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ht=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var E=ee.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"]),w$=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ut=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ut.create=t=>new ut(t);var x$=(t,e)=>{let r;switch(t.code){case E.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case E.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ee.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:r=`Unrecognized key(s) in object: ${ee.joinValues(t.keys,", ")}`;break;case E.invalid_union:r="Invalid input";break;case E.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ee.joinValues(t.options)}`;break;case E.invalid_enum_value:r=`Invalid enum value. Expected ${ee.joinValues(t.options)}, received '${t.received}'`;break;case E.invalid_arguments:r="Invalid function arguments";break;case E.invalid_return_type:r="Invalid function return type";break;case E.invalid_date:r="Invalid date";break;case E.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ee.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case E.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case E.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case E.custom:r="Invalid input";break;case E.invalid_intersection_types:r="Intersection results could not be merged";break;case E.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case E.not_finite:r="Number must be finite";break;default:r=e.defaultError,ee.assertNever(t)}return{message:r}},ur=x$;var Ah=ur;function $$(t){Ah=t}function Jn(){return Ah}var is=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},S$=[];function P(t,e){let r=Jn(),n=is({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ur?void 0:ur].filter(o=>!!o)});t.common.issues.push(n)}var Ke=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return Z;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return Z;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},Z=Object.freeze({status:"aborted"}),Yr=t=>({status:"dirty",value:t}),Ye=t=>({status:"valid",value:t}),Ui=t=>t.status==="aborted",qi=t=>t.status==="dirty",Sr=t=>t.status==="valid",Xn=t=>typeof Promise<"u"&&t instanceof Promise;var O;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(O||(O={}));var kt=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}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}},Ch=(t,e)=>{if(Sr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new ut(t.common.issues);return this._error=r,this._error}}};function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var K=class{get description(){return this._def.description}_getType(e){return Ht(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:Ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Xn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)},o=this._parseSync({data:e,path:n.path,parent:n});return Ch(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Sr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Sr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Xn(o)?o:Promise.resolve(o));return Ch(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:E.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Tt({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return lt.create(this,this._def)}nullable(){return Bt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pr.create(this)}promise(){return Tr.create(this,this._def)}or(e){return sn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Tt({...G(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new pn({...G(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new as({typeName:k.ZodBranded,type:this,...G(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new fn({...G(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return cs.create(this,e)}readonly(){return mn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},E$=/^c[^\s-]{8,}$/i,k$=/^[0-9a-z]+$/,T$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,P$=/^[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,R$=/^[a-z0-9_-]{21}$/i,I$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z$=/^[-+]?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)?)??$/,O$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Al,A$=/^(?:(?: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])$/,C$=/^(?:(?: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])$/,M$=/^(([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]))$/,j$=/^(([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])$/,D$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,L$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jh="((\\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(`^${jh}$`);function Dh(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function U$(t){return new RegExp(`^${Dh(t)}$`)}function Lh(t){let e=`${jh}T${Dh(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function q$(t,e){return!!((e==="v4"||!e)&&A$.test(t)||(e==="v6"||!e)&&M$.test(t))}function F$(t,e){if(!I$.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function V$(t,e){return!!((e==="v4"||!e)&&C$.test(t)||(e==="v6"||!e)&&j$.test(t))}var Er=class t extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.string,received:s.parsedType}),Z}let n=new Ke,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?P(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&P(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")O$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"email",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Al||(Al=new RegExp(N$,"u")),Al.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"emoji",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")P$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"uuid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")R$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"nanoid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")E$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cuid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")k$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cuid2",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")T$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"ulid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),P(o,{validation:"url",code:E.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"regex",code:E.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Lh(s).test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Z$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?U$(s).test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?z$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"duration",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?q$(e.data,s.version)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"ip",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?F$(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"jwt",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?V$(e.data,s.version)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cidr",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?D$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"base64",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?L$.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"base64url",code:E.invalid_string,message:s.message}),n.dirty()):ee.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:E.invalid_string,...O.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...O.errToObj(e)})}url(e){return this._addCheck({kind:"url",...O.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...O.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...O.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...O.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...O.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...O.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...O.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...O.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...O.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...O.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...O.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...O.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...O.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...O.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...O.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...O.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...O.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...O.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...O.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...O.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...O.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...O.errToObj(r)})}nonempty(e){return this.min(1,O.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Er.create=t=>new Er({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...G(t)});function H$(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var Qr=class t extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==R.number){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.number,received:s.parsedType}),Z}let n,o=new Ke;for(let s of this._def.checks)s.kind==="int"?ee.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),P(n,{code:E.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?H$(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_finite,message:s.message}),o.dirty()):ee.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,O.toString(r))}gt(e,r){return this.setLimit("min",e,!1,O.toString(r))}lte(e,r){return this.setLimit("max",e,!0,O.toString(r))}lt(e,r){return this.setLimit("max",e,!1,O.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:O.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:O.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:O.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ee.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Qr.create=t=>new Qr({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...G(t)});var en=class t extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==R.bigint)return this._getInvalidInput(e);let n,o=new Ke;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):ee.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return P(r,{code:E.invalid_type,expected:R.bigint,received:r.parsedType}),Z}gte(e,r){return this.setLimit("min",e,!0,O.toString(r))}gt(e,r){return this.setLimit("min",e,!1,O.toString(r))}lte(e,r){return this.setLimit("max",e,!0,O.toString(r))}lt(e,r){return this.setLimit("max",e,!1,O.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:O.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};en.create=t=>new en({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var tn=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.boolean,received:n.parsedType}),Z}return Ye(e.data)}};tn.create=t=>new tn({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var rn=class t extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.date,received:s.parsedType}),Z}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_date}),Z}let n=new Ke,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ee.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:O.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:O.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};rn.create=t=>new rn({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...G(t)});var Qn=class extends K{_parse(e){if(this._getType(e)!==R.symbol){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.symbol,received:n.parsedType}),Z}return Ye(e.data)}};Qn.create=t=>new Qn({typeName:k.ZodSymbol,...G(t)});var nn=class extends K{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.undefined,received:n.parsedType}),Z}return Ye(e.data)}};nn.create=t=>new nn({typeName:k.ZodUndefined,...G(t)});var on=class extends K{_parse(e){if(this._getType(e)!==R.null){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.null,received:n.parsedType}),Z}return Ye(e.data)}};on.create=t=>new on({typeName:k.ZodNull,...G(t)});var kr=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ye(e.data)}};kr.create=t=>new kr({typeName:k.ZodAny,...G(t)});var dr=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ye(e.data)}};dr.create=t=>new dr({typeName:k.ZodUnknown,...G(t)});var Ct=class extends K{_parse(e){let r=this._getOrReturnCtx(e);return P(r,{code:E.invalid_type,expected:R.never,received:r.parsedType}),Z}};Ct.create=t=>new Ct({typeName:k.ZodNever,...G(t)});var eo=class extends K{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.void,received:n.parsedType}),Z}return Ye(e.data)}};eo.create=t=>new eo({typeName:k.ZodVoid,...G(t)});var pr=class t extends K{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==R.array)return P(r,{code:E.invalid_type,expected:R.array,received:r.parsedType}),Z;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(P(r,{code:i?E.too_big:E.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(P(r,{code:E.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(P(r,{code:E.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new kt(r,i,r.path,a)))).then(i=>Ke.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new kt(r,i,r.path,a)));return Ke.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:O.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:O.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:O.toString(r)}})}nonempty(e){return this.min(1,e)}};pr.create=(t,e)=>new pr({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...G(e)});function Yn(t){if(t instanceof dt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=lt.create(Yn(n))}return new dt({...t._def,shape:()=>e})}else return t instanceof pr?new pr({...t._def,type:Yn(t.element)}):t instanceof lt?lt.create(Yn(t.unwrap())):t instanceof Bt?Bt.create(Yn(t.unwrap())):t instanceof Gt?Gt.create(t.items.map(e=>Yn(e))):t}var dt=class t extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ee.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let u=this._getOrReturnCtx(e);return P(u,{code:E.invalid_type,expected:R.object,received:u.parsedType}),Z}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ct&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new kt(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Ct){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(P(o,{code:E.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new kt(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,h=await l.value;u.push({key:d,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>Ke.mergeObjectSync(n,u)):Ke.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return O.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:O.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of ee.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of ee.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Yn(this)}partial(e){let r={};for(let n of ee.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of ee.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof lt;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return Zh(ee.objectKeys(this.shape))}};dt.create=(t,e)=>new dt({shape:()=>t,unknownKeys:"strip",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});dt.strictCreate=(t,e)=>new dt({shape:()=>t,unknownKeys:"strict",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});dt.lazycreate=(t,e)=>new dt({shape:t,unknownKeys:"strip",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});var sn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new ut(a.ctx.common.issues));return P(r,{code:E.invalid_union,unionErrors:i}),Z}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new ut(c));return P(r,{code:E.invalid_union,unionErrors:a}),Z}}get options(){return this._def.options}};sn.create=(t,e)=>new sn({options:t,typeName:k.ZodUnion,...G(e)});var lr=t=>t instanceof cn?lr(t.schema):t instanceof Tt?lr(t.innerType()):t instanceof un?[t.value]:t instanceof ln?t.options:t instanceof dn?ee.objectValues(t.enum):t instanceof pn?lr(t._def.innerType):t instanceof nn?[void 0]:t instanceof on?[null]:t instanceof lt?[void 0,...lr(t.unwrap())]:t instanceof Bt?[null,...lr(t.unwrap())]:t instanceof as||t instanceof mn?lr(t.unwrap()):t instanceof fn?lr(t._def.innerType):[],Fi=class t extends K{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return P(r,{code:E.invalid_type,expected:R.object,received:r.parsedType}),Z;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(P(r,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=lr(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...G(n)})}};function Cl(t,e){let r=Ht(t),n=Ht(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&n===R.object){let o=ee.objectKeys(e),s=ee.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Cl(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===R.array&&n===R.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=Cl(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===R.date&&n===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var an=class extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Ui(s)||Ui(i))return Z;let a=Cl(s.value,i.value);return a.valid?((qi(s)||qi(i))&&r.dirty(),{status:r.value,value:a.data}):(P(n,{code:E.invalid_intersection_types}),Z)};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(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};an.create=(t,e,r)=>new an({left:t,right:e,typeName:k.ZodIntersection,...G(r)});var Gt=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return P(n,{code:E.invalid_type,expected:R.array,received:n.parsedType}),Z;if(n.data.length<this._def.items.length)return P(n,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&n.data.length>this._def.items.length&&(P(n,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new kt(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Ke.mergeArray(r,i)):Ke.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Gt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gt({items:t,typeName:k.ZodTuple,rest:null,...G(e)})};var Vi=class t extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.object)return P(n,{code:E.invalid_type,expected:R.object,received:n.parsedType}),Z;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new kt(n,a,n.path,a)),value:i._parse(new kt(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Ke.mergeObjectAsync(r,o):Ke.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof K?new t({keyType:e,valueType:r,typeName:k.ZodRecord,...G(n)}):new t({keyType:Er.create(),valueType:e,typeName:k.ZodRecord,...G(r)})}},to=class extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.map)return P(n,{code:E.invalid_type,expected:R.map,received:n.parsedType}),Z;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new kt(n,a,n.path,[u,"key"])),value:s._parse(new kt(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};to.create=(t,e,r)=>new to({valueType:e,keyType:t,typeName:k.ZodMap,...G(r)});var ro=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return P(n,{code:E.invalid_type,expected:R.set,received:n.parsedType}),Z;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(P(n,{code:E.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(P(n,{code:E.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return Z;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new kt(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:O.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:O.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ro.create=(t,e)=>new ro({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...G(e)});var Hi=class t extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return P(r,{code:E.invalid_type,expected:R.function,received:r.parsedType}),Z;function n(a,c){return is({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jn(),ur].filter(u=>!!u),issueData:{code:E.invalid_arguments,argumentsError:c}})}function o(a,c){return is({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Jn(),ur].filter(u=>!!u),issueData:{code:E.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Tr){let a=this;return Ye(async function(...c){let u=new ut([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return Ye(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new ut([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new ut([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Gt.create(e).rest(dr.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Gt.create([]).rest(dr.create()),returns:r||dr.create(),typeName:k.ZodFunction,...G(n)})}},cn=class extends K{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};cn.create=(t,e)=>new cn({getter:t,typeName:k.ZodLazy,...G(e)});var un=class extends K{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return P(r,{received:r.data,code:E.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:e.data}}get value(){return this._def.value}};un.create=(t,e)=>new un({value:t,typeName:k.ZodLiteral,...G(e)});function Zh(t,e){return new ln({values:t,typeName:k.ZodEnum,...G(e)})}var ln=class t extends K{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return P(r,{expected:ee.joinValues(n),received:r.parsedType,code:E.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return P(r,{received:r.data,code:E.invalid_enum_value,options:n}),Z}return Ye(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ln.create=Zh;var dn=class extends K{_parse(e){let r=ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let o=ee.objectValues(r);return P(n,{expected:ee.joinValues(o),received:n.parsedType,code:E.invalid_type}),Z}if(this._cache||(this._cache=new Set(ee.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=ee.objectValues(r);return P(n,{received:n.data,code:E.invalid_enum_value,options:o}),Z}return Ye(e.data)}get enum(){return this._def.values}};dn.create=(t,e)=>new dn({values:t,typeName:k.ZodNativeEnum,...G(e)});var Tr=class extends K{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return P(r,{code:E.invalid_type,expected:R.promise,received:r.parsedType}),Z;let n=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return Ye(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Tr.create=(t,e)=>new Tr({type:t,typeName:k.ZodPromise,...G(e)});var Tt=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{P(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return Z;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Z:c.status==="dirty"?Yr(c.value):r.value==="dirty"?Yr(c.value):c});{if(r.value==="aborted")return Z;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?Z:a.status==="dirty"?Yr(a.value):r.value==="dirty"?Yr(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Z:(a.status==="dirty"&&r.dirty(),i(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"?Z:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Sr(i))return Z;let a=o.transform(i.value,s);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(i=>Sr(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):Z);ee.assertNever(o)}};Tt.create=(t,e,r)=>new Tt({schema:t,typeName:k.ZodEffects,effect:e,...G(r)});Tt.createWithPreprocess=(t,e,r)=>new Tt({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...G(r)});var lt=class extends K{_parse(e){return this._getType(e)===R.undefined?Ye(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lt.create=(t,e)=>new lt({innerType:t,typeName:k.ZodOptional,...G(e)});var Bt=class extends K{_parse(e){return this._getType(e)===R.null?Ye(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Bt.create=(t,e)=>new Bt({innerType:t,typeName:k.ZodNullable,...G(e)});var pn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};pn.create=(t,e)=>new pn({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var fn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fn.create=(t,e)=>new fn({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var no=class extends K{_parse(e){if(this._getType(e)!==R.nan){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.nan,received:n.parsedType}),Z}return{status:"valid",value:e.data}}};no.create=t=>new no({typeName:k.ZodNaN,...G(t)});var G$=Symbol("zod_brand"),as=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},cs=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Z:s.status==="dirty"?(r.dirty(),Yr(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Z:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:k.ZodPipeline})}},mn=class extends K{_parse(e){let r=this._def.innerType._parse(e),n=o=>(Sr(o)&&(o.value=Object.freeze(o.value)),o);return Xn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};mn.create=(t,e)=>new mn({innerType:t,typeName:k.ZodReadonly,...G(e)});function Mh(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Uh(t,e={},r){return t?kr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Mh(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=Mh(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):kr.create()}var B$={object:dt.lazycreate},k;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));var K$=(t,e={message:`Input not instance of ${t.name}`})=>Uh(r=>r instanceof t,e),qh=Er.create,Fh=Qr.create,W$=no.create,J$=en.create,Vh=tn.create,X$=rn.create,Y$=Qn.create,Q$=nn.create,eS=on.create,tS=kr.create,rS=dr.create,nS=Ct.create,oS=eo.create,sS=pr.create,Ml=dt.create,iS=dt.strictCreate,aS=sn.create,cS=Fi.create,uS=an.create,lS=Gt.create,dS=Vi.create,pS=to.create,fS=ro.create,mS=Hi.create,hS=cn.create,gS=un.create,_S=ln.create,yS=dn.create,vS=Tr.create,bS=Tt.create,wS=lt.create,xS=Bt.create,$S=Tt.createWithPreprocess,SS=cs.create,ES=()=>qh().optional(),kS=()=>Fh().optional(),TS=()=>Vh().optional(),PS={string:(t=>Er.create({...t,coerce:!0})),number:(t=>Qr.create({...t,coerce:!0})),boolean:(t=>tn.create({...t,coerce:!0})),bigint:(t=>en.create({...t,coerce:!0})),date:(t=>rn.create({...t,coerce:!0}))};var RS=Z;var zS=x("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");he.init(t,e),t.def=e,t.parse=(r,n)=>Tc(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Kr(t,r,n),t.parseAsync=async(r,n)=>Rc(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Wr(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>wt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var OS=x("ZodMiniObject",(t,e)=>{ii.init(t,e),zS.init(t,e),re.defineLazy(t,"shape",()=>e.shape)});function jl(t,e){let r={type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},...re.normalizeParams(e)};return new OS(r)}function Pt(t){return!!t._zod}function hn(t){let e=Object.values(t);if(e.length===0)return jl({});let r=e.every(Pt),n=e.every(o=>!Pt(o));if(r)return jl(t);if(n)return Ml(t);throw new Error("Mixed Zod versions detected in object shape.")}function Pr(t,e){return Pt(t)?Kr(t,e):t.safeParse(e)}async function Gi(t,e){return Pt(t)?await Wr(t,e):await t.safeParseAsync(e)}function Rr(t){if(!t)return;let e;if(Pt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function oo(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return hn(t)}}if(Pt(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Bi(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Hh(t){return t.description}function Gh(t){if(Pt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Ki(t){if(Pt(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}function Ir(t){return t==="completed"||t==="failed"||t==="cancelled"}var Kh=Symbol("Let zodToJsonSchema decide on which parser to use");var Bh={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"},Wh=t=>typeof t=="string"?{...Bh,name:t}:{...Bh,...t};var Jh=t=>{let e=Wh(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Dl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function oe(t,e,r,n,o){t[e]=r,Dl(t,e,n,o)}var Wi=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function ze(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Wi(e,t.currentPath):e.join("/")}}function Xh(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==k.ZodAny&&(r.items=V(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&oe(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&oe(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(oe(r,"minItems",t.exactLength.value,t.exactLength.message,e),oe(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Yh(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?oe(r,"minimum",n.value,n.message,e):oe(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),oe(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?oe(r,"maximum",n.value,n.message,e):oe(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),oe(r,"maximum",n.value,n.message,e));break;case"multipleOf":oe(r,"multipleOf",n.value,n.message,e);break}return r}function Qh(){return{type:"boolean"}}function Ji(t,e){return V(t.type._def,e)}var eg=(t,e)=>V(t.innerType._def,e);function Ll(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>Ll(t,e,o))};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 AS(t,e)}}var AS=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":oe(r,"minimum",n.value,n.message,e);break;case"max":oe(r,"maximum",n.value,n.message,e);break}return r};function tg(t,e){return{...V(t.innerType._def,e),default:t.defaultValue()}}function rg(t,e){return e.effectStrategy==="input"?V(t.schema._def,e):ze(e)}function ng(t){return{type:"string",enum:Array.from(t.values)}}var CS=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function og(t,e){let r=[V(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),V(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(CS(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function sg(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var Zl,Mt={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:()=>(Zl===void 0&&(Zl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Zl),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 Xi(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":jt(r,"email",n.message,e);break;case"format:idn-email":jt(r,"idn-email",n.message,e);break;case"pattern:zod":ot(r,Mt.email,n.message,e);break}break;case"url":jt(r,"uri",n.message,e);break;case"uuid":jt(r,"uuid",n.message,e);break;case"regex":ot(r,n.regex,n.message,e);break;case"cuid":ot(r,Mt.cuid,n.message,e);break;case"cuid2":ot(r,Mt.cuid2,n.message,e);break;case"startsWith":ot(r,RegExp(`^${Ul(n.value,e)}`),n.message,e);break;case"endsWith":ot(r,RegExp(`${Ul(n.value,e)}$`),n.message,e);break;case"datetime":jt(r,"date-time",n.message,e);break;case"date":jt(r,"date",n.message,e);break;case"time":jt(r,"time",n.message,e);break;case"duration":jt(r,"duration",n.message,e);break;case"length":oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{ot(r,RegExp(Ul(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&jt(r,"ipv4",n.message,e),n.version!=="v4"&&jt(r,"ipv6",n.message,e);break}case"base64url":ot(r,Mt.base64url,n.message,e);break;case"jwt":ot(r,Mt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&ot(r,Mt.ipv4Cidr,n.message,e),n.version!=="v4"&&ot(r,Mt.ipv6Cidr,n.message,e);break}case"emoji":ot(r,Mt.emoji(),n.message,e);break;case"ulid":{ot(r,Mt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{jt(r,"binary",n.message,e);break}case"contentEncoding:base64":{oe(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{ot(r,Mt.base64,n.message,e);break}}break}case"nanoid":ot(r,Mt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Ul(t,e){return e.patternStrategy==="escape"?jS(t):t}var MS=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function jS(t){let e="";for(let r=0;r<t.length;r++)MS.has(t[r])||(e+="\\"),e+=t[r];return e}function jt(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):oe(t,"format",e,r,n)}function ot(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:ig(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):oe(t,"pattern",ig(e,n),r,n)}function ig(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
38
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(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 c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function ul(t,e){if(t instanceof Fo){let n=new mi(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new mi(e);return r.process(t),r.emit(t,e)}function Ue(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.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 Ue(o.element,r);case"object":{for(let s in o.shape)if(Ue(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Ue(s,r))return!0;return!1}case"intersection":return Ue(o.left,r)||Ue(o.right,r);case"tuple":{for(let s of o.items)if(Ue(s,r))return!0;return!!(o.rest&&Ue(o.rest,r))}case"record":return Ue(o.keyType,r)||Ue(o.valueType,r);case"map":return Ue(o.keyType,r)||Ue(o.valueType,r);case"set":return Ue(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ue(o.innerType,r);case"lazy":return Ue(o.getter(),r);case"default":return Ue(o.innerType,r);case"prefault":return Ue(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ue(o.in,r)||Ue(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var Go={};pc(Go,{ZodISODate:()=>Km,ZodISODateTime:()=>Bm,ZodISODuration:()=>Jm,ZodISOTime:()=>Wm,date:()=>dl,datetime:()=>ll,duration:()=>fl,time:()=>pl});var Bm=x("ZodISODateTime",(t,e)=>{Am.init(t,e),Pe.init(t,e)});function ll(t){return Um(Bm,t)}var Km=x("ZodISODate",(t,e)=>{Cm.init(t,e),Pe.init(t,e)});function dl(t){return qm(Km,t)}var Wm=x("ZodISOTime",(t,e)=>{Mm.init(t,e),Pe.init(t,e)});function pl(t){return Fm(Wm,t)}var Jm=x("ZodISODuration",(t,e)=>{jm.init(t,e),Pe.init(t,e)});function fl(t){return Vm(Jm,t)}var Xm=(t,e)=>{ti.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Ec(t,r)},flatten:{value:r=>$c(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},vN=x("ZodError",Xm),Bo=x("ZodError",Xm,{Parent:Error});var Ym=kc(Bo),Qm=Pc(Bo),eh=Ic(Bo),th=zc(Bo);var Ne=x("ZodType",(t,e)=>(he.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>wt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Ym(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>eh(t,r,n),t.parseAsync=async(r,n)=>Qm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>th(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Yx(r,n)),t.superRefine=r=>t.check(Qx(r)),t.overwrite=r=>t.check(Jr(r)),t.optional=()=>Ie(t),t.nullable=()=>oh(t),t.nullish=()=>Ie(oh(t)),t.nonoptional=r=>Hx(t,r),t.array=()=>ne(t),t.or=r=>Ee([t,r]),t.and=r=>gi(t,r),t.transform=r=>hl(t,lh(r)),t.default=r=>qx(t,r),t.prefault=r=>Vx(t,r),t.catch=r=>Bx(t,r),t.pipe=r=>hl(t,r),t.readonly=()=>Jx(t),t.describe=r=>{let n=t.clone();return wr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return wr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return wr.get(t);let n=t.clone();return wr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),sh=x("_ZodString",(t,e)=>{qo.init(t,e),Ne.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Xu(...n)),t.includes=(...n)=>t.check(el(...n)),t.startsWith=(...n)=>t.check(tl(...n)),t.endsWith=(...n)=>t.check(rl(...n)),t.min=(...n)=>t.check(Un(...n)),t.max=(...n)=>t.check(pi(...n)),t.length=(...n)=>t.check(fi(...n)),t.nonempty=(...n)=>t.check(Un(1,...n)),t.lowercase=n=>t.check(Yu(n)),t.uppercase=n=>t.check(Qu(n)),t.trim=()=>t.check(ol()),t.normalize=(...n)=>t.check(nl(...n)),t.toLowerCase=()=>t.check(sl()),t.toUpperCase=()=>t.check(il())}),lx=x("ZodString",(t,e)=>{qo.init(t,e),sh.init(t,e),t.email=r=>t.check($u(dx,r)),t.url=r=>t.check(Ru(px,r)),t.jwt=r=>t.check(Vu(Tx,r)),t.emoji=r=>t.check(Iu(fx,r)),t.guid=r=>t.check(ci(rh,r)),t.uuid=r=>t.check(Eu(hi,r)),t.uuidv4=r=>t.check(ku(hi,r)),t.uuidv6=r=>t.check(Tu(hi,r)),t.uuidv7=r=>t.check(Pu(hi,r)),t.nanoid=r=>t.check(zu(mx,r)),t.guid=r=>t.check(ci(rh,r)),t.cuid=r=>t.check(Ou(hx,r)),t.cuid2=r=>t.check(Nu(gx,r)),t.ulid=r=>t.check(Au(_x,r)),t.base64=r=>t.check(Uu($x,r)),t.base64url=r=>t.check(qu(Ex,r)),t.xid=r=>t.check(Cu(yx,r)),t.ksuid=r=>t.check(Mu(vx,r)),t.ipv4=r=>t.check(ju(bx,r)),t.ipv6=r=>t.check(Du(wx,r)),t.cidrv4=r=>t.check(Lu(xx,r)),t.cidrv6=r=>t.check(Zu(Sx,r)),t.e164=r=>t.check(Fu(kx,r)),t.datetime=r=>t.check(ll(r)),t.date=r=>t.check(dl(r)),t.time=r=>t.check(pl(r)),t.duration=r=>t.check(fl(r))});function w(t){return Su(lx,t)}var Pe=x("ZodStringFormat",(t,e)=>{xe.init(t,e),sh.init(t,e)}),dx=x("ZodEmail",(t,e)=>{Lc.init(t,e),Pe.init(t,e)});var rh=x("ZodGUID",(t,e)=>{jc.init(t,e),Pe.init(t,e)});var hi=x("ZodUUID",(t,e)=>{Dc.init(t,e),Pe.init(t,e)});var px=x("ZodURL",(t,e)=>{Zc.init(t,e),Pe.init(t,e)});var fx=x("ZodEmoji",(t,e)=>{Uc.init(t,e),Pe.init(t,e)});var mx=x("ZodNanoID",(t,e)=>{qc.init(t,e),Pe.init(t,e)});var hx=x("ZodCUID",(t,e)=>{Fc.init(t,e),Pe.init(t,e)});var gx=x("ZodCUID2",(t,e)=>{Vc.init(t,e),Pe.init(t,e)});var _x=x("ZodULID",(t,e)=>{Hc.init(t,e),Pe.init(t,e)});var yx=x("ZodXID",(t,e)=>{Gc.init(t,e),Pe.init(t,e)});var vx=x("ZodKSUID",(t,e)=>{Bc.init(t,e),Pe.init(t,e)});var bx=x("ZodIPv4",(t,e)=>{Kc.init(t,e),Pe.init(t,e)});var wx=x("ZodIPv6",(t,e)=>{Wc.init(t,e),Pe.init(t,e)});var xx=x("ZodCIDRv4",(t,e)=>{Jc.init(t,e),Pe.init(t,e)});var Sx=x("ZodCIDRv6",(t,e)=>{Xc.init(t,e),Pe.init(t,e)});var $x=x("ZodBase64",(t,e)=>{Yc.init(t,e),Pe.init(t,e)});var Ex=x("ZodBase64URL",(t,e)=>{Qc.init(t,e),Pe.init(t,e)});var kx=x("ZodE164",(t,e)=>{eu.init(t,e),Pe.init(t,e)});var Tx=x("ZodJWT",(t,e)=>{tu.init(t,e),Pe.init(t,e)});var ih=x("ZodNumber",(t,e)=>{si.init(t,e),Ne.init(t,e),t.gt=(n,o)=>t.check(li(n,o)),t.gte=(n,o)=>t.check(Ho(n,o)),t.min=(n,o)=>t.check(Ho(n,o)),t.lt=(n,o)=>t.check(ui(n,o)),t.lte=(n,o)=>t.check(Vo(n,o)),t.max=(n,o)=>t.check(Vo(n,o)),t.int=n=>t.check(nh(n)),t.safe=n=>t.check(nh(n)),t.positive=n=>t.check(li(0,n)),t.nonnegative=n=>t.check(Ho(0,n)),t.negative=n=>t.check(ui(0,n)),t.nonpositive=n=>t.check(Vo(0,n)),t.multipleOf=(n,o)=>t.check(di(n,o)),t.step=(n,o)=>t.check(di(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function fe(t){return Hu(ih,t)}var Px=x("ZodNumberFormat",(t,e)=>{ru.init(t,e),ih.init(t,e)});function nh(t){return Gu(Px,t)}var Rx=x("ZodBoolean",(t,e)=>{nu.init(t,e),Ne.init(t,e)});function Fe(t){return Bu(Rx,t)}var Ix=x("ZodNull",(t,e)=>{ou.init(t,e),Ne.init(t,e)});function ah(t){return Ku(Ix,t)}var zx=x("ZodUnknown",(t,e)=>{su.init(t,e),Ne.init(t,e)});function Re(){return Wu(zx)}var Ox=x("ZodNever",(t,e)=>{iu.init(t,e),Ne.init(t,e)});function Nx(t){return Ju(Ox,t)}var Ax=x("ZodArray",(t,e)=>{au.init(t,e),Ne.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Un(r,n)),t.nonempty=r=>t.check(Un(1,r)),t.max=(r,n)=>t.check(pi(r,n)),t.length=(r,n)=>t.check(fi(r,n)),t.unwrap=()=>t.element});function ne(t,e){return Hm(Ax,t,e)}var ch=x("ZodObject",(t,e)=>{ii.init(t,e),Ne.init(t,e),re.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>ct(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Re()}),t.loose=()=>t.clone({...t._zod.def,catchall:Re()}),t.strict=()=>t.clone({...t._zod.def,catchall:Nx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>re.extend(t,r),t.merge=r=>re.merge(t,r),t.pick=r=>re.pick(t,r),t.omit=r=>re.omit(t,r),t.partial=(...r)=>re.partial(dh,t,r[0]),t.required=(...r)=>re.required(ph,t,r[0])});function I(t,e){let r={type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},...re.normalizeParams(e)};return new ch(r)}function nt(t,e){return new ch({type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},catchall:Re(),...re.normalizeParams(e)})}var uh=x("ZodUnion",(t,e)=>{ai.init(t,e),Ne.init(t,e),t.options=e.options});function Ee(t,e){return new uh({type:"union",options:t,...re.normalizeParams(e)})}var Cx=x("ZodDiscriminatedUnion",(t,e)=>{uh.init(t,e),cu.init(t,e)});function gl(t,e,r){return new Cx({type:"union",options:e,discriminator:t,...re.normalizeParams(r)})}var Mx=x("ZodIntersection",(t,e)=>{uu.init(t,e),Ne.init(t,e)});function gi(t,e){return new Mx({type:"intersection",left:t,right:e})}var jx=x("ZodRecord",(t,e)=>{lu.init(t,e),Ne.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Se(t,e,r){return new jx({type:"record",keyType:t,valueType:e,...re.normalizeParams(r)})}var ml=x("ZodEnum",(t,e)=>{du.init(t,e),Ne.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ml({...e,checks:[],...re.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ml({...e,checks:[],...re.normalizeParams(o),entries:s})}});function ct(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ml({type:"enum",entries:r,...re.normalizeParams(e)})}var Dx=x("ZodLiteral",(t,e)=>{pu.init(t,e),Ne.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new Dx({type:"literal",values:Array.isArray(t)?t:[t],...re.normalizeParams(e)})}var Lx=x("ZodTransform",(t,e)=>{fu.init(t,e),Ne.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(re.issue(s,r.value,e));else{let i=s;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=!0),r.issues.push(re.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function lh(t){return new Lx({type:"transform",transform:t})}var dh=x("ZodOptional",(t,e)=>{mu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ie(t){return new dh({type:"optional",innerType:t})}var Zx=x("ZodNullable",(t,e)=>{hu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function oh(t){return new Zx({type:"nullable",innerType:t})}var Ux=x("ZodDefault",(t,e)=>{gu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function qx(t,e){return new Ux({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Fx=x("ZodPrefault",(t,e)=>{_u.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Vx(t,e){return new Fx({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var ph=x("ZodNonOptional",(t,e)=>{yu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Hx(t,e){return new ph({type:"nonoptional",innerType:t,...re.normalizeParams(e)})}var Gx=x("ZodCatch",(t,e)=>{vu.init(t,e),Ne.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Bx(t,e){return new Gx({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Kx=x("ZodPipe",(t,e)=>{bu.init(t,e),Ne.init(t,e),t.in=e.in,t.out=e.out});function hl(t,e){return new Kx({type:"pipe",in:t,out:e})}var Wx=x("ZodReadonly",(t,e)=>{wu.init(t,e),Ne.init(t,e)});function Jx(t){return new Wx({type:"readonly",innerType:t})}var fh=x("ZodCustom",(t,e)=>{xu.init(t,e),Ne.init(t,e)});function Xx(t){let e=new He({check:"custom"});return e._zod.check=t,e}function mh(t,e){return al(fh,t??(()=>!0),e)}function Yx(t,e={}){return cl(fh,t,e)}function Qx(t){let e=Xx(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(re.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(re.issue(o))}},t(r.value,r)));return e}function _l(t,e){return hl(lh(t),e)}bt(Lm());var vl="2025-11-25",hh="2025-03-26",Fn=[vl,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],xr="io.modelcontextprotocol/related-task",yi="2.0",qe=mh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),gh=Ee([w(),fe().int()]),_h=w(),NN=nt({ttl:fe().optional(),pollInterval:fe().optional()}),e0=I({ttl:fe().optional()}),t0=I({taskId:w()}),bl=nt({progressToken:gh.optional(),[xr]:t0.optional()}),xt=I({_meta:bl.optional()}),Ko=xt.extend({task:e0.optional()}),yh=t=>Ko.safeParse(t).success,Ge=I({method:w(),params:xt.loose().optional()}),$t=I({_meta:bl.optional()}),Et=I({method:w(),params:$t.loose().optional()}),Be=nt({_meta:bl.optional()}),vi=Ee([w(),fe().int()]),vh=I({jsonrpc:A(yi),id:vi,...Ge.shape}).strict(),Sr=t=>vh.safeParse(t).success,bh=I({jsonrpc:A(yi),...Et.shape}).strict(),wh=t=>bh.safeParse(t).success,wl=I({jsonrpc:A(yi),id:vi,result:Be}).strict(),cr=t=>wl.safeParse(t).success;var M;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(M||(M={}));var xl=I({jsonrpc:A(yi),id:vi.optional(),error:I({code:fe().int(),message:w(),data:Re().optional()})}).strict();var Vn=t=>xl.safeParse(t).success;var Wo=Ee([vh,bh,wl,xl]),AN=Ee([wl,xl]),bi=Be.strict(),r0=$t.extend({requestId:vi.optional(),reason:w().optional()}),wi=Et.extend({method:A("notifications/cancelled"),params:r0}),n0=I({src:w(),mimeType:w().optional(),sizes:ne(w()).optional(),theme:ct(["light","dark"]).optional()}),Jo=I({icons:ne(n0).optional()}),qn=I({name:w(),title:w().optional()}),xh=qn.extend({...qn.shape,...Jo.shape,version:w(),websiteUrl:w().optional(),description:w().optional()}),o0=gi(I({applyDefaults:Fe().optional()}),Se(w(),Re())),s0=_l(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,gi(I({form:o0.optional(),url:qe.optional()}),Se(w(),Re()).optional())),i0=nt({list:qe.optional(),cancel:qe.optional(),requests:nt({sampling:nt({createMessage:qe.optional()}).optional(),elicitation:nt({create:qe.optional()}).optional()}).optional()}),a0=nt({list:qe.optional(),cancel:qe.optional(),requests:nt({tools:nt({call:qe.optional()}).optional()}).optional()}),c0=I({experimental:Se(w(),qe).optional(),sampling:I({context:qe.optional(),tools:qe.optional()}).optional(),elicitation:s0.optional(),roots:I({listChanged:Fe().optional()}).optional(),tasks:i0.optional(),extensions:Se(w(),qe).optional()}),u0=xt.extend({protocolVersion:w(),capabilities:c0,clientInfo:xh}),xi=Ge.extend({method:A("initialize"),params:u0}),Xo=t=>xi.safeParse(t).success,l0=I({experimental:Se(w(),qe).optional(),logging:qe.optional(),completions:qe.optional(),prompts:I({listChanged:Fe().optional()}).optional(),resources:I({subscribe:Fe().optional(),listChanged:Fe().optional()}).optional(),tools:I({listChanged:Fe().optional()}).optional(),tasks:a0.optional(),extensions:Se(w(),qe).optional()}),d0=Be.extend({protocolVersion:w(),capabilities:l0,serverInfo:xh,instructions:w().optional()}),Sl=Et.extend({method:A("notifications/initialized"),params:$t.optional()});var Si=Ge.extend({method:A("ping"),params:xt.optional()}),p0=I({progress:fe(),total:Ie(fe()),message:Ie(w())}),f0=I({...$t.shape,...p0.shape,progressToken:gh}),$i=Et.extend({method:A("notifications/progress"),params:f0}),m0=xt.extend({cursor:_h.optional()}),Yo=Ge.extend({params:m0.optional()}),Qo=Be.extend({nextCursor:_h.optional()}),h0=ct(["working","input_required","completed","failed","cancelled"]),es=I({taskId:w(),status:h0,ttl:Ee([fe(),ah()]),createdAt:w(),lastUpdatedAt:w(),pollInterval:Ie(fe()),statusMessage:Ie(w())}),Hn=Be.extend({task:es}),g0=$t.merge(es),ts=Et.extend({method:A("notifications/tasks/status"),params:g0}),Ei=Ge.extend({method:A("tasks/get"),params:xt.extend({taskId:w()})}),ki=Be.merge(es),Ti=Ge.extend({method:A("tasks/result"),params:xt.extend({taskId:w()})}),CN=Be.loose(),Pi=Yo.extend({method:A("tasks/list")}),Ri=Qo.extend({tasks:ne(es)}),Ii=Ge.extend({method:A("tasks/cancel"),params:xt.extend({taskId:w()})}),Sh=Be.merge(es),$h=I({uri:w(),mimeType:Ie(w()),_meta:Se(w(),Re()).optional()}),Eh=$h.extend({text:w()}),$l=w().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),kh=$h.extend({blob:$l}),rs=ct(["user","assistant"]),Gn=I({audience:ne(rs).optional(),priority:fe().min(0).max(1).optional(),lastModified:Go.datetime({offset:!0}).optional()}),Th=I({...qn.shape,...Jo.shape,uri:w(),description:Ie(w()),mimeType:Ie(w()),size:Ie(fe()),annotations:Gn.optional(),_meta:Ie(nt({}))}),_0=I({...qn.shape,...Jo.shape,uriTemplate:w(),description:Ie(w()),mimeType:Ie(w()),annotations:Gn.optional(),_meta:Ie(nt({}))}),zi=Yo.extend({method:A("resources/list")}),y0=Qo.extend({resources:ne(Th)}),Oi=Yo.extend({method:A("resources/templates/list")}),v0=Qo.extend({resourceTemplates:ne(_0)}),El=xt.extend({uri:w()}),b0=El,Ni=Ge.extend({method:A("resources/read"),params:b0}),w0=Be.extend({contents:ne(Ee([Eh,kh]))}),x0=Et.extend({method:A("notifications/resources/list_changed"),params:$t.optional()}),S0=El,$0=Ge.extend({method:A("resources/subscribe"),params:S0}),E0=El,k0=Ge.extend({method:A("resources/unsubscribe"),params:E0}),T0=$t.extend({uri:w()}),P0=Et.extend({method:A("notifications/resources/updated"),params:T0}),R0=I({name:w(),description:Ie(w()),required:Ie(Fe())}),I0=I({...qn.shape,...Jo.shape,description:Ie(w()),arguments:Ie(ne(R0)),_meta:Ie(nt({}))}),Ai=Yo.extend({method:A("prompts/list")}),z0=Qo.extend({prompts:ne(I0)}),O0=xt.extend({name:w(),arguments:Se(w(),w()).optional()}),Ci=Ge.extend({method:A("prompts/get"),params:O0}),kl=I({type:A("text"),text:w(),annotations:Gn.optional(),_meta:Se(w(),Re()).optional()}),Tl=I({type:A("image"),data:$l,mimeType:w(),annotations:Gn.optional(),_meta:Se(w(),Re()).optional()}),Pl=I({type:A("audio"),data:$l,mimeType:w(),annotations:Gn.optional(),_meta:Se(w(),Re()).optional()}),N0=I({type:A("tool_use"),name:w(),id:w(),input:Se(w(),Re()),_meta:Se(w(),Re()).optional()}),A0=I({type:A("resource"),resource:Ee([Eh,kh]),annotations:Gn.optional(),_meta:Se(w(),Re()).optional()}),C0=Th.extend({type:A("resource_link")}),Rl=Ee([kl,Tl,Pl,C0,A0]),M0=I({role:rs,content:Rl}),j0=Be.extend({description:w().optional(),messages:ne(M0)}),D0=Et.extend({method:A("notifications/prompts/list_changed"),params:$t.optional()}),L0=I({title:w().optional(),readOnlyHint:Fe().optional(),destructiveHint:Fe().optional(),idempotentHint:Fe().optional(),openWorldHint:Fe().optional()}),Z0=I({taskSupport:ct(["required","optional","forbidden"]).optional()}),Ph=I({...qn.shape,...Jo.shape,description:w().optional(),inputSchema:I({type:A("object"),properties:Se(w(),qe).optional(),required:ne(w()).optional()}).catchall(Re()),outputSchema:I({type:A("object"),properties:Se(w(),qe).optional(),required:ne(w()).optional()}).catchall(Re()).optional(),annotations:L0.optional(),execution:Z0.optional(),_meta:Se(w(),Re()).optional()}),Mi=Yo.extend({method:A("tools/list")}),U0=Qo.extend({tools:ne(Ph)}),ji=Be.extend({content:ne(Rl).default([]),structuredContent:Se(w(),Re()).optional(),isError:Fe().optional()}),MN=ji.or(Be.extend({toolResult:Re()})),q0=Ko.extend({name:w(),arguments:Se(w(),Re()).optional()}),Bn=Ge.extend({method:A("tools/call"),params:q0}),F0=Et.extend({method:A("notifications/tools/list_changed"),params:$t.optional()}),jN=I({autoRefresh:Fe().default(!0),debounceMs:fe().int().nonnegative().default(300)}),ns=ct(["debug","info","notice","warning","error","critical","alert","emergency"]),V0=xt.extend({level:ns}),Il=Ge.extend({method:A("logging/setLevel"),params:V0}),H0=$t.extend({level:ns,logger:w().optional(),data:Re()}),G0=Et.extend({method:A("notifications/message"),params:H0}),B0=I({name:w().optional()}),K0=I({hints:ne(B0).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),W0=I({mode:ct(["auto","required","none"]).optional()}),J0=I({type:A("tool_result"),toolUseId:w().describe("The unique identifier for the corresponding tool call."),content:ne(Rl).default([]),structuredContent:I({}).loose().optional(),isError:Fe().optional(),_meta:Se(w(),Re()).optional()}),X0=gl("type",[kl,Tl,Pl]),_i=gl("type",[kl,Tl,Pl,N0,J0]),Y0=I({role:rs,content:Ee([_i,ne(_i)]),_meta:Se(w(),Re()).optional()}),Q0=Ko.extend({messages:ne(Y0),modelPreferences:K0.optional(),systemPrompt:w().optional(),includeContext:ct(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:ne(w()).optional(),metadata:qe.optional(),tools:ne(Ph).optional(),toolChoice:W0.optional()}),eS=Ge.extend({method:A("sampling/createMessage"),params:Q0}),os=Be.extend({model:w(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens"]).or(w())),role:rs,content:X0}),zl=Be.extend({model:w(),stopReason:Ie(ct(["endTurn","stopSequence","maxTokens","toolUse"]).or(w())),role:rs,content:Ee([_i,ne(_i)])}),tS=I({type:A("boolean"),title:w().optional(),description:w().optional(),default:Fe().optional()}),rS=I({type:A("string"),title:w().optional(),description:w().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:ct(["email","uri","date","date-time"]).optional(),default:w().optional()}),nS=I({type:ct(["number","integer"]),title:w().optional(),description:w().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),oS=I({type:A("string"),title:w().optional(),description:w().optional(),enum:ne(w()),default:w().optional()}),sS=I({type:A("string"),title:w().optional(),description:w().optional(),oneOf:ne(I({const:w(),title:w()})),default:w().optional()}),iS=I({type:A("string"),title:w().optional(),description:w().optional(),enum:ne(w()),enumNames:ne(w()).optional(),default:w().optional()}),aS=Ee([oS,sS]),cS=I({type:A("array"),title:w().optional(),description:w().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:I({type:A("string"),enum:ne(w())}),default:ne(w()).optional()}),uS=I({type:A("array"),title:w().optional(),description:w().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:I({anyOf:ne(I({const:w(),title:w()}))}),default:ne(w()).optional()}),lS=Ee([cS,uS]),dS=Ee([iS,aS,lS]),pS=Ee([dS,tS,rS,nS]),fS=Ko.extend({mode:A("form").optional(),message:w(),requestedSchema:I({type:A("object"),properties:Se(w(),pS),required:ne(w()).optional()})}),mS=Ko.extend({mode:A("url"),message:w(),elicitationId:w(),url:w().url()}),hS=Ee([fS,mS]),gS=Ge.extend({method:A("elicitation/create"),params:hS}),_S=$t.extend({elicitationId:w()}),yS=Et.extend({method:A("notifications/elicitation/complete"),params:_S}),Kn=Be.extend({action:ct(["accept","decline","cancel"]),content:_l(t=>t===null?void 0:t,Se(w(),Ee([w(),fe(),Fe(),ne(w())])).optional())}),vS=I({type:A("ref/resource"),uri:w()});var bS=I({type:A("ref/prompt"),name:w()}),wS=xt.extend({ref:Ee([bS,vS]),argument:I({name:w(),value:w()}),context:I({arguments:Se(w(),w()).optional()}).optional()}),Di=Ge.extend({method:A("completion/complete"),params:wS});function Rh(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Ih(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var xS=Be.extend({completion:nt({values:ne(w()).max(100),total:Ie(fe().int()),hasMore:Ie(Fe())})}),SS=I({uri:w().startsWith("file://"),name:w().optional(),_meta:Se(w(),Re()).optional()}),$S=Ge.extend({method:A("roots/list"),params:xt.optional()}),Ol=Be.extend({roots:ne(SS)}),ES=Et.extend({method:A("notifications/roots/list_changed"),params:$t.optional()}),DN=Ee([Si,xi,Di,Il,Ci,Ai,zi,Oi,Ni,$0,k0,Bn,Mi,Ei,Ti,Pi,Ii]),LN=Ee([wi,$i,Sl,ES,ts]),ZN=Ee([bi,os,zl,Kn,Ol,ki,Ri,Hn]),UN=Ee([Si,eS,gS,$S,Ei,Ti,Pi,Ii]),qN=Ee([wi,$i,G0,P0,x0,F0,D0,ts,yS]),FN=Ee([bi,d0,xS,j0,z0,y0,v0,w0,ji,U0,ki,Ri,Hn]),N=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===M.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new yl(o.elicitations,r)}return new t(e,r,n)}},yl=class extends N{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(M.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};var Li=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
39
+ `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),kS(r)}clear(){this._buffer=void 0}};function kS(t){return Wo.parse(JSON.parse(t))}function zh(t){return JSON.stringify(t)+`
40
+ `}var Zi=class{constructor(e=Oh.stdin,r=Oh.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Li,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=zh(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var b={};pc(b,{BRAND:()=>YS,DIRTY:()=>Yr,EMPTY_PATH:()=>IS,INVALID:()=>U,NEVER:()=>C$,OK:()=>Ye,ParseStatus:()=>Ke,Schema:()=>K,ZodAny:()=>kr,ZodArray:()=>pr,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>is,ZodCatch:()=>fn,ZodDate:()=>rn,ZodDefault:()=>pn,ZodDiscriminatedUnion:()=>Fi,ZodEffects:()=>Tt,ZodEnum:()=>ln,ZodError:()=>ut,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Hi,ZodIntersection:()=>an,ZodIssueCode:()=>E,ZodLazy:()=>cn,ZodLiteral:()=>un,ZodMap:()=>eo,ZodNaN:()=>ro,ZodNativeEnum:()=>dn,ZodNever:()=>Ct,ZodNull:()=>on,ZodNullable:()=>Bt,ZodNumber:()=>Qr,ZodObject:()=>dt,ZodOptional:()=>lt,ZodParsedType:()=>R,ZodPipeline:()=>as,ZodPromise:()=>Tr,ZodReadonly:()=>mn,ZodRecord:()=>Vi,ZodSchema:()=>K,ZodSet:()=>to,ZodString:()=>Er,ZodSymbol:()=>Yn,ZodTransformer:()=>Tt,ZodTuple:()=>Gt,ZodType:()=>K,ZodUndefined:()=>nn,ZodUnion:()=>sn,ZodUnknown:()=>dr,ZodVoid:()=>Qn,addIssueToContext:()=>P,any:()=>a$,array:()=>d$,bigint:()=>r$,boolean:()=>Fh,coerce:()=>A$,custom:()=>Zh,date:()=>n$,datetimeRegex:()=>Dh,defaultErrorMap:()=>ur,discriminatedUnion:()=>m$,effect:()=>k$,enum:()=>S$,function:()=>b$,getErrorMap:()=>Wn,getParsedType:()=>Ht,instanceof:()=>e$,intersection:()=>h$,isAborted:()=>Ui,isAsync:()=>Jn,isDirty:()=>qi,isValid:()=>$r,late:()=>QS,lazy:()=>w$,literal:()=>x$,makeIssue:()=>ss,map:()=>y$,nan:()=>t$,nativeEnum:()=>$$,never:()=>u$,null:()=>i$,nullable:()=>P$,number:()=>qh,object:()=>Ml,objectUtil:()=>Nl,oboolean:()=>N$,onumber:()=>O$,optional:()=>T$,ostring:()=>z$,pipeline:()=>I$,preprocess:()=>R$,promise:()=>E$,quotelessJson:()=>TS,record:()=>_$,set:()=>v$,setErrorMap:()=>RS,strictObject:()=>p$,string:()=>Uh,symbol:()=>o$,transformer:()=>k$,tuple:()=>g$,undefined:()=>s$,union:()=>f$,unknown:()=>c$,util:()=>ee,void:()=>l$});var ee;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(ee||(ee={}));var Nl;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Nl||(Nl={}));var R=ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ht=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var E=ee.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"]),TS=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ut=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ut.create=t=>new ut(t);var PS=(t,e)=>{let r;switch(t.code){case E.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case E.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ee.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:r=`Unrecognized key(s) in object: ${ee.joinValues(t.keys,", ")}`;break;case E.invalid_union:r="Invalid input";break;case E.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ee.joinValues(t.options)}`;break;case E.invalid_enum_value:r=`Invalid enum value. Expected ${ee.joinValues(t.options)}, received '${t.received}'`;break;case E.invalid_arguments:r="Invalid function arguments";break;case E.invalid_return_type:r="Invalid function return type";break;case E.invalid_date:r="Invalid date";break;case E.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ee.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case E.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case E.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case E.custom:r="Invalid input";break;case E.invalid_intersection_types:r="Intersection results could not be merged";break;case E.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case E.not_finite:r="Number must be finite";break;default:r=e.defaultError,ee.assertNever(t)}return{message:r}},ur=PS;var Nh=ur;function RS(t){Nh=t}function Wn(){return Nh}var ss=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},IS=[];function P(t,e){let r=Wn(),n=ss({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ur?void 0:ur].filter(o=>!!o)});t.common.issues.push(n)}var Ke=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return U;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return U;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},U=Object.freeze({status:"aborted"}),Yr=t=>({status:"dirty",value:t}),Ye=t=>({status:"valid",value:t}),Ui=t=>t.status==="aborted",qi=t=>t.status==="dirty",$r=t=>t.status==="valid",Jn=t=>typeof Promise<"u"&&t instanceof Promise;var O;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(O||(O={}));var kt=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}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}},Ah=(t,e)=>{if($r(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new ut(t.common.issues);return this._error=r,this._error}}};function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var K=class{get description(){return this._def.description}_getType(e){return Ht(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:Ht(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Jn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)},o=this._parseSync({data:e,path:n.path,parent:n});return Ah(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return $r(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>$r(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ht(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Jn(o)?o:Promise.resolve(o));return Ah(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:E.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Tt({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return lt.create(this,this._def)}nullable(){return Bt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pr.create(this)}promise(){return Tr.create(this,this._def)}or(e){return sn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new Tt({...G(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new pn({...G(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new is({typeName:k.ZodBranded,type:this,...G(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new fn({...G(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return as.create(this,e)}readonly(){return mn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},zS=/^c[^\s-]{8,}$/i,OS=/^[0-9a-z]+$/,NS=/^[0-9A-HJKMNP-TV-Z]{26}$/i,AS=/^[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,CS=/^[a-z0-9_-]{21}$/i,MS=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jS=/^[-+]?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)?)??$/,DS=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,LS="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Al,ZS=/^(?:(?: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])$/,US=/^(?:(?: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])$/,qS=/^(([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]))$/,FS=/^(([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])$/,VS=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,HS=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mh="((\\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])))",GS=new RegExp(`^${Mh}$`);function jh(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function BS(t){return new RegExp(`^${jh(t)}$`)}function Dh(t){let e=`${Mh}T${jh(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function KS(t,e){return!!((e==="v4"||!e)&&ZS.test(t)||(e==="v6"||!e)&&qS.test(t))}function WS(t,e){if(!MS.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function JS(t,e){return!!((e==="v4"||!e)&&US.test(t)||(e==="v6"||!e)&&FS.test(t))}var Er=class t extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.string,received:s.parsedType}),U}let n=new Ke,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?P(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&P(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")DS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"email",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Al||(Al=new RegExp(LS,"u")),Al.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"emoji",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")AS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"uuid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")CS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"nanoid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")zS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cuid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")OS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cuid2",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")NS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"ulid",code:E.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),P(o,{validation:"url",code:E.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"regex",code:E.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Dh(s).test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?GS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?BS(s).test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{code:E.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?jS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"duration",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?KS(e.data,s.version)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"ip",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?WS(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"jwt",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?JS(e.data,s.version)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"cidr",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?VS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"base64",code:E.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?HS.test(e.data)||(o=this._getOrReturnCtx(e,o),P(o,{validation:"base64url",code:E.invalid_string,message:s.message}),n.dirty()):ee.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:E.invalid_string,...O.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...O.errToObj(e)})}url(e){return this._addCheck({kind:"url",...O.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...O.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...O.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...O.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...O.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...O.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...O.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...O.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...O.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...O.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...O.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...O.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...O.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...O.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...O.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...O.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...O.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...O.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...O.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...O.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...O.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...O.errToObj(r)})}nonempty(e){return this.min(1,O.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Er.create=t=>new Er({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...G(t)});function XS(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var Qr=class t extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==R.number){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.number,received:s.parsedType}),U}let n,o=new Ke;for(let s of this._def.checks)s.kind==="int"?ee.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),P(n,{code:E.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?XS(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_finite,message:s.message}),o.dirty()):ee.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,O.toString(r))}gt(e,r){return this.setLimit("min",e,!1,O.toString(r))}lte(e,r){return this.setLimit("max",e,!0,O.toString(r))}lt(e,r){return this.setLimit("max",e,!1,O.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:O.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:O.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:O.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ee.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Qr.create=t=>new Qr({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...G(t)});var en=class t extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==R.bigint)return this._getInvalidInput(e);let n,o=new Ke;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),P(n,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):ee.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return P(r,{code:E.invalid_type,expected:R.bigint,received:r.parsedType}),U}gte(e,r){return this.setLimit("min",e,!0,O.toString(r))}gt(e,r){return this.setLimit("min",e,!1,O.toString(r))}lte(e,r){return this.setLimit("max",e,!0,O.toString(r))}lt(e,r){return this.setLimit("max",e,!1,O.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:O.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};en.create=t=>new en({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var tn=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.boolean,received:n.parsedType}),U}return Ye(e.data)}};tn.create=t=>new tn({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var rn=class t extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_type,expected:R.date,received:s.parsedType}),U}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return P(s,{code:E.invalid_date}),U}let n=new Ke,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),P(o,{code:E.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ee.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:O.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:O.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};rn.create=t=>new rn({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...G(t)});var Yn=class extends K{_parse(e){if(this._getType(e)!==R.symbol){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.symbol,received:n.parsedType}),U}return Ye(e.data)}};Yn.create=t=>new Yn({typeName:k.ZodSymbol,...G(t)});var nn=class extends K{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.undefined,received:n.parsedType}),U}return Ye(e.data)}};nn.create=t=>new nn({typeName:k.ZodUndefined,...G(t)});var on=class extends K{_parse(e){if(this._getType(e)!==R.null){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.null,received:n.parsedType}),U}return Ye(e.data)}};on.create=t=>new on({typeName:k.ZodNull,...G(t)});var kr=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ye(e.data)}};kr.create=t=>new kr({typeName:k.ZodAny,...G(t)});var dr=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ye(e.data)}};dr.create=t=>new dr({typeName:k.ZodUnknown,...G(t)});var Ct=class extends K{_parse(e){let r=this._getOrReturnCtx(e);return P(r,{code:E.invalid_type,expected:R.never,received:r.parsedType}),U}};Ct.create=t=>new Ct({typeName:k.ZodNever,...G(t)});var Qn=class extends K{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.void,received:n.parsedType}),U}return Ye(e.data)}};Qn.create=t=>new Qn({typeName:k.ZodVoid,...G(t)});var pr=class t extends K{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==R.array)return P(r,{code:E.invalid_type,expected:R.array,received:r.parsedType}),U;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(P(r,{code:i?E.too_big:E.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(P(r,{code:E.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(P(r,{code:E.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new kt(r,i,r.path,a)))).then(i=>Ke.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new kt(r,i,r.path,a)));return Ke.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:O.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:O.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:O.toString(r)}})}nonempty(e){return this.min(1,e)}};pr.create=(t,e)=>new pr({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...G(e)});function Xn(t){if(t instanceof dt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=lt.create(Xn(n))}return new dt({...t._def,shape:()=>e})}else return t instanceof pr?new pr({...t._def,type:Xn(t.element)}):t instanceof lt?lt.create(Xn(t.unwrap())):t instanceof Bt?Bt.create(Xn(t.unwrap())):t instanceof Gt?Gt.create(t.items.map(e=>Xn(e))):t}var dt=class t extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ee.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let u=this._getOrReturnCtx(e);return P(u,{code:E.invalid_type,expected:R.object,received:u.parsedType}),U}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ct&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new kt(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Ct){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(P(o,{code:E.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new kt(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,h=await l.value;u.push({key:d,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>Ke.mergeObjectSync(n,u)):Ke.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return O.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:O.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of ee.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of ee.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Xn(this)}partial(e){let r={};for(let n of ee.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of ee.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof lt;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return Lh(ee.objectKeys(this.shape))}};dt.create=(t,e)=>new dt({shape:()=>t,unknownKeys:"strip",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});dt.strictCreate=(t,e)=>new dt({shape:()=>t,unknownKeys:"strict",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});dt.lazycreate=(t,e)=>new dt({shape:t,unknownKeys:"strip",catchall:Ct.create(),typeName:k.ZodObject,...G(e)});var sn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new ut(a.ctx.common.issues));return P(r,{code:E.invalid_union,unionErrors:i}),U}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new ut(c));return P(r,{code:E.invalid_union,unionErrors:a}),U}}get options(){return this._def.options}};sn.create=(t,e)=>new sn({options:t,typeName:k.ZodUnion,...G(e)});var lr=t=>t instanceof cn?lr(t.schema):t instanceof Tt?lr(t.innerType()):t instanceof un?[t.value]:t instanceof ln?t.options:t instanceof dn?ee.objectValues(t.enum):t instanceof pn?lr(t._def.innerType):t instanceof nn?[void 0]:t instanceof on?[null]:t instanceof lt?[void 0,...lr(t.unwrap())]:t instanceof Bt?[null,...lr(t.unwrap())]:t instanceof is||t instanceof mn?lr(t.unwrap()):t instanceof fn?lr(t._def.innerType):[],Fi=class t extends K{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return P(r,{code:E.invalid_type,expected:R.object,received:r.parsedType}),U;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(P(r,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),U)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=lr(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...G(n)})}};function Cl(t,e){let r=Ht(t),n=Ht(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&n===R.object){let o=ee.objectKeys(e),s=ee.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Cl(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===R.array&&n===R.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=Cl(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===R.date&&n===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var an=class extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Ui(s)||Ui(i))return U;let a=Cl(s.value,i.value);return a.valid?((qi(s)||qi(i))&&r.dirty(),{status:r.value,value:a.data}):(P(n,{code:E.invalid_intersection_types}),U)};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(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};an.create=(t,e,r)=>new an({left:t,right:e,typeName:k.ZodIntersection,...G(r)});var Gt=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return P(n,{code:E.invalid_type,expected:R.array,received:n.parsedType}),U;if(n.data.length<this._def.items.length)return P(n,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;!this._def.rest&&n.data.length>this._def.items.length&&(P(n,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new kt(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Ke.mergeArray(r,i)):Ke.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Gt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gt({items:t,typeName:k.ZodTuple,rest:null,...G(e)})};var Vi=class t extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.object)return P(n,{code:E.invalid_type,expected:R.object,received:n.parsedType}),U;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new kt(n,a,n.path,a)),value:i._parse(new kt(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Ke.mergeObjectAsync(r,o):Ke.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof K?new t({keyType:e,valueType:r,typeName:k.ZodRecord,...G(n)}):new t({keyType:Er.create(),valueType:e,typeName:k.ZodRecord,...G(r)})}},eo=class extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.map)return P(n,{code:E.invalid_type,expected:R.map,received:n.parsedType}),U;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new kt(n,a,n.path,[u,"key"])),value:s._parse(new kt(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return U;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return U;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};eo.create=(t,e,r)=>new eo({valueType:e,keyType:t,typeName:k.ZodMap,...G(r)});var to=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return P(n,{code:E.invalid_type,expected:R.set,received:n.parsedType}),U;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(P(n,{code:E.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(P(n,{code:E.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return U;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new kt(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:O.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:O.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};to.create=(t,e)=>new to({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...G(e)});var Hi=class t extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return P(r,{code:E.invalid_type,expected:R.function,received:r.parsedType}),U;function n(a,c){return ss({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wn(),ur].filter(u=>!!u),issueData:{code:E.invalid_arguments,argumentsError:c}})}function o(a,c){return ss({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Wn(),ur].filter(u=>!!u),issueData:{code:E.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Tr){let a=this;return Ye(async function(...c){let u=new ut([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return Ye(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new ut([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new ut([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Gt.create(e).rest(dr.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Gt.create([]).rest(dr.create()),returns:r||dr.create(),typeName:k.ZodFunction,...G(n)})}},cn=class extends K{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};cn.create=(t,e)=>new cn({getter:t,typeName:k.ZodLazy,...G(e)});var un=class extends K{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return P(r,{received:r.data,code:E.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:e.data}}get value(){return this._def.value}};un.create=(t,e)=>new un({value:t,typeName:k.ZodLiteral,...G(e)});function Lh(t,e){return new ln({values:t,typeName:k.ZodEnum,...G(e)})}var ln=class t extends K{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return P(r,{expected:ee.joinValues(n),received:r.parsedType,code:E.invalid_type}),U}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return P(r,{received:r.data,code:E.invalid_enum_value,options:n}),U}return Ye(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ln.create=Lh;var dn=class extends K{_parse(e){let r=ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let o=ee.objectValues(r);return P(n,{expected:ee.joinValues(o),received:n.parsedType,code:E.invalid_type}),U}if(this._cache||(this._cache=new Set(ee.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=ee.objectValues(r);return P(n,{received:n.data,code:E.invalid_enum_value,options:o}),U}return Ye(e.data)}get enum(){return this._def.values}};dn.create=(t,e)=>new dn({values:t,typeName:k.ZodNativeEnum,...G(e)});var Tr=class extends K{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return P(r,{code:E.invalid_type,expected:R.promise,received:r.parsedType}),U;let n=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return Ye(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Tr.create=(t,e)=>new Tr({type:t,typeName:k.ZodPromise,...G(e)});var Tt=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{P(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return U;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?U:c.status==="dirty"?Yr(c.value):r.value==="dirty"?Yr(c.value):c});{if(r.value==="aborted")return U;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?U:a.status==="dirty"?Yr(a.value):r.value==="dirty"?Yr(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?U:(a.status==="dirty"&&r.dirty(),i(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"?U:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$r(i))return U;let a=o.transform(i.value,s);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(i=>$r(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):U);ee.assertNever(o)}};Tt.create=(t,e,r)=>new Tt({schema:t,typeName:k.ZodEffects,effect:e,...G(r)});Tt.createWithPreprocess=(t,e,r)=>new Tt({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...G(r)});var lt=class extends K{_parse(e){return this._getType(e)===R.undefined?Ye(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lt.create=(t,e)=>new lt({innerType:t,typeName:k.ZodOptional,...G(e)});var Bt=class extends K{_parse(e){return this._getType(e)===R.null?Ye(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Bt.create=(t,e)=>new Bt({innerType:t,typeName:k.ZodNullable,...G(e)});var pn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};pn.create=(t,e)=>new pn({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var fn=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Jn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fn.create=(t,e)=>new fn({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var ro=class extends K{_parse(e){if(this._getType(e)!==R.nan){let n=this._getOrReturnCtx(e);return P(n,{code:E.invalid_type,expected:R.nan,received:n.parsedType}),U}return{status:"valid",value:e.data}}};ro.create=t=>new ro({typeName:k.ZodNaN,...G(t)});var YS=Symbol("zod_brand"),is=class extends K{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},as=class t extends K{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?U:s.status==="dirty"?(r.dirty(),Yr(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?U:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:k.ZodPipeline})}},mn=class extends K{_parse(e){let r=this._def.innerType._parse(e),n=o=>($r(o)&&(o.value=Object.freeze(o.value)),o);return Jn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};mn.create=(t,e)=>new mn({innerType:t,typeName:k.ZodReadonly,...G(e)});function Ch(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Zh(t,e={},r){return t?kr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Ch(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=Ch(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):kr.create()}var QS={object:dt.lazycreate},k;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));var e$=(t,e={message:`Input not instance of ${t.name}`})=>Zh(r=>r instanceof t,e),Uh=Er.create,qh=Qr.create,t$=ro.create,r$=en.create,Fh=tn.create,n$=rn.create,o$=Yn.create,s$=nn.create,i$=on.create,a$=kr.create,c$=dr.create,u$=Ct.create,l$=Qn.create,d$=pr.create,Ml=dt.create,p$=dt.strictCreate,f$=sn.create,m$=Fi.create,h$=an.create,g$=Gt.create,_$=Vi.create,y$=eo.create,v$=to.create,b$=Hi.create,w$=cn.create,x$=un.create,S$=ln.create,$$=dn.create,E$=Tr.create,k$=Tt.create,T$=lt.create,P$=Bt.create,R$=Tt.createWithPreprocess,I$=as.create,z$=()=>Uh().optional(),O$=()=>qh().optional(),N$=()=>Fh().optional(),A$={string:(t=>Er.create({...t,coerce:!0})),number:(t=>Qr.create({...t,coerce:!0})),boolean:(t=>tn.create({...t,coerce:!0})),bigint:(t=>en.create({...t,coerce:!0})),date:(t=>rn.create({...t,coerce:!0}))};var C$=U;var Vh=b.object({access_token:b.string().optional()}).passthrough(),Hh=b.object({revision:b.number()}).passthrough(),Gh=b.object({id:b.string(),name:b.string(),version:b.number(),latestData:b.array(b.unknown()).optional()}).passthrough();var cs="0.1.1";var Bh=3e4;function oo(t){return t?.proposed===!0}var Kt=class extends Error{status;constructor(e,r){super(e),this.name="FlowpadError",this.status=r}};function Kh(t,e,r){let n=t.safeParse(e);if(!n.success)throw new Kt(`Backend response for ${r} did not match the expected shape: ${n.error.message}`);return n.data}var no=class{constructor(e){this.cfg=e;if(e.token)this.token=e.token;else if(!e.mcpKey)throw new Kt("Missing credential: provide an OAuth access token, or a FLOWPAD_API_KEY (Settings \u2192 Integrations) for the MCP server env.")}cfg;token;cache=new Map;clientName;updateAdvisory;url(e){return`${this.cfg.baseUrl.replace(/\/$/,"")}${e}`}setClientName(e){let r=e?.trim();this.clientName=r?r.slice(0,64):void 0}getUpdateAdvisory(){return this.updateAdvisory}async login(){if(!this.cfg.mcpKey)throw new Kt("Access token rejected and no MCP key to re-authenticate \u2014 the OAuth token is likely expired; reconnect the connector.",401);let e;try{e=await fetch(this.url("/mcp/auth/login"),{method:"POST",headers:{"Content-Type":"application/json","x-mcp-key":this.cfg.mcpKey,"X-Flowpad-MCP-Version":cs},signal:AbortSignal.timeout(Bh)})}catch(n){throw n instanceof Error&&n.name==="TimeoutError"?new Kt("Backend timed out \u2014 retry"):n}if(!e.ok)throw new Kt(`MCP login failed (${e.status}): ${await e.text()}. Check FLOWPAD_API_KEY is a valid, non-revoked key and FLOWPAD_API_URL points at the right backend.`,e.status);let r=Kh(Vh,await e.json(),"POST /mcp/auth/login");if(!r.access_token)throw new Kt("MCP login response did not contain access_token.");this.token=r.access_token}async guidance(){return(await this.request("/mcp/guidance")).instructions}async request(e,r={},n=!0,o){this.token||await this.login();let s;try{s=await fetch(this.url(e),{...r,headers:{"Content-Type":"application/json","X-Flowpad-MCP-Version":cs,...this.clientName?{"x-mcp-client":this.clientName}:{},...r.headers??{},Authorization:`Bearer ${this.token}`},signal:AbortSignal.timeout(Bh)})}catch(a){throw a instanceof Error&&a.name==="TimeoutError"?new Kt("Backend timed out \u2014 retry"):a}if(s.headers.get("x-flowpad-mcp-update")==="available"&&(this.updateAdvisory=s.headers.get("x-flowpad-mcp-latest")??"newer"),s.status===401&&n&&this.cfg.mcpKey)return this.token=void 0,await this.login(),this.request(e,r,!1,o);if(!s.ok)throw new Kt(`${r.method??"GET"} ${e} failed (${s.status}): ${await s.text()}`,s.status);if(s.status===204)return;let i=await s.json();return o?Kh(o,i,`${r.method??"GET"} ${e}`):i}async listProjects(e){let r=e?`?query=${encodeURIComponent(e)}`:"";return this.request(`/mcp/projects${r}`)}async getProjectRaw(e){return this.request(`/mcp/projects/${e}/raw`,{},!0,Gh)}async getRevision(e){return this.request(`/mcp/projects/${e}/revision`,{},!0,Hh)}async getProjectRawCached(e){let r=this.cache.get(e);if(r)try{let{revision:o}=await this.getRevision(e);if(o===r.version)return r.project}catch{}let n=await this.getProjectRaw(e);return this.cache.set(e,{version:n.version,project:n}),n}invalidate(e){this.cache.delete(e)}async outline(e,r){let n=r!==void 0?`?maxDepth=${r}`:"",{text:o}=await this.request(`/mcp/projects/${e}/outline${n}`);return o}async searchNodes(e,r){let n=new URLSearchParams;for(let[i,a]of Object.entries(r))a!==void 0&&a!==""&&n.set(i,String(a));let o=n.toString()?`?${n.toString()}`:"",{text:s}=await this.request(`/mcp/projects/${e}/search${o}`);return s}async getNode(e,r,n){let o=n!==void 0?`?depth=${n}`:"",{text:s}=await this.request(`/mcp/projects/${e}/nodes/${encodeURIComponent(r)}${o}`);return s}async analyze(e){let{text:r}=await this.request(`/mcp/projects/${e}/analyze`);return r}async connections(e,r={}){let n=new URLSearchParams;r.nodeId&&n.set("nodeId",r.nodeId),r.nodeName&&n.set("nodeName",r.nodeName);let o=n.toString()?`?${n.toString()}`:"",{text:s}=await this.request(`/mcp/projects/${e}/connections${o}`);return s}async updateProject(e,r){let n=await this.request(`/mcp/projects/${e}`,{method:"PUT",body:JSON.stringify(r)});return oo(n)?this.invalidate(e):n&&typeof n.version=="number"&&n.latestData?this.cache.set(e,{version:n.version,project:n}):this.invalidate(e),n}async createProject(e){return this.request("/mcp/projects",{method:"POST",body:JSON.stringify(e)})}async deleteProject(e){return this.request(`/mcp/projects/${e}`,{method:"DELETE"})}async bindTemplate(e,r){return this.request(`/mcp/projects/${e}/bind-template`,{method:"POST",body:JSON.stringify({templateProjectId:r})})}async listTemplates(){return this.request("/mcp/templates")}};var j$=x("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");he.init(t,e),t.def=e,t.parse=(r,n)=>Tc(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Kr(t,r,n),t.parseAsync=async(r,n)=>Rc(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Wr(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>wt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var D$=x("ZodMiniObject",(t,e)=>{ii.init(t,e),j$.init(t,e),re.defineLazy(t,"shape",()=>e.shape)});function jl(t,e){let r={type:"object",get shape(){return re.assignProp(this,"shape",{...t}),this.shape},...re.normalizeParams(e)};return new D$(r)}function Pt(t){return!!t._zod}function hn(t){let e=Object.values(t);if(e.length===0)return jl({});let r=e.every(Pt),n=e.every(o=>!Pt(o));if(r)return jl(t);if(n)return Ml(t);throw new Error("Mixed Zod versions detected in object shape.")}function Pr(t,e){return Pt(t)?Kr(t,e):t.safeParse(e)}async function Gi(t,e){return Pt(t)?await Wr(t,e):await t.safeParseAsync(e)}function Rr(t){if(!t)return;let e;if(Pt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function so(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return hn(t)}}if(Pt(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Bi(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Wh(t){return t.description}function Jh(t){if(Pt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Ki(t){if(Pt(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}function Ir(t){return t==="completed"||t==="failed"||t==="cancelled"}var Yh=Symbol("Let zodToJsonSchema decide on which parser to use");var Xh={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"},Qh=t=>typeof t=="string"?{...Xh,name:t}:{...Xh,...t};var eg=t=>{let e=Qh(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Dl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function oe(t,e,r,n,o){t[e]=r,Dl(t,e,n,o)}var Wi=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function ze(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Wi(e,t.currentPath):e.join("/")}}function tg(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==k.ZodAny&&(r.items=V(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&oe(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&oe(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(oe(r,"minItems",t.exactLength.value,t.exactLength.message,e),oe(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function rg(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?oe(r,"minimum",n.value,n.message,e):oe(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),oe(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?oe(r,"maximum",n.value,n.message,e):oe(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),oe(r,"maximum",n.value,n.message,e));break;case"multipleOf":oe(r,"multipleOf",n.value,n.message,e);break}return r}function ng(){return{type:"boolean"}}function Ji(t,e){return V(t.type._def,e)}var og=(t,e)=>V(t.innerType._def,e);function Ll(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>Ll(t,e,o))};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 Z$(t,e)}}var Z$=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":oe(r,"minimum",n.value,n.message,e);break;case"max":oe(r,"maximum",n.value,n.message,e);break}return r};function sg(t,e){return{...V(t.innerType._def,e),default:t.defaultValue()}}function ig(t,e){return e.effectStrategy==="input"?V(t.schema._def,e):ze(e)}function ag(t){return{type:"string",enum:Array.from(t.values)}}var U$=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function cg(t,e){let r=[V(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),V(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(U$(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function ug(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var Zl,Mt={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:()=>(Zl===void 0&&(Zl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Zl),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 Xi(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":jt(r,"email",n.message,e);break;case"format:idn-email":jt(r,"idn-email",n.message,e);break;case"pattern:zod":ot(r,Mt.email,n.message,e);break}break;case"url":jt(r,"uri",n.message,e);break;case"uuid":jt(r,"uuid",n.message,e);break;case"regex":ot(r,n.regex,n.message,e);break;case"cuid":ot(r,Mt.cuid,n.message,e);break;case"cuid2":ot(r,Mt.cuid2,n.message,e);break;case"startsWith":ot(r,RegExp(`^${Ul(n.value,e)}`),n.message,e);break;case"endsWith":ot(r,RegExp(`${Ul(n.value,e)}$`),n.message,e);break;case"datetime":jt(r,"date-time",n.message,e);break;case"date":jt(r,"date",n.message,e);break;case"time":jt(r,"time",n.message,e);break;case"duration":jt(r,"duration",n.message,e);break;case"length":oe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),oe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{ot(r,RegExp(Ul(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&jt(r,"ipv4",n.message,e),n.version!=="v4"&&jt(r,"ipv6",n.message,e);break}case"base64url":ot(r,Mt.base64url,n.message,e);break;case"jwt":ot(r,Mt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&ot(r,Mt.ipv4Cidr,n.message,e),n.version!=="v4"&&ot(r,Mt.ipv6Cidr,n.message,e);break}case"emoji":ot(r,Mt.emoji(),n.message,e);break;case"ulid":{ot(r,Mt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{jt(r,"binary",n.message,e);break}case"contentEncoding:base64":{oe(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{ot(r,Mt.base64,n.message,e);break}}break}case"nanoid":ot(r,Mt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Ul(t,e){return e.patternStrategy==="escape"?F$(t):t}var q$=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function F$(t){let e="";for(let r=0;r<t.length;r++)q$.has(t[r])||(e+="\\"),e+=t[r];return e}function jt(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):oe(t,"format",e,r,n)}function ot(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:lg(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):oe(t,"pattern",lg(e,n),r,n)}function lg(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
41
41
  ]))`;continue}else if(n[c]==="$"){o+=`($|(?=[\r
42
42
  ]))`;continue}}if(r.s&&n[c]==="."){o+=i?`${n[c]}\r
43
43
  `:`[${n[c]}\r
44
- ]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function Yi(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===k.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??ze(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===k.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Xi(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===k.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===k.ZodBranded&&t.keyType._def.type._def.typeName===k.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Ji(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function ag(t,e){if(e.mapStrategy==="record")return Yi(t,e);let r=V(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||ze(e),n=V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||ze(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function cg(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function ug(t){return t.target==="openAi"?void 0:{not:ze({...t,currentPath:[...t.currentPath,"not"]})}}function lg(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var us={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function pg(t,e){if(e.target==="openApi3")return dg(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in us&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=us[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return dg(t,e)}var dg=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>V(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function fg(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:us[t.innerType._def.typeName],nullable:!0}:{type:[us[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=V(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function mg(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",Dl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?oe(r,"minimum",n.value,n.message,e):oe(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),oe(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?oe(r,"maximum",n.value,n.message,e):oe(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),oe(r,"maximum",n.value,n.message,e));break;case"multipleOf":oe(r,"multipleOf",n.value,n.message,e);break}return r}function hg(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=LS(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=V(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=DS(t,e);return i!==void 0&&(n.additionalProperties=i),n}function DS(t,e){if(t.catchall._def.typeName!=="ZodNever")return V(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function LS(t){try{return t.isOptional()}catch{return!0}}var gg=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return V(t.innerType._def,e);let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:ze(e)},r]}:ze(e)};var _g=(t,e)=>{if(e.pipeStrategy==="input")return V(t.in._def,e);if(e.pipeStrategy==="output")return V(t.out._def,e);let r=V(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=V(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function yg(t,e){return V(t.type._def,e)}function vg(t,e){let n={type:"array",uniqueItems:!0,items:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&oe(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&oe(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function bg(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:V(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function wg(t){return{not:ze(t)}}function xg(t){return ze(t)}var $g=(t,e)=>V(t.innerType._def,e);var Sg=(t,e,r)=>{switch(e){case k.ZodString:return Xi(t,r);case k.ZodNumber:return mg(t,r);case k.ZodObject:return hg(t,r);case k.ZodBigInt:return Yh(t,r);case k.ZodBoolean:return Qh();case k.ZodDate:return Ll(t,r);case k.ZodUndefined:return wg(r);case k.ZodNull:return lg(r);case k.ZodArray:return Xh(t,r);case k.ZodUnion:case k.ZodDiscriminatedUnion:return pg(t,r);case k.ZodIntersection:return og(t,r);case k.ZodTuple:return bg(t,r);case k.ZodRecord:return Yi(t,r);case k.ZodLiteral:return sg(t,r);case k.ZodEnum:return ng(t);case k.ZodNativeEnum:return cg(t);case k.ZodNullable:return fg(t,r);case k.ZodOptional:return gg(t,r);case k.ZodMap:return ag(t,r);case k.ZodSet:return vg(t,r);case k.ZodLazy:return()=>t.getter()._def;case k.ZodPromise:return yg(t,r);case k.ZodNaN:case k.ZodNever:return ug(r);case k.ZodEffects:return rg(t,r);case k.ZodAny:return ze(r);case k.ZodUnknown:return xg(r);case k.ZodDefault:return tg(t,r);case k.ZodBranded:return Ji(t,r);case k.ZodReadonly:return $g(t,r);case k.ZodCatch:return eg(t,r);case k.ZodPipeline:return _g(t,r);case k.ZodFunction:case k.ZodVoid:case k.ZodSymbol:return;default:return(n=>{})(e)}};function V(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Kh)return a}if(n&&!r){let a=ZS(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=Sg(t,t.typeName,e),i=typeof s=="function"?V(s(),e):s;if(i&&US(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var ZS=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Wi(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),ze(e)):e.$refStrategy==="seen"?ze(e):void 0}},US=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var ql=(t,e)=>{let r=Jh(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:V(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??ze(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=V(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??ze(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.title=i),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=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};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 qS(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Fl(t,e){return Pt(t)?ul(t,{target:qS(e?.target),io:e?.pipeStrategy??"input"}):ql(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Vl(t){let r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ki(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Hl(t,e){let r=Pr(t,e);if(!r.success)throw r.error;return r.data}var FS=6e4,Qi=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wi,r=>{this._oncancel(r)}),this.setNotificationHandler(Si,r=>{this._onprogress(r)}),this.setRequestHandler($i,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ei,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(M.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ti,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,h=new N(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 ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new N(M.InvalidParams,`Task not found: ${s}`);if(!Ir(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Ir(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[xr]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Pi,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new N(M.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ii,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(M.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ir(o.status))throw new N(M.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new N(M.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof N?o:new N(M.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),N.fromError(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),ar(s)||Fn(s)?this._onresponse(s):$r(s)?this._onrequest(s,i):wh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=N.fromError(M.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[xr]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:M.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=yh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,h)=>{if(i.signal.aborted)throw new N(M.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let p=m.relatedTask?.taskId??s;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:M.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),ar(e))n(e);else{let i=new N(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(ar(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),ar(e))o(e);else{let i=N.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof N?i:new N(M.InternalError,String(i))}}return}let s;try{let i=await this.request(e,Vn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new N(M.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Ir(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new N(M.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new N(M.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof N?i:new N(M.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[xr]:c}});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:o,resumptionToken:s,onresumptiontoken:i}).catch(y=>this._onerror(new Error(`Failed to send cancellation: ${y}`)));let $=v instanceof N?v:new N(M.RequestTimeout,String(v));l($)};this._responseHandlers.set(h,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let $=Pr(r,v.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let f=n?.timeout??FS,g=()=>p(N.fromError(M.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let _=c?.taskId;if(_){let v=$=>{let y=this._responseHandlers.get(h);y?y($):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(_,{type:"request",message:m,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(h),l($)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(h),l(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ki,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Ri,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},$h,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[xr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[xr]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[xr]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Vl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Hl(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Vl(e);this._notificationHandlers.set(n,o=>{let s=Hl(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&$r(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new N(M.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new N(M.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new N(M.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new N(M.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=ts.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ir(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new N(M.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ir(a.status))throw new N(M.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=ts.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ir(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Eg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function kg(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Eg(i)&&Eg(s)?r[o]={...i,...s}:r[o]=s}return r}var _v=Ws(zp(),1),yv=Ws(gv(),1);function GI(){let t=new _v.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,yv.default)(t),t}var Aa=class{constructor(e){this._ajv=e??GI()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ca=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(h=>h.type==="tool_use").map(h=>h.id)),d=new Set(s.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:e},os,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){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 s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Bn,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function vv(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function bv(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Ma=class extends Qi{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ns.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Aa,this.setRequestHandler(xi,n=>this._oninitialize(n)),this.setNotificationHandler($l,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Il,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ns.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ca(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=kg(this._capabilities,e)}setRequestHandler(e,r){let o=Rr(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Pt(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Pr(Gn,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new N(M.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,h=await Promise.resolve(r(c,u));if(d.task){let p=Pr(Vn,h);if(!p.success){let f=p.error instanceof Error?p.error.message:String(p.error);throw new N(M.InvalidParams,`Invalid task creation result: ${f}`)}return p.data}let m=Pr(ji,h);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new N(M.InvalidParams,`Invalid tools/call result: ${p}`)}return m.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){bv(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&vv(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:qn.includes(r)?r:vl,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"},bi)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},zl,r):this.request({method:"sampling/createMessage",params:e},os,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},Bn,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Bn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new N(M.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof N?i:new N(M.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Ol,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var xv=Symbol.for("mcp.completable");function Lp(t){return!!t&&typeof t=="object"&&xv in t}function $v(t){return t[xv]?.complete}var wv;(function(t){t.Completable="McpCompletable"})(wv||(wv={}));var BI=/^[A-Za-z0-9._-]{1,128}$/;function KI(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!BI.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function WI(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Zp(t){let e=KI(t);return WI(t,e.warnings),e.isValid}var ja=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};var Da=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Ma(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ja(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(Mi)),this.server.assertCanSetRequestHandler(Lr(Gn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Mi,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=oo(r.inputSchema);return o?Fl(o,{strictUnions:!0,pipeStrategy:"input"}):JI})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=oo(r.outputSchema);o&&(n.outputSchema=Fl(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Gn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new N(M.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new N(M.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new N(M.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof N&&n.code===M.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let s=oo(e.inputSchema)??e.inputSchema,i=await Gi(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=Bi(a);throw new N(M.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new N(M.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=oo(e.outputSchema),s=await Gi(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=Bi(i);throw new N(M.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let d=await n.taskStore.getTask(c);if(!d)throw new N(M.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Lr(Di)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Di,async e=>{switch(e.params.ref.type){case"ref/prompt":return Rh(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Ih(e),this.handleResourceCompletion(e,e.params.ref);default:throw new N(M.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new N(M.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Ls;let s=Rr(n.argsSchema)?.[e.params.argument.name];if(!Lp(s))return Ls;let i=$v(s);if(!i)return Ls;let a=await i(e.params.argument.value,e.params.context);return Ev(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Ls;throw new N(M.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return Ls;let s=await o(e.params.argument.value,e.params.context);return Ev(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(zi)),this.server.assertCanSetRequestHandler(Lr(Oi)),this.server.assertCanSetRequestHandler(Lr(Ni)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(zi,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(Oi,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ni,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new N(M.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new N(M.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(Ai)),this.server.assertCanSetRequestHandler(Lr(Ci)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ai,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?XI(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ci,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new N(M.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=oo(n.argsSchema),s=await Gi(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=Bi(c);throw new N(M.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:hn(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=hn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof lt?c._def?.innerType:c;return Lp(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){Zp(e);let l={title:r,description:n,inputSchema:Sv(o),outputSchema:Sv(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Zp(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=hn(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=hn(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(Up(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Up(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var JI={type:"object",properties:{}};function kv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Tv(t){return"_def"in t||"_zod"in t||kv(t)}function Up(t){return typeof t!="object"||t===null||Tv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(kv)}function Sv(t){if(t){if(Up(t))return hn(t);if(!Tv(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function XI(t){let e=Rr(t);return e?Object.entries(e).map(([r,n])=>{let o=Hh(n),s=Gh(n);return{name:r,description:o,required:!s}}):[]}function Lr(t){let r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ki(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Ev(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Ls={completion:{values:[],hasMore:!1}};import{randomUUID as YI}from"node:crypto";function Zr(){return YI()}function Pv(t){let e={x:t.bounds?.x??0,y:t.bounds?.y??0,width:t.bounds?.width??240,height:t.bounds?.height??120};return qp({id:t.id,bounds:e,children:[],parent:t.parentId??null,edges:[],...t.type?{type:t.type}:{},...t.name?{name:t.name}:{},...t.description?{description:t.description}:{},...t.isAutoLayout!=null?{isAutoLayout:t.isAutoLayout}:{},...t.layout?{layout:t.layout}:{},...t.style??{}})}function qp(t){if(t.type!=="text")return t;let e=t.content;if(typeof e=="string"&&e.length>0)return t;let r=t.description??t.name;return r?{...t,content:r}:t}function Rv(t){return!t.added?.length&&!t.updated?.length&&!t.removedIds?.length}var lf=Ws(of(),1);var pe=Ws(of(),1);function sf(t,e=0){return(0,pe.validateDiffPayload)(t,e)}function tb(t){let e={nodes:structuredClone(t)};(0,pe.layoutContainerChildren)(e);let r=e.nodes;return{nodes:r.map(n=>({id:String(n.id),bounds:n.bounds})),overflows:(0,pe.detectLayoutOverflows)(r)}}function rb(){let t=Object.entries(pe.NODE_RULES.STYLE_CAPABILITIES).filter(([,e])=>e.length>0).map(([e,r])=>` ${e}: ${r.join(", ")}`);return["FLOWPAD ENGINE \u2014 rules an edit must satisfy (validated locally before send):","","NODES",` allowed types: ${pe.NODE_RULES.ALLOWED_TYPES.join(", ")}`,` name \u2264 ${pe.NODE_RULES.NAME_MAX_LENGTH} chars; \u2264 ${pe.NODE_RULES.MAX_CHILDREN} children/node;`,` \u2264 ${pe.NODE_RULES.MAX_EDGES_PER_NODE} edges/node; \u2264 ${pe.NODE_RULES.MAX_NODES_PER_PROJECT} nodes/project.`," box fill/border style props are type-specific:",...t," (text/sticky/image paint their own colors via separate fields, not these.)","","BOUNDS (x, y, width, height \u2014 all finite numbers)",` width/height \u2265 0 (0 collapses a flex item; negative rejected), \u2264 ${pe.BOUNDS_RULES.MAX_WIDTH}.`,` x/y within ${pe.BOUNDS_RULES.MIN_COORDINATE}\u2026${pe.BOUNDS_RULES.MAX_COORDINATE}.`,"","LAYOUT (only when isAutoLayout:true \u2014 node becomes a flex container)",` flexDirection: ${pe.LAYOUT_RULES.ALLOWED_FLEX_DIRECTIONS.join(" | ")}`,` justifyContent: ${pe.LAYOUT_RULES.ALLOWED_JUSTIFY_CONTENT.join(" | ")}`,` alignItems: ${pe.LAYOUT_RULES.ALLOWED_ALIGN_ITEMS.join(" | ")}`,` gap ${pe.LAYOUT_RULES.MIN_GAP}\u2026${pe.LAYOUT_RULES.MAX_GAP}, padding ${pe.LAYOUT_RULES.MIN_PADDING}\u2026${pe.LAYOUT_RULES.MAX_PADDING},`,` margin ${pe.LAYOUT_RULES.MIN_MARGIN}\u2026${pe.LAYOUT_RULES.MAX_MARGIN}, flexGrow/Shrink ${pe.LAYOUT_RULES.MIN_FLEX_GROW}\u2026${pe.LAYOUT_RULES.MAX_FLEX_GROW}.`," defaults are browser-parity: flexShrink 1, flexWrap nowrap, alignItems stretch.","","EDGES (connections FROM a node TO another)",` ports: ${pe.EDGE_RULES.ALLOWED_PORTS.join(", ")}; no self-loops; no dangling targets.`," direction rule: an edge may NOT point INTO a task node \u2014 connect task\u2192regular,"," never regular\u2192task or task\u2192task (such edges are dropped)."].join(`
45
- `)}var ve=t=>({content:[{type:"text",text:t}]}),Rn=t=>ve(`Proposed for the user's review: ${t}. They are viewing this project, so the change is waiting in their accept/reject preview \u2014 nothing is saved until they approve it.`),Oe=t=>({content:[{type:"text",text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}),nb=w.object({x:w.number().optional(),y:w.number().optional(),width:w.number().optional(),height:w.number().optional()}).describe("Position/size. Missing fields default to x:0 y:0 w:240 h:120."),oc=w.enum(["top","right","bottom","left"]),ob=w.object({id:w.string().optional().describe("Edge id; a fresh one is minted if omitted."),to:w.string().describe("Target node id this edge points to."),fromPort:oc.optional(),toPort:oc.optional()}).describe("A connection FROM this node TO another node. Direction rule: you may NOT point an edge INTO a task node \u2014 connect task\u2192regular, never regular\u2192task or task\u2192task (invalid edges are dropped server-side)."),af=w.object({flexDirection:w.enum(["row","row-reverse","column","column-reverse"]).optional(),flexWrap:w.enum(["nowrap","wrap","wrap-reverse"]).optional(),justifyContent:w.enum(["flex-start","center","flex-end","space-between","space-around","space-evenly"]).optional(),alignItems:w.enum(["flex-start","center","flex-end","stretch","baseline"]).optional(),alignSelf:w.enum(["flex-start","center","flex-end","stretch","baseline","auto"]).optional(),gap:w.number().optional(),padding:w.number().optional(),paddingTop:w.number().optional(),paddingRight:w.number().optional(),paddingBottom:w.number().optional(),paddingLeft:w.number().optional(),margin:w.number().optional(),marginTop:w.number().optional(),marginRight:w.number().optional(),marginBottom:w.number().optional(),marginLeft:w.number().optional(),flexGrow:w.number().optional(),flexShrink:w.number().optional()}).describe("Flexbox layout (standard CSS semantics). CONTAINER props position this node's children: flexDirection, justifyContent (main axis), alignItems (cross axis), gap, padding. PER-CHILD props control how THIS node behaves inside its parent: flexGrow, flexShrink, alignSelf, margin. Engine defaults are browser-parity \u2014 flexShrink 1, flexWrap nowrap, alignItems stretch \u2014 so set flexShrink:0 / a fixed bound only when you want NO shrinking. Use flexGrow:1 on siblings to share a row/column equally without computing widths. A node is a flex container only when isAutoLayout:true."),rc={textColor:w.string().optional().describe('Text fill color as hex, e.g. "#FFFFFF" (text nodes).'),fontSize:w.number().min(6).max(200).optional().describe("Font size in px, 6\u2013200 (text nodes)."),textAlign:w.enum(["left","center","right"]).optional().describe("Horizontal text alignment within the node (text nodes)."),backgroundColor:w.string().optional().describe("Fill color as hex (view/container nodes)."),borderColor:w.string().optional().describe("Border color as hex (view nodes)."),borderWidth:w.number().min(0).optional().describe("Border thickness in px (view nodes)."),borderRadius:w.number().min(0).optional().describe("Corner radius in px (view/container nodes)."),borderStyle:w.enum(["solid","dashed","dotted"]).optional().describe("Border line style (view nodes)."),overflow:w.enum(["hidden","visible"]).optional().describe("Clip content to the node bounds (view & text nodes)."),iconColor:w.string().optional().describe("Tint for FontAwesome icon sources as hex; ignored for raster/SVG (image nodes)."),resizeMode:w.enum(["cover","contain","fill","none"]).optional().describe("How the image fits its bounds (image nodes)."),stickyColor:w.enum(["yellow","pink","green","blue","orange","purple"]).optional().describe("Sticky note color (sticky nodes)."),stickyVariant:w.enum(["note","node"]).optional().describe('Sticky note presentation (sticky nodes): "note" = folded sticky-paper look (default), "node" = clean flat card with the color as a thin border accent.')},nc={content:w.string().optional().describe("A TEXT node's visible body \u2014 THIS is what renders on canvas. name/description are metadata and are NOT painted; set `content` for visible text."),title:w.string().optional().describe("A STICKY note's heading text (sticky nodes).")},Gz=[...Object.keys(nc),...Object.keys(rc)];function cf(t){let e={};for(let r of Gz)t[r]!==void 0&&(e[r]=t[r]);return e}function sb(t){return(t??[]).map(e=>({id:e.id??Zr(),to:e.to,...e.fromPort?{fromPort:e.fromPort}:{},...e.toPort?{toPort:e.toPort}:{}}))}var uf;async function sc(t){let e;if(uf!==void 0)e=uf;else try{e=await t.guidance(),uf=e}catch(o){console.error("flowpad-mcp: could not fetch guidance from backend; using minimal fallback.",o),e="Flowpad is a visual canvas of nodes. Read a project (get_project / get_outline) before editing, then write changes with apply_edit / add_node / connect_nodes. (Full design guidance was unavailable.)"}let r=t.getUpdateAdvisory();r&&(e+=`
44
+ ]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function Yi(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===k.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??ze(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===k.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Xi(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===k.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===k.ZodBranded&&t.keyType._def.type._def.typeName===k.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Ji(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function dg(t,e){if(e.mapStrategy==="record")return Yi(t,e);let r=V(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||ze(e),n=V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||ze(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function pg(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function fg(t){return t.target==="openAi"?void 0:{not:ze({...t,currentPath:[...t.currentPath,"not"]})}}function mg(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var us={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function gg(t,e){if(e.target==="openApi3")return hg(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in us&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=us[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return hg(t,e)}var hg=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>V(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function _g(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:us[t.innerType._def.typeName],nullable:!0}:{type:[us[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=V(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function yg(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",Dl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?oe(r,"minimum",n.value,n.message,e):oe(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),oe(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?oe(r,"maximum",n.value,n.message,e):oe(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),oe(r,"maximum",n.value,n.message,e));break;case"multipleOf":oe(r,"multipleOf",n.value,n.message,e);break}return r}function vg(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=H$(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=V(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=V$(t,e);return i!==void 0&&(n.additionalProperties=i),n}function V$(t,e){if(t.catchall._def.typeName!=="ZodNever")return V(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function H$(t){try{return t.isOptional()}catch{return!0}}var bg=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return V(t.innerType._def,e);let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:ze(e)},r]}:ze(e)};var wg=(t,e)=>{if(e.pipeStrategy==="input")return V(t.in._def,e);if(e.pipeStrategy==="output")return V(t.out._def,e);let r=V(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=V(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function xg(t,e){return V(t.type._def,e)}function Sg(t,e){let n={type:"array",uniqueItems:!0,items:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&oe(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&oe(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function $g(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:V(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function Eg(t){return{not:ze(t)}}function kg(t){return ze(t)}var Tg=(t,e)=>V(t.innerType._def,e);var Pg=(t,e,r)=>{switch(e){case k.ZodString:return Xi(t,r);case k.ZodNumber:return yg(t,r);case k.ZodObject:return vg(t,r);case k.ZodBigInt:return rg(t,r);case k.ZodBoolean:return ng();case k.ZodDate:return Ll(t,r);case k.ZodUndefined:return Eg(r);case k.ZodNull:return mg(r);case k.ZodArray:return tg(t,r);case k.ZodUnion:case k.ZodDiscriminatedUnion:return gg(t,r);case k.ZodIntersection:return cg(t,r);case k.ZodTuple:return $g(t,r);case k.ZodRecord:return Yi(t,r);case k.ZodLiteral:return ug(t,r);case k.ZodEnum:return ag(t);case k.ZodNativeEnum:return pg(t);case k.ZodNullable:return _g(t,r);case k.ZodOptional:return bg(t,r);case k.ZodMap:return dg(t,r);case k.ZodSet:return Sg(t,r);case k.ZodLazy:return()=>t.getter()._def;case k.ZodPromise:return xg(t,r);case k.ZodNaN:case k.ZodNever:return fg(r);case k.ZodEffects:return ig(t,r);case k.ZodAny:return ze(r);case k.ZodUnknown:return kg(r);case k.ZodDefault:return sg(t,r);case k.ZodBranded:return Ji(t,r);case k.ZodReadonly:return Tg(t,r);case k.ZodCatch:return og(t,r);case k.ZodPipeline:return wg(t,r);case k.ZodFunction:case k.ZodVoid:case k.ZodSymbol:return;default:return(n=>{})(e)}};function V(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Yh)return a}if(n&&!r){let a=G$(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=Pg(t,t.typeName,e),i=typeof s=="function"?V(s(),e):s;if(i&&B$(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var G$=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Wi(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),ze(e)):e.$refStrategy==="seen"?ze(e):void 0}},B$=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var ql=(t,e)=>{let r=eg(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:V(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??ze(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=V(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??ze(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.title=i),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=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};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 K$(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Fl(t,e){return Pt(t)?ul(t,{target:K$(e?.target),io:e?.pipeStrategy??"input"}):ql(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Vl(t){let r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ki(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Hl(t,e){let r=Pr(t,e);if(!r.success)throw r.error;return r.data}var W$=6e4,Qi=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wi,r=>{this._oncancel(r)}),this.setNotificationHandler($i,r=>{this._onprogress(r)}),this.setRequestHandler(Si,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ei,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(M.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ti,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,h=new N(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 ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new N(M.InvalidParams,`Task not found: ${s}`);if(!Ir(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Ir(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[xr]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Pi,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new N(M.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ii,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(M.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ir(o.status))throw new N(M.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new N(M.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof N?o:new N(M.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),N.fromError(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),cr(s)||Vn(s)?this._onresponse(s):Sr(s)?this._onrequest(s,i):wh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=N.fromError(M.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[xr]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:M.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=yh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,h)=>{if(i.signal.aborted)throw new N(M.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let p=m.relatedTask?.taskId??s;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:M.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),cr(e))n(e);else{let i=new N(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(cr(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),cr(e))o(e);else{let i=N.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof N?i:new N(M.InternalError,String(i))}}return}let s;try{let i=await this.request(e,Hn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new N(M.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Ir(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new N(M.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new N(M.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof N?i:new N(M.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[xr]:c}});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:o,resumptionToken:s,onresumptiontoken:i}).catch(y=>this._onerror(new Error(`Failed to send cancellation: ${y}`)));let S=v instanceof N?v:new N(M.RequestTimeout,String(v));l(S)};this._responseHandlers.set(h,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let S=Pr(r,v.result);S.success?u(S.data):l(S.error)}catch(S){l(S)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let f=n?.timeout??W$,g=()=>p(N.fromError(M.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let _=c?.taskId;if(_){let v=S=>{let y=this._responseHandlers.get(h);y?y(S):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(_,{type:"request",message:m,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(h),l(S)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(h),l(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ki,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Ri,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Sh,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[xr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[xr]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[xr]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Vl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Hl(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Vl(e);this._notificationHandlers.set(n,o=>{let s=Hl(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&Sr(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new N(M.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new N(M.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new N(M.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new N(M.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=ts.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ir(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new N(M.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ir(a.status))throw new N(M.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=ts.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ir(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Rg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ig(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Rg(i)&&Rg(s)?r[o]={...i,...s}:r[o]=s}return r}var wv=Ws(zp(),1),xv=Ws(bv(),1);function YI(){let t=new wv.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,xv.default)(t),t}var Aa=class{constructor(e){this._ajv=e??YI()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ca=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(h=>h.type==="tool_use").map(h=>h.id)),d=new Set(s.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:e},os,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){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 s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Kn,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function Sv(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function $v(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Ma=class extends Qi{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ns.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Aa,this.setRequestHandler(xi,n=>this._oninitialize(n)),this.setNotificationHandler(Sl,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Il,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ns.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ca(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ig(this._capabilities,e)}setRequestHandler(e,r){let o=Rr(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Pt(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Pr(Bn,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new N(M.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,h=await Promise.resolve(r(c,u));if(d.task){let p=Pr(Hn,h);if(!p.success){let f=p.error instanceof Error?p.error.message:String(p.error);throw new N(M.InvalidParams,`Invalid task creation result: ${f}`)}return p.data}let m=Pr(ji,h);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new N(M.InvalidParams,`Invalid tools/call result: ${p}`)}return m.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){$v(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Sv(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Fn.includes(r)?r:vl,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"},bi)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},zl,r):this.request({method:"sampling/createMessage",params:e},os,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},Kn,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Kn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new N(M.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof N?i:new N(M.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Ol,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var kv=Symbol.for("mcp.completable");function Lp(t){return!!t&&typeof t=="object"&&kv in t}function Tv(t){return t[kv]?.complete}var Ev;(function(t){t.Completable="McpCompletable"})(Ev||(Ev={}));var QI=/^[A-Za-z0-9._-]{1,128}$/;function ez(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!QI.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function tz(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Zp(t){let e=ez(t);return tz(t,e.warnings),e.isValid}var ja=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};var Da=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Ma(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ja(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(Mi)),this.server.assertCanSetRequestHandler(Lr(Bn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Mi,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=so(r.inputSchema);return o?Fl(o,{strictUnions:!0,pipeStrategy:"input"}):rz})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=so(r.outputSchema);o&&(n.outputSchema=Fl(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Bn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new N(M.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new N(M.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new N(M.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof N&&n.code===M.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let s=so(e.inputSchema)??e.inputSchema,i=await Gi(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=Bi(a);throw new N(M.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new N(M.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=so(e.outputSchema),s=await Gi(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=Bi(i);throw new N(M.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let d=await n.taskStore.getTask(c);if(!d)throw new N(M.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Lr(Di)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Di,async e=>{switch(e.params.ref.type){case"ref/prompt":return Rh(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Ih(e),this.handleResourceCompletion(e,e.params.ref);default:throw new N(M.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new N(M.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Ls;let s=Rr(n.argsSchema)?.[e.params.argument.name];if(!Lp(s))return Ls;let i=Tv(s);if(!i)return Ls;let a=await i(e.params.argument.value,e.params.context);return Rv(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Ls;throw new N(M.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return Ls;let s=await o(e.params.argument.value,e.params.context);return Rv(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(zi)),this.server.assertCanSetRequestHandler(Lr(Oi)),this.server.assertCanSetRequestHandler(Lr(Ni)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(zi,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(Oi,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ni,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new N(M.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new N(M.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Lr(Ai)),this.server.assertCanSetRequestHandler(Lr(Ci)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ai,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?nz(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ci,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new N(M.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new N(M.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=so(n.argsSchema),s=await Gi(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=Bi(c);throw new N(M.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:hn(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=hn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof lt?c._def?.innerType:c;return Lp(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){Zp(e);let l={title:r,description:n,inputSchema:Pv(o),outputSchema:Pv(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Zp(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=hn(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=hn(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(Up(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Up(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var rz={type:"object",properties:{}};function Iv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function zv(t){return"_def"in t||"_zod"in t||Iv(t)}function Up(t){return typeof t!="object"||t===null||zv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Iv)}function Pv(t){if(t){if(Up(t))return hn(t);if(!zv(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function nz(t){let e=Rr(t);return e?Object.entries(e).map(([r,n])=>{let o=Wh(n),s=Jh(n);return{name:r,description:o,required:!s}}):[]}function Lr(t){let r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ki(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Rv(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Ls={completion:{values:[],hasMore:!1}};import{randomUUID as oz}from"node:crypto";function Zr(){return oz()}function Ov(t){let e={x:t.bounds?.x??0,y:t.bounds?.y??0,width:t.bounds?.width??240,height:t.bounds?.height??120};return qp({id:t.id,bounds:e,children:[],parent:t.parentId??null,edges:[],...t.type?{type:t.type}:{},...t.name?{name:t.name}:{},...t.description?{description:t.description}:{},...t.isAutoLayout!=null?{isAutoLayout:t.isAutoLayout}:{},...t.layout?{layout:t.layout}:{},...t.style??{}})}function qp(t){if(t.type!=="text")return t;let e=t.content;if(typeof e=="string"&&e.length>0)return t;let r=t.description??t.name;return r?{...t,content:r}:t}function Nv(t){return!t.added?.length&&!t.updated?.length&&!t.removedIds?.length}var lf=Ws(of(),1);var pe=Ws(of(),1);function sf(t,e=0){return(0,pe.validateDiffPayload)(t,e)}function sb(t){let e={nodes:structuredClone(t)};(0,pe.layoutContainerChildren)(e);let r=e.nodes;return{nodes:r.map(n=>({id:String(n.id),bounds:n.bounds})),overflows:(0,pe.detectLayoutOverflows)(r)}}function ib(){let t=Object.entries(pe.NODE_RULES.STYLE_CAPABILITIES).filter(([,e])=>e.length>0).map(([e,r])=>` ${e}: ${r.join(", ")}`);return["FLOWPAD ENGINE \u2014 rules an edit must satisfy (validated locally before send):","","NODES",` allowed types: ${pe.NODE_RULES.ALLOWED_TYPES.join(", ")}`,` name \u2264 ${pe.NODE_RULES.NAME_MAX_LENGTH} chars; \u2264 ${pe.NODE_RULES.MAX_CHILDREN} children/node;`,` \u2264 ${pe.NODE_RULES.MAX_EDGES_PER_NODE} edges/node; \u2264 ${pe.NODE_RULES.MAX_NODES_PER_PROJECT} nodes/project.`," box fill/border style props are type-specific:",...t," (text/sticky/image paint their own colors via separate fields, not these.)","","BOUNDS (x, y, width, height \u2014 all finite numbers)",` width/height \u2265 0 (0 collapses a flex item; negative rejected), \u2264 ${pe.BOUNDS_RULES.MAX_WIDTH}.`,` x/y within ${pe.BOUNDS_RULES.MIN_COORDINATE}\u2026${pe.BOUNDS_RULES.MAX_COORDINATE}.`,"","LAYOUT (only when isAutoLayout:true \u2014 node becomes a flex container)",` flexDirection: ${pe.LAYOUT_RULES.ALLOWED_FLEX_DIRECTIONS.join(" | ")}`,` justifyContent: ${pe.LAYOUT_RULES.ALLOWED_JUSTIFY_CONTENT.join(" | ")}`,` alignItems: ${pe.LAYOUT_RULES.ALLOWED_ALIGN_ITEMS.join(" | ")}`,` gap ${pe.LAYOUT_RULES.MIN_GAP}\u2026${pe.LAYOUT_RULES.MAX_GAP}, padding ${pe.LAYOUT_RULES.MIN_PADDING}\u2026${pe.LAYOUT_RULES.MAX_PADDING},`,` margin ${pe.LAYOUT_RULES.MIN_MARGIN}\u2026${pe.LAYOUT_RULES.MAX_MARGIN}, flexGrow/Shrink ${pe.LAYOUT_RULES.MIN_FLEX_GROW}\u2026${pe.LAYOUT_RULES.MAX_FLEX_GROW}.`," defaults are browser-parity: flexShrink 1, flexWrap nowrap, alignItems stretch.","","EDGES (connections FROM a node TO another)",` ports: ${pe.EDGE_RULES.ALLOWED_PORTS.join(", ")}; no self-loops; no dangling targets.`," direction rule: an edge may NOT point INTO a task node \u2014 connect task\u2192regular,"," never regular\u2192task or task\u2192task (such edges are dropped)."].join(`
45
+ `)}var ve=t=>({content:[{type:"text",text:t}]}),Rn=t=>ve(`Proposed for the user's review: ${t}. They are viewing this project, so the change is waiting in their accept/reject preview \u2014 nothing is saved until they approve it.`),Oe=t=>({content:[{type:"text",text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}),ab=b.object({x:b.number().optional(),y:b.number().optional(),width:b.number().optional(),height:b.number().optional()}).describe("Position/size. Missing fields default to x:0 y:0 w:240 h:120."),oc=b.enum(["top","right","bottom","left"]),cb=b.object({id:b.string().optional().describe("Edge id; a fresh one is minted if omitted."),to:b.string().describe("Target node id this edge points to."),fromPort:oc.optional(),toPort:oc.optional()}).describe("A connection FROM this node TO another node. Direction rule: you may NOT point an edge INTO a task node \u2014 connect task\u2192regular, never regular\u2192task or task\u2192task (invalid edges are dropped server-side)."),af=b.object({flexDirection:b.enum(["row","row-reverse","column","column-reverse"]).optional(),flexWrap:b.enum(["nowrap","wrap","wrap-reverse"]).optional(),justifyContent:b.enum(["flex-start","center","flex-end","space-between","space-around","space-evenly"]).optional(),alignItems:b.enum(["flex-start","center","flex-end","stretch","baseline"]).optional(),alignSelf:b.enum(["flex-start","center","flex-end","stretch","baseline","auto"]).optional(),gap:b.number().optional(),padding:b.number().optional(),paddingTop:b.number().optional(),paddingRight:b.number().optional(),paddingBottom:b.number().optional(),paddingLeft:b.number().optional(),margin:b.number().optional(),marginTop:b.number().optional(),marginRight:b.number().optional(),marginBottom:b.number().optional(),marginLeft:b.number().optional(),flexGrow:b.number().optional(),flexShrink:b.number().optional()}).describe("Flexbox layout (standard CSS semantics). CONTAINER props position this node's children: flexDirection, justifyContent (main axis), alignItems (cross axis), gap, padding. PER-CHILD props control how THIS node behaves inside its parent: flexGrow, flexShrink, alignSelf, margin. Engine defaults are browser-parity \u2014 flexShrink 1, flexWrap nowrap, alignItems stretch \u2014 so set flexShrink:0 / a fixed bound only when you want NO shrinking. Use flexGrow:1 on siblings to share a row/column equally without computing widths. A node is a flex container only when isAutoLayout:true."),rc={textColor:b.string().optional().describe('Text fill color as hex, e.g. "#FFFFFF" (text nodes).'),fontSize:b.number().min(6).max(200).optional().describe("Font size in px, 6\u2013200 (text nodes)."),textAlign:b.enum(["left","center","right"]).optional().describe("Horizontal text alignment within the node (text nodes)."),backgroundColor:b.string().optional().describe("Fill color as hex (view/container nodes)."),borderColor:b.string().optional().describe("Border color as hex (view nodes)."),borderWidth:b.number().min(0).optional().describe("Border thickness in px (view nodes)."),borderRadius:b.number().min(0).optional().describe("Corner radius in px (view/container nodes)."),borderStyle:b.enum(["solid","dashed","dotted"]).optional().describe("Border line style (view nodes)."),overflow:b.enum(["hidden","visible"]).optional().describe("Clip content to the node bounds (view & text nodes)."),iconColor:b.string().optional().describe("Tint for FontAwesome icon sources as hex; ignored for raster/SVG (image nodes)."),resizeMode:b.enum(["cover","contain","fill","none"]).optional().describe("How the image fits its bounds (image nodes)."),stickyColor:b.enum(["yellow","pink","green","blue","orange","purple"]).optional().describe("Sticky note color (sticky nodes)."),stickyVariant:b.enum(["note","node"]).optional().describe('Sticky note presentation (sticky nodes): "note" = folded sticky-paper look (default), "node" = clean flat card with the color as a thin border accent.')},nc={content:b.string().optional().describe("A TEXT node's visible body \u2014 THIS is what renders on canvas. name/description are metadata and are NOT painted; set `content` for visible text."),title:b.string().optional().describe("A STICKY note's heading text (sticky nodes).")},Yz=[...Object.keys(nc),...Object.keys(rc)];function cf(t){let e={};for(let r of Yz)t[r]!==void 0&&(e[r]=t[r]);return e}function ub(t){return(t??[]).map(e=>({id:e.id??Zr(),to:e.to,...e.fromPort?{fromPort:e.fromPort}:{},...e.toPort?{toPort:e.toPort}:{}}))}var uf;async function sc(t){let e;if(uf!==void 0)e=uf;else try{e=await t.guidance(),uf=e}catch(o){console.error("flowpad-mcp: could not fetch guidance from backend; using minimal fallback.",o),e="Flowpad is a visual canvas of nodes. Read a project (get_project / get_outline) before editing, then write changes with apply_edit / add_node / connect_nodes. (Full design guidance was unavailable.)"}let r=t.getUpdateAdvisory();r&&(e+=`
46
46
 
47
- \u26A0 UPDATE AVAILABLE: a newer flowpad-mcp (v${r}) is out. Tell the user to update with: npx flowpad-mcp@latest.`);let n=new Da({name:"flowpad-mcp",version:ss},{instructions:e});return n.server.oninitialized=()=>{t.setClientName(n.server.getClientVersion()?.name)},n.tool("list_projects","List Flowpad projects for the logged-in user. Optionally filter by a substring of the project name. Returns id + name for each match.",{query:w.string().optional().describe("Case-insensitive substring to match against project names.")},async({query:o})=>{try{let{data:s}=await t.listProjects(o);if(s.length===0)return ve(o?`No projects matching "${o}".`:"No projects found.");let i=s.map(a=>`- ${a.name} (id: ${a.id})`);return ve(`${s.length} project(s):
47
+ \u26A0 UPDATE AVAILABLE: a newer flowpad-mcp (v${r}) is out. Tell the user to update with: npx flowpad-mcp@latest.`);let n=new Da({name:"flowpad-mcp",version:cs},{instructions:e});return n.server.oninitialized=()=>{t.setClientName(n.server.getClientVersion()?.name)},n.tool("list_projects","List Flowpad projects for the logged-in user. Optionally filter by a substring of the project name. Returns id + name for each match.",{query:b.string().optional().describe("Case-insensitive substring to match against project names.")},async({query:o})=>{try{let{data:s}=await t.listProjects(o);if(s.length===0)return ve(o?`No projects matching "${o}".`:"No projects found.");let i=s.map(a=>`- ${a.name} (id: ${a.id})`);return ve(`${s.length} project(s):
48
48
  ${i.join(`
49
- `)}`)}catch(s){return Oe(s)}}),n.tool("get_project","Get a single Flowpad project: its current revision and a summary of its canvas nodes (id, type, name, parent). Use this to understand the canvas before editing.",{projectId:w.string().describe("The project UUID.")},async({projectId:o})=>{try{let s=await t.getProjectRaw(o),i=s.latestData??[],a=`Project "${s.name}" (id: ${s.id})
49
+ `)}`)}catch(s){return Oe(s)}}),n.tool("get_project","Get a single Flowpad project: its current revision and a summary of its canvas nodes (id, type, name, parent). Use this to understand the canvas before editing.",{projectId:b.string().describe("The project UUID.")},async({projectId:o})=>{try{let s=await t.getProjectRaw(o),i=s.latestData??[],a=`Project "${s.name}" (id: ${s.id})
50
50
  revision: ${s.version}
51
51
  nodes: ${i.length}`;if(i.length===0)return ve(`${a}
52
52
  (empty canvas)`);let c=i.slice(0,200).map(u=>`- #${u.id} ${u.type??"node"}${u.name?` "${u.name}"`:""}${u.parent!==null&&u.parent!==void 0?` (parent #${u.parent})`:""}`);return ve(`${a}
53
53
  ${c.join(`
54
- `)}`)}catch(s){return Oe(s)}}),n.tool("get_outline","Get a compact, depth-limited outline of a project's canvas (node ids, types, names, child counts). Like `ls -R` for the canvas \u2014 use it to understand structure before drilling in. Scales to large canvases.",{projectId:w.string().describe("The project UUID."),maxDepth:w.number().int().min(0).max(4).optional().describe("How deep to expand the tree. Default 2.")},async({projectId:o,maxDepth:s})=>{try{return ve(await t.outline(o,s))}catch(i){return Oe(i)}}),n.tool("search_nodes","Search a project's canvas for nodes by name/description substring, type, parent id, and/or faceted labels (category bucket, tag). Paginated. Like `grep` for the canvas \u2014 use it to locate the nodes you need to read or edit. Run get_outline first to see which categories/tags exist.",{projectId:w.string().describe("The project UUID."),query:w.string().optional().describe("Case-insensitive substring matched against name/description."),type:w.string().optional().describe("Restrict to a node type, e.g. 'text', 'view', 'container'."),parentId:w.string().optional().describe("Restrict to direct children of this node id."),category:w.string().optional().describe("Exact-match a node's coarse `category` bucket, e.g. 'auth'."),tag:w.string().optional().describe("Match nodes whose `tags` include this tag, e.g. 'platform:ios'."),limit:w.number().int().min(1).max(100).optional().describe("Default 20."),offset:w.number().int().min(0).optional().describe("For pagination.")},async({projectId:o,query:s,type:i,parentId:a,category:c,tag:u,limit:l,offset:d})=>{try{let h=await t.searchNodes(o,{query:s,type:i,parentId:a,category:c,tag:u,limit:l,offset:d});return ve(h)}catch(h){return Oe(h)}}),n.tool("get_node","Get a single node's full fields plus its subtree to a given depth. Like `cat` for a canvas node \u2014 use after get_outline/search_nodes to read just the part you care about.",{projectId:w.string().describe("The project UUID."),nodeId:w.string().describe("The node id to inspect."),depth:w.number().int().min(0).max(4).optional().describe("How many child levels to include. Default 1.")},async({projectId:o,nodeId:s,depth:i})=>{try{return ve(await t.getNode(o,s,i))}catch(a){return Oe(a)}}),n.tool("analyze_project","Analyze a project's canvas: structural stats (node/type counts, root count, max nesting depth) plus deterministic layout-overflow warnings (flex containers whose children can't fit). Lead with this to gauge the shape and health of a project before editing.",{projectId:w.string().describe("The project UUID.")},async({projectId:o})=>{try{return ve(await t.analyze(o))}catch(s){return Oe(s)}}),n.tool("query_connections",'Answer relationship/rollup questions about a project canvas using edges + work items \u2014 e.g. "how many bugs are attached to the header", "what is connected to this feature", project-wide work-item counts by type/status. Pass nodeId OR nodeName to focus on one node; omit both for a project-wide rollup. Use this instead of inferring relationships from the raw node tree. (To CREATE work items or connections, use apply_edit: add a `type:"task"` node \u2014 the backend creates its task record automatically \u2014 and put an edge in the source node\'s `edges` array.)',{projectId:w.string().describe("The project UUID."),nodeId:w.string().optional().describe("Focus node id. Omit for a project-wide rollup."),nodeName:w.string().optional().describe("Focus node by name. Omit for a project-wide rollup.")},async({projectId:o,nodeId:s,nodeName:i})=>{try{return ve(await t.connections(o,{nodeId:s,nodeName:i}))}catch(a){return Oe(a)}}),n.tool("describe_engine","Describe the Flowpad layout engine you are designing for: allowed node types, bounds/layout/edge rules and limits. Read this BEFORE building a non-trivial design so what you produce is valid on the first try. Answered locally from the bundled engine (no network, instant).",{},async()=>{try{return ve(rb())}catch(o){return Oe(o)}}),n.tool("validate_design","Check a canvas diff against the engine rules LOCALLY, before sending it. Pass the same added/updated/removedIds you intend to give apply_edit; get back either OK or a precise, fixable reason. Runs on your machine via the bundled engine (no network) \u2014 use it to self-correct before committing a change. apply_edit runs this same check, so a passing result means apply_edit won't reject the shape.",{added:w.array(w.record(w.unknown())).optional().describe("Nodes you plan to add (same shape as apply_edit.added)."),updated:w.array(w.record(w.unknown())).optional().describe("Node patches you plan to apply (same shape as apply_edit.updated)."),removedIds:w.array(w.string()).optional().describe("Node ids you plan to remove."),existingNodeCount:w.number().int().min(0).optional().describe("Current node count in the project (for size-limit checks). Omit if unknown.")},async({added:o,updated:s,removedIds:i,existingNodeCount:a})=>{try{let c=sf({added:o,updated:s,removedIds:i},a??0);return c.valid?ve("\u2713 Valid \u2014 this design satisfies the engine rules. Safe to apply_edit."):ve(`\u2717 Invalid (rule: ${c.rule}): ${c.message}
55
- Fix this and re-check before apply_edit.`)}catch(c){return Oe(c)}}),n.tool("preview_layout","Preview where an auto-layout container's children will be positioned, using the REAL layout engine \u2014 locally, no network. Pass the container + its children (same node shape as apply_edit, with bounds/layout/isAutoLayout/children/parent). Returns each node's computed bounds so you can verify a frame tree renders as intended BEFORE apply_edit, instead of hand-computing x/y. Only nodes inside an isAutoLayout container are repositioned.",{nodes:w.array(w.record(w.unknown())).describe("The container + children to lay out (apply_edit node shape: bounds, layout, isAutoLayout, children, parent).")},async({nodes:o})=>{try{let{nodes:s,overflows:i}=tb(o),a=s.map(u=>`- #${u.id}: x=${Math.round(u.bounds.x)} y=${Math.round(u.bounds.y)} w=${Math.round(u.bounds.width)} h=${Math.round(u.bounds.height)}`),c=i.length?`
54
+ `)}`)}catch(s){return Oe(s)}}),n.tool("get_outline","Get a compact, depth-limited outline of a project's canvas (node ids, types, names, child counts). Like `ls -R` for the canvas \u2014 use it to understand structure before drilling in. Scales to large canvases.",{projectId:b.string().describe("The project UUID."),maxDepth:b.number().int().min(0).max(4).optional().describe("How deep to expand the tree. Default 2.")},async({projectId:o,maxDepth:s})=>{try{return ve(await t.outline(o,s))}catch(i){return Oe(i)}}),n.tool("search_nodes","Search a project's canvas for nodes by name/description substring, type, parent id, and/or faceted labels (category bucket, tag). Paginated. Like `grep` for the canvas \u2014 use it to locate the nodes you need to read or edit. Run get_outline first to see which categories/tags exist.",{projectId:b.string().describe("The project UUID."),query:b.string().optional().describe("Case-insensitive substring matched against name/description."),type:b.string().optional().describe("Restrict to a node type, e.g. 'text', 'view', 'container'."),parentId:b.string().optional().describe("Restrict to direct children of this node id."),category:b.string().optional().describe("Exact-match a node's coarse `category` bucket, e.g. 'auth'."),tag:b.string().optional().describe("Match nodes whose `tags` include this tag, e.g. 'platform:ios'."),limit:b.number().int().min(1).max(100).optional().describe("Default 20."),offset:b.number().int().min(0).optional().describe("For pagination.")},async({projectId:o,query:s,type:i,parentId:a,category:c,tag:u,limit:l,offset:d})=>{try{let h=await t.searchNodes(o,{query:s,type:i,parentId:a,category:c,tag:u,limit:l,offset:d});return ve(h)}catch(h){return Oe(h)}}),n.tool("get_node","Get a single node's full fields plus its subtree to a given depth. Like `cat` for a canvas node \u2014 use after get_outline/search_nodes to read just the part you care about.",{projectId:b.string().describe("The project UUID."),nodeId:b.string().describe("The node id to inspect."),depth:b.number().int().min(0).max(4).optional().describe("How many child levels to include. Default 1.")},async({projectId:o,nodeId:s,depth:i})=>{try{return ve(await t.getNode(o,s,i))}catch(a){return Oe(a)}}),n.tool("analyze_project","Analyze a project's canvas: structural stats (node/type counts, root count, max nesting depth) plus deterministic layout-overflow warnings (flex containers whose children can't fit). Lead with this to gauge the shape and health of a project before editing.",{projectId:b.string().describe("The project UUID.")},async({projectId:o})=>{try{return ve(await t.analyze(o))}catch(s){return Oe(s)}}),n.tool("query_connections",'Answer relationship/rollup questions about a project canvas using edges + work items \u2014 e.g. "how many bugs are attached to the header", "what is connected to this feature", project-wide work-item counts by type/status. Pass nodeId OR nodeName to focus on one node; omit both for a project-wide rollup. Use this instead of inferring relationships from the raw node tree. (To CREATE work items or connections, use apply_edit: add a `type:"task"` node \u2014 the backend creates its task record automatically \u2014 and put an edge in the source node\'s `edges` array.)',{projectId:b.string().describe("The project UUID."),nodeId:b.string().optional().describe("Focus node id. Omit for a project-wide rollup."),nodeName:b.string().optional().describe("Focus node by name. Omit for a project-wide rollup.")},async({projectId:o,nodeId:s,nodeName:i})=>{try{return ve(await t.connections(o,{nodeId:s,nodeName:i}))}catch(a){return Oe(a)}}),n.tool("describe_engine","Describe the Flowpad layout engine you are designing for: allowed node types, bounds/layout/edge rules and limits. Read this BEFORE building a non-trivial design so what you produce is valid on the first try. Answered locally from the bundled engine (no network, instant).",{},async()=>{try{return ve(ib())}catch(o){return Oe(o)}}),n.tool("validate_design","Check a canvas diff against the engine rules LOCALLY, before sending it. Pass the same added/updated/removedIds you intend to give apply_edit; get back either OK or a precise, fixable reason. Runs on your machine via the bundled engine (no network) \u2014 use it to self-correct before committing a change. apply_edit runs this same check, so a passing result means apply_edit won't reject the shape.",{added:b.array(b.record(b.unknown())).optional().describe("Nodes you plan to add (same shape as apply_edit.added)."),updated:b.array(b.record(b.unknown())).optional().describe("Node patches you plan to apply (same shape as apply_edit.updated)."),removedIds:b.array(b.string()).optional().describe("Node ids you plan to remove."),existingNodeCount:b.number().int().min(0).optional().describe("Current node count in the project (for size-limit checks). Omit if unknown.")},async({added:o,updated:s,removedIds:i,existingNodeCount:a})=>{try{let c=sf({added:o,updated:s,removedIds:i},a??0);return c.valid?ve("\u2713 Valid \u2014 this design satisfies the engine rules. Safe to apply_edit."):ve(`\u2717 Invalid (rule: ${c.rule}): ${c.message}
55
+ Fix this and re-check before apply_edit.`)}catch(c){return Oe(c)}}),n.tool("preview_layout","Preview where an auto-layout container's children will be positioned, using the REAL layout engine \u2014 locally, no network. Pass the container + its children (same node shape as apply_edit, with bounds/layout/isAutoLayout/children/parent). Returns each node's computed bounds so you can verify a frame tree renders as intended BEFORE apply_edit, instead of hand-computing x/y. Only nodes inside an isAutoLayout container are repositioned.",{nodes:b.array(b.record(b.unknown())).describe("The container + children to lay out (apply_edit node shape: bounds, layout, isAutoLayout, children, parent).")},async({nodes:o})=>{try{let{nodes:s,overflows:i}=sb(o),a=s.map(u=>`- #${u.id}: x=${Math.round(u.bounds.x)} y=${Math.round(u.bounds.y)} w=${Math.round(u.bounds.width)} h=${Math.round(u.bounds.height)}`),c=i.length?`
56
56
 
57
57
  \u26A0 Overflow (${i.length}):
58
58
  ${i.map(u=>`- ${u}`).join(`
@@ -60,9 +60,9 @@ ${i.map(u=>`- ${u}`).join(`
60
60
 
61
61
  \u2713 No overflow \u2014 children fit their containers.`;return ve(`Computed layout (${s.length} node(s)):
62
62
  ${a.join(`
63
- `)}${c}`)}catch(s){return Oe(s)}}),n.tool("apply_edit","Apply a targeted edit to a project's canvas: add, update, and/or remove nodes in one diff. Build the edit yourself from what you read via get_outline/search_nodes/get_node. New nodes get ids assigned automatically if omitted. On a revision conflict the edit is NOT force-written \u2014 re-read the latest and reapply.",{projectId:w.string().describe("The project UUID."),added:w.array(w.object({id:w.string().optional(),type:w.string().optional(),name:w.string().optional(),description:w.string().optional().describe("Metadata, NOT painted. A TEXT node\u2019s visible string lives in `content`."),parent:w.string().nullable().optional(),children:w.array(w.string()).optional(),bounds:nb.optional(),category:w.string().optional().describe("Coarse discovery bucket, e.g. 'auth'."),tags:w.array(w.string()).optional().describe("Faceted labels, e.g. ['platform:ios','type:dialog']."),edges:w.array(ob).optional().describe("Connections FROM this node to other nodes. For a task node, use this to attach it to what it relates to."),isAutoLayout:w.boolean().optional().describe("Set true to make this node a flexbox container that auto-positions its children (then give it a `layout`). A container WITHOUT isAutoLayout leaves children at their absolute bounds \u2014 almost always wrong for real UI."),layout:af.optional(),...nc,...rc})).optional().describe("New nodes to add."),updated:w.array(w.object({id:w.string().describe("Existing node id to update."),type:w.string().optional(),name:w.string().optional(),description:w.string().optional().describe("Metadata, NOT painted. A TEXT node\u2019s visible string lives in `content`."),parent:w.string().nullable().optional(),bounds:nb.optional(),category:w.string().optional().describe("Coarse discovery bucket."),tags:w.array(w.string()).optional().describe("Replaces the node's tags."),edges:w.array(ob).optional().describe("Replaces the node's outgoing connections."),isAutoLayout:w.boolean().optional().describe("Toggle whether this node is a flexbox container."),layout:af.optional().describe("Merged onto the node's existing layout."),...nc,...rc})).optional().describe("Patches to existing nodes (merged onto current values)."),removedIds:w.array(w.string()).optional().describe("Ids of nodes to delete.")},async({projectId:o,added:s,updated:i,removedIds:a})=>{try{let c=await t.getProjectRawCached(o),u=c.latestData??[],l=new Map(u.map(y=>[String(y.id),y])),d=new Set(l.keys());for(let y of s??[])y.id!=null&&d.add(y.id);let h=()=>{let y=Zr();for(;d.has(y);)y=Zr();return d.add(y),y},m=(s??[]).map(y=>qp({id:y.id??h(),bounds:{x:y.bounds?.x??0,y:y.bounds?.y??0,width:y.bounds?.width??240,height:y.bounds?.height??120},children:y.children??[],parent:y.parent??null,edges:sb(y.edges),...y.type?{type:y.type}:{},...y.name?{name:y.name}:{},...y.description?{description:y.description}:{},...y.category?{category:y.category}:{},...y.tags?{tags:y.tags}:{},...y.isAutoLayout!=null?{isAutoLayout:y.isAutoLayout}:{},...y.layout?{layout:y.layout}:{},...cf(y)})),p=[],f=[];for(let y of i??[]){let T=l.get(String(y.id));if(!T){f.push(y.id);continue}let F={...T};if(y.name!==void 0&&(F.name=y.name),y.description!==void 0&&(F.description=y.description),y.type!==void 0&&(F.type=y.type),y.parent!==void 0&&(F.parent=y.parent),y.bounds&&(F.bounds={...T.bounds,...y.bounds}),y.category!==void 0&&(F.category=y.category),y.tags!==void 0&&(F.tags=y.tags),y.edges!==void 0&&(F.edges=sb(y.edges)),y.isAutoLayout!==void 0&&(F.isAutoLayout=y.isAutoLayout),y.layout!==void 0){let te=T.layout??{};F.layout={...te,...y.layout}}Object.assign(F,cf(y)),p.push(F)}let g=(a??[]).map(y=>l.get(String(y))?.id).filter(y=>y!==void 0),_={};m.length&&(_.added=m),p.length&&(_.updated=p),g.length&&(_.removedIds=g);let v=f.length?` (skipped unknown update ids: ${f.join(", ")})`:"";if(Rv(_))return ve(`Nothing to apply.${v}`);let $=sf(_,u.length);if(!$.valid)return ve(`Edit not sent \u2014 local validation failed (rule: ${$.rule}): ${$.message}. This was caught on your machine before any save. Fix the nodes and retry; run validate_design to re-check.`);try{let y=[m.length?`${m.length} added (#${m.map(F=>F.id).join(", #")})`:null,p.length?`${p.length} updated`:null,g.length?`${g.length} removed`:null].filter(Boolean).join(", "),T=await t.updateProject(o,{diff:_,baseRevision:c.version});return Wn(T)?Rn(y):ve(`Applied: ${y}. New revision: ${T.version}.${v}`)}catch(y){if(y instanceof Error&&/409|conflict|revision/i.test(y.message))return t.invalidate(o),ve(`Revision conflict: the project changed since you last read it (your baseRevision ${c.version} is stale). Re-read with get_outline/get_node and reapply your edit. (Non-overlapping edits will merge automatically once server-side node-merge lands.)`);throw y}}catch(c){return Oe(c)}}),n.tool("add_node","Add a single node to a Flowpad project directly. Use for a deterministic single-node addition when you know its content. For multi-node structures build the tree yourself and use apply_edit. To make this node lay its children out with flexbox, pass isAutoLayout:true + layout.",{projectId:w.string().describe("The project UUID."),name:w.string().optional().describe("Node title (metadata, NOT painted)."),description:w.string().optional().describe("Node description (metadata, NOT painted on canvas). For a TEXT node\u2019s VISIBLE string use `content`, not this."),type:w.string().optional().describe("Node type, e.g. 'view'. Defaults to a plain node."),parentId:w.string().optional().describe("Existing node id to attach this node under."),x:w.number().optional().describe("Top-left x. Default 0."),y:w.number().optional().describe("Top-left y. Default 0."),width:w.number().optional().describe("Width. Default 240."),height:w.number().optional().describe("Height. Default 120."),isAutoLayout:w.boolean().optional().describe("Make this node a flexbox container (pair with `layout`)."),layout:af.optional(),...nc,...rc},async o=>{let{projectId:s,name:i,description:a,type:c,parentId:u,x:l,y:d,width:h,height:m,isAutoLayout:p,layout:f}=o;try{let g=await t.getProjectRaw(s),_=Zr(),v=Pv({id:_,type:c,name:i,description:a,parentId:u??null,bounds:{x:l,y:d,width:h,height:m},isAutoLayout:p,layout:f,style:cf(o)}),$=await t.updateProject(s,{diff:{added:[v]},baseRevision:g.version});return Wn($)?Rn(`1 node added${i?` ("${i}")`:""}`):ve(`Added node #${_}${i?` "${i}"`:""}. New revision: ${$.version}.`)}catch(g){return Oe(g)}}),n.tool("create_project","Create a NEW, empty project (a fresh canvas) for the user. Use this when the request is a new app/design that does NOT belong in an existing project \u2014 never dump unrelated screens into whatever project happens to be open. Returns the new project id; pass it as projectId to add_node/apply_edit to design into it. Applies immediately (a new empty project is non-destructive).",{name:w.string().describe('The project name, e.g. "Mobile App \u2014 Onboarding".'),isTemplateProject:w.boolean().optional().describe("Mark as a reusable template project. Default false.")},async({name:o,isTemplateProject:s})=>{try{let i=await t.createProject({name:o,...s!=null?{isTemplateProject:s}:{}});return"proposed"in i?Rn(`create project "${o}" (the user confirms/edits the name on their screen)`):ve(`Created project "${o}" (#${i.id}). Design into it by passing projectId:"${i.id}" to add_node / apply_edit.`)}catch(i){return Oe(i instanceof Error?i:new Error(String(i)))}}),n.tool("delete_project","Delete a project by id. DESTRUCTIVE. If the owner is currently viewing that project, the deletion is routed to their accept/reject confirm \u2014 nothing is deleted until they approve. Otherwise it deletes immediately. Use the UUID from list_projects; never guess.",{projectId:w.string().describe("The project UUID to delete.")},async({projectId:o})=>{try{return(await t.deleteProject(o)).proposed?Rn(`delete project ${o}`):ve(`Deleted project ${o}.`)}catch(s){return Oe(s instanceof Error?s:new Error(String(s)))}}),n.tool("bind_template","Install a template project INTO a project so its template nodes become available there. If the owner is viewing the target project, the bind is routed to their confirm dialog; otherwise it applies. Find template project ids via list_projects (template projects) or the project catalog. Both ids are UUIDs.",{projectId:w.string().describe("The project UUID to install the template into."),templateProjectId:w.string().describe("The template project UUID to install.")},async({projectId:o,templateProjectId:s})=>{try{return(await t.bindTemplate(o,s)).proposed?Rn(`install template ${s} into ${o}`):ve(`Installed template ${s} into project ${o}.`)}catch(i){return Oe(i instanceof Error?i:new Error(String(i)))}}),n.tool("list_templates","List the BINDABLE templates you can install into a project: bundled built-ins + the user's own template projects. Returns id + name + source for each \u2014 pick one and pass its id as bind_template's templateProjectId. (Templates already INSTALLED on a project are shown by get_project; THIS is the catalog of what you CAN add.)",{},async()=>{try{let{data:o}=await t.listTemplates();if(!o.length)return ve("No bindable templates available.");let s=o.map(i=>`- ${i.name} (id: ${i.id}, ${i.source})${i.description?` \u2014 ${i.description}`:""}`);return ve(`${o.length} template(s) you can bind:
63
+ `)}${c}`)}catch(s){return Oe(s)}}),n.tool("apply_edit","Apply a targeted edit to a project's canvas: add, update, and/or remove nodes in one diff. Build the edit yourself from what you read via get_outline/search_nodes/get_node. New nodes get ids assigned automatically if omitted. On a revision conflict the edit is NOT force-written \u2014 re-read the latest and reapply.",{projectId:b.string().describe("The project UUID."),added:b.array(b.object({id:b.string().optional(),type:b.string().optional(),name:b.string().optional(),description:b.string().optional().describe("Metadata, NOT painted. A TEXT node\u2019s visible string lives in `content`."),parent:b.string().nullable().optional(),children:b.array(b.string()).optional(),bounds:ab.optional(),category:b.string().optional().describe("Coarse discovery bucket, e.g. 'auth'."),tags:b.array(b.string()).optional().describe("Faceted labels, e.g. ['platform:ios','type:dialog']."),edges:b.array(cb).optional().describe("Connections FROM this node to other nodes. For a task node, use this to attach it to what it relates to."),isAutoLayout:b.boolean().optional().describe("Set true to make this node a flexbox container that auto-positions its children (then give it a `layout`). A container WITHOUT isAutoLayout leaves children at their absolute bounds \u2014 almost always wrong for real UI."),layout:af.optional(),...nc,...rc})).optional().describe("New nodes to add."),updated:b.array(b.object({id:b.string().describe("Existing node id to update."),type:b.string().optional(),name:b.string().optional(),description:b.string().optional().describe("Metadata, NOT painted. A TEXT node\u2019s visible string lives in `content`."),parent:b.string().nullable().optional(),bounds:ab.optional(),category:b.string().optional().describe("Coarse discovery bucket."),tags:b.array(b.string()).optional().describe("Replaces the node's tags."),edges:b.array(cb).optional().describe("Replaces the node's outgoing connections."),isAutoLayout:b.boolean().optional().describe("Toggle whether this node is a flexbox container."),layout:af.optional().describe("Merged onto the node's existing layout."),...nc,...rc})).optional().describe("Patches to existing nodes (merged onto current values)."),removedIds:b.array(b.string()).optional().describe("Ids of nodes to delete.")},async({projectId:o,added:s,updated:i,removedIds:a})=>{try{let c=await t.getProjectRawCached(o),u=c.latestData??[],l=new Map(u.map(y=>[String(y.id),y])),d=new Set(l.keys());for(let y of s??[])y.id!=null&&d.add(y.id);let h=()=>{let y=Zr();for(;d.has(y);)y=Zr();return d.add(y),y},m=(s??[]).map(y=>qp({id:y.id??h(),bounds:{x:y.bounds?.x??0,y:y.bounds?.y??0,width:y.bounds?.width??240,height:y.bounds?.height??120},children:y.children??[],parent:y.parent??null,edges:ub(y.edges),...y.type?{type:y.type}:{},...y.name?{name:y.name}:{},...y.description?{description:y.description}:{},...y.category?{category:y.category}:{},...y.tags?{tags:y.tags}:{},...y.isAutoLayout!=null?{isAutoLayout:y.isAutoLayout}:{},...y.layout?{layout:y.layout}:{},...cf(y)})),p=[],f=[];for(let y of i??[]){let T=l.get(String(y.id));if(!T){f.push(y.id);continue}let L={...T};if(y.name!==void 0&&(L.name=y.name),y.description!==void 0&&(L.description=y.description),y.type!==void 0&&(L.type=y.type),y.parent!==void 0&&(L.parent=y.parent),y.bounds&&(L.bounds={...T.bounds,...y.bounds}),y.category!==void 0&&(L.category=y.category),y.tags!==void 0&&(L.tags=y.tags),y.edges!==void 0&&(L.edges=ub(y.edges)),y.isAutoLayout!==void 0&&(L.isAutoLayout=y.isAutoLayout),y.layout!==void 0){let te=T.layout??{};L.layout={...te,...y.layout}}Object.assign(L,cf(y)),p.push(L)}let g=(a??[]).map(y=>l.get(String(y))?.id).filter(y=>y!==void 0),_={};m.length&&(_.added=m),p.length&&(_.updated=p),g.length&&(_.removedIds=g);let v=f.length?` (skipped unknown update ids: ${f.join(", ")})`:"";if(Nv(_))return ve(`Nothing to apply.${v}`);let S=sf(_,u.length);if(!S.valid)return ve(`Edit not sent \u2014 local validation failed (rule: ${S.rule}): ${S.message}. This was caught on your machine before any save. Fix the nodes and retry; run validate_design to re-check.`);try{let y=[m.length?`${m.length} added (#${m.map(L=>L.id).join(", #")})`:null,p.length?`${p.length} updated`:null,g.length?`${g.length} removed`:null].filter(Boolean).join(", "),T=await t.updateProject(o,{diff:_,baseRevision:c.version});return oo(T)?Rn(y):ve(`Applied: ${y}. New revision: ${T.version}.${v}`)}catch(y){if(y instanceof Error&&/409|conflict|revision/i.test(y.message))return t.invalidate(o),ve(`Revision conflict: the project changed since you last read it (your baseRevision ${c.version} is stale). Re-read with get_outline/get_node and reapply your edit. (Non-overlapping edits will merge automatically once server-side node-merge lands.)`);throw y}}catch(c){return Oe(c)}}),n.tool("add_node","Add a single node to a Flowpad project directly. Use for a deterministic single-node addition when you know its content. For multi-node structures build the tree yourself and use apply_edit. To make this node lay its children out with flexbox, pass isAutoLayout:true + layout.",{projectId:b.string().describe("The project UUID."),name:b.string().optional().describe("Node title (metadata, NOT painted)."),description:b.string().optional().describe("Node description (metadata, NOT painted on canvas). For a TEXT node\u2019s VISIBLE string use `content`, not this."),type:b.string().optional().describe("Node type, e.g. 'view'. Defaults to a plain node."),parentId:b.string().optional().describe("Existing node id to attach this node under."),x:b.number().optional().describe("Top-left x. Default 0."),y:b.number().optional().describe("Top-left y. Default 0."),width:b.number().optional().describe("Width. Default 240."),height:b.number().optional().describe("Height. Default 120."),isAutoLayout:b.boolean().optional().describe("Make this node a flexbox container (pair with `layout`)."),layout:af.optional(),...nc,...rc},async o=>{let{projectId:s,name:i,description:a,type:c,parentId:u,x:l,y:d,width:h,height:m,isAutoLayout:p,layout:f}=o;try{let g=await t.getProjectRaw(s),_=Zr(),v=Ov({id:_,type:c,name:i,description:a,parentId:u??null,bounds:{x:l,y:d,width:h,height:m},isAutoLayout:p,layout:f,style:cf(o)}),S=await t.updateProject(s,{diff:{added:[v]},baseRevision:g.version});return oo(S)?Rn(`1 node added${i?` ("${i}")`:""}`):ve(`Added node #${_}${i?` "${i}"`:""}. New revision: ${S.version}.`)}catch(g){return Oe(g)}}),n.tool("create_project","Create a NEW, empty project (a fresh canvas) for the user. Use this when the request is a new app/design that does NOT belong in an existing project \u2014 never dump unrelated screens into whatever project happens to be open. Returns the new project id; pass it as projectId to add_node/apply_edit to design into it. Applies immediately (a new empty project is non-destructive).",{name:b.string().describe('The project name, e.g. "Mobile App \u2014 Onboarding".'),isTemplateProject:b.boolean().optional().describe("Mark as a reusable template project. Default false.")},async({name:o,isTemplateProject:s})=>{try{let i=await t.createProject({name:o,...s!=null?{isTemplateProject:s}:{}});return"proposed"in i?Rn(`create project "${o}" (the user confirms/edits the name on their screen)`):ve(`Created project "${o}" (#${i.id}). Design into it by passing projectId:"${i.id}" to add_node / apply_edit.`)}catch(i){return Oe(i instanceof Error?i:new Error(String(i)))}}),n.tool("delete_project","Delete a project by id. DESTRUCTIVE. If the owner is currently viewing that project, the deletion is routed to their accept/reject confirm \u2014 nothing is deleted until they approve. Otherwise it deletes immediately. Use the UUID from list_projects; never guess.",{projectId:b.string().describe("The project UUID to delete.")},async({projectId:o})=>{try{return(await t.deleteProject(o)).proposed?Rn(`delete project ${o}`):ve(`Deleted project ${o}.`)}catch(s){return Oe(s instanceof Error?s:new Error(String(s)))}}),n.tool("bind_template","Install a template project INTO a project so its template nodes become available there. If the owner is viewing the target project, the bind is routed to their confirm dialog; otherwise it applies. Find template project ids via list_projects (template projects) or the project catalog. Both ids are UUIDs.",{projectId:b.string().describe("The project UUID to install the template into."),templateProjectId:b.string().describe("The template project UUID to install.")},async({projectId:o,templateProjectId:s})=>{try{return(await t.bindTemplate(o,s)).proposed?Rn(`install template ${s} into ${o}`):ve(`Installed template ${s} into project ${o}.`)}catch(i){return Oe(i instanceof Error?i:new Error(String(i)))}}),n.tool("list_templates","List the BINDABLE templates you can install into a project: bundled built-ins + the user's own template projects. Returns id + name + source for each \u2014 pick one and pass its id as bind_template's templateProjectId. (Templates already INSTALLED on a project are shown by get_project; THIS is the catalog of what you CAN add.)",{},async()=>{try{let{data:o}=await t.listTemplates();if(!o.length)return ve("No bindable templates available.");let s=o.map(i=>`- ${i.name} (id: ${i.id}, ${i.source})${i.description?` \u2014 ${i.description}`:""}`);return ve(`${o.length} template(s) you can bind:
64
64
  ${s.join(`
65
- `)}`)}catch(o){return Oe(o instanceof Error?o:new Error(String(o)))}}),n.tool("create_task","Create a work item (task / feature / bug) on a project canvas. Adds a first-class task node; the backend auto-creates the backing task record and resolves taskType/taskStatus to the workspace's tag ids by name. Optionally connect it to an existing node in one shot. This is the deterministic equivalent of the in-app AI's <AddTask> \u2014 use it to plan/track work, not just draw UI.",{projectId:w.string().describe("The project UUID."),title:w.string().describe("Short imperative summary (the task title)."),description:w.string().optional().describe("More detail about the work."),taskType:w.string().optional().describe('Work-item kind, e.g. "bug" / "feat" / "chore". Resolved to a workspace task-type tag by name; omit if unknown (run analyze_project / get_outline to learn the workspace vocabulary).'),taskStatus:w.string().optional().describe('Progress, e.g. "todo" / "in-progress" / "done". Resolved to a workspace progress tag by name; omit if unknown.'),connectTo:w.string().optional().describe("Existing node id to attach this task to. Creates an edge FROM the task TO that node (e.g. a bug attached to the header it affects)."),parentId:w.string().optional().describe("Existing node id to nest under."),x:w.number().optional().describe("Top-left x. Default 0."),y:w.number().optional().describe("Top-left y. Default 0.")},async({projectId:o,title:s,description:i,taskType:a,taskStatus:c,connectTo:u,parentId:l,x:d,y:h})=>{try{let m=await t.getProjectRaw(o),p=u?(m.latestData??[]).find($=>String($.id)===u):void 0;if(u&&!p)return Oe(new Error(`connectTo node ${u} not found in project.`));if(p&&!(0,lf.canConnectNodes)({type:"task"},p))return Oe(new Error(`Cannot connect task "${s}" to ${u}: an edge may not point INTO a task node. Connect a task to a regular node, not another task.`));let f=Zr(),g={id:f,type:"task",name:s,bounds:{x:d??0,y:h??0,width:100,height:100},children:[],parent:l??null,edges:u?[{id:Zr(),to:u}]:[],taskId:null,taskVersionNumber:null,...i?{description:i}:{},...a?{aiTaskType:a}:{},...c?{aiTaskStatus:c}:{}},_=await t.updateProject(o,{diff:{added:[g]},baseRevision:m.version}),v=u?`, connected to ${u}`:"";return Wn(_)?Rn(`task "${s}" created${v}`):ve(`Created task "${s}" (#${f}${a?`, ${a}`:""}${c?`, ${c}`:""}${v}). New revision: ${_.version}.`)}catch(m){return Oe(m)}}),n.tool("connect_nodes","Draw a connection (edge) between two EXISTING nodes \u2014 e.g. attach a bug to the feature it affects, or link a task to a design region. The edge points FROM fromId TO toId. Direction rule: you may NOT point an edge INTO a task node (connect task\u2192regular, never regular\u2192task or task\u2192task). Idempotent: re-running with the same pair is a no-op.",{projectId:w.string().describe("The project UUID."),fromId:w.string().describe("Source node id (the edge starts here)."),toId:w.string().describe("Target node id (the edge points here)."),fromPort:oc.optional(),toPort:oc.optional()},async({projectId:o,fromId:s,toId:i,fromPort:a,toPort:c})=>{try{if(s===i)return Oe(new Error("Cannot connect a node to itself."));let u=await t.getProjectRaw(o),l=u.latestData??[],d=l.find(_=>String(_.id)===s);if(!d)return Oe(new Error(`Source node ${s} not found.`));let h=l.find(_=>String(_.id)===i);if(!h)return Oe(new Error(`Target node ${i} not found.`));if(!(0,lf.canConnectNodes)(d,h))return Oe(new Error(`Cannot connect ${s} \u2192 ${i}: an edge may not point INTO a task node. Connect a task to a regular node, not another task.`));let m=Array.isArray(d.edges)?d.edges:[];if(m.some(_=>{let v=_;return v.to===i&&v.fromPort===a&&v.toPort===c}))return ve(`Edge ${s} \u2192 ${i} already exists.`);let f={...d,edges:[...m,{id:Zr(),to:i,...a?{fromPort:a}:{},...c?{toPort:c}:{}}]},g=await t.updateProject(o,{diff:{updated:[f]},baseRevision:u.version});return Wn(g)?Rn(`edge ${s} \u2192 ${i}`):ve(`Connected ${s} \u2192 ${i}. New revision: ${g.version}.`)}catch(u){return Oe(u)}}),n}import{createServer as lO}from"node:http";import{randomUUID as dO}from"node:crypto";import{Http2ServerRequest as cb,constants as Bz}from"http2";import{Http2ServerRequest as df}from"http2";import{Readable as ib}from"stream";import oO from"crypto";var In=class extends Error{constructor(t,e){super(t,e),this.name="RequestError"}},Kz=t=>t instanceof In?t:new In(t.message,{cause:t}),Wz=global.Request,qs=class extends Wz{constructor(t,e){typeof t=="object"&&Ro in t&&(t=t[Ro]()),typeof e?.body?.getReader<"u"&&(e.duplex??="half"),super(t,e)}},Jz=t=>{let e=[],r=t.rawHeaders;for(let n=0;n<r.length;n+=2){let{[n]:o,[n+1]:s}=r;o.charCodeAt(0)!==58&&e.push([o,s])}return new Headers(e)},ub=Symbol("wrapBodyStream"),Xz=(t,e,r,n,o)=>{let s={method:t,headers:r,signal:o.signal};if(t==="TRACE"){s.method="GET";let i=new qs(e,s);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(t==="GET"||t==="HEAD"))if("rawBody"in n&&n.rawBody instanceof Buffer)s.body=new ReadableStream({start(i){i.enqueue(n.rawBody),i.close()}});else if(n[ub]){let i;s.body=new ReadableStream({async pull(a){try{i||=ib.toWeb(n).getReader();let{done:c,value:u}=await i.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else s.body=ib.toWeb(n);return new qs(e,s)},Ro=Symbol("getRequestCache"),lb=Symbol("requestCache"),ic=Symbol("incomingKey"),ac=Symbol("urlKey"),Yz=Symbol("headersKey"),Po=Symbol("abortControllerKey"),Qz=Symbol("getAbortController"),Fs={get method(){return this[ic].method||"GET"},get url(){return this[ac]},get headers(){return this[Yz]||=Jz(this[ic])},[Qz](){return this[Ro](),this[Po]},[Ro](){return this[Po]||=new AbortController,this[lb]||=Xz(this.method,this[ac],this.headers,this[ic],this[Po])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(Fs,t,{get(){return this[Ro]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Fs,t,{value:function(){return this[Ro]()[t]()}})});Object.defineProperty(Fs,Symbol.for("nodejs.util.inspect.custom"),{value:function(t,e,r){let n={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[lb]};return`Request (lightweight) ${r(n,{...e,depth:t==null?null:t-1})}`}});Object.setPrototypeOf(Fs,qs.prototype);var eO=(t,e)=>{let r=Object.create(Fs);r[ic]=t;let n=t.url||"";if(n[0]!=="/"&&(n.startsWith("http://")||n.startsWith("https://"))){if(t instanceof df)throw new In("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(n);r[ac]=a.href}catch(a){throw new In("Invalid absolute URL",{cause:a})}return r}let o=(t instanceof df?t.authority:t.headers.host)||e;if(!o)throw new In("Missing host header");let s;if(t instanceof df){if(s=t.scheme,!(s==="http"||s==="https"))throw new In("Unsupported scheme")}else s=t.socket&&t.socket.encrypted?"https":"http";let i=new URL(`${s}://${o}${n}`);if(i.hostname.length!==o.length&&i.hostname!==o.replace(/:\d+$/,""))throw new In("Invalid host header");return r[ac]=i.href,r},ff=Symbol("responseCache"),To=Symbol("getResponseCache"),zn=Symbol("cache"),gf=global.Response,Io=class db{#t;#e;[To](){return delete this[zn],this[ff]||=new gf(this.#t,this.#e)}constructor(e,r){let n;if(this.#t=e,r instanceof db){let o=r[ff];if(o){this.#e=o,this[To]();return}else this.#e=r.#e,n=new Headers(r.#e.headers)}else this.#e=r;(typeof e=="string"||typeof e?.getReader<"u"||e instanceof Blob||e instanceof Uint8Array)&&(this[zn]=[r?.status||200,e,n||r?.headers])}get headers(){let e=this[zn];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[To]().headers}get status(){return this[zn]?.[0]??this[To]().status}get ok(){let e=this.status;return e>=200&&e<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(Io.prototype,t,{get(){return this[To]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Io.prototype,t,{value:function(){return this[To]()[t]()}})});Object.defineProperty(Io.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(t,e,r){let n={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[ff]};return`Response (lightweight) ${r(n,{...e,depth:t==null?null:t-1})}`}});Object.setPrototypeOf(Io,gf);Object.setPrototypeOf(Io.prototype,gf.prototype);async function tO(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function pb(t,e,r){let n=a=>{t.cancel(a).catch(()=>{})};return e.on("close",n),e.on("error",n),(r??t.read()).then(i,o),t.closed.finally(()=>{e.off("close",n),e.off("error",n)});function o(a){a&&e.destroy(a)}function s(){t.read().then(i,o)}function i({done:a,value:c}){try{if(a)e.end();else if(!e.write(c))e.once("drain",s);else return t.read().then(i,o)}catch(u){o(u)}}}function rO(t,e){if(t.locked)throw new TypeError("ReadableStream is locked.");return e.destroyed?void 0:pb(t.getReader(),e)}var mf=t=>{let e={};t instanceof Headers||(t=new Headers(t??void 0));let r=[];for(let[n,o]of t)n==="set-cookie"?r.push(o):e[n]=o;return r.length>0&&(e["set-cookie"]=r),e["content-type"]??="text/plain; charset=UTF-8",e},nO="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=oO);var _f=Symbol("outgoingEnded"),ab=Symbol("incomingDraining"),sO=500,iO=64*1024*1024,pf=t=>{let e=t;if(t.destroyed||e[ab])return;if(e[ab]=!0,t instanceof cb){try{t.stream?.close?.(Bz.NGHTTP2_NO_ERROR)}catch{}return}let r=0,n=()=>{clearTimeout(s),t.off("data",i),t.off("end",n),t.off("error",n)},o=()=>{n();let a=t.socket;a&&!a.destroyed&&a.destroySoon()},s=setTimeout(o,sO);s.unref?.();let i=a=>{r+=a.length,r>iO&&o()};t.on("data",i),t.on("end",n),t.on("error",n),t.resume()},aO=()=>new Response(null,{status:400}),fb=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),hf=(t,e)=>{let r=t instanceof Error?t:new Error("unknown error",{cause:t});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),e.headersSent||e.writeHead(500,{"Content-Type":"text/plain"}),e.end(`Error: ${r.message}`),e.destroy(r))},mb=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},hb=async(t,e)=>{let[r,n,o]=t[zn],s=!1;if(!o)o={"content-type":"text/plain; charset=UTF-8"};else if(o instanceof Headers)s=o.has("content-length"),o=mf(o);else if(Array.isArray(o)){let i=new Headers(o);s=i.has("content-length"),o=mf(i)}else for(let i in o)if(i.length===14&&i.toLowerCase()==="content-length"){s=!0;break}s||(typeof n=="string"?o["Content-Length"]=Buffer.byteLength(n):n instanceof Uint8Array?o["Content-Length"]=n.byteLength:n instanceof Blob&&(o["Content-Length"]=n.size)),e.writeHead(r,o),typeof n=="string"||n instanceof Uint8Array?e.end(n):n instanceof Blob?e.end(new Uint8Array(await n.arrayBuffer())):(mb(e),await rO(n,e)?.catch(i=>hf(i,e))),e[_f]?.()},cO=t=>typeof t.then=="function",uO=async(t,e,r={})=>{if(cO(t))if(r.errorHandler)try{t=await t}catch(o){let s=await r.errorHandler(o);if(!s)return;t=s}else t=await t.catch(fb);if(zn in t)return hb(t,e);let n=mf(t.headers);if(t.body){let o=t.body.getReader(),s=[],i=!1,a;if(n["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=o.read();let l=await tO(a).catch(d=>{console.error(d),i=!0});if(!l){if(u===1){await new Promise(d=>setTimeout(d)),c=3;continue}break}if(a=void 0,l.value&&s.push(l.value),l.done){i=!0;break}}i&&!("content-length"in n)&&(n["content-length"]=s.reduce((u,l)=>u+l.length,0))}e.writeHead(t.status,n),s.forEach(c=>{e.write(c)}),i?e.end():(s.length===0&&mb(e),await pb(o,e,a))}else n[nO]||(e.writeHead(t.status,n),e.end());e[_f]?.()},yf=(t,e={})=>{let r=e.autoCleanupIncoming??!0;return e.overrideGlobalObjects!==!1&&global.Request!==qs&&(Object.defineProperty(global,"Request",{value:qs}),Object.defineProperty(global,"Response",{value:Io})),async(n,o)=>{let s,i;try{i=eO(n,e.hostname);let a=!r||n.method==="GET"||n.method==="HEAD";if(a||(n[ub]=!0,n.on("end",()=>{a=!0}),n instanceof cb&&(o[_f]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{pf(n)})})}),o.on("finish",()=>{a||pf(n)})),o.on("close",()=>{i[Po]&&(n.errored?i[Po].abort(n.errored.toString()):o.writableFinished||i[Po].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{pf(n)})})}),s=t(i,{incoming:n,outgoing:o}),zn in s)return hb(s,o)}catch(a){if(s)return hf(a,o);if(e.errorHandler){if(s=await e.errorHandler(i?a:Kz(a)),!s)return}else i?s=fb(a):s=aO()}try{return await uO(s,o,e)}catch(a){return hf(a,o)}}};var cc=class{constructor(e={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(e,r,n,o){let s={code:r,message:n};return o?.data!==void 0&&(s.data=o.data),new Response(JSON.stringify({jsonrpc:"2.0",error:s,id:null}),{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=e.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let n=`Invalid Host header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=e.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let n=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}}}async handleRequest(e,r){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case"POST":return this.handlePostRequest(e,r);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(e,r,n,o){if(!this._eventStore||o<"2025-11-25")return;let s=await this._eventStore.storeEvent(n,{}),i=`id: ${s}
65
+ `)}`)}catch(o){return Oe(o instanceof Error?o:new Error(String(o)))}}),n.tool("create_task","Create a work item (task / feature / bug) on a project canvas. Adds a first-class task node; the backend auto-creates the backing task record and resolves taskType/taskStatus to the workspace's tag ids by name. Optionally connect it to an existing node in one shot. This is the deterministic equivalent of the in-app AI's <AddTask> \u2014 use it to plan/track work, not just draw UI.",{projectId:b.string().describe("The project UUID."),title:b.string().describe("Short imperative summary (the task title)."),description:b.string().optional().describe("More detail about the work."),taskType:b.string().optional().describe('Work-item kind, e.g. "bug" / "feat" / "chore". Resolved to a workspace task-type tag by name; omit if unknown (run analyze_project / get_outline to learn the workspace vocabulary).'),taskStatus:b.string().optional().describe('Progress, e.g. "todo" / "in-progress" / "done". Resolved to a workspace progress tag by name; omit if unknown.'),connectTo:b.string().optional().describe("Existing node id to attach this task to. Creates an edge FROM the task TO that node (e.g. a bug attached to the header it affects)."),parentId:b.string().optional().describe("Existing node id to nest under."),x:b.number().optional().describe("Top-left x. Default 0."),y:b.number().optional().describe("Top-left y. Default 0.")},async({projectId:o,title:s,description:i,taskType:a,taskStatus:c,connectTo:u,parentId:l,x:d,y:h})=>{try{let m=await t.getProjectRaw(o),p=u?(m.latestData??[]).find(S=>String(S.id)===u):void 0;if(u&&!p)return Oe(new Error(`connectTo node ${u} not found in project.`));if(p&&!(0,lf.canConnectNodes)({type:"task"},p))return Oe(new Error(`Cannot connect task "${s}" to ${u}: an edge may not point INTO a task node. Connect a task to a regular node, not another task.`));let f=Zr(),g={id:f,type:"task",name:s,bounds:{x:d??0,y:h??0,width:100,height:100},children:[],parent:l??null,edges:u?[{id:Zr(),to:u}]:[],taskId:null,taskVersionNumber:null,...i?{description:i}:{},...a?{aiTaskType:a}:{},...c?{aiTaskStatus:c}:{}},_=await t.updateProject(o,{diff:{added:[g]},baseRevision:m.version}),v=u?`, connected to ${u}`:"";return oo(_)?Rn(`task "${s}" created${v}`):ve(`Created task "${s}" (#${f}${a?`, ${a}`:""}${c?`, ${c}`:""}${v}). New revision: ${_.version}.`)}catch(m){return Oe(m)}}),n.tool("connect_nodes","Draw a connection (edge) between two EXISTING nodes \u2014 e.g. attach a bug to the feature it affects, or link a task to a design region. The edge points FROM fromId TO toId. Direction rule: you may NOT point an edge INTO a task node (connect task\u2192regular, never regular\u2192task or task\u2192task). Idempotent: re-running with the same pair is a no-op.",{projectId:b.string().describe("The project UUID."),fromId:b.string().describe("Source node id (the edge starts here)."),toId:b.string().describe("Target node id (the edge points here)."),fromPort:oc.optional(),toPort:oc.optional()},async({projectId:o,fromId:s,toId:i,fromPort:a,toPort:c})=>{try{if(s===i)return Oe(new Error("Cannot connect a node to itself."));let u=await t.getProjectRaw(o),l=u.latestData??[],d=l.find(_=>String(_.id)===s);if(!d)return Oe(new Error(`Source node ${s} not found.`));let h=l.find(_=>String(_.id)===i);if(!h)return Oe(new Error(`Target node ${i} not found.`));if(!(0,lf.canConnectNodes)(d,h))return Oe(new Error(`Cannot connect ${s} \u2192 ${i}: an edge may not point INTO a task node. Connect a task to a regular node, not another task.`));let m=Array.isArray(d.edges)?d.edges:[];if(m.some(_=>{let v=_;return v.to===i&&v.fromPort===a&&v.toPort===c}))return ve(`Edge ${s} \u2192 ${i} already exists.`);let f={...d,edges:[...m,{id:Zr(),to:i,...a?{fromPort:a}:{},...c?{toPort:c}:{}}]},g=await t.updateProject(o,{diff:{updated:[f]},baseRevision:u.version});return oo(g)?Rn(`edge ${s} \u2192 ${i}`):ve(`Connected ${s} \u2192 ${i}. New revision: ${g.version}.`)}catch(u){return Oe(u)}}),n}import{createServer as gO}from"node:http";import{createHash as _O,randomUUID as yO}from"node:crypto";import{Http2ServerRequest as pb,constants as Qz}from"http2";import{Http2ServerRequest as df}from"http2";import{Readable as lb}from"stream";import lO from"crypto";var In=class extends Error{constructor(t,e){super(t,e),this.name="RequestError"}},eO=t=>t instanceof In?t:new In(t.message,{cause:t}),tO=global.Request,qs=class extends tO{constructor(t,e){typeof t=="object"&&Io in t&&(t=t[Io]()),typeof e?.body?.getReader<"u"&&(e.duplex??="half"),super(t,e)}},rO=t=>{let e=[],r=t.rawHeaders;for(let n=0;n<r.length;n+=2){let{[n]:o,[n+1]:s}=r;o.charCodeAt(0)!==58&&e.push([o,s])}return new Headers(e)},fb=Symbol("wrapBodyStream"),nO=(t,e,r,n,o)=>{let s={method:t,headers:r,signal:o.signal};if(t==="TRACE"){s.method="GET";let i=new qs(e,s);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(t==="GET"||t==="HEAD"))if("rawBody"in n&&n.rawBody instanceof Buffer)s.body=new ReadableStream({start(i){i.enqueue(n.rawBody),i.close()}});else if(n[fb]){let i;s.body=new ReadableStream({async pull(a){try{i||=lb.toWeb(n).getReader();let{done:c,value:u}=await i.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else s.body=lb.toWeb(n);return new qs(e,s)},Io=Symbol("getRequestCache"),mb=Symbol("requestCache"),ic=Symbol("incomingKey"),ac=Symbol("urlKey"),oO=Symbol("headersKey"),Ro=Symbol("abortControllerKey"),sO=Symbol("getAbortController"),Fs={get method(){return this[ic].method||"GET"},get url(){return this[ac]},get headers(){return this[oO]||=rO(this[ic])},[sO](){return this[Io](),this[Ro]},[Io](){return this[Ro]||=new AbortController,this[mb]||=nO(this.method,this[ac],this.headers,this[ic],this[Ro])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(Fs,t,{get(){return this[Io]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Fs,t,{value:function(){return this[Io]()[t]()}})});Object.defineProperty(Fs,Symbol.for("nodejs.util.inspect.custom"),{value:function(t,e,r){let n={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[mb]};return`Request (lightweight) ${r(n,{...e,depth:t==null?null:t-1})}`}});Object.setPrototypeOf(Fs,qs.prototype);var iO=(t,e)=>{let r=Object.create(Fs);r[ic]=t;let n=t.url||"";if(n[0]!=="/"&&(n.startsWith("http://")||n.startsWith("https://"))){if(t instanceof df)throw new In("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(n);r[ac]=a.href}catch(a){throw new In("Invalid absolute URL",{cause:a})}return r}let o=(t instanceof df?t.authority:t.headers.host)||e;if(!o)throw new In("Missing host header");let s;if(t instanceof df){if(s=t.scheme,!(s==="http"||s==="https"))throw new In("Unsupported scheme")}else s=t.socket&&t.socket.encrypted?"https":"http";let i=new URL(`${s}://${o}${n}`);if(i.hostname.length!==o.length&&i.hostname!==o.replace(/:\d+$/,""))throw new In("Invalid host header");return r[ac]=i.href,r},ff=Symbol("responseCache"),Po=Symbol("getResponseCache"),zn=Symbol("cache"),gf=global.Response,zo=class hb{#t;#e;[Po](){return delete this[zn],this[ff]||=new gf(this.#t,this.#e)}constructor(e,r){let n;if(this.#t=e,r instanceof hb){let o=r[ff];if(o){this.#e=o,this[Po]();return}else this.#e=r.#e,n=new Headers(r.#e.headers)}else this.#e=r;(typeof e=="string"||typeof e?.getReader<"u"||e instanceof Blob||e instanceof Uint8Array)&&(this[zn]=[r?.status||200,e,n||r?.headers])}get headers(){let e=this[zn];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[Po]().headers}get status(){return this[zn]?.[0]??this[Po]().status}get ok(){let e=this.status;return e>=200&&e<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(zo.prototype,t,{get(){return this[Po]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(zo.prototype,t,{value:function(){return this[Po]()[t]()}})});Object.defineProperty(zo.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(t,e,r){let n={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[ff]};return`Response (lightweight) ${r(n,{...e,depth:t==null?null:t-1})}`}});Object.setPrototypeOf(zo,gf);Object.setPrototypeOf(zo.prototype,gf.prototype);async function aO(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function gb(t,e,r){let n=a=>{t.cancel(a).catch(()=>{})};return e.on("close",n),e.on("error",n),(r??t.read()).then(i,o),t.closed.finally(()=>{e.off("close",n),e.off("error",n)});function o(a){a&&e.destroy(a)}function s(){t.read().then(i,o)}function i({done:a,value:c}){try{if(a)e.end();else if(!e.write(c))e.once("drain",s);else return t.read().then(i,o)}catch(u){o(u)}}}function cO(t,e){if(t.locked)throw new TypeError("ReadableStream is locked.");return e.destroyed?void 0:gb(t.getReader(),e)}var mf=t=>{let e={};t instanceof Headers||(t=new Headers(t??void 0));let r=[];for(let[n,o]of t)n==="set-cookie"?r.push(o):e[n]=o;return r.length>0&&(e["set-cookie"]=r),e["content-type"]??="text/plain; charset=UTF-8",e},uO="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=lO);var _f=Symbol("outgoingEnded"),db=Symbol("incomingDraining"),dO=500,pO=64*1024*1024,pf=t=>{let e=t;if(t.destroyed||e[db])return;if(e[db]=!0,t instanceof pb){try{t.stream?.close?.(Qz.NGHTTP2_NO_ERROR)}catch{}return}let r=0,n=()=>{clearTimeout(s),t.off("data",i),t.off("end",n),t.off("error",n)},o=()=>{n();let a=t.socket;a&&!a.destroyed&&a.destroySoon()},s=setTimeout(o,dO);s.unref?.();let i=a=>{r+=a.length,r>pO&&o()};t.on("data",i),t.on("end",n),t.on("error",n),t.resume()},fO=()=>new Response(null,{status:400}),_b=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),hf=(t,e)=>{let r=t instanceof Error?t:new Error("unknown error",{cause:t});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),e.headersSent||e.writeHead(500,{"Content-Type":"text/plain"}),e.end(`Error: ${r.message}`),e.destroy(r))},yb=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},vb=async(t,e)=>{let[r,n,o]=t[zn],s=!1;if(!o)o={"content-type":"text/plain; charset=UTF-8"};else if(o instanceof Headers)s=o.has("content-length"),o=mf(o);else if(Array.isArray(o)){let i=new Headers(o);s=i.has("content-length"),o=mf(i)}else for(let i in o)if(i.length===14&&i.toLowerCase()==="content-length"){s=!0;break}s||(typeof n=="string"?o["Content-Length"]=Buffer.byteLength(n):n instanceof Uint8Array?o["Content-Length"]=n.byteLength:n instanceof Blob&&(o["Content-Length"]=n.size)),e.writeHead(r,o),typeof n=="string"||n instanceof Uint8Array?e.end(n):n instanceof Blob?e.end(new Uint8Array(await n.arrayBuffer())):(yb(e),await cO(n,e)?.catch(i=>hf(i,e))),e[_f]?.()},mO=t=>typeof t.then=="function",hO=async(t,e,r={})=>{if(mO(t))if(r.errorHandler)try{t=await t}catch(o){let s=await r.errorHandler(o);if(!s)return;t=s}else t=await t.catch(_b);if(zn in t)return vb(t,e);let n=mf(t.headers);if(t.body){let o=t.body.getReader(),s=[],i=!1,a;if(n["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=o.read();let l=await aO(a).catch(d=>{console.error(d),i=!0});if(!l){if(u===1){await new Promise(d=>setTimeout(d)),c=3;continue}break}if(a=void 0,l.value&&s.push(l.value),l.done){i=!0;break}}i&&!("content-length"in n)&&(n["content-length"]=s.reduce((u,l)=>u+l.length,0))}e.writeHead(t.status,n),s.forEach(c=>{e.write(c)}),i?e.end():(s.length===0&&yb(e),await gb(o,e,a))}else n[uO]||(e.writeHead(t.status,n),e.end());e[_f]?.()},yf=(t,e={})=>{let r=e.autoCleanupIncoming??!0;return e.overrideGlobalObjects!==!1&&global.Request!==qs&&(Object.defineProperty(global,"Request",{value:qs}),Object.defineProperty(global,"Response",{value:zo})),async(n,o)=>{let s,i;try{i=iO(n,e.hostname);let a=!r||n.method==="GET"||n.method==="HEAD";if(a||(n[fb]=!0,n.on("end",()=>{a=!0}),n instanceof pb&&(o[_f]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{pf(n)})})}),o.on("finish",()=>{a||pf(n)})),o.on("close",()=>{i[Ro]&&(n.errored?i[Ro].abort(n.errored.toString()):o.writableFinished||i[Ro].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{pf(n)})})}),s=t(i,{incoming:n,outgoing:o}),zn in s)return vb(s,o)}catch(a){if(s)return hf(a,o);if(e.errorHandler){if(s=await e.errorHandler(i?a:eO(a)),!s)return}else i?s=_b(a):s=fO()}try{return await hO(s,o,e)}catch(a){return hf(a,o)}}};var cc=class{constructor(e={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(e,r,n,o){let s={code:r,message:n};return o?.data!==void 0&&(s.data=o.data),new Response(JSON.stringify({jsonrpc:"2.0",error:s,id:null}),{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=e.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let n=`Invalid Host header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=e.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let n=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}}}async handleRequest(e,r){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case"POST":return this.handlePostRequest(e,r);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(e,r,n,o){if(!this._eventStore||o<"2025-11-25")return;let s=await this._eventStore.storeEvent(n,{}),i=`id: ${s}
66
66
  data:
67
67
 
68
68
  `;this._retryInterval!==void 0&&(i=`id: ${s}
@@ -73,4 +73,4 @@ data:
73
73
  `;return o&&(s+=`id: ${o}
74
74
  `),s+=`data: ${JSON.stringify(n)}
75
75
 
76
- `,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map(_=>Wo.parse(_)):a=[Wo.parse(i)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let c=a.some(Xo);if(c){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(a.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!c){let _=this.validateSession(e);if(_)return _;let v=this.validateProtocolVersion(e);if(v)return v}if(!a.some($r)){for(let _ of a)this.onmessage?.(_,{authInfo:r?.authInfo,requestInfo:s});return new Response(null,{status:202})}let l=crypto.randomUUID(),d=a.find(_=>Xo(_)),h=d?d.params.protocolVersion:e.headers.get("mcp-protocol-version")??hh;if(this._enableJsonResponse)return new Promise(_=>{this._streamMapping.set(l,{resolveJson:_,cleanup:()=>{this._streamMapping.delete(l)}});for(let v of a)$r(v)&&this._requestToStreamMapping.set(v.id,l);for(let v of a)this.onmessage?.(v,{authInfo:r?.authInfo,requestInfo:s})});let m=new TextEncoder,p,f=new ReadableStream({start:_=>{p=_},cancel:()=>{this._streamMapping.delete(l)}}),g={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(g["mcp-session-id"]=this.sessionId);for(let _ of a)$r(_)&&(this._streamMapping.set(l,{controller:p,encoder:m,cleanup:()=>{this._streamMapping.delete(l);try{p.close()}catch{}}}),this._requestToStreamMapping.set(_.id,l));await this.writePrimingEvent(p,m,l,h);for(let _ of a){let v,$;$r(_)&&this._eventStore&&h>="2025-11-25"&&(v=()=>{this.closeSSEStream(_.id)},$=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(_,{authInfo:r?.authInfo,requestInfo:s,closeSSEStream:v,closeStandaloneSSEStream:$})}return new Response(f,{status:200,headers:g})}catch(n){return this.onerror?.(n),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(n)})}}async handleDeleteRequest(e){let r=this.validateSession(e);if(r)return r;let n=this.validateProtocolVersion(e);return n||(await Promise.resolve(this._onsessionclosed?.(this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=e.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(e){let r=e.headers.get("mcp-protocol-version");if(r!==null&&!qn.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${qn.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${qn.join(", ")})`)}async close(){this._streamMapping.forEach(({cleanup:e})=>{e()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(e){let r=this._requestToStreamMapping.get(e);if(!r)return;let n=this._streamMapping.get(r);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,r){let n=r?.relatedRequestId;if((ar(e)||Fn(e))&&(n=e.id),n===void 0){if(ar(e)||Fn(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let a=this._streamMapping.get(this._standaloneSseStreamId);if(a===void 0)return;a.controller&&a.encoder&&this.writeSSEEvent(a.controller,a.encoder,e,i);return}let o=this._requestToStreamMapping.get(n);if(!o)throw new Error(`No connection established for request ID: ${String(n)}`);let s=this._streamMapping.get(o);if(!this._enableJsonResponse&&s?.controller&&s?.encoder){let i;this._eventStore&&(i=await this._eventStore.storeEvent(o,e)),this.writeSSEEvent(s.controller,s.encoder,e,i)}if(ar(e)||Fn(e)){this._requestResponseMap.set(n,e);let i=Array.from(this._requestToStreamMapping.entries()).filter(([c,u])=>u===o).map(([c])=>c);if(i.every(c=>this._requestResponseMap.has(c))){if(!s)throw new Error(`No connection established for request ID: ${String(n)}`);if(this._enableJsonResponse&&s.resolveJson){let c={"Content-Type":"application/json"};this.sessionId!==void 0&&(c["mcp-session-id"]=this.sessionId);let u=i.map(l=>this._requestResponseMap.get(l));u.length===1?s.resolveJson(new Response(JSON.stringify(u[0]),{status:200,headers:c})):s.resolveJson(new Response(JSON.stringify(u),{status:200,headers:c}))}else s.cleanup();for(let c of i)this._requestResponseMap.delete(c),this._requestToStreamMapping.delete(c)}}}};var uc=class{constructor(e={}){this._requestContext=new WeakMap,this._webStandardTransport=new cc(e),this._requestListener=yf(async r=>{let n=this._requestContext.get(r);return this._webStandardTransport.handleRequest(r,{authInfo:n?.authInfo,parsedBody:n?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(e){this._webStandardTransport.onclose=e}get onclose(){return this._webStandardTransport.onclose}set onerror(e){this._webStandardTransport.onerror=e}get onerror(){return this._webStandardTransport.onerror}set onmessage(e){this._webStandardTransport.onmessage=e}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(e,r){return this._webStandardTransport.send(e,r)}async handleRequest(e,r,n){let o=e.auth;await yf(async i=>this._webStandardTransport.handleRequest(i,{authInfo:o,parsedBody:n}),{overrideGlobalObjects:!1})(e,r)}closeSSEStream(e){this._webStandardTransport.closeSSEStream(e)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};var pO="mcp-session-id",gb="fp_live_",_b="/.well-known/oauth-protected-resource";function fO(t){let e=t.headers["x-mcp-key"],r=Array.isArray(e)?e[0]:e;if(typeof r=="string"&&r.startsWith(gb))return{mcpKey:r};let n=t.headers.authorization;if(typeof n=="string"&&n.toLowerCase().startsWith("bearer ")){let o=n.slice(7).trim();return o?o.startsWith(gb)?{mcpKey:o}:{token:o}:{}}return{}}function yb(t){return new Promise((e,r)=>{let n=[];t.on("data",o=>n.push(o)),t.on("end",()=>{let o=Buffer.concat(n).toString("utf8");if(!o)return e(void 0);try{e(JSON.parse(o))}catch(s){r(s instanceof Error?s:new Error(String(s)))}}),t.on("error",r)})}function bb(t,e,r){t.writeHead(e,{"Content-Type":"application/json"}),t.end(JSON.stringify(r))}function zo(t,e,r){bb(t,e,{jsonrpc:"2.0",error:{code:-32e3,message:r},id:null})}function vb(t){let e=t.headers["x-forwarded-proto"]?.split(",")[0]||"http",r=t.headers["x-forwarded-host"]??t.headers.host??"localhost";return`${e}://${Array.isArray(r)?r[0]:r}`}async function wb(t){let e=t.path??"/mcp",r=new Map,n=c=>t.publicResourceUrl??`${vb(c)}${e}`,o=c=>`${t.publicResourceUrl?new URL(t.publicResourceUrl).origin:vb(c)}${_b}`,s=lO((c,u)=>{a(c,u).catch(l=>{console.error("Unhandled request error:",l),u.headersSent||zo(u,500,"Internal server error")})});function i(c,u){u.setHeader("WWW-Authenticate",`Bearer resource_metadata="${o(c)}"`),zo(u,401,"Authorization required. Connect via OAuth.")}async function a(c,u){let l=new URL(c.url??"/",`http://${c.headers.host??"localhost"}`);if(l.pathname===_b){bb(u,200,{resource:n(c),authorization_servers:t.authorizationServers??[]});return}if(l.pathname!==e){zo(u,404,`Not found. MCP endpoint is ${e}.`);return}let d=c.headers[pO],h=Array.isArray(d)?d[0]:d;if(h&&r.has(h)){let v=r.get(h),$=c.method==="POST"?await yb(c):void 0;await v.handleRequest(c,u,$);return}if(h){zo(u,404,"Session not found or expired \u2014 reinitialize.");return}if(c.method!=="POST"){zo(u,400,"Missing mcp-session-id.");return}let m=await yb(c);if(!Xo(m)){zo(u,400,"Bad Request: no valid session id, and not an initialize request.");return}let p=fO(c);if(!p.token&&!p.mcpKey){i(c,u);return}let f=new Kn({baseUrl:t.baseUrl,token:p.token,mcpKey:p.mcpKey}),g=new uc({sessionIdGenerator:()=>dO(),onsessioninitialized:v=>{r.set(v,g)}});g.onclose=()=>{g.sessionId&&r.delete(g.sessionId)},await(await sc(f)).connect(g),await g.handleRequest(c,u,m)}await new Promise(c=>{s.listen(t.port,()=>c())}),console.error(`flowpad-mcp HTTP transport listening on :${t.port}${e}`)}var xb="http://localhost:8080",mO=8091;function hO(){return process.argv.includes("--http")?!0:(process.env.MCP_TRANSPORT??"").toLowerCase()==="http"}async function gO(){let t=new Kn({baseUrl:process.env.FLOWPAD_API_URL??xb,mcpKey:process.env.FLOWPAD_API_KEY??process.env.MCP_API_KEY}),e=await sc(t),r=new Zi;await e.connect(r),console.error("flowpad-mcp server running on stdio")}async function _O(){let t=Number(process.env.MCP_PORT??mO),e=(process.env.OAUTH_AUTH_SERVERS??"").split(",").map(r=>r.trim()).filter(Boolean);await wb({port:t,baseUrl:process.env.FLOWPAD_API_URL??xb,path:process.env.MCP_PATH??"/mcp",publicResourceUrl:process.env.MCP_PUBLIC_URL,authorizationServers:e})}async function yO(){hO()?await _O():await gO()}yO().catch(t=>{console.error("Fatal:",t),process.exit(1)});
76
+ `,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map(_=>Wo.parse(_)):a=[Wo.parse(i)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let c=a.some(Xo);if(c){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(a.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!c){let _=this.validateSession(e);if(_)return _;let v=this.validateProtocolVersion(e);if(v)return v}if(!a.some(Sr)){for(let _ of a)this.onmessage?.(_,{authInfo:r?.authInfo,requestInfo:s});return new Response(null,{status:202})}let l=crypto.randomUUID(),d=a.find(_=>Xo(_)),h=d?d.params.protocolVersion:e.headers.get("mcp-protocol-version")??hh;if(this._enableJsonResponse)return new Promise(_=>{this._streamMapping.set(l,{resolveJson:_,cleanup:()=>{this._streamMapping.delete(l)}});for(let v of a)Sr(v)&&this._requestToStreamMapping.set(v.id,l);for(let v of a)this.onmessage?.(v,{authInfo:r?.authInfo,requestInfo:s})});let m=new TextEncoder,p,f=new ReadableStream({start:_=>{p=_},cancel:()=>{this._streamMapping.delete(l)}}),g={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(g["mcp-session-id"]=this.sessionId);for(let _ of a)Sr(_)&&(this._streamMapping.set(l,{controller:p,encoder:m,cleanup:()=>{this._streamMapping.delete(l);try{p.close()}catch{}}}),this._requestToStreamMapping.set(_.id,l));await this.writePrimingEvent(p,m,l,h);for(let _ of a){let v,S;Sr(_)&&this._eventStore&&h>="2025-11-25"&&(v=()=>{this.closeSSEStream(_.id)},S=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(_,{authInfo:r?.authInfo,requestInfo:s,closeSSEStream:v,closeStandaloneSSEStream:S})}return new Response(f,{status:200,headers:g})}catch(n){return this.onerror?.(n),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(n)})}}async handleDeleteRequest(e){let r=this.validateSession(e);if(r)return r;let n=this.validateProtocolVersion(e);return n||(await Promise.resolve(this._onsessionclosed?.(this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=e.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(e){let r=e.headers.get("mcp-protocol-version");if(r!==null&&!Fn.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${Fn.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${Fn.join(", ")})`)}async close(){this._streamMapping.forEach(({cleanup:e})=>{e()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(e){let r=this._requestToStreamMapping.get(e);if(!r)return;let n=this._streamMapping.get(r);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,r){let n=r?.relatedRequestId;if((cr(e)||Vn(e))&&(n=e.id),n===void 0){if(cr(e)||Vn(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let a=this._streamMapping.get(this._standaloneSseStreamId);if(a===void 0)return;a.controller&&a.encoder&&this.writeSSEEvent(a.controller,a.encoder,e,i);return}let o=this._requestToStreamMapping.get(n);if(!o)throw new Error(`No connection established for request ID: ${String(n)}`);let s=this._streamMapping.get(o);if(!this._enableJsonResponse&&s?.controller&&s?.encoder){let i;this._eventStore&&(i=await this._eventStore.storeEvent(o,e)),this.writeSSEEvent(s.controller,s.encoder,e,i)}if(cr(e)||Vn(e)){this._requestResponseMap.set(n,e);let i=Array.from(this._requestToStreamMapping.entries()).filter(([c,u])=>u===o).map(([c])=>c);if(i.every(c=>this._requestResponseMap.has(c))){if(!s)throw new Error(`No connection established for request ID: ${String(n)}`);if(this._enableJsonResponse&&s.resolveJson){let c={"Content-Type":"application/json"};this.sessionId!==void 0&&(c["mcp-session-id"]=this.sessionId);let u=i.map(l=>this._requestResponseMap.get(l));u.length===1?s.resolveJson(new Response(JSON.stringify(u[0]),{status:200,headers:c})):s.resolveJson(new Response(JSON.stringify(u),{status:200,headers:c}))}else s.cleanup();for(let c of i)this._requestResponseMap.delete(c),this._requestToStreamMapping.delete(c)}}}};var uc=class{constructor(e={}){this._requestContext=new WeakMap,this._webStandardTransport=new cc(e),this._requestListener=yf(async r=>{let n=this._requestContext.get(r);return this._webStandardTransport.handleRequest(r,{authInfo:n?.authInfo,parsedBody:n?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(e){this._webStandardTransport.onclose=e}get onclose(){return this._webStandardTransport.onclose}set onerror(e){this._webStandardTransport.onerror=e}get onerror(){return this._webStandardTransport.onerror}set onmessage(e){this._webStandardTransport.onmessage=e}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(e,r){return this._webStandardTransport.send(e,r)}async handleRequest(e,r,n){let o=e.auth;await yf(async i=>this._webStandardTransport.handleRequest(i,{authInfo:o,parsedBody:n}),{overrideGlobalObjects:!1})(e,r)}closeSSEStream(e){this._webStandardTransport.closeSSEStream(e)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};var vO="mcp-session-id",bb="fp_live_",wb="/.well-known/oauth-protected-resource",bO=30*6e4,wO=5*6e4;function xb(t){let e=t.mcpKey??t.token;if(e)return _O("sha256").update(e).digest("hex")}function Sb(t){let e=t.headers["x-mcp-key"],r=Array.isArray(e)?e[0]:e;if(typeof r=="string"&&r.startsWith(bb))return{mcpKey:r};let n=t.headers.authorization;if(typeof n=="string"&&n.toLowerCase().startsWith("bearer ")){let o=n.slice(7).trim();return o?o.startsWith(bb)?{mcpKey:o}:{token:o}:{}}return{}}function $b(t){return new Promise((e,r)=>{let n=[];t.on("data",o=>n.push(o)),t.on("end",()=>{let o=Buffer.concat(n).toString("utf8");if(!o)return e(void 0);try{e(JSON.parse(o))}catch(s){r(s instanceof Error?s:new Error(String(s)))}}),t.on("error",r)})}function kb(t,e,r){t.writeHead(e,{"Content-Type":"application/json"}),t.end(JSON.stringify(r))}function On(t,e,r){kb(t,e,{jsonrpc:"2.0",error:{code:-32e3,message:r},id:null})}function Eb(t){let e=t.headers["x-forwarded-proto"]?.split(",")[0]||"http",r=t.headers["x-forwarded-host"]??t.headers.host??"localhost";return`${e}://${Array.isArray(r)?r[0]:r}`}async function Tb(t){let e=t.path??"/mcp",r=new Map;setInterval(()=>{let u=Date.now()-bO;for(let[l,d]of r)d.lastSeen>=u||(r.delete(l),Promise.resolve(d.transport.close()).catch(h=>console.error("Idle session close failed:",h)))},wO).unref();let o=u=>t.publicResourceUrl??`${Eb(u)}${e}`,s=u=>`${t.publicResourceUrl?new URL(t.publicResourceUrl).origin:Eb(u)}${wb}`,i=gO((u,l)=>{c(u,l).catch(d=>{console.error("Unhandled request error:",d),l.headersSent||On(l,500,"Internal server error")})});function a(u,l){l.setHeader("WWW-Authenticate",`Bearer resource_metadata="${s(u)}"`),On(l,401,"Authorization required. Connect via OAuth.")}async function c(u,l){let d=new URL(u.url??"/",`http://${u.headers.host??"localhost"}`);if(d.pathname===wb){kb(l,200,{resource:o(u),authorization_servers:t.authorizationServers??[]});return}if(d.pathname!==e){On(l,404,`Not found. MCP endpoint is ${e}.`);return}let h=u.headers[vO],m=Array.isArray(h)?h[0]:h;if(m&&r.has(m)){let y=r.get(m),T=xb(Sb(u));if(!T||T!==y.credFingerprint){On(l,401,"Session credential mismatch \u2014 reinitialize.");return}y.lastSeen=Date.now();let L=u.method==="POST"?await $b(u):void 0;await y.transport.handleRequest(u,l,L);return}if(m){On(l,404,"Session not found or expired \u2014 reinitialize.");return}if(u.method!=="POST"){On(l,400,"Missing mcp-session-id.");return}let p=await $b(u);if(!Xo(p)){On(l,400,"Bad Request: no valid session id, and not an initialize request.");return}let f=Sb(u);if(!f.token&&!f.mcpKey){a(u,l);return}let g=new no({baseUrl:t.baseUrl,token:f.token,mcpKey:f.mcpKey}),_=xb(f),v=new uc({sessionIdGenerator:()=>yO(),onsessioninitialized:y=>{r.set(y,{transport:v,credFingerprint:_,lastSeen:Date.now()})}});v.onclose=()=>{v.sessionId&&r.delete(v.sessionId)},await(await sc(g)).connect(v),await v.handleRequest(u,l,p)}await new Promise(u=>{i.listen(t.port,()=>u())}),console.error(`flowpad-mcp HTTP transport listening on :${t.port}${e}`)}var Pb="http://localhost:8080",xO=8091;function SO(){return process.argv.includes("--http")?!0:(process.env.MCP_TRANSPORT??"").toLowerCase()==="http"}async function $O(){let t=new no({baseUrl:process.env.FLOWPAD_API_URL??Pb,mcpKey:process.env.FLOWPAD_API_KEY??process.env.MCP_API_KEY}),e=await sc(t),r=new Zi;await e.connect(r),console.error("flowpad-mcp server running on stdio")}async function EO(){let t=Number(process.env.MCP_PORT??xO),e=(process.env.OAUTH_AUTH_SERVERS??"").split(",").map(r=>r.trim()).filter(Boolean);await Tb({port:t,baseUrl:process.env.FLOWPAD_API_URL??Pb,path:process.env.MCP_PATH??"/mcp",publicResourceUrl:process.env.MCP_PUBLIC_URL,authorizationServers:e})}async function kO(){SO()?await EO():await $O()}kO().catch(t=>{console.error("Fatal:",t),process.exit(1)});