goatchain-cli 0.0.2-beta.8 → 0.0.2

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,8 +1,42 @@
1
- import{n as e,r as t,t as n}from"./chunk-B_5Rb6Gi.js";import{d as r,l as i,m as a,u as o}from"./ui-DM2shvqf.js";import{randomUUID as s}from"node:crypto";import{mkdir as c,readFile as l,readdir as u,rename as d,stat as f,writeFile as p}from"node:fs/promises";import m from"node:path";import{existsSync as h}from"node:fs";import{fileURLToPath as g,pathToFileURL as _}from"node:url";import v from"node:process";import{PassThrough as y}from"node:stream";const ee=[`ToolRegistry`,`WriteTool`,`ReadTool`,`EditTool`,`GlobTool`,`GrepTool`,`AstGrepSearchTool`,`TodoWriteTool`,`WebSearchTool`];function b(e){return ee.every(t=>typeof e?.[t]==`function`)}async function te(){try{let e=m.dirname(g(import.meta.url)),t=[m.resolve(e,`../../../src/index.ts`)];for(let e of t)if(h(e))try{return await import(_(e).href)}catch{}}catch{}}async function x(){try{return await import(`./src-DjihPInC.js`)}catch(e){let t=e instanceof Error?e.message:String(e);try{let e=m.dirname(g(import.meta.url)),t=[m.resolve(e,`../../dist/index`),m.resolve(e,`../../../dist/index`)];for(let e of t)try{return await import(_(e).href)}catch{}}catch{}throw Error(["Failed to load `goatchain`.","If you are running from the repo, run `pnpm -r -s build` first.","If this is a workspace setup, ensure `packages/cli` depends on `goatchain` and run `pnpm install`.",`cause: ${t}`].join(`
2
- `))}}function S(e,t){return{get modelId(){return e.modelId},...typeof e?.setModelId==`function`?{setModelId(t){e.setModelId(t)}}:{},stream:n=>e.stream({...t,...n}),...typeof e?.run==`function`?{run:n=>e.run({...t,...n})}:{}}}function C(e,t,n,a){if(!b(e))throw Error(["Missing builtin tool exports from `goatchain`.","Reinstall the package, or rebuild it from the repo (`pnpm -r -s build`)."].join(`
3
- `));let{ToolRegistry:o,WriteTool:s,ReadTool:c,EditTool:l,GlobTool:u,GrepTool:d,AstGrepSearchTool:f,AstGrepReplaceTool:p,TodoWriteTool:h,WebSearchTool:g,AskUserTool:_}=e,v=e?.BashTool,y=m.join(t,`.goatchain`),ee=()=>a?i(r(a.get()?.approvalMode)):{allowOutsideWorkspace:!0,allowNetwork:!0},te=(e,t)=>{let n=m.relative(m.resolve(e),m.resolve(t));return n===``?!0:n===`..`?!1:!n.startsWith(`..${m.sep}`)&&!m.isAbsolute(n)},x=e=>{if(te(y,e))throw Error(`Access denied: ${e}\nRestricted: ${y}`)},S=e=>{let n=m.isAbsolute(e)?e:m.resolve(t,e),{allowOutsideWorkspace:r}=ee();if(!r&&!te(t,n))throw Error(`Access denied: ${n}\nAllowed directory: ${t}`);return x(n),n},C=e=>{let n=m.isAbsolute(e)?e:m.resolve(t,e),{allowOutsideWorkspace:r}=ee();if(!r&&!te(t,n))throw Error(`Access denied: ${n}\nAllowed directory: ${t}`);return x(n),n},w=new o,T=new s({cwd:t});w.register({name:T.name,description:T.description,parameters:T.parameters,riskLevel:T.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&S(e.file_path),T.execute(e))});let ne=new c({cwd:t});w.register({name:ne.name,description:ne.description,parameters:ne.parameters,riskLevel:ne.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&S(e.file_path),ne.execute(e))});let E=new l({cwd:t});w.register({name:E.name,description:E.description,parameters:E.parameters,riskLevel:E.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&S(e.file_path),E.execute(e))});let D=new u({cwd:t});w.register({name:D.name,description:D.description,parameters:D.parameters,riskLevel:D.riskLevel,execute:e=>(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`&&e.path.trim()&&C(e.path),D.execute(e))});let re=new d({cwd:t});w.register({name:re.name,description:re.description,parameters:re.parameters,riskLevel:re.riskLevel,execute:e=>(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`&&e.path.trim()&&C(e.path),re.execute(e))});let ie=new f({cwd:t});w.register({name:ie.name,description:ie.description,parameters:ie.parameters,riskLevel:ie.riskLevel,execute:e=>{if(e&&typeof e==`object`&&Array.isArray(e.paths))for(let t of e.paths)typeof t==`string`&&t.trim()&&C(t);return ie.execute(e)}});let ae=new p({cwd:t});w.register({name:ae.name,description:ae.description,parameters:ae.parameters,riskLevel:ae.riskLevel,execute:e=>{if(e&&typeof e==`object`&&Array.isArray(e.paths))for(let t of e.paths)typeof t==`string`&&t.trim()&&C(t);return ae.execute(e)}});let oe=new v({cwd:t});w.register({name:oe.name,description:oe.description,parameters:oe.parameters,riskLevel:oe.riskLevel,execute:e=>oe.execute(e)});let se=()=>{let e=n?.get(),t=process.env.GOATCHAIN_SERPER_API_KEY??process.env.SERPER_API_KEY,r=process.env.GOATCHAIN_SERPER_API_ENDPOINT??process.env.SERPER_API_ENDPOINT,i=process.env.GOATCHAIN_SERPER_NUM_RESULTS??process.env.SERPER_NUM_RESULTS,a=typeof i==`string`&&i.trim()?Number.parseInt(i.trim(),10):void 0;return{apiKey:e?.webSearch?.apiKey??t??``,apiEndpoint:e?.webSearch?.apiEndpoint??r,numResults:e?.webSearch?.numResults??(Number.isFinite(a)?a:void 0)}},ce=new g;w.register({name:ce.name,description:ce.description,parameters:ce.parameters,riskLevel:ce.riskLevel,execute:async e=>{if(!ee().allowNetwork)return{content:[{type:`text`,text:[`Access denied: WebSearch requires network access.`,`Switch to Approval Mode: Agent (full access) via /approvals.`,`Or set GOATCHAIN_APPROVAL_MODE=full_access.`].join(`
4
- `)}],isError:!0};let{apiKey:t,apiEndpoint:n,numResults:r}=se();if(!t)return{content:[{type:`text`,text:[`Missing Serper API key for WebSearch.`,`Set it via one of:`,`- /web-search-key <key> (interactive)`,`- env: SERPER_API_KEY or GOATCHAIN_SERPER_API_KEY`,`- config: ./.goatchain/config.json -> tools.webSearch.apiKey`].join(`
5
- `)}],isError:!0};let i=new g({...t?{apiKey:t}:{},...n?{apiEndpoint:n}:{},...typeof r==`number`?{numResults:r}:{}});try{return await i.execute(e)}catch(e){return{content:[{type:`text`,text:`WebSearch failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}}});let O=new h;w.register({name:O.name,description:O.description,parameters:O.parameters,riskLevel:O.riskLevel,execute:e=>O.execute(e)});let le=new _;return w.register({name:le.name,description:le.description,parameters:le.parameters,riskLevel:le.riskLevel,execute:e=>le.execute(e)}),{registry:w,workspaceCwd:t}}async function w(e,{getApiKey:t,modelId:n,baseUrl:r,requestDefaults:i,openaiCompat:a}){let{createModel:o,createOpenAIAdapter:s}=e;if(typeof o==`function`&&typeof s==`function`)return S(o({adapter:s({defaultModelId:n,baseUrl:r,apiKey:t,compat:a})}),i);let{default:c}=await import(`./openai-COAwgJce.js`),l=null,u=n,d=r,f=()=>{if(l)return l;let e=t()??process.env.OPENAI_API_KEY;if(!e)throw Error(`Missing OPENAI_API_KEY (required for chatting)`);return l=new c({apiKey:e,baseURL:d||void 0}),l};return{get modelId(){return u},setModelId(e){u=e},setBaseUrl(e){d=e,l=null},resetClient(){l=null},async*stream(e){let t=f(),n=e?.model?.modelId??u,r=e?.requestId??`req_${Date.now()}`,o=e?.signal,s=Array.isArray(e?.messages)?e.messages:[...typeof e?.instructions==`string`&&e.instructions.length>0?[{role:`system`,content:e.instructions}]:[],{role:`user`,content:e?.input??``}],c=e?.tools,l=e=>{let t=a?.requireReasoningContentForToolCalls;return typeof t==`boolean`?t:typeof d==`string`&&/deepseek/i.test(d)?!0:/^deepseek-/i.test(e)},p=(e,t)=>!l(t)||!Array.isArray(e)||e.length===0?e:e.map(e=>{if(!e||typeof e!=`object`||e.role!==`assistant`)return e;let t=e.tool_calls;return!Array.isArray(t)||t.length===0||`reasoning_content`in e&&typeof e.reasoning_content==`string`?e:{...e,reasoning_content:`.`}});yield{type:`response_start`,requestId:r,model:{provider:`openai`,modelId:n}};let m=await t.chat.completions.create({model:n,messages:p(s,n),tools:c,stream:!0,stream_options:{include_usage:!0},max_completion_tokens:i.maxOutputTokens??void 0,temperature:i.temperature??void 0,top_p:i.topP??void 0,presence_penalty:i.presencePenalty??void 0,frequency_penalty:i.frequencyPenalty??void 0,seed:i.seed??void 0},{signal:o,timeout:typeof i.timeoutMs==`number`?i.timeoutMs:void 0}),h;for await(let e of m){let t=e?.choices?.[0]?.delta?.content;typeof t==`string`&&t.length>0&&(yield{type:`delta`,requestId:r,chunk:{kind:`text`,text:t}});let n=e?.usage;n&&typeof n==`object`&&(h=n)}yield{type:`response_end`,requestId:r,stopReason:`final`,usage:h}}}}async function T({getApiKey:e,modelId:t,system:n,baseUrl:r,requestDefaults:i,openaiCompat:a,toolsConfigRef:o,workspaceCwd:s,accessRef:c}){let l=await x();if(!b(l)){let e=await te();e&&b(e)&&(l=e)}let{Agent:u,FileStateStore:d}=l,f=typeof s==`string`&&s.trim()?s.trim():process.cwd(),p=C(l,f,o,c),h=await w(l,{getApiKey:e,modelId:t,baseUrl:r,requestDefaults:i,openaiCompat:a}),g=new d({dir:m.join(f,`.goatchain`),savePoint:`both`,deleteOnComplete:!0}),_=new u({name:`GoatChain CLI`,systemPrompt:n??`You are GoatChain CLI, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
1
+ import{n as e,r as t,t as n}from"./chunk-B_5Rb6Gi.js";import{a as r,o as i,r as a,s as o}from"./args-B4NUWmzz.js";import"./ui-D4n45LUU.js";import{randomUUID as s}from"node:crypto";import{mkdir as c,readFile as l,readdir as u,rename as d,stat as f,writeFile as p}from"node:fs/promises";import m from"node:path";import h from"node:process";import{PassThrough as g}from"node:stream";import{existsSync as _}from"node:fs";import{fileURLToPath as v,pathToFileURL as y}from"node:url";const b=Object.freeze({status:`aborted`});function x(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var S=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},C=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const w={};function T(e){return e&&Object.assign(w,e),w}function E(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function D(e,t){return typeof t==`bigint`?t.toString():t}function O(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function k(e){return e==null}function A(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ee(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const te=Symbol(`evaluating`);function j(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==te)return r===void 0&&(r=te,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ne(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function M(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function re(e){return JSON.stringify(e)}function ie(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const ae=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const se=O(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ce(e){if(oe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(oe(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function le(e){return ce(e)?{...e}:Array.isArray(e)?[...e]:e}const ue=new Set([`string`,`number`,`symbol`]);function de(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fe(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function pe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const me={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function he(e,t){let n=e._zod.def;return fe(e,M(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ne(this,`shape`,e),e},checks:[]}))}function ge(e,t){let n=e._zod.def;return fe(e,M(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ne(this,`shape`,r),r},checks:[]}))}function _e(e,t){if(!ce(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return fe(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ne(this,`shape`,n),n},checks:[]}))}function ve(e,t){if(!ce(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return fe(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ne(this,`shape`,n),n},checks:e._zod.def.checks})}function ye(e,t){return fe(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ne(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function be(e,t,n){return fe(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ne(this,`shape`,i),i},checks:[]}))}function xe(e,t,n){return fe(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ne(this,`shape`,i),i},checks:[]}))}function Se(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ce(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function we(e){return typeof e==`string`?e:e?.message}function Te(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=we(e.inst?._zod.def?.error?.(e))??we(t?.error?.(e))??we(n.customError?.(e))??we(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ee(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function De(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Oe=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,D,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},ke=x(`$ZodError`,Oe),Ae=x(`$ZodError`,Oe,{Parent:Error});function je(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Me(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const Ne=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new S;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Te(e,a,T())));throw ae(t,i?.callee),t}return o.value},Pe=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Te(e,a,T())));throw ae(t,i?.callee),t}return o.value},Fe=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new S;return a.issues.length?{success:!1,error:new(e??ke)(a.issues.map(e=>Te(e,i,T())))}:{success:!0,data:a.value}},Ie=Fe(Ae),Le=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Te(e,i,T())))}:{success:!0,data:a.value}},Re=Le(Ae),ze=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ne(e)(t,n,i)},Be=e=>(t,n,r)=>Ne(e)(t,n,r),Ve=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Pe(e)(t,n,i)},He=e=>async(t,n,r)=>Pe(e)(t,n,r),Ue=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Fe(e)(t,n,i)},We=e=>(t,n,r)=>Fe(e)(t,n,r),Ge=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Le(e)(t,n,i)},Ke=e=>async(t,n,r)=>Le(e)(t,n,r),qe=/^[cC][^\s-]{8,}$/,Je=/^[0-9a-z]+$/,Ye=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xe=/^[0-9a-vA-V]{20}$/,Ze=/^[A-Za-z0-9]{27}$/,Qe=/^[a-zA-Z0-9_-]{21}$/,$e=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,et=/^([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})$/,tt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function rt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const it=/^(?:(?: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])$/,at=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,ot=/^((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])$/,st=/^(([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])$/,ct=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lt=/^[A-Za-z0-9_-]*$/,ut=/^\+(?:[0-9]){6,14}[0-9]$/,dt=`(?:(?:\\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])))`,ft=RegExp(`^${dt}$`);function pt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function mt(e){return RegExp(`^${pt(e)}$`)}function ht(e){let t=pt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${dt}T(?:${r})$`)}const gt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},_t=/^-?\d+$/,vt=/^-?\d+(?:\.\d+)?/,yt=/^(?:true|false)$/i,bt=/^null$/i,xt=/^[^A-Z]*$/,St=/^[^a-z]*$/,Ct=x(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wt={number:`number`,bigint:`bigint`,object:`date`},Tt=x(`$ZodCheckLessThan`,(e,t)=>{Ct.init(e,t);let n=wt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Et=x(`$ZodCheckGreaterThan`,(e,t)=>{Ct.init(e,t);let n=wt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dt=x(`$ZodCheckMultipleOf`,(e,t)=>{Ct.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):ee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ot=x(`$ZodCheckNumberFormat`,(e,t)=>{Ct.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=me[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=_t)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),kt=x(`$ZodCheckMaxLength`,(e,t)=>{var n;Ct.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Ee(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),At=x(`$ZodCheckMinLength`,(e,t)=>{var n;Ct.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Ee(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),jt=x(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ct.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ee(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Mt=x(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ct.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Nt=x(`$ZodCheckRegex`,(e,t)=>{Mt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Pt=x(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=xt,Mt.init(e,t)}),Ft=x(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=St,Mt.init(e,t)}),It=x(`$ZodCheckIncludes`,(e,t)=>{Ct.init(e,t);let n=de(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Lt=x(`$ZodCheckStartsWith`,(e,t)=>{Ct.init(e,t);let n=RegExp(`^${de(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Rt=x(`$ZodCheckEndsWith`,(e,t)=>{Ct.init(e,t);let n=RegExp(`.*${de(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),zt=x(`$ZodCheckOverwrite`,(e,t)=>{Ct.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Bt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
+ `))}};const Vt={major:4,minor:2,patch:1},P=x(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Se(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new S;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Se(e,t))});else{if(e.issues.length===t)continue;r||=Se(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Se(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new S;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new S;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Ie(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Re(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Ht=x(`$ZodString`,(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),F=x(`$ZodStringFormat`,(e,t)=>{Mt.init(e,t),Ht.init(e,t)}),Ut=x(`$ZodGUID`,(e,t)=>{t.pattern??=et,F.init(e,t)}),Wt=x(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=tt(e)}else t.pattern??=tt();F.init(e,t)}),Gt=x(`$ZodEmail`,(e,t)=>{t.pattern??=nt,F.init(e,t)}),Kt=x(`$ZodURL`,(e,t)=>{F.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),qt=x(`$ZodEmoji`,(e,t)=>{t.pattern??=rt(),F.init(e,t)}),Jt=x(`$ZodNanoID`,(e,t)=>{t.pattern??=Qe,F.init(e,t)}),Yt=x(`$ZodCUID`,(e,t)=>{t.pattern??=qe,F.init(e,t)}),Xt=x(`$ZodCUID2`,(e,t)=>{t.pattern??=Je,F.init(e,t)}),Zt=x(`$ZodULID`,(e,t)=>{t.pattern??=Ye,F.init(e,t)}),Qt=x(`$ZodXID`,(e,t)=>{t.pattern??=Xe,F.init(e,t)}),$t=x(`$ZodKSUID`,(e,t)=>{t.pattern??=Ze,F.init(e,t)}),en=x(`$ZodISODateTime`,(e,t)=>{t.pattern??=ht(t),F.init(e,t)}),tn=x(`$ZodISODate`,(e,t)=>{t.pattern??=ft,F.init(e,t)}),nn=x(`$ZodISOTime`,(e,t)=>{t.pattern??=mt(t),F.init(e,t)}),rn=x(`$ZodISODuration`,(e,t)=>{t.pattern??=$e,F.init(e,t)}),an=x(`$ZodIPv4`,(e,t)=>{t.pattern??=it,F.init(e,t),e._zod.bag.format=`ipv4`}),on=x(`$ZodIPv6`,(e,t)=>{t.pattern??=at,F.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),sn=x(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ot,F.init(e,t)}),cn=x(`$ZodCIDRv6`,(e,t)=>{t.pattern??=st,F.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ln(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const un=x(`$ZodBase64`,(e,t)=>{t.pattern??=ct,F.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ln(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function dn(e){if(!lt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ln(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const fn=x(`$ZodBase64URL`,(e,t)=>{t.pattern??=lt,F.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{dn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),pn=x(`$ZodE164`,(e,t)=>{t.pattern??=ut,F.init(e,t)});function mn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const hn=x(`$ZodJWT`,(e,t)=>{F.init(e,t),e._zod.check=n=>{mn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),gn=x(`$ZodNumber`,(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??vt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),_n=x(`$ZodNumberFormat`,(e,t)=>{Ot.init(e,t),gn.init(e,t)}),vn=x(`$ZodBoolean`,(e,t)=>{P.init(e,t),e._zod.pattern=yt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),yn=x(`$ZodNull`,(e,t)=>{P.init(e,t),e._zod.pattern=bt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),bn=x(`$ZodAny`,(e,t)=>{P.init(e,t),e._zod.parse=e=>e}),xn=x(`$ZodUnknown`,(e,t)=>{P.init(e,t),e._zod.parse=e=>e}),Sn=x(`$ZodNever`,(e,t)=>{P.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Cn(e,t,n){e.issues.length&&t.issues.push(...Ce(n,e.issues)),t.value[n]=e.value}const wn=x(`$ZodArray`,(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Cn(t,n,e))):Cn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Tn(e,t,n,r){e.issues.length&&t.issues.push(...Ce(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function En(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=pe(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Dn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Tn(e,n,i,t))):Tn(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const On=x(`$ZodObject`,(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=O(()=>En(t));j(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=oe,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Tn(n,t,e,s))):Tn(n,t,e,s)}return i?Dn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),kn=x(`$ZodObjectJIT`,(e,t)=>{On.init(e,t);let n=e._zod.parse,r=O(()=>En(t)),i=e=>{let t=new Bt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=re(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=re(e);t.write(`const ${n} = ${i(e)};`),t.write(`
4
+ if (${n}.issues.length) {
5
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
6
+ ...iss,
7
+ path: iss.path ? [${r}, ...iss.path] : [${r}]
8
+ })));
9
+ }
10
+
11
+
12
+ if (${n}.value === undefined) {
13
+ if (${r} in input) {
14
+ newResult[${r}] = undefined;
15
+ }
16
+ } else {
17
+ newResult[${r}] = ${n}.value;
18
+ }
19
+
20
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=oe,s=!w.jitless,c=s&&se.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Dn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function An(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Se(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Te(e,r,T())))}),t)}const jn=x(`$ZodUnion`,(e,t)=>{P.init(e,t),j(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),j(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),j(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>A(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>An(t,i,e,a)):An(s,i,e,a)}}),Mn=x(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,jn.init(e,t);let n=e._zod.parse;j(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=O(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!oe(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),Nn=x(`$ZodIntersection`,(e,t)=>{P.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Fn(e,t,n)):Fn(e,i,a)}});function Pn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ce(e)&&ce(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Pn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Pn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Fn(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Se(e))return e;let r=Pn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const In=x(`$ZodRecord`,(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ce(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Ce(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ce(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Te(e,r,T())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ce(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ce(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ln=x(`$ZodEnum`,(e,t)=>{P.init(e,t);let n=E(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ue.has(typeof e)).map(e=>typeof e==`string`?de(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Rn=x(`$ZodLiteral`,(e,t)=>{if(P.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?de(e):e?de(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),zn=x(`$ZodTransform`,(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new C(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new S;return n.value=i,n}});function Bn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Vn=x(`$ZodOptional`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${A(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Bn(t,e.value)):Bn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Hn=x(`$ZodNullable`,(e,t)=>{P.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${A(e.source)}|null)$`):void 0}),j(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Un=x(`$ZodDefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Wn(e,t)):Wn(r,t)}});function Wn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gn=x(`$ZodPrefault`,(e,t)=>{P.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Kn=x(`$ZodNonOptional`,(e,t)=>{P.init(e,t),j(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>qn(t,e)):qn(i,e)}});function qn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Jn=x(`$ZodCatch`,(e,t)=>{P.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Te(e,n,T()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Te(e,n,T()))},input:e.value}),e.issues=[]),e)}}),Yn=x(`$ZodPipe`,(e,t)=>{P.init(e,t),j(e._zod,`values`,()=>t.in._zod.values),j(e._zod,`optin`,()=>t.in._zod.optin),j(e._zod,`optout`,()=>t.out._zod.optout),j(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Xn(e,t.in,n)):Xn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Xn(e,t.out,n)):Xn(r,t.out,n)}});function Xn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Zn=x(`$ZodReadonly`,(e,t)=>{P.init(e,t),j(e._zod,`propValues`,()=>t.innerType._zod.propValues),j(e._zod,`values`,()=>t.innerType._zod.values),j(e._zod,`optin`,()=>t.innerType?._zod?.optin),j(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Qn):Qn(r)}});function Qn(e){return e.value=Object.freeze(e.value),e}const $n=x(`$ZodCustom`,(e,t)=>{Ct.init(e,t),P.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>er(t,n,r,e));er(i,n,r,e)}});function er(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(De(e))}}var tr,nr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function rr(){return new nr}(tr=globalThis).__zod_globalRegistry??(tr.__zod_globalRegistry=rr());const ir=globalThis.__zod_globalRegistry;function ar(e,t){return new e({type:`string`,...N(t)})}function or(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function sr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function cr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function lr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function ur(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function dr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function fr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function pr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function mr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function hr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function gr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function _r(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function vr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function yr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function br(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function xr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Sr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function Cr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function wr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function Tr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function Er(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function Dr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Or(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function kr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Ar(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function jr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Mr(e,t){return new e({type:`number`,checks:[],...N(t)})}function Nr(e,t){return new e({type:`number`,coerce:!0,checks:[],...N(t)})}function Pr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Fr(e,t){return new e({type:`boolean`,...N(t)})}function Ir(e,t){return new e({type:`null`,...N(t)})}function Lr(e){return new e({type:`any`})}function Rr(e){return new e({type:`unknown`})}function zr(e,t){return new e({type:`never`,...N(t)})}function Br(e,t){return new Tt({check:`less_than`,...N(t),value:e,inclusive:!1})}function Vr(e,t){return new Tt({check:`less_than`,...N(t),value:e,inclusive:!0})}function Hr(e,t){return new Et({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Ur(e,t){return new Et({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Wr(e,t){return new Dt({check:`multiple_of`,...N(t),value:e})}function Gr(e,t){return new kt({check:`max_length`,...N(t),maximum:e})}function Kr(e,t){return new At({check:`min_length`,...N(t),minimum:e})}function qr(e,t){return new jt({check:`length_equals`,...N(t),length:e})}function Jr(e,t){return new Nt({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Yr(e){return new Pt({check:`string_format`,format:`lowercase`,...N(e)})}function Xr(e){return new Ft({check:`string_format`,format:`uppercase`,...N(e)})}function Zr(e,t){return new It({check:`string_format`,format:`includes`,...N(t),includes:e})}function Qr(e,t){return new Lt({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function $r(e,t){return new Rt({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function ei(e){return new zt({check:`overwrite`,tx:e})}function ti(e){return ei(t=>t.normalize(e))}function ni(){return ei(e=>e.trim())}function ri(){return ei(e=>e.toLowerCase())}function ii(){return ei(e=>e.toUpperCase())}function ai(){return ei(e=>ie(e))}function oi(e,t,n){return new e({type:`array`,element:t,...N(n)})}function si(e,t,n){let r=N(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ci(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function li(e){let t=ui(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(De(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(De(r))}},e(n.value,n)));return t}function ui(e,t){let n=new Ct({check:`custom`,...N(t)});return n._zod.check=e,n}function di(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ir,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function I(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path},a=e._zod.parent;if(a)o.ref=a,I(a,t,r),t.seen.get(a).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&mi(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},i=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:i}=r(e);t.def={...t.schema},i&&(t.defId=i);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
21
+
22
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){i(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}if(e.metadataRegistry.get(n[0])?.id){i(n);continue}if(r.cycle){i(n);continue}if(r.count>1&&e.reused===`ref`){i(n);continue}}}function pi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t),i=n.def??n.schema,a={...i};if(n.ref===null)return;let o=n.ref;if(n.ref=null,o){r(o);let t=e.seen.get(o).schema;t.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(t)):(Object.assign(i,t),Object.assign(i,a))}n.isParent||e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let e=JSON.parse(JSON.stringify(i));return Object.defineProperty(e,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:gi(t,`input`),output:gi(t,`output`)}},enumerable:!1,writable:!1}),e}catch{throw Error(`Error converting schema to JSON.`)}}function mi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return mi(r.element,n);if(r.type===`set`)return mi(r.valueType,n);if(r.type===`lazy`)return mi(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return mi(r.innerType,n);if(r.type===`intersection`)return mi(r.left,n)||mi(r.right,n);if(r.type===`record`||r.type===`map`)return mi(r.keyType,n)||mi(r.valueType,n);if(r.type===`pipe`)return mi(r.in,n)||mi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(mi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(mi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(mi(e,n))return!0;return!!(r.rest&&mi(r.rest,n))}return!1}const hi=(e,t={})=>n=>{let r=di({...n,processors:t});return I(e,r),fi(r,e),pi(r,e)},gi=(e,t)=>n=>{let{libraryOptions:r,target:i}=n??{},a=di({...r??{},target:i,io:t,processors:{}});return I(e,a),fi(a,e),pi(a,e)},_i={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},vi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=_i[s]??s,i.format===``&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},yi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},bi=(e,t,n,r)=>{n.type=`boolean`},xi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Si=(e,t,n,r)=>{n.not={}},Ci=(e,t,n,r)=>{let i=e._zod.def,a=E(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},wi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Ti=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ei=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Di=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=I(a.element,t,{...r,path:[...r.path,`items`]})},Oi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=I(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=I(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ki=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>I(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ai=(e,t,n,r)=>{let i=e._zod.def,a=I(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=I(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ji=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=I(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=I(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})},Mi=(e,t,n,r)=>{let i=e._zod.def,a=I(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ni=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Pi=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Fi=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ii=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Li=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;I(a,t,r);let o=t.seen.get(e);o.ref=a},Ri=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},zi=(e,t,n,r)=>{let i=e._zod.def;I(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};function Bi(e){return!!e._zod}function Vi(e,t){return Bi(e)?Ie(e,t):e.safeParse(t)}function Hi(e){if(!e)return;let t;if(t=Bi(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Ui(e){if(Bi(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}const Wi=x(`ZodISODateTime`,(e,t)=>{en.init(e,t),z.init(e,t)});function Gi(e){return Or(Wi,e)}const Ki=x(`ZodISODate`,(e,t)=>{tn.init(e,t),z.init(e,t)});function qi(e){return kr(Ki,e)}const Ji=x(`ZodISOTime`,(e,t)=>{nn.init(e,t),z.init(e,t)});function Yi(e){return Ar(Ji,e)}const Xi=x(`ZodISODuration`,(e,t)=>{rn.init(e,t),z.init(e,t)});function Zi(e){return jr(Xi,e)}const Qi=(e,t)=>{ke.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Me(e,t)},flatten:{value:t=>je(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,D,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,D,2)}},isEmpty:{get(){return e.issues.length===0}}})};x(`ZodError`,Qi);const $i=x(`ZodError`,Qi,{Parent:Error}),ea=Ne($i),ta=Pe($i),na=Fe($i),ra=Le($i),ia=ze($i),aa=Be($i),oa=Ve($i),sa=He($i),ca=Ue($i),la=We($i),ua=Ge($i),da=Ke($i),L=x(`ZodType`,(e,t)=>(P.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:gi(e,`input`),output:gi(e,`output`)}}),e.toJSONSchema=hi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(M(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>fe(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ea(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>na(e,t,n),e.parseAsync=async(t,n)=>ta(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ra(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ia(e,t,n),e.decode=(t,n)=>aa(e,t,n),e.encodeAsync=async(t,n)=>oa(e,t,n),e.decodeAsync=async(t,n)=>sa(e,t,n),e.safeEncode=(t,n)=>ca(e,t,n),e.safeDecode=(t,n)=>la(e,t,n),e.safeEncodeAsync=async(t,n)=>ua(e,t,n),e.safeDecodeAsync=async(t,n)=>da(e,t,n),e.refine=(t,n)=>e.check(Co(t,n)),e.superRefine=t=>e.check(wo(t)),e.overwrite=t=>e.check(ei(t)),e.optional=()=>J(e),e.nullable=()=>so(e),e.nullish=()=>J(so(e)),e.nonoptional=t=>mo(e,t),e.array=()=>U(e),e.or=t=>G([e,t]),e.and=t=>Qa(e,t),e.transform=t=>vo(e,io(t)),e.default=t=>lo(e,t),e.prefault=t=>fo(e,t),e.catch=t=>go(e,t),e.pipe=t=>vo(e,t),e.readonly=()=>bo(e),e.describe=t=>{let n=e.clone();return ir.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return ir.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return ir.get(e);let n=e.clone();return ir.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),fa=x(`_ZodString`,(e,t)=>{Ht.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Jr(...t)),e.includes=(...t)=>e.check(Zr(...t)),e.startsWith=(...t)=>e.check(Qr(...t)),e.endsWith=(...t)=>e.check($r(...t)),e.min=(...t)=>e.check(Kr(...t)),e.max=(...t)=>e.check(Gr(...t)),e.length=(...t)=>e.check(qr(...t)),e.nonempty=(...t)=>e.check(Kr(1,...t)),e.lowercase=t=>e.check(Yr(t)),e.uppercase=t=>e.check(Xr(t)),e.trim=()=>e.check(ni()),e.normalize=(...t)=>e.check(ti(...t)),e.toLowerCase=()=>e.check(ri()),e.toUpperCase=()=>e.check(ii()),e.slugify=()=>e.check(ai())}),pa=x(`ZodString`,(e,t)=>{Ht.init(e,t),fa.init(e,t),e.email=t=>e.check(or(ma,t)),e.url=t=>e.check(fr(_a,t)),e.jwt=t=>e.check(Dr(Na,t)),e.emoji=t=>e.check(pr(ya,t)),e.guid=t=>e.check(sr(ha,t)),e.uuid=t=>e.check(cr(ga,t)),e.uuidv4=t=>e.check(lr(ga,t)),e.uuidv6=t=>e.check(ur(ga,t)),e.uuidv7=t=>e.check(dr(ga,t)),e.nanoid=t=>e.check(mr(ba,t)),e.guid=t=>e.check(sr(ha,t)),e.cuid=t=>e.check(hr(xa,t)),e.cuid2=t=>e.check(gr(Sa,t)),e.ulid=t=>e.check(_r(Ca,t)),e.base64=t=>e.check(wr(Aa,t)),e.base64url=t=>e.check(Tr(ja,t)),e.xid=t=>e.check(vr(wa,t)),e.ksuid=t=>e.check(yr(Ta,t)),e.ipv4=t=>e.check(br(Ea,t)),e.ipv6=t=>e.check(xr(Da,t)),e.cidrv4=t=>e.check(Sr(Oa,t)),e.cidrv6=t=>e.check(Cr(ka,t)),e.e164=t=>e.check(Er(Ma,t)),e.datetime=t=>e.check(Gi(t)),e.date=t=>e.check(qi(t)),e.time=t=>e.check(Yi(t)),e.duration=t=>e.check(Zi(t))});function R(e){return ar(pa,e)}const z=x(`ZodStringFormat`,(e,t)=>{F.init(e,t),fa.init(e,t)}),ma=x(`ZodEmail`,(e,t)=>{Gt.init(e,t),z.init(e,t)}),ha=x(`ZodGUID`,(e,t)=>{Ut.init(e,t),z.init(e,t)}),ga=x(`ZodUUID`,(e,t)=>{Wt.init(e,t),z.init(e,t)}),_a=x(`ZodURL`,(e,t)=>{Kt.init(e,t),z.init(e,t)});function va(e){return fr(_a,e)}const ya=x(`ZodEmoji`,(e,t)=>{qt.init(e,t),z.init(e,t)}),ba=x(`ZodNanoID`,(e,t)=>{Jt.init(e,t),z.init(e,t)}),xa=x(`ZodCUID`,(e,t)=>{Yt.init(e,t),z.init(e,t)}),Sa=x(`ZodCUID2`,(e,t)=>{Xt.init(e,t),z.init(e,t)}),Ca=x(`ZodULID`,(e,t)=>{Zt.init(e,t),z.init(e,t)}),wa=x(`ZodXID`,(e,t)=>{Qt.init(e,t),z.init(e,t)}),Ta=x(`ZodKSUID`,(e,t)=>{$t.init(e,t),z.init(e,t)}),Ea=x(`ZodIPv4`,(e,t)=>{an.init(e,t),z.init(e,t)}),Da=x(`ZodIPv6`,(e,t)=>{on.init(e,t),z.init(e,t)}),Oa=x(`ZodCIDRv4`,(e,t)=>{sn.init(e,t),z.init(e,t)}),ka=x(`ZodCIDRv6`,(e,t)=>{cn.init(e,t),z.init(e,t)}),Aa=x(`ZodBase64`,(e,t)=>{un.init(e,t),z.init(e,t)}),ja=x(`ZodBase64URL`,(e,t)=>{fn.init(e,t),z.init(e,t)}),Ma=x(`ZodE164`,(e,t)=>{pn.init(e,t),z.init(e,t)}),Na=x(`ZodJWT`,(e,t)=>{hn.init(e,t),z.init(e,t)}),Pa=x(`ZodNumber`,(e,t)=>{gn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.gt=(t,n)=>e.check(Hr(t,n)),e.gte=(t,n)=>e.check(Ur(t,n)),e.min=(t,n)=>e.check(Ur(t,n)),e.lt=(t,n)=>e.check(Br(t,n)),e.lte=(t,n)=>e.check(Vr(t,n)),e.max=(t,n)=>e.check(Vr(t,n)),e.int=t=>e.check(Ia(t)),e.safe=t=>e.check(Ia(t)),e.positive=t=>e.check(Hr(0,t)),e.nonnegative=t=>e.check(Ur(0,t)),e.negative=t=>e.check(Br(0,t)),e.nonpositive=t=>e.check(Vr(0,t)),e.multipleOf=(t,n)=>e.check(Wr(t,n)),e.step=(t,n)=>e.check(Wr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function B(e){return Mr(Pa,e)}const Fa=x(`ZodNumberFormat`,(e,t)=>{_n.init(e,t),Pa.init(e,t)});function Ia(e){return Pr(Fa,e)}const La=x(`ZodBoolean`,(e,t)=>{vn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r)});function V(e){return Fr(La,e)}const Ra=x(`ZodNull`,(e,t)=>{yn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r)});function za(e){return Ir(Ra,e)}const Ba=x(`ZodAny`,(e,t)=>{bn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Va(){return Lr(Ba)}const Ha=x(`ZodUnknown`,(e,t)=>{xn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function H(){return Rr(Ha)}const Ua=x(`ZodNever`,(e,t)=>{Sn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r)});function Wa(e){return zr(Ua,e)}const Ga=x(`ZodArray`,(e,t)=>{wn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Kr(t,n)),e.nonempty=t=>e.check(Kr(1,t)),e.max=(t,n)=>e.check(Gr(t,n)),e.length=(t,n)=>e.check(qr(t,n)),e.unwrap=()=>e.element});function U(e,t){return oi(Ga,e,t)}const Ka=x(`ZodObject`,(e,t)=>{kn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),j(e,`shape`,()=>t.shape),e.keyof=()=>to(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:H()}),e.loose=()=>e.clone({...e._zod.def,catchall:H()}),e.strict=()=>e.clone({...e._zod.def,catchall:Wa()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>_e(e,t),e.safeExtend=t=>ve(e,t),e.merge=t=>ye(e,t),e.pick=t=>he(e,t),e.omit=t=>ge(e,t),e.partial=(...t)=>be(ao,e,t[0]),e.required=(...t)=>xe(po,e,t[0])});function W(e,t){return new Ka({type:`object`,shape:e??{},...N(t)})}function qa(e,t){return new Ka({type:`object`,shape:e,catchall:H(),...N(t)})}const Ja=x(`ZodUnion`,(e,t)=>{jn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.options=t.options});function G(e,t){return new Ja({type:`union`,options:e,...N(t)})}const Ya=x(`ZodDiscriminatedUnion`,(e,t)=>{Ja.init(e,t),Mn.init(e,t)});function Xa(e,t,n){return new Ya({type:`union`,options:t,discriminator:e,...N(n)})}const Za=x(`ZodIntersection`,(e,t)=>{Nn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r)});function Qa(e,t){return new Za({type:`intersection`,left:e,right:t})}const $a=x(`ZodRecord`,(e,t)=>{In.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,n){return new $a({type:`record`,keyType:e,valueType:t,...N(n)})}const eo=x(`ZodEnum`,(e,t)=>{Ln.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new eo({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new eo({...t,checks:[],...N(r),entries:i})}});function to(e,t){return new eo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}const no=x(`ZodLiteral`,(e,t)=>{Rn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function q(e,t){return new no({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}const ro=x(`ZodTransform`,(e,t)=>{zn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new C(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(De(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(De(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function io(e){return new ro({type:`transform`,transform:e})}const ao=x(`ZodOptional`,(e,t)=>{Vn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function J(e){return new ao({type:`optional`,innerType:e})}const oo=x(`ZodNullable`,(e,t)=>{Hn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function so(e){return new oo({type:`nullable`,innerType:e})}const co=x(`ZodDefault`,(e,t)=>{Un.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lo(e,t){return new co({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():le(t)}})}const uo=x(`ZodPrefault`,(e,t)=>{Gn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fo(e,t){return new uo({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():le(t)}})}const po=x(`ZodNonOptional`,(e,t)=>{Kn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mo(e,t){return new po({type:`nonoptional`,innerType:e,...N(t)})}const ho=x(`ZodCatch`,(e,t)=>{Jn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function go(e,t){return new ho({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const _o=x(`ZodPipe`,(e,t)=>{Yn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.in=t.in,e.out=t.out});function vo(e,t){return new _o({type:`pipe`,in:e,out:t})}const yo=x(`ZodReadonly`,(e,t)=>{Zn.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e){return new yo({type:`readonly`,innerType:e})}const xo=x(`ZodCustom`,(e,t)=>{$n.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function So(e,t){return si(xo,e??(()=>!0),t)}function Co(e,t={}){return ci(xo,e,t)}function wo(e){return li(e)}function To(e,t){return vo(io(e),t)}const Eo={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var Do;(function(e){})(Do||={});function Oo(e){return Nr(Pa,e)}const ko=`2025-11-25`,Ao=[ko,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],jo=`io.modelcontextprotocol/related-task`,Mo=So(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),No=G([R(),B().int()]),Po=R();qa({ttl:G([B(),za()]).optional(),pollInterval:B().optional()});const Fo=W({ttl:B().optional()}),Io=W({taskId:R()}),Lo=qa({progressToken:No.optional(),[jo]:Io.optional()}),Ro=W({_meta:Lo.optional()}),zo=Ro.extend({task:Fo.optional()}),Bo=e=>zo.safeParse(e).success,Vo=W({method:R(),params:Ro.loose().optional()}),Ho=W({_meta:Lo.optional()}),Uo=W({method:R(),params:Ho.loose().optional()}),Wo=qa({_meta:Lo.optional()}),Go=G([R(),B().int()]),Ko=W({jsonrpc:q(`2.0`),id:Go,...Vo.shape}).strict(),qo=e=>Ko.safeParse(e).success,Jo=W({jsonrpc:q(`2.0`),...Uo.shape}).strict(),Yo=e=>Jo.safeParse(e).success,Xo=W({jsonrpc:q(`2.0`),id:Go,result:Wo}).strict(),Zo=e=>Xo.safeParse(e).success;var Y;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Y||={});const Qo=W({jsonrpc:q(`2.0`),id:Go.optional(),error:W({code:B().int(),message:R(),data:H().optional()})}).strict(),$o=e=>Qo.safeParse(e).success,es=G([Ko,Jo,Xo,Qo]);G([Xo,Qo]);const ts=Wo.strict(),ns=Ho.extend({requestId:Go.optional(),reason:R().optional()}),rs=Uo.extend({method:q(`notifications/cancelled`),params:ns}),is=W({icons:U(W({src:R(),mimeType:R().optional(),sizes:U(R()).optional(),theme:to([`light`,`dark`]).optional()})).optional()}),as=W({name:R(),title:R().optional()}),os=as.extend({...as.shape,...is.shape,version:R(),websiteUrl:R().optional(),description:R().optional()}),ss=To(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Qa(W({form:Qa(W({applyDefaults:V().optional()}),K(R(),H())).optional(),url:Mo.optional()}),K(R(),H()).optional())),cs=qa({list:Mo.optional(),cancel:Mo.optional(),requests:qa({sampling:qa({createMessage:Mo.optional()}).optional(),elicitation:qa({create:Mo.optional()}).optional()}).optional()}),ls=qa({list:Mo.optional(),cancel:Mo.optional(),requests:qa({tools:qa({call:Mo.optional()}).optional()}).optional()}),us=W({experimental:K(R(),Mo).optional(),sampling:W({context:Mo.optional(),tools:Mo.optional()}).optional(),elicitation:ss.optional(),roots:W({listChanged:V().optional()}).optional(),tasks:cs.optional()}),ds=Ro.extend({protocolVersion:R(),capabilities:us,clientInfo:os}),fs=Vo.extend({method:q(`initialize`),params:ds}),ps=W({experimental:K(R(),Mo).optional(),logging:Mo.optional(),completions:Mo.optional(),prompts:W({listChanged:V().optional()}).optional(),resources:W({subscribe:V().optional(),listChanged:V().optional()}).optional(),tools:W({listChanged:V().optional()}).optional(),tasks:ls.optional()}),ms=Wo.extend({protocolVersion:R(),capabilities:ps,serverInfo:os,instructions:R().optional()}),hs=Uo.extend({method:q(`notifications/initialized`),params:Ho.optional()}),gs=e=>hs.safeParse(e).success,_s=Vo.extend({method:q(`ping`),params:Ro.optional()}),vs=W({progress:B(),total:J(B()),message:J(R())}),ys=W({...Ho.shape,...vs.shape,progressToken:No}),bs=Uo.extend({method:q(`notifications/progress`),params:ys}),xs=Ro.extend({cursor:Po.optional()}),Ss=Vo.extend({params:xs.optional()}),Cs=Wo.extend({nextCursor:Po.optional()}),ws=to([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Ts=W({taskId:R(),status:ws,ttl:G([B(),za()]),createdAt:R(),lastUpdatedAt:R(),pollInterval:J(B()),statusMessage:J(R())}),Es=Wo.extend({task:Ts}),Ds=Ho.merge(Ts),Os=Uo.extend({method:q(`notifications/tasks/status`),params:Ds}),ks=Vo.extend({method:q(`tasks/get`),params:Ro.extend({taskId:R()})}),As=Wo.merge(Ts),js=Vo.extend({method:q(`tasks/result`),params:Ro.extend({taskId:R()})});Wo.loose();const Ms=Ss.extend({method:q(`tasks/list`)}),Ns=Cs.extend({tasks:U(Ts)}),Ps=Vo.extend({method:q(`tasks/cancel`),params:Ro.extend({taskId:R()})}),Fs=Wo.merge(Ts),Is=W({uri:R(),mimeType:J(R()),_meta:K(R(),H()).optional()}),Ls=Is.extend({text:R()}),Rs=R().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),zs=Is.extend({blob:Rs}),Bs=to([`user`,`assistant`]),Vs=W({audience:U(Bs).optional(),priority:B().min(0).max(1).optional(),lastModified:Gi({offset:!0}).optional()}),Hs=W({...as.shape,...is.shape,uri:R(),description:J(R()),mimeType:J(R()),annotations:Vs.optional(),_meta:J(qa({}))}),Us=W({...as.shape,...is.shape,uriTemplate:R(),description:J(R()),mimeType:J(R()),annotations:Vs.optional(),_meta:J(qa({}))}),Ws=Ss.extend({method:q(`resources/list`)}),Gs=Cs.extend({resources:U(Hs)}),Ks=Ss.extend({method:q(`resources/templates/list`)}),qs=Cs.extend({resourceTemplates:U(Us)}),Js=Ro.extend({uri:R()}),Ys=Js,Xs=Vo.extend({method:q(`resources/read`),params:Ys}),Zs=Wo.extend({contents:U(G([Ls,zs]))}),Qs=Uo.extend({method:q(`notifications/resources/list_changed`),params:Ho.optional()}),$s=Js,ec=Vo.extend({method:q(`resources/subscribe`),params:$s}),tc=Js,nc=Vo.extend({method:q(`resources/unsubscribe`),params:tc}),rc=Ho.extend({uri:R()}),ic=Uo.extend({method:q(`notifications/resources/updated`),params:rc}),ac=W({name:R(),description:J(R()),required:J(V())}),oc=W({...as.shape,...is.shape,description:J(R()),arguments:J(U(ac)),_meta:J(qa({}))}),sc=Ss.extend({method:q(`prompts/list`)}),cc=Cs.extend({prompts:U(oc)}),lc=Ro.extend({name:R(),arguments:K(R(),R()).optional()}),uc=Vo.extend({method:q(`prompts/get`),params:lc}),dc=W({type:q(`text`),text:R(),annotations:Vs.optional(),_meta:K(R(),H()).optional()}),fc=W({type:q(`image`),data:Rs,mimeType:R(),annotations:Vs.optional(),_meta:K(R(),H()).optional()}),pc=W({type:q(`audio`),data:Rs,mimeType:R(),annotations:Vs.optional(),_meta:K(R(),H()).optional()}),mc=W({type:q(`tool_use`),name:R(),id:R(),input:K(R(),H()),_meta:K(R(),H()).optional()}),hc=W({type:q(`resource`),resource:G([Ls,zs]),annotations:Vs.optional(),_meta:K(R(),H()).optional()}),gc=G([dc,fc,pc,Hs.extend({type:q(`resource_link`)}),hc]),_c=W({role:Bs,content:gc}),vc=Wo.extend({description:R().optional(),messages:U(_c)}),yc=Uo.extend({method:q(`notifications/prompts/list_changed`),params:Ho.optional()}),bc=W({title:R().optional(),readOnlyHint:V().optional(),destructiveHint:V().optional(),idempotentHint:V().optional(),openWorldHint:V().optional()}),xc=W({taskSupport:to([`required`,`optional`,`forbidden`]).optional()}),Sc=W({...as.shape,...is.shape,description:R().optional(),inputSchema:W({type:q(`object`),properties:K(R(),Mo).optional(),required:U(R()).optional()}).catchall(H()),outputSchema:W({type:q(`object`),properties:K(R(),Mo).optional(),required:U(R()).optional()}).catchall(H()).optional(),annotations:bc.optional(),execution:xc.optional(),_meta:K(R(),H()).optional()}),Cc=Ss.extend({method:q(`tools/list`)}),wc=Cs.extend({tools:U(Sc)}),Tc=Wo.extend({content:U(gc).default([]),structuredContent:K(R(),H()).optional(),isError:V().optional()});Tc.or(Wo.extend({toolResult:H()}));const Ec=zo.extend({name:R(),arguments:K(R(),H()).optional()}),Dc=Vo.extend({method:q(`tools/call`),params:Ec}),Oc=Uo.extend({method:q(`notifications/tools/list_changed`),params:Ho.optional()}),kc=W({autoRefresh:V().default(!0),debounceMs:B().int().nonnegative().default(300)}),Ac=to([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),jc=Ro.extend({level:Ac}),Mc=Vo.extend({method:q(`logging/setLevel`),params:jc}),Nc=Ho.extend({level:Ac,logger:R().optional(),data:H()}),Pc=Uo.extend({method:q(`notifications/message`),params:Nc}),Fc=W({hints:U(W({name:R().optional()})).optional(),costPriority:B().min(0).max(1).optional(),speedPriority:B().min(0).max(1).optional(),intelligencePriority:B().min(0).max(1).optional()}),Ic=W({mode:to([`auto`,`required`,`none`]).optional()}),Lc=W({type:q(`tool_result`),toolUseId:R().describe(`The unique identifier for the corresponding tool call.`),content:U(gc).default([]),structuredContent:W({}).loose().optional(),isError:V().optional(),_meta:K(R(),H()).optional()}),Rc=Xa(`type`,[dc,fc,pc]),zc=Xa(`type`,[dc,fc,pc,mc,Lc]),Bc=W({role:Bs,content:G([zc,U(zc)]),_meta:K(R(),H()).optional()}),Vc=zo.extend({messages:U(Bc),modelPreferences:Fc.optional(),systemPrompt:R().optional(),includeContext:to([`none`,`thisServer`,`allServers`]).optional(),temperature:B().optional(),maxTokens:B().int(),stopSequences:U(R()).optional(),metadata:Mo.optional(),tools:U(Sc).optional(),toolChoice:Ic.optional()}),Hc=Vo.extend({method:q(`sampling/createMessage`),params:Vc}),Uc=Wo.extend({model:R(),stopReason:J(to([`endTurn`,`stopSequence`,`maxTokens`]).or(R())),role:Bs,content:Rc}),Wc=Wo.extend({model:R(),stopReason:J(to([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(R())),role:Bs,content:G([zc,U(zc)])}),Gc=W({type:q(`boolean`),title:R().optional(),description:R().optional(),default:V().optional()}),Kc=W({type:q(`string`),title:R().optional(),description:R().optional(),minLength:B().optional(),maxLength:B().optional(),format:to([`email`,`uri`,`date`,`date-time`]).optional(),default:R().optional()}),qc=W({type:to([`number`,`integer`]),title:R().optional(),description:R().optional(),minimum:B().optional(),maximum:B().optional(),default:B().optional()}),Jc=W({type:q(`string`),title:R().optional(),description:R().optional(),enum:U(R()),default:R().optional()}),Yc=W({type:q(`string`),title:R().optional(),description:R().optional(),oneOf:U(W({const:R(),title:R()})),default:R().optional()}),Xc=G([G([W({type:q(`string`),title:R().optional(),description:R().optional(),enum:U(R()),enumNames:U(R()).optional(),default:R().optional()}),G([Jc,Yc]),G([W({type:q(`array`),title:R().optional(),description:R().optional(),minItems:B().optional(),maxItems:B().optional(),items:W({type:q(`string`),enum:U(R())}),default:U(R()).optional()}),W({type:q(`array`),title:R().optional(),description:R().optional(),minItems:B().optional(),maxItems:B().optional(),items:W({anyOf:U(W({const:R(),title:R()}))}),default:U(R()).optional()})])]),Gc,Kc,qc]),Zc=G([zo.extend({mode:q(`form`).optional(),message:R(),requestedSchema:W({type:q(`object`),properties:K(R(),Xc),required:U(R()).optional()})}),zo.extend({mode:q(`url`),message:R(),elicitationId:R(),url:R().url()})]),Qc=Vo.extend({method:q(`elicitation/create`),params:Zc}),$c=Ho.extend({elicitationId:R()}),el=Uo.extend({method:q(`notifications/elicitation/complete`),params:$c}),tl=Wo.extend({action:to([`accept`,`decline`,`cancel`]),content:To(e=>e===null?void 0:e,K(R(),G([R(),B(),V(),U(R())])).optional())}),nl=W({type:q(`ref/resource`),uri:R()}),rl=W({type:q(`ref/prompt`),name:R()}),il=Ro.extend({ref:G([rl,nl]),argument:W({name:R(),value:R()}),context:W({arguments:K(R(),R()).optional()}).optional()}),al=Vo.extend({method:q(`completion/complete`),params:il}),ol=Wo.extend({completion:qa({values:U(R()).max(100),total:J(B().int()),hasMore:J(V())})}),sl=W({uri:R().startsWith(`file://`),name:R().optional(),_meta:K(R(),H()).optional()}),cl=Vo.extend({method:q(`roots/list`),params:Ro.optional()}),ll=Wo.extend({roots:U(sl)}),ul=Uo.extend({method:q(`notifications/roots/list_changed`),params:Ho.optional()});G([_s,fs,al,Mc,uc,sc,Ws,Ks,Xs,ec,nc,Dc,Cc,ks,js,Ms,Ps]),G([rs,bs,hs,ul,Os]),G([ts,Uc,Wc,tl,ll,As,Ns,Es]),G([_s,Hc,Qc,cl,ks,js,Ms,Ps]),G([rs,bs,Pc,ic,Qs,Oc,yc,Os,el]),G([ts,ms,ol,vc,cc,Gs,qs,Zs,Tc,wc,As,Ns,Es]);var X=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===Y.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new dl(e.elicitations,n)}return new e(t,n,r)}},dl=class extends X{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Y.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function fl(e){return e===`completed`||e===`failed`||e===`cancelled`}function pl(e){let t=Hi(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Ui(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function ml(e,t){let n=Vi(e,t);if(!n.success)throw n.error;return n.data}var hl=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(rs,e=>{this._oncancel(e)}),this.setNotificationHandler(bs,e=>{this._onprogress(e)}),this.setRequestHandler(_s,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ks,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new X(Y.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(js,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new X(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new X(Y.InvalidParams,`Task not found: ${r}`);if(!fl(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(fl(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[jo]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Ms,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new X(Y.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Ps,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new X(Y.InvalidParams,`Task not found: ${e.params.taskId}`);if(fl(n.status))throw new X(Y.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new X(Y.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof X?e:new X(Y.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),X.fromError(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Zo(e)||$o(e)?this._onresponse(e):qo(e)?this._onrequest(e,t):Yo(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let t=X.fromError(Y.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[jo]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:Y.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=Bo(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{let a={...r,relatedRequestId:e.id};i&&!a.relatedTask&&(a.relatedTask={taskId:i});let o=a.relatedTask?.taskId??i;return o&&s&&await s.updateTaskStatus(o,`input_required`),await this.request(t,n,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Y.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),Zo(e)?n(e):n(new X(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(Zo(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),Zo(e)?r(e):r(X.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof X?e:new X(Y.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Es,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new X(Y.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},fl(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new X(Y.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new X(Y.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof X?e:new X(Y.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[jo]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof X?e:new X(Y.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Vi(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(X.fromError(Y.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},As,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},Ns,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},Fs,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[jo]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.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 n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[jo]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[jo]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=pl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=ml(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=pl(e);this._notificationHandlers.set(n,n=>{let r=ml(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&qo(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new X(Y.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new X(Y.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new X(Y.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new X(Y.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=Os.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),fl(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new X(Y.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(fl(a.status))throw new X(Y.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=Os.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),fl(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function gl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _l(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];gl(a)&&gl(i)?n[r]={...a,...i}:n[r]=i}return n}var vl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{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(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),yl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=vl();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Z=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=vl(),n=yl();var r=vl();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=yl();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ee(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
23
+ `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}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,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ee(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ie(e)}`}e.not=ee;let te=re(e.operators.AND);function j(...e){return e.reduce(te)}e.and=j;let ne=re(e.operators.OR);function M(...e){return e.reduce(ne)}e.or=M;function re(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ie(n)} ${e} ${ie(r)}`}function ie(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Q=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=Z(),n=vl();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),bl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),xl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=Z(),n=Q(),r=bl();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Sl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=xl(),n=Z(),r=bl(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Cl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),wl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Tl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=Cl(),n=wl(),r=xl(),i=Z(),a=Q();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
24
+ || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
25
+ || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
26
+ || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;for(let e in s.number&&delete s.integer,s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),El=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=Z(),n=Q();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Dl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=Z(),n=Q(),r=bl(),i=Q();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Ol=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=Z(),n=bl(),r=Dl(),i=xl();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),kl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=Z(),n=Q();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Al=n(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),jl=n(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Ml=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Q(),n=Al(),r=jl(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Nl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Sl(),n=Tl(),r=wl(),i=Tl(),a=El(),o=Ol(),s=kl(),c=Z(),l=bl(),u=Ml(),d=Q(),f=xl();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ee(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return j(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);j(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ee(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&te(e),t.return((0,c._)`${l.default.errors} === 0`))}function te({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function j(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>de(e,`$ref`,h.all.$ref.definition));return}p.jtd||M(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),ne(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ne(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ne(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&de(e,n.keyword,n.definition,t.type)})}function M(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(re(e,t),e.opts.allowUnionTypes||ie(e,t),ae(e,e.dataTypes))}function re(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{se(e.dataTypes,t)||le(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ce(e,t)}}function ie(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&le(e,`use allowUnionTypes to allow union type keyword`)}function ae(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>oe(t,e))&&le(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function oe(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function se(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ce(e,t){let n=[];for(let r of e.dataTypes)se(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function le(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var ue=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,pe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}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:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=ue;function de(e,t,n,r){let i=new ue(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let fe=/^\/(?:[^~]|~0|~1)*$/,N=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function pe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!fe.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=N.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=pe})),Pl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Fl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ml();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Il=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=Z(),n=Pl(),r=bl(),i=Ml(),a=Q(),o=Nl();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Ll=n(((e,t)=>{t.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}})),Rl=n(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function i(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let a=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){let r=i(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function c(e){let t=0,n={error:!1,address:``,zone:``},r=[],a=[],c=!1,l=!1,u=s;for(let i=0;i<e.length;i++){let s=e[i];if(!(s===`[`||s===`]`))if(s===`:`){if(c===!0&&(l=!0),!u(a,r,n))break;if(++t>7){n.error=!0;break}i>0&&e[i-1]===`:`&&(c=!0),r.push(`:`);continue}else if(s===`%`){if(!u(a,r,n))break;u=o}else{a.push(s);continue}}return a.length&&(u===o?n.zone=a.join(``):l?r.push(a.join(``)):r.push(i(a))),n.address=r.join(``),n}function l(e){if(u(e,`:`)<2)return{host:e,isIPV6:!1};let t=c(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function u(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function d(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}function f(e,t){let n=t===!0?unescape:escape;return e.scheme!==void 0&&(e.scheme=n(e.scheme)),e.userinfo!==void 0&&(e.userinfo=n(e.userinfo)),e.host!==void 0&&(e.host=n(e.host)),e.path!==void 0&&(e.path=n(e.path)),e.query!==void 0&&(e.query=n(e.query)),e.fragment!==void 0&&(e.fragment=n(e.fragment)),e}function p(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let t=l(n);n=t.isIPV6===!0?`[${t.escapedHost}]`:e.host}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:a,recomposeAuthority:p,normalizeComponentEncoding:f,removeDotSegments:d,isIPv4:r,isUUID:n,normalizeIPv6:l,stringArrayToHexStripped:i}})),zl=n(((e,t)=>{let{isUUID:n}=Rl(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=S(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=S(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},y={scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},b={scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0},x={http:h,https:g,ws:_,wss:v,urn:y,"urn:uuid":b};Object.setPrototypeOf(x,null);function S(e){return e&&(x[e]||x[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:x,isValidSchemeName:a,getSchemeHandler:S}})),Bl=n(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:o,nonSimpleDomain:s}=Rl(),{SCHEMES:c,getSchemeHandler:l}=zl();function u(e,t){return typeof e==`string`?e=m(g(e,t),t):typeof e==`object`&&(e=g(m(e,t),t)),e}function d(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=f(g(e,r),g(t,r),r,!0);return r.skipEscape=!0,m(i,r)}function f(e,t,n,i){let a={};return i||(e=g(m(e,n),n),t=g(m(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function p(e,t,n){return typeof e==`string`?(e=unescape(e),e=m(a(g(e,n),!0),{...n,skipEscape:!0})):typeof e==`object`&&(e=m(a(e,!0),{...n,skipEscape:!0})),typeof t==`string`?(t=unescape(t),t=m(a(g(t,n),!0),{...n,skipEscape:!0})):typeof t==`object`&&(t=m(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function m(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},a=Object.assign({},t),o=[],s=l(a.scheme||n.scheme);s&&s.serialize&&s.serialize(n,a),n.path!==void 0&&(a.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),a.reference!==`suffix`&&n.scheme&&o.push(n.scheme,`:`);let c=i(n);if(c!==void 0&&(a.reference!==`suffix`&&o.push(`//`),o.push(c),n.path&&n.path[0]!==`/`&&o.push(`/`)),n.path!==void 0){let e=n.path;!a.absolutePath&&(!s||!s.absolutePath)&&(e=r(e)),c===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),o.push(e)}return n.query!==void 0&&o.push(`?`,n.query),n.fragment!==void 0&&o.push(`#`,n.fragment),o.join(``)}let h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function g(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let c=e.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||``,i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(o(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),a=e.isIPV6}else a=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let t=l(r.scheme||i.scheme);if(!r.unicodeSupport&&(!t||!t.unicodeSupport)&&i.host&&(r.domainHost||t&&t.domainHost)&&a===!1&&s(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}(!t||t&&!t.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=unescape(i.host))),i.path&&=escape(unescape(i.path)),i.fragment&&=encodeURI(decodeURIComponent(i.fragment))),t&&t.parse&&t.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return i}let _={SCHEMES:c,normalize:u,resolve:d,resolveComponent:f,equal:p,serialize:m,parse:g};t.exports=_,t.exports.default=_,t.exports.fastUri=_})),Vl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Bl();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Hl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Nl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Z();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Pl(),i=Fl(),a=Cl(),o=Il(),s=Z(),c=Ml(),l=Tl(),u=Q(),d=Ll(),f=Vl(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=D(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=T.call(this),e.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&w.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),S.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw 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 r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}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 t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(k.call(this,n,t),!t)return(0,u.eachItem)(n,e=>A.call(this,e)),this;te.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>A.call(this,e,r):e=>r.type.forEach(t=>A.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=ne(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function S(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function C(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function w(e){if(Array.isArray(e)){this.addVocabulary(e);return}for(let t in this.logger.warn(`keywords option as map is deprecated, pass array`),e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function T(){let e={...this.opts};for(let t of m)delete e[t];return e}let E={log(){},warn(){},error(){}};function D(e){if(e===!1)return E;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let O=/^[a-z_$][a-z0-9_$:-]*$/i;function k(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!O.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function A(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ee.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ee(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function te(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ne(t)),e.validateSchema=this.compile(t,!0))}let j={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ne(e){return{anyOf:[e,j]}}})),Ul=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Wl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Fl(),n=Dl(),r=Z(),i=bl(),a=Il(),o=Q(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),Gl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul(),n=Wl();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Kl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),ql=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Jl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),Yl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=Jl();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Xl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dl(),n=Z();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,n.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,n._)`{pattern: ${e}}`},code(e){let{data:r,$data:i,schema:a,schemaCode:o,it:s}=e,c=s.opts.unicodeRegExp?`u`:``,l=i?(0,n._)`(new RegExp(${o}, ${c}))`:(0,t.usePattern)(e,a);e.fail$data((0,n._)`!${l}.test(${r})`)}}})),Zl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Ql=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dl(),n=Z(),r=Q();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),$l=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),eu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Al();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),tu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Tl(),n=Z(),r=Q(),i=eu();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),nu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=eu();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),ru=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=eu();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),iu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Kl(),n=ql(),r=Yl(),i=Xl(),a=Zl(),o=Ql(),s=$l(),c=tu(),l=nu(),u=ru();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),au=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=Z(),n=Q(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),ou=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=Z(),n=Q(),r=Dl(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),su=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ou();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),cu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=Dl(),i=au();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),lu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),uu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=Z(),n=Q(),r=Dl();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
27
+ missingProperty: ${i},
28
+ depsCount: ${n},
29
+ deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),du=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),fu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dl(),n=Z(),r=bl(),i=Q();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),pu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Nl(),n=Dl(),r=Q(),i=fu();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),mu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Dl(),n=Z(),r=Q(),i=Q();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),hu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),gu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Dl().validateUnion,error:{message:`must match a schema in anyOf`}}})),_u=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),vu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),yu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),bu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),xu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=au(),n=su(),r=ou(),i=cu(),a=lu(),o=uu(),s=du(),c=fu(),l=pu(),u=mu(),d=hu(),f=gu(),p=_u(),m=vu(),h=yu(),g=bu();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Su=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Cu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Su().default]})),wu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Tu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Gl(),n=iu(),r=xu(),i=Cu(),a=wu();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Eu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Du=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Eu(),r=Il(),i=Fl(),a=Q();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();for(let e in o.if(!1),r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Ou=n(((e,t)=>{t.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}})),ku=n(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Hl(),r=Tu(),i=Du(),a=Ou(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.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(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=Nl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Z();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Pl();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Fl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})})),Au=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:E,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:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\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,m),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},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[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 _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}let T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),ju=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatLimitDefinition=void 0;let t=ku(),n=Z(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),Mu=n(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});let n=Au(),r=ju(),i=Z(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=s})),Nu=t(ku(),1),Pu=t(Mu(),1);function Fu(){let e=new Nu.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Pu.default)(e),e}var Iu=class{constructor(e){this._ajv=e??Fu()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},Lu=class{constructor(e){this._client=e}async*callToolStream(e,t=Tc,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new X(Y.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new X(Y.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof X){yield{type:`error`,error:e};return}yield{type:`error`,error:new X(Y.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function Ru(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`tools/call`:if(!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function zu(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function Bu(e,t){if(!(!e||typeof t!=`object`||!t)){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&Bu(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&Bu(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&Bu(n,t)}}function Vu(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var Hu=class extends hl{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Iu,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,Oc,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,yc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,Qs,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new Lu(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=_l(this._capabilities,e)}setRequestHandler(e,t){let n=Hi(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(Bi(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=Vi(Qc,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new X(Y.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=Vu(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new X(Y.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new X(Y.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=Vi(Es,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new X(Y.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=Vi(tl,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new X(Y.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{Bu(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=Vi(Hc,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new X(Y.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=Vi(Es,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new X(Y.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=Vi(Uc,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new X(Y.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:ko,capabilities:this._capabilities,clientInfo:this._clientInfo}},ms,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!Ao.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`initialize`:break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/roots/list_changed`:if(!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`);break;case`notifications/initialized`:break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`);break;case`ping`:break}}assertTaskCapability(e){Ru(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&zu(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},ts,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},ol,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},ts,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},vc,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},cc,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},Gs,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},qs,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},Zs,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},ts,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},ts,t)}async callTool(e,t=Tc,n){if(this.isToolTaskRequired(e.name))throw new X(Y.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new X(Y.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new X(Y.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof X?e:new X(Y.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},wc,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=kc.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{s(null,await r())}catch(e){s(e instanceof Error?e:Error(String(e)),null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}},Uu=n(((t,n)=>{n.exports=o,o.sync=s;var r=e(`fs`);function i(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function a(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:i(t,n)}function o(e,t,n){r.stat(e,function(r,i){n(r,r?!1:a(i,e,t))})}function s(e,t){return a(r.statSync(e),e,t)}})),Wu=n(((t,n)=>{n.exports=i,i.sync=a;var r=e(`fs`);function i(e,t,n){r.stat(e,function(e,r){n(e,e?!1:o(r,t))})}function a(e,t){return o(r.statSync(e),t)}function o(e,t){return e.isFile()&&s(e,t)}function s(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Gu=n(((t,n)=>{e(`fs`);var r=process.platform===`win32`||global.TESTING_WINDOWS?Uu():Wu();n.exports=i,i.sync=a;function i(e,t,n){if(typeof t==`function`&&(n=t,t={}),!n){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,r){i(e,t||{},function(e,t){e?r(e):n(t)})})}r(e,t||{},function(e,r){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)})}function a(e,t){try{return r.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Ku=n(((t,n)=>{let r=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,i=e(`path`),a=r?`;`:`:`,o=Gu(),s=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),c=(e,t)=>{let n=t.colon||a,i=e.match(/\//)||r&&e.match(/\\/)?[``]:[...r?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(n)],o=r?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=r?o.split(n):[``];return r&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:i,pathExt:s,pathExtExe:o}},l=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:r,pathExt:a,pathExtExe:l}=c(e,t),u=[],d=n=>new Promise((a,o)=>{if(n===r.length)return t.all&&u.length?a(u):o(s(e));let c=r[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,s)=>{if(r===a.length)return i(d(n+1));let c=a[r];o(e+c,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+c);else return i(e+c);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};n.exports=l,l.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:r,pathExtExe:a}=c(e,t),l=[];for(let s=0;s<n.length;s++){let c=n[s],u=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<r.length;e++){let n=f+r[e];try{if(o.sync(n,{pathExt:a}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw s(e)}})),qu=n(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Ju=n(((t,n)=>{let r=e(`path`),i=Ku(),a=qu();function o(e,t){let n=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=i.sync(e.command,{path:n[a({env:n})],pathExt:t?r.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=r.resolve(s?e.options.cwd:``,l),l}function s(e){return o(e)||o(e,!0)}n.exports=s})),Yu=n(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Xu=n(((e,t)=>{t.exports=/^#!(.*)/})),Zu=n(((e,t)=>{let n=Xu();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Qu=n(((t,n)=>{let r=e(`fs`),i=Zu();function a(e){let t=Buffer.alloc(150),n;try{n=r.openSync(e,`r`),r.readSync(n,t,0,150,0),r.closeSync(n)}catch{}return i(t.toString())}n.exports=a})),$u=n(((t,n)=>{let r=e(`path`),i=Ju(),a=Yu(),o=Qu(),s=process.platform===`win32`,c=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(e){e.file=i(e);let t=e.file&&o(e.file);return t?(e.args.unshift(e.file),e.command=t,i(e)):e.file}function d(e){if(!s)return e;let t=u(e),n=!c.test(t);if(e.options.forceShell||n){let n=l.test(t);e.command=r.normalize(e.command),e.command=a.command(e.command),e.args=e.args.map(e=>a.argument(e,n)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function f(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:d(r)}n.exports=f})),ed=n(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),td=t(n(((t,n)=>{let r=e(`child_process`),i=$u(),a=ed();function o(e,t,n){let o=i(e,t,n),s=r.spawn(o.command,o.args,o.options);return a.hookChildProcess(s,o),s}function s(e,t,n){let o=i(e,t,n),s=r.spawnSync(o.command,o.args,o.options);return s.error=s.error||a.verifyENOENTSync(s.status,o),s}n.exports=o,n.exports.spawn=o,n.exports.sync=s,n.exports._parse=i,n.exports._enoent=a}))(),1),nd=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
30
+ `);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);return this._buffer=this._buffer.subarray(e+1),rd(t)}clear(){this._buffer=void 0}};function rd(e){return es.parse(JSON.parse(e))}function id(e){return JSON.stringify(e)+`
31
+ `}const ad=h.platform===`win32`?[`APPDATA`,`HOMEDRIVE`,`HOMEPATH`,`LOCALAPPDATA`,`PATH`,`PROCESSOR_ARCHITECTURE`,`SYSTEMDRIVE`,`SYSTEMROOT`,`TEMP`,`USERNAME`,`USERPROFILE`,`PROGRAMFILES`]:[`HOME`,`LOGNAME`,`PATH`,`SHELL`,`TERM`,`USER`];function od(){let e={};for(let t of ad){let n=h.env[t];n!==void 0&&(n.startsWith(`()`)||(e[t]=n))}return e}var sd=class{constructor(e){this._readBuffer=new nd,this._stderrStream=null,this._serverParams=e,(e.stderr===`pipe`||e.stderr===`overlapped`)&&(this._stderrStream=new g)}async start(){if(this._process)throw Error(`StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return new Promise((e,t)=>{this._process=(0,td.default)(this._serverParams.command,this._serverParams.args??[],{env:{...od(),...this._serverParams.env},stdio:[`pipe`,`pipe`,this._serverParams.stderr??`inherit`],shell:!1,windowsHide:h.platform===`win32`&&cd(),cwd:this._serverParams.cwd}),this._process.on(`error`,e=>{t(e),this.onerror?.(e)}),this._process.on(`spawn`,()=>{e()}),this._process.on(`close`,e=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on(`error`,e=>{this.onerror?.(e)}),this._process.stdout?.on(`data`,e=>{this._readBuffer.append(e),this.processReadBuffer()}),this._process.stdout?.on(`error`,e=>{this.onerror?.(e)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let t=new Promise(t=>{e.once(`close`,()=>{t()})});try{e.stdin?.end()}catch{}if(await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())]),e.exitCode===null){try{e.kill(`SIGTERM`)}catch{}await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())])}if(e.exitCode===null)try{e.kill(`SIGKILL`)}catch{}}this._readBuffer.clear()}send(e){return new Promise(t=>{if(!this._process?.stdin)throw Error(`Not connected`);let n=id(e);this._process.stdin.write(n)?t():this._process.stdin.once(`drain`,t)})}};function cd(){return`type`in h}function ld(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function ud(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...ld(t.headers),...ld(r.headers)}:t.headers}):e}let dd;dd=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function fd(e){return(await dd).getRandomValues(new Uint8Array(e))}async function pd(e){let t=``;for(;t.length<e;){let n=await fd(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function md(e){return await pd(e)}async function hd(e){let t=await(await dd).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function gd(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await md(e);return{code_verifier:t,code_challenge:await hd(t)}}const _d=va().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Eo.custom,message:`URL must be parseable`,fatal:!0}),b}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),vd=qa({resource:R().url(),authorization_servers:U(_d).optional(),jwks_uri:R().url().optional(),scopes_supported:U(R()).optional(),bearer_methods_supported:U(R()).optional(),resource_signing_alg_values_supported:U(R()).optional(),resource_name:R().optional(),resource_documentation:R().optional(),resource_policy_uri:R().url().optional(),resource_tos_uri:R().url().optional(),tls_client_certificate_bound_access_tokens:V().optional(),authorization_details_types_supported:U(R()).optional(),dpop_signing_alg_values_supported:U(R()).optional(),dpop_bound_access_tokens_required:V().optional()}),yd=qa({issuer:R(),authorization_endpoint:_d,token_endpoint:_d,registration_endpoint:_d.optional(),scopes_supported:U(R()).optional(),response_types_supported:U(R()),response_modes_supported:U(R()).optional(),grant_types_supported:U(R()).optional(),token_endpoint_auth_methods_supported:U(R()).optional(),token_endpoint_auth_signing_alg_values_supported:U(R()).optional(),service_documentation:_d.optional(),revocation_endpoint:_d.optional(),revocation_endpoint_auth_methods_supported:U(R()).optional(),revocation_endpoint_auth_signing_alg_values_supported:U(R()).optional(),introspection_endpoint:R().optional(),introspection_endpoint_auth_methods_supported:U(R()).optional(),introspection_endpoint_auth_signing_alg_values_supported:U(R()).optional(),code_challenge_methods_supported:U(R()).optional(),client_id_metadata_document_supported:V().optional()}),bd=W({...qa({issuer:R(),authorization_endpoint:_d,token_endpoint:_d,userinfo_endpoint:_d.optional(),jwks_uri:_d,registration_endpoint:_d.optional(),scopes_supported:U(R()).optional(),response_types_supported:U(R()),response_modes_supported:U(R()).optional(),grant_types_supported:U(R()).optional(),acr_values_supported:U(R()).optional(),subject_types_supported:U(R()),id_token_signing_alg_values_supported:U(R()),id_token_encryption_alg_values_supported:U(R()).optional(),id_token_encryption_enc_values_supported:U(R()).optional(),userinfo_signing_alg_values_supported:U(R()).optional(),userinfo_encryption_alg_values_supported:U(R()).optional(),userinfo_encryption_enc_values_supported:U(R()).optional(),request_object_signing_alg_values_supported:U(R()).optional(),request_object_encryption_alg_values_supported:U(R()).optional(),request_object_encryption_enc_values_supported:U(R()).optional(),token_endpoint_auth_methods_supported:U(R()).optional(),token_endpoint_auth_signing_alg_values_supported:U(R()).optional(),display_values_supported:U(R()).optional(),claim_types_supported:U(R()).optional(),claims_supported:U(R()).optional(),service_documentation:R().optional(),claims_locales_supported:U(R()).optional(),ui_locales_supported:U(R()).optional(),claims_parameter_supported:V().optional(),request_parameter_supported:V().optional(),request_uri_parameter_supported:V().optional(),require_request_uri_registration:V().optional(),op_policy_uri:_d.optional(),op_tos_uri:_d.optional(),client_id_metadata_document_supported:V().optional()}).shape,...yd.pick({code_challenge_methods_supported:!0}).shape}),xd=W({access_token:R(),id_token:R().optional(),token_type:R(),expires_in:Oo().optional(),scope:R().optional(),refresh_token:R().optional()}).strip(),Sd=W({error:R(),error_description:R().optional(),error_uri:R().optional()}),Cd=_d.optional().or(q(``).transform(()=>void 0)),wd=W({redirect_uris:U(_d),token_endpoint_auth_method:R().optional(),grant_types:U(R()).optional(),response_types:U(R()).optional(),client_name:R().optional(),client_uri:_d.optional(),logo_uri:Cd,scope:R().optional(),contacts:U(R()).optional(),tos_uri:Cd,policy_uri:R().optional(),jwks_uri:_d.optional(),jwks:Va().optional(),software_id:R().optional(),software_version:R().optional(),software_statement:R().optional()}).strip(),Td=W({client_id:R(),client_secret:R().optional(),client_id_issued_at:B().optional(),client_secret_expires_at:B().optional()}).strip(),Ed=wd.merge(Td);W({error:R(),error_description:R().optional()}).strip(),W({token:R(),token_type_hint:R().optional()}).strip();function Dd(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function Od({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var $=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},kd=class extends ${};kd.errorCode=`invalid_request`;var Ad=class extends ${};Ad.errorCode=`invalid_client`;var jd=class extends ${};jd.errorCode=`invalid_grant`;var Md=class extends ${};Md.errorCode=`unauthorized_client`;var Nd=class extends ${};Nd.errorCode=`unsupported_grant_type`;var Pd=class extends ${};Pd.errorCode=`invalid_scope`;var Fd=class extends ${};Fd.errorCode=`access_denied`;var Id=class extends ${};Id.errorCode=`server_error`;var Ld=class extends ${};Ld.errorCode=`temporarily_unavailable`;var Rd=class extends ${};Rd.errorCode=`unsupported_response_type`;var zd=class extends ${};zd.errorCode=`unsupported_token_type`;var Bd=class extends ${};Bd.errorCode=`invalid_token`;var Vd=class extends ${};Vd.errorCode=`method_not_allowed`;var Hd=class extends ${};Hd.errorCode=`too_many_requests`;var Ud=class extends ${};Ud.errorCode=`invalid_client_metadata`;var Wd=class extends ${};Wd.errorCode=`insufficient_scope`;var Gd=class extends ${};Gd.errorCode=`invalid_target`;const Kd={[kd.errorCode]:kd,[Ad.errorCode]:Ad,[jd.errorCode]:jd,[Md.errorCode]:Md,[Nd.errorCode]:Nd,[Pd.errorCode]:Pd,[Fd.errorCode]:Fd,[Id.errorCode]:Id,[Ld.errorCode]:Ld,[Rd.errorCode]:Rd,[zd.errorCode]:zd,[Bd.errorCode]:Bd,[Vd.errorCode]:Vd,[Hd.errorCode]:Hd,[Ud.errorCode]:Ud,[Wd.errorCode]:Wd,[Gd.errorCode]:Gd};var qd=class extends Error{constructor(e){super(e??`Unauthorized`)}};function Jd(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const Yd=`code`,Xd=`S256`;function Zd(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&Jd(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Qd(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:$d(i,a,n);return;case`client_secret_post`:ef(i,a,r);return;case`none`:tf(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function $d(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function ef(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function tf(e,t){t.set(`client_id`,e)}async function nf(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Sd.parse(JSON.parse(n));return new(Kd[e]||Id)(t||``,r)}catch(e){return new Id(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function rf(e,t){try{return await af(e,t)}catch(n){if(n instanceof Ad||n instanceof Md)return await e.invalidateCredentials?.(`all`),await af(e,t);if(n instanceof jd)return await e.invalidateCredentials?.(`tokens`),await af(e,t);throw n}}async function af(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o,s;try{o=await uf(t,{resourceMetadataUrl:i},a),o.authorization_servers&&o.authorization_servers.length>0&&(s=o.authorization_servers[0])}catch{}s||=new URL(`/`,t);let c=await sf(t,e,o),l=await _f(s,{fetchFn:a}),u=await Promise.resolve(e.clientInformation());if(!u){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!of(r))throw new Ud(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)u={client_id:r},await e.saveClientInformation?.(u);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await Cf(s,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),u=t}}let d=!e.redirectUrl;if(n!==void 0||d){let t=await Sf(e,s,{metadata:l,resource:c,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let f=await e.tokens();if(f?.refresh_token)try{let t=await xf(s,{metadata:l,clientInformation:u,refreshToken:f.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof $)||e instanceof Id))throw e}let p=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:h}=await vf(s,{metadata:l,clientInformation:u,state:p,redirectUrl:e.redirectUrl,scope:r||o?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(m),`REDIRECT`}function of(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function sf(e,t,n){let r=Dd(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!Od({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function cf(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=lf(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=lf(e,`scope`)||void 0,s=lf(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function lf(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function uf(e,t,n=fetch){let r=await hf(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return vd.parse(await r.json())}async function df(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?df(e,void 0,n):void 0;throw r}}function ff(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function pf(e,t,n=fetch){return await df(e,{"MCP-Protocol-Version":t},n)}function mf(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function hf(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??ko,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=ff(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await pf(o,a,n);return!r?.metadataUrl&&mf(s,i.pathname)&&(s=await pf(new URL(`/.well-known/${t}`,i),a,n)),s}function gf(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function _f(e,{fetchFn:t=fetch,protocolVersion:n=ko}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=gf(e);for(let{url:e,type:n}of i){let i=await df(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?yd.parse(await i.json()):bd.parse(await i.json())}}}async function vf(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Yd))throw Error(`Incompatible auth server: does not support response type ${Yd}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Xd))throw Error(`Incompatible auth server: does not support code challenge method ${Xd}`)}else s=new URL(`/authorize`,e);let c=await gd(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,Yd),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,Xd),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function yf(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function bf(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&Qd(Zd(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await nf(l);return xd.parse(await l.json())}async function xf(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await bf(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function Sf(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=yf(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return bf(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function Cf(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await nf(a);return Ed.parse(await a.json())}var wf=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Tf(e){}function Ef(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Tf,onError:n=Tf,onRetry:r=Tf,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=Df(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
32
+ `;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new wf(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new wf(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
33
+ `)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function Df(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
34
+ `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
35
+ `&&r++}}return[t,n]}var Of=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Ef({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const kf={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Af=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},jf=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=ud(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??kf}async _authThenStart(){if(!this._authProvider)throw new qd(`No auth provider`);let e;try{e=await rf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new qd;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=ld(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Af(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Of({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=es.parse(JSON.parse(e.data));Zo(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new qd(`No auth provider`);if(await rf(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qd(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:qo(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Af(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=cf(o);if(this._resourceMetadataUrl=t,this._scope=n,await rf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qd;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=cf(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Af(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await rf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new qd;return this.send(e)}}throw new Af(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),gs(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c)if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>es.parse(e)):[es.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Af(-1,`Unexpected content type: ${l}`);else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Af(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}},Mf=class{registry;accessRef;servers=new Map;constructor(e){this.registry=e.registry,this.accessRef=e.accessRef}allowNetwork(){return r(o(this.accessRef?.get()?.approvalMode)).allowNetwork}normalizeToolName(e,t){let n=e=>e.trim().replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``),r=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t>>>0},i=`mcp__${n(e)}__${n(t)}`||`mcp__tool`;if(i.length<=64)return i;let a=r(`${e}\u0000${t}`).toString(36).slice(0,8);return`${i.slice(0,Math.max(1,64-(1+a.length)))}_${a}`.slice(0,64)}unregisterServerTools(e){for(let t of e.registeredToolNames)try{this.registry.unregister(t)}catch{}e.registeredToolNames=[],e.remoteTools=[]}async connectServer(e){let t=String(e?.name??``).trim();if(!t)throw Error(`MCP server missing name`);if(e.enabled===!1)return{toolCount:0};let n=this.servers.get(t);if(n){this.unregisterServerTools(n);let e=await n.client.listTools();return this.registerTools({serverName:t,state:n,tools:e}),{toolCount:n.registeredToolNames.length}}let r=await this.createTransport(e),i=new Hu({name:`GoatChain CLI`,version:`0.0.0`});await i.connect(r);let a=await i.listTools(),o={config:e,client:i,transport:r,registeredToolNames:[],remoteTools:[]};return this.servers.set(t,o),this.registerTools({serverName:t,state:o,tools:a}),{toolCount:o.registeredToolNames.length}}async disconnectServer(e){let t=String(e??``).trim(),n=this.servers.get(t);if(n){this.unregisterServerTools(n);try{await n.transport.close()}catch{}this.servers.delete(t)}}async disconnectAll(){let e=[...this.servers.keys()];for(let t of e)await this.disconnectServer(t)}listConnected(){let e=[];for(let[t,n]of this.servers.entries())e.push({name:t,toolCount:n.registeredToolNames.length,transport:this.serverTransportName(n.config)});return e}listRegisteredTools(){let e=[];for(let t of this.servers.values())e.push(...t.registeredToolNames);return e}listRemoteTools(e){let t=String(e??``).trim(),n=this.servers.get(t);return n?[...n.remoteTools]:[]}async connectFromConfig(e){let t=Array.isArray(e?.servers)?e.servers:[],n=0,r=0;for(let e of t){let t=String(e?.name??``).trim();try{let i=await this.connectServer(e);t&&this.servers.has(t)&&n++,r+=i.toolCount}catch{}}return{connected:n,toolCount:r}}async createTransport(e){if((e.transport??`stdio`)===`http`){if(!this.allowNetwork())throw Error(`MCP HTTP transport requires Approval Mode: Agent (full access)`);let t=String(e.url??``).trim();if(!t)throw Error(`MCP http server missing url`);let n=e.headers??{},r=Object.keys(n).length>0?{headers:n}:void 0;return new jf(new URL(t),{requestInit:r})}let t=String(e.command??``).trim();if(!t)throw Error(`MCP stdio server missing command`);return new sd({command:t,args:Array.isArray(e.args)?e.args.map(String):void 0,env:e.env??void 0,cwd:typeof e.cwd==`string`?String(e.cwd):void 0})}serverTransportName(e){return e.transport===`http`?`http`:`stdio`}registerTools(e){let t=Array.isArray(e.tools?.tools)?e.tools.tools:[];e.state.remoteTools=t;for(let n of t){let t=String(n.name??``).trim();if(!t)continue;let r=this.normalizeToolName(e.serverName,t);if(typeof this.registry?.has==`function`&&this.registry.has(r))try{this.registry.unregister(r)}catch{}let i=`[mcp:${e.serverName}/${t}]\n${String(n.description??``).trim()}`,a=n.inputSchema??{type:`object`},o=String(n?.annotations?.riskLevel??`high`).trim().toLowerCase(),s=o===`safe`||o===`low`||o===`medium`||o===`high`||o===`critical`?o:`high`;this.registry.register({name:r,description:i,parameters:a,riskLevel:s,execute:async n=>{let r=await e.state.client.callTool({name:t,arguments:n??{}});return r.content?r:{content:[],isError:r.isError,_meta:r._meta}}}),e.state.registeredToolNames.push(r)}}};const Nf=[`ToolRegistry`,`WriteTool`,`ReadTool`,`EditTool`,`GlobTool`,`GrepTool`,`AstGrepSearchTool`,`TodoWriteTool`,`WebSearchTool`];function Pf(e){return Nf.every(t=>typeof e?.[t]==`function`)}async function Ff(){try{let e=m.dirname(v(import.meta.url)),t=[m.resolve(e,`../../../src/index.ts`)];for(let e of t)if(_(e))try{return await import(y(e).href)}catch{}}catch{}}async function If(){try{return await import(`./src-Bcu1Lib4.js`)}catch(e){let t=e instanceof Error?e.message:String(e);try{let e=m.dirname(v(import.meta.url)),t=[m.resolve(e,`../../dist/index`),m.resolve(e,`../../../dist/index`)];for(let e of t)try{return await import(y(e).href)}catch{}}catch{}throw Error(["Failed to load `goatchain`.","If you are running from the repo, run `pnpm -r -s build` first.","If this is a workspace setup, ensure `packages/cli` depends on `goatchain` and run `pnpm install`.",`cause: ${t}`].join(`
36
+ `))}}function Lf(e,t){return{get modelId(){return e.modelId},...typeof e?.setModelId==`function`?{setModelId(t){e.setModelId(t)}}:{},stream:n=>e.stream({...t,...n}),...typeof e?.run==`function`?{run:n=>e.run({...t,...n})}:{}}}function Rf(e,t,n,i){if(!Pf(e))throw Error(["Missing builtin tool exports from `goatchain`.","Reinstall the package, or rebuild it from the repo (`pnpm -r -s build`)."].join(`
37
+ `));let{ToolRegistry:a,WriteTool:s,ReadTool:c,EditTool:l,GlobTool:u,GrepTool:d,AstGrepSearchTool:f,AstGrepReplaceTool:p,TodoWriteTool:h,WebSearchTool:g,AskUserTool:_}=e,v=e?.BashTool,y=m.join(t,`.goatchain`),b=()=>i?r(o(i.get()?.approvalMode)):{allowOutsideWorkspace:!0,allowNetwork:!0},x=(e,t)=>{let n=m.relative(m.resolve(e),m.resolve(t));return n===``?!0:n===`..`?!1:!n.startsWith(`..${m.sep}`)&&!m.isAbsolute(n)},S=e=>{if(x(y,e))throw Error(`Access denied: ${e}\nRestricted: ${y}`)},C=e=>{let n=m.isAbsolute(e)?e:m.resolve(t,e),{allowOutsideWorkspace:r}=b();if(!r&&!x(t,n))throw Error(`Access denied: ${n}\nAllowed directory: ${t}`);return S(n),n},w=e=>{let n=m.isAbsolute(e)?e:m.resolve(t,e),{allowOutsideWorkspace:r}=b();if(!r&&!x(t,n))throw Error(`Access denied: ${n}\nAllowed directory: ${t}`);return S(n),n},T=new a,E=new s({cwd:t});T.register({name:E.name,description:E.description,parameters:E.parameters,riskLevel:E.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&C(e.file_path),E.execute(e))});let D=new c({cwd:t});T.register({name:D.name,description:D.description,parameters:D.parameters,riskLevel:D.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&C(e.file_path),D.execute(e))});let O=new l({cwd:t});T.register({name:O.name,description:O.description,parameters:O.parameters,riskLevel:O.riskLevel,execute:e=>(e&&typeof e==`object`&&`file_path`in e&&C(e.file_path),O.execute(e))});let k=new u({cwd:t});T.register({name:k.name,description:k.description,parameters:k.parameters,riskLevel:k.riskLevel,execute:e=>(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`&&e.path.trim()&&w(e.path),k.execute(e))});let A=new d({cwd:t});T.register({name:A.name,description:A.description,parameters:A.parameters,riskLevel:A.riskLevel,execute:e=>(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`&&e.path.trim()&&w(e.path),A.execute(e))});let ee=new f({cwd:t});T.register({name:ee.name,description:ee.description,parameters:ee.parameters,riskLevel:ee.riskLevel,execute:e=>{if(e&&typeof e==`object`&&Array.isArray(e.paths))for(let t of e.paths)typeof t==`string`&&t.trim()&&w(t);return ee.execute(e)}});let te=new p({cwd:t});T.register({name:te.name,description:te.description,parameters:te.parameters,riskLevel:te.riskLevel,execute:e=>{if(e&&typeof e==`object`&&Array.isArray(e.paths))for(let t of e.paths)typeof t==`string`&&t.trim()&&w(t);return te.execute(e)}});let j=new v({cwd:t});T.register({name:j.name,description:j.description,parameters:j.parameters,riskLevel:j.riskLevel,execute:e=>j.execute(e)});let ne=()=>{let e=n?.get(),t=process.env.GOATCHAIN_SERPER_API_KEY??process.env.SERPER_API_KEY,r=process.env.GOATCHAIN_SERPER_API_ENDPOINT??process.env.SERPER_API_ENDPOINT,i=process.env.GOATCHAIN_SERPER_NUM_RESULTS??process.env.SERPER_NUM_RESULTS,a=typeof i==`string`&&i.trim()?Number.parseInt(i.trim(),10):void 0;return{apiKey:e?.webSearch?.apiKey??t??``,apiEndpoint:e?.webSearch?.apiEndpoint??r,numResults:e?.webSearch?.numResults??(Number.isFinite(a)?a:void 0)}},M=new g;T.register({name:M.name,description:M.description,parameters:M.parameters,riskLevel:M.riskLevel,execute:async e=>{if(!b().allowNetwork)return{content:[{type:`text`,text:[`Access denied: WebSearch requires network access.`,`Switch to Approval Mode: Read Only (prompt) or Agent (full access) via /approvals.`,`Or set GOATCHAIN_APPROVAL_MODE=read_only|full_access.`].join(`
38
+ `)}],isError:!0};let{apiKey:t,apiEndpoint:n,numResults:r}=ne();if(!t)return{content:[{type:`text`,text:[`Missing Serper API key for WebSearch.`,`Set it via one of:`,`- /web-search-key <key> (interactive)`,`- env: SERPER_API_KEY or GOATCHAIN_SERPER_API_KEY`,`- config: ./.goatchain/config.json -> tools.webSearch.apiKey`].join(`
39
+ `)}],isError:!0};let i=new g({...t?{apiKey:t}:{},...n?{apiEndpoint:n}:{},...typeof r==`number`?{numResults:r}:{}});try{return await i.execute(e)}catch(e){return{content:[{type:`text`,text:`WebSearch failed: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}}});let re=new h;T.register({name:re.name,description:re.description,parameters:re.parameters,riskLevel:re.riskLevel,execute:e=>re.execute(e)});let ie=new _;return T.register({name:ie.name,description:ie.description,parameters:ie.parameters,riskLevel:ie.riskLevel,execute:e=>ie.execute(e)}),{registry:T,workspaceCwd:t}}async function zf(e,{getApiKey:t,modelId:n,baseUrl:r,requestDefaults:i,openaiCompat:a}){let{createModel:o,createOpenAIAdapter:s}=e;if(typeof o==`function`&&typeof s==`function`)return Lf(o({adapter:s({defaultModelId:n,baseUrl:r,apiKey:t,compat:a})}),i);let{default:c}=await import(`./openai-BOGzt3st.js`),l=null,u=n,d=r,f=()=>{if(l)return l;let e=t()??process.env.OPENAI_API_KEY;if(!e)throw Error(`Missing OPENAI_API_KEY (required for chatting)`);return l=new c({apiKey:e,baseURL:d||void 0}),l};return{get modelId(){return u},setModelId(e){u=e},setBaseUrl(e){d=e,l=null},resetClient(){l=null},async*stream(e){let t=f(),n=e?.model?.modelId??u,r=e?.requestId??`req_${Date.now()}`,o=e?.signal,s=Array.isArray(e?.messages)?e.messages:[...typeof e?.instructions==`string`&&e.instructions.length>0?[{role:`system`,content:e.instructions}]:[],{role:`user`,content:e?.input??``}],c=e?.tools,l=e=>{let t=a?.requireReasoningContentForToolCalls;return typeof t==`boolean`?t:typeof d==`string`&&/deepseek/i.test(d)?!0:/^deepseek-/i.test(e)},p=(e,t)=>!l(t)||!Array.isArray(e)||e.length===0?e:e.map(e=>{if(!e||typeof e!=`object`||e.role!==`assistant`)return e;let t=e.tool_calls;return!Array.isArray(t)||t.length===0||`reasoning_content`in e&&typeof e.reasoning_content==`string`?e:{...e,reasoning_content:`.`}});yield{type:`response_start`,requestId:r,model:{provider:`openai`,modelId:n}};let m=await t.chat.completions.create({model:n,messages:p(s,n),tools:c,stream:!0,stream_options:{include_usage:!0},max_completion_tokens:i.maxOutputTokens??void 0,temperature:i.temperature??void 0,top_p:i.topP??void 0,presence_penalty:i.presencePenalty??void 0,frequency_penalty:i.frequencyPenalty??void 0,seed:i.seed??void 0},{signal:o,timeout:typeof i.timeoutMs==`number`?i.timeoutMs:void 0}),h;for await(let e of m){let t=e?.choices?.[0]?.delta?.content;typeof t==`string`&&t.length>0&&(yield{type:`delta`,requestId:r,chunk:{kind:`text`,text:t}});let n=e?.usage;n&&typeof n==`object`&&(h=n)}yield{type:`response_end`,requestId:r,stopReason:`final`,usage:h}}}}async function Bf({getApiKey:e,modelId:t,system:n,baseUrl:r,requestDefaults:i,openaiCompat:a,toolsConfigRef:o,workspaceCwd:s,accessRef:c,middleware:l}){let u=await If();if(!Pf(u)){let e=await Ff();e&&Pf(e)&&(u=e)}let{Agent:d,FileStateStore:f,createContextCompressionMiddleware:p}=u,h=typeof s==`string`&&s.trim()?s.trim():process.cwd(),g=Rf(u,h,o,c),_=await zf(u,{getApiKey:e,modelId:t,baseUrl:r,requestDefaults:i,openaiCompat:a}),v=new f({dir:m.join(h,`.goatchain`),savePoint:`both`,deleteOnComplete:!0}),y=[];if(typeof p==`function`){let e=p({maxTokens:128e3,protectedTurns:2,enableSummary:!0,getModel:()=>_,getStateStore:()=>v,persistClearedContent:!1});y.push(e)}let b=[...y,...l??[]],x=new d({name:`GoatChain CLI`,systemPrompt:n??`You are GoatChain CLI, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
6
40
 
7
41
  IMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.
8
42
  IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).
@@ -107,39 +141,5 @@ When referencing specific functions or pieces of code include the pattern \`file
107
141
  <example>
108
142
  user: Where are errors from the client handled?
109
143
  assistant: Clients are marked as failed in the \`connectToServer\` function in src/services/process.ts:712.
110
- </example>`,model:h,tools:p.registry,stateStore:g});return{agent:_,model:h,tools:p,stateStore:g,sessionManager:_.sessionManager}}function ne(e){let t=m.join(e,`.goatchain`);return{workspaceCwd:e,cacheDir:t,sessionsDir:m.join(t,`sessions`),configPath:m.join(t,`config.json`)}}async function E(e){await c(e,{recursive:!0})}async function D(e){try{let t=await l(e,`utf8`);return JSON.parse(t)}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)return;throw e}}async function re(e,t){await E(m.dirname(e));let n=`${e}.tmp.${s()}`;await p(n,`${JSON.stringify(t,null,2)}\n`,{mode:384}),await d(n,e)}async function ie(e){let t=await D(e.configPath);return!t||typeof t!=`object`?{schemaVersion:1}:t}async function ae(e,t){let n={schemaVersion:1,...t,updatedAt:Date.now()};return await re(e.configPath,n),n}function oe(e,t){return m.join(e.sessionsDir,`${t}.json`)}async function se(e,t){let n=await D(oe(e,t));if(!n||typeof n!=`object`)return;let r=Array.isArray(n.messages)?n.messages:[];return{sessionId:typeof n.sessionId==`string`?n.sessionId:t,createdAt:typeof n.createdAt==`number`?n.createdAt:Date.now(),updatedAt:typeof n.updatedAt==`number`?n.updatedAt:Date.now(),modelId:typeof n.modelId==`string`?n.modelId:void 0,systemPrompt:typeof n.systemPrompt==`string`?n.systemPrompt:void 0,title:typeof n.title==`string`?n.title:void 0,summary:typeof n.summary==`string`?n.summary:void 0,pinned:!!n.pinned,messages:r}}const ce=Object.freeze({status:`aborted`});function O(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var le=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},k=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const ue={};function de(e){return e&&Object.assign(ue,e),ue}function fe(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function pe(e,t){return typeof t==`bigint`?t.toString():t}function me(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function he(e){return e==null}function ge(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _e(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const ve=Symbol(`evaluating`);function A(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ve)return r===void 0&&(r=ve,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function be(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function xe(e){return JSON.stringify(e)}function Se(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Ce=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function we(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Te=me(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ee(e){if(we(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(we(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function De(e){return Ee(e)?{...e}:Array.isArray(e)?[...e]:e}const Oe=new Set([`string`,`number`,`symbol`]);function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ae(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function j(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function je(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Me={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ne(e,t){let n=e._zod.def;return Ae(e,be(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ye(this,`shape`,e),e},checks:[]}))}function Pe(e,t){let n=e._zod.def;return Ae(e,be(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ye(this,`shape`,r),r},checks:[]}))}function Fe(e,t){if(!Ee(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return Ae(e,be(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ye(this,`shape`,n),n},checks:[]}))}function Ie(e,t){if(!Ee(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ae(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ye(this,`shape`,n),n},checks:e._zod.def.checks})}function Le(e,t){return Ae(e,be(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ye(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Re(e,t,n){return Ae(t,be(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ye(this,`shape`,i),i},checks:[]}))}function ze(e,t,n){return Ae(t,be(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ye(this,`shape`,i),i},checks:[]}))}function Be(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function He(e){return typeof e==`string`?e:e?.message}function Ue(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=He(e.inst?._zod.def?.error?.(e))??He(t?.error?.(e))??He(n.customError?.(e))??He(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function We(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ge(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Ke=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,pe,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},qe=O(`$ZodError`,Ke),Je=O(`$ZodError`,Ke,{Parent:Error});function Ye(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Xe(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const Ze=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new le;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ue(e,a,de())));throw Ce(t,i?.callee),t}return o.value},Qe=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ue(e,a,de())));throw Ce(t,i?.callee),t}return o.value},$e=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new le;return a.issues.length?{success:!1,error:new(e??qe)(a.issues.map(e=>Ue(e,i,de())))}:{success:!0,data:a.value}},et=$e(Je),tt=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ue(e,i,de())))}:{success:!0,data:a.value}},nt=tt(Je),rt=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ze(e)(t,n,i)},it=e=>(t,n,r)=>Ze(e)(t,n,r),at=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Qe(e)(t,n,i)},ot=e=>async(t,n,r)=>Qe(e)(t,n,r),st=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $e(e)(t,n,i)},ct=e=>(t,n,r)=>$e(e)(t,n,r),lt=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return tt(e)(t,n,i)},ut=e=>async(t,n,r)=>tt(e)(t,n,r),dt=/^[cC][^\s-]{8,}$/,ft=/^[0-9a-z]+$/,pt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mt=/^[0-9a-vA-V]{20}$/,ht=/^[A-Za-z0-9]{27}$/,gt=/^[a-zA-Z0-9_-]{21}$/,_t=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vt=/^([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})$/,yt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,bt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function xt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const St=/^(?:(?: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])$/,Ct=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,wt=/^((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])$/,Tt=/^(([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])$/,Et=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Dt=/^[A-Za-z0-9_-]*$/,Ot=/^\+(?:[0-9]){6,14}[0-9]$/,kt=`(?:(?:\\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])))`,At=RegExp(`^${kt}$`);function jt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Mt(e){return RegExp(`^${jt(e)}$`)}function Nt(e){let t=jt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${kt}T(?:${r})$`)}const Pt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ft=/^-?\d+$/,It=/^-?\d+(?:\.\d+)?/,Lt=/^(?:true|false)$/i,Rt=/^null$/i,zt=/^[^A-Z]*$/,Bt=/^[^a-z]*$/,Vt=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ht={number:`number`,bigint:`bigint`,object:`date`},Ut=O(`$ZodCheckLessThan`,(e,t)=>{Vt.init(e,t);let n=Ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wt=O(`$ZodCheckGreaterThan`,(e,t)=>{Vt.init(e,t);let n=Ht[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gt=O(`$ZodCheckMultipleOf`,(e,t)=>{Vt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):_e(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Kt=O(`$ZodCheckNumberFormat`,(e,t)=>{Vt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Me[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Ft)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),qt=O(`$ZodCheckMaxLength`,(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=We(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jt=O(`$ZodCheckMinLength`,(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=We(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Yt=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!he(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=We(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Xt=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Vt.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Zt=O(`$ZodCheckRegex`,(e,t)=>{Xt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Qt=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=zt,Xt.init(e,t)}),$t=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Bt,Xt.init(e,t)}),en=O(`$ZodCheckIncludes`,(e,t)=>{Vt.init(e,t);let n=ke(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),tn=O(`$ZodCheckStartsWith`,(e,t)=>{Vt.init(e,t);let n=RegExp(`^${ke(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),nn=O(`$ZodCheckEndsWith`,(e,t)=>{Vt.init(e,t);let n=RegExp(`.*${ke(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),rn=O(`$ZodCheckOverwrite`,(e,t)=>{Vt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var an=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
111
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
112
- `))}};const on={major:4,minor:2,patch:1},M=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=on;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Be(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new le;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Be(e,t))});else{if(e.issues.length===t)continue;r||=Be(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Be(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new le;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new le;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=et(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return nt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),sn=O(`$ZodString`,(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Pt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),N=O(`$ZodStringFormat`,(e,t)=>{Xt.init(e,t),sn.init(e,t)}),cn=O(`$ZodGUID`,(e,t)=>{t.pattern??=vt,N.init(e,t)}),ln=O(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=yt(e)}else t.pattern??=yt();N.init(e,t)}),un=O(`$ZodEmail`,(e,t)=>{t.pattern??=bt,N.init(e,t)}),dn=O(`$ZodURL`,(e,t)=>{N.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),fn=O(`$ZodEmoji`,(e,t)=>{t.pattern??=xt(),N.init(e,t)}),pn=O(`$ZodNanoID`,(e,t)=>{t.pattern??=gt,N.init(e,t)}),mn=O(`$ZodCUID`,(e,t)=>{t.pattern??=dt,N.init(e,t)}),hn=O(`$ZodCUID2`,(e,t)=>{t.pattern??=ft,N.init(e,t)}),gn=O(`$ZodULID`,(e,t)=>{t.pattern??=pt,N.init(e,t)}),_n=O(`$ZodXID`,(e,t)=>{t.pattern??=mt,N.init(e,t)}),vn=O(`$ZodKSUID`,(e,t)=>{t.pattern??=ht,N.init(e,t)}),yn=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Nt(t),N.init(e,t)}),bn=O(`$ZodISODate`,(e,t)=>{t.pattern??=At,N.init(e,t)}),xn=O(`$ZodISOTime`,(e,t)=>{t.pattern??=Mt(t),N.init(e,t)}),Sn=O(`$ZodISODuration`,(e,t)=>{t.pattern??=_t,N.init(e,t)}),Cn=O(`$ZodIPv4`,(e,t)=>{t.pattern??=St,N.init(e,t),e._zod.bag.format=`ipv4`}),wn=O(`$ZodIPv6`,(e,t)=>{t.pattern??=Ct,N.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Tn=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=wt,N.init(e,t)}),En=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Tt,N.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Dn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const On=O(`$ZodBase64`,(e,t)=>{t.pattern??=Et,N.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Dn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function kn(e){if(!Dt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Dn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const An=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Dt,N.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{kn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),jn=O(`$ZodE164`,(e,t)=>{t.pattern??=Ot,N.init(e,t)});function Mn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Nn=O(`$ZodJWT`,(e,t)=>{N.init(e,t),e._zod.check=n=>{Mn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Pn=O(`$ZodNumber`,(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??It,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Fn=O(`$ZodNumberFormat`,(e,t)=>{Kt.init(e,t),Pn.init(e,t)}),In=O(`$ZodBoolean`,(e,t)=>{M.init(e,t),e._zod.pattern=Lt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ln=O(`$ZodNull`,(e,t)=>{M.init(e,t),e._zod.pattern=Rt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Rn=O(`$ZodAny`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),zn=O(`$ZodUnknown`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),Bn=O(`$ZodNever`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Vn(e,t,n){e.issues.length&&t.issues.push(...Ve(n,e.issues)),t.value[n]=e.value}const Hn=O(`$ZodArray`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Vn(t,n,e))):Vn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Un(e,t,n,r){e.issues.length&&t.issues.push(...Ve(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Wn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=je(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Gn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Un(e,n,i,t))):Un(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const Kn=O(`$ZodObject`,(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=me(()=>Wn(t));A(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=we,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Un(n,t,e,s))):Un(n,t,e,s)}return i?Gn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),qn=O(`$ZodObjectJIT`,(e,t)=>{Kn.init(e,t);let n=e._zod.parse,r=me(()=>Wn(t)),i=e=>{let t=new an([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=xe(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=xe(e);t.write(`const ${n} = ${i(e)};`),t.write(`
113
- if (${n}.issues.length) {
114
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
115
- ...iss,
116
- path: iss.path ? [${r}, ...iss.path] : [${r}]
117
- })));
118
- }
119
-
120
-
121
- if (${n}.value === undefined) {
122
- if (${r} in input) {
123
- newResult[${r}] = undefined;
124
- }
125
- } else {
126
- newResult[${r}] = ${n}.value;
127
- }
128
-
129
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=we,s=!ue.jitless,c=s&&Te.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Gn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Jn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Be(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ue(e,r,de())))}),t)}const Yn=O(`$ZodUnion`,(e,t)=>{M.init(e,t),A(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),A(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),A(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ge(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Jn(t,i,e,a)):Jn(s,i,e,a)}}),Xn=O(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Yn.init(e,t);let n=e._zod.parse;A(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=me(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!we(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),Zn=O(`$ZodIntersection`,(e,t)=>{M.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>$n(e,t,n)):$n(e,i,a)}});function Qn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ee(e)&&Ee(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Qn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Qn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function $n(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Be(e))return e;let r=Qn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const er=O(`$ZodRecord`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ee(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Ve(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ve(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Ue(e,r,de())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ve(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ve(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),tr=O(`$ZodEnum`,(e,t)=>{M.init(e,t);let n=fe(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Oe.has(typeof e)).map(e=>typeof e==`string`?ke(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),nr=O(`$ZodLiteral`,(e,t)=>{if(M.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ke(e):e?ke(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),rr=O(`$ZodTransform`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new k(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new le;return n.value=i,n}});function ir(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ar=O(`$ZodOptional`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>ir(t,e.value)):ir(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),or=O(`$ZodNullable`,(e,t)=>{M.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ge(e.source)}|null)$`):void 0}),A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),sr=O(`$ZodDefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>cr(e,t)):cr(r,t)}});function cr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const lr=O(`$ZodPrefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ur=O(`$ZodNonOptional`,(e,t)=>{M.init(e,t),A(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>dr(t,e)):dr(i,e)}});function dr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const fr=O(`$ZodCatch`,(e,t)=>{M.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ue(e,n,de()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ue(e,n,de()))},input:e.value}),e.issues=[]),e)}}),pr=O(`$ZodPipe`,(e,t)=>{M.init(e,t),A(e._zod,`values`,()=>t.in._zod.values),A(e._zod,`optin`,()=>t.in._zod.optin),A(e._zod,`optout`,()=>t.out._zod.optout),A(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>mr(e,t.in,n)):mr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mr(e,t.out,n)):mr(r,t.out,n)}});function mr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const hr=O(`$ZodReadonly`,(e,t)=>{M.init(e,t),A(e._zod,`propValues`,()=>t.innerType._zod.propValues),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`optin`,()=>t.innerType?._zod?.optin),A(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(gr):gr(r)}});function gr(e){return e.value=Object.freeze(e.value),e}const _r=O(`$ZodCustom`,(e,t)=>{Vt.init(e,t),M.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>vr(t,n,r,e));vr(i,n,r,e)}});function vr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ge(e))}}var yr,br=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function xr(){return new br}(yr=globalThis).__zod_globalRegistry??(yr.__zod_globalRegistry=xr());const Sr=globalThis.__zod_globalRegistry;function Cr(e,t){return new e({type:`string`,...j(t)})}function wr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...j(t)})}function Tr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...j(t)})}function Er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...j(t)})}function Dr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...j(t)})}function Or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...j(t)})}function kr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...j(t)})}function Ar(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...j(t)})}function jr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...j(t)})}function Mr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...j(t)})}function Nr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...j(t)})}function Pr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...j(t)})}function Fr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...j(t)})}function Ir(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...j(t)})}function Lr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...j(t)})}function Rr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...j(t)})}function zr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...j(t)})}function Br(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...j(t)})}function Vr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...j(t)})}function Hr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...j(t)})}function Ur(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...j(t)})}function Wr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...j(t)})}function Gr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...j(t)})}function Kr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...j(t)})}function qr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...j(t)})}function Jr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...j(t)})}function Yr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...j(t)})}function Xr(e,t){return new e({type:`number`,checks:[],...j(t)})}function Zr(e,t){return new e({type:`number`,coerce:!0,checks:[],...j(t)})}function Qr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...j(t)})}function $r(e,t){return new e({type:`boolean`,...j(t)})}function ei(e,t){return new e({type:`null`,...j(t)})}function ti(e){return new e({type:`any`})}function ni(e){return new e({type:`unknown`})}function ri(e,t){return new e({type:`never`,...j(t)})}function ii(e,t){return new Ut({check:`less_than`,...j(t),value:e,inclusive:!1})}function ai(e,t){return new Ut({check:`less_than`,...j(t),value:e,inclusive:!0})}function oi(e,t){return new Wt({check:`greater_than`,...j(t),value:e,inclusive:!1})}function si(e,t){return new Wt({check:`greater_than`,...j(t),value:e,inclusive:!0})}function ci(e,t){return new Gt({check:`multiple_of`,...j(t),value:e})}function li(e,t){return new qt({check:`max_length`,...j(t),maximum:e})}function ui(e,t){return new Jt({check:`min_length`,...j(t),minimum:e})}function di(e,t){return new Yt({check:`length_equals`,...j(t),length:e})}function fi(e,t){return new Zt({check:`string_format`,format:`regex`,...j(t),pattern:e})}function pi(e){return new Qt({check:`string_format`,format:`lowercase`,...j(e)})}function mi(e){return new $t({check:`string_format`,format:`uppercase`,...j(e)})}function hi(e,t){return new en({check:`string_format`,format:`includes`,...j(t),includes:e})}function gi(e,t){return new tn({check:`string_format`,format:`starts_with`,...j(t),prefix:e})}function _i(e,t){return new nn({check:`string_format`,format:`ends_with`,...j(t),suffix:e})}function vi(e){return new rn({check:`overwrite`,tx:e})}function yi(e){return vi(t=>t.normalize(e))}function bi(){return vi(e=>e.trim())}function xi(){return vi(e=>e.toLowerCase())}function Si(){return vi(e=>e.toUpperCase())}function Ci(){return vi(e=>Se(e))}function wi(e,t,n){return new e({type:`array`,element:t,...j(n)})}function Ti(e,t,n){let r=j(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Ei(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...j(n)})}function Di(e){let t=Oi(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Ge(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Ge(r))}},e(n.value,n)));return t}function Oi(e,t){let n=new Vt({check:`custom`,...j(t)});return n._zod.check=e,n}function ki(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Sr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function P(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path},a=e._zod.parent;if(a)o.ref=a,P(a,t,r),t.seen.get(a).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Mi(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ai(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},i=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:i}=r(e);t.def={...t.schema},i&&(t.defId=i);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
130
-
131
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){i(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}if(e.metadataRegistry.get(n[0])?.id){i(n);continue}if(r.cycle){i(n);continue}if(r.count>1&&e.reused===`ref`){i(n);continue}}}function ji(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t),i=n.def??n.schema,a={...i};if(n.ref===null)return;let o=n.ref;if(n.ref=null,o){r(o);let t=e.seen.get(o).schema;t.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(t)):(Object.assign(i,t),Object.assign(i,a))}n.isParent||e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let e=JSON.parse(JSON.stringify(i));return Object.defineProperty(e,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Pi(t,`input`),output:Pi(t,`output`)}},enumerable:!1,writable:!1}),e}catch{throw Error(`Error converting schema to JSON.`)}}function Mi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Mi(r.element,n);if(r.type===`set`)return Mi(r.valueType,n);if(r.type===`lazy`)return Mi(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Mi(r.innerType,n);if(r.type===`intersection`)return Mi(r.left,n)||Mi(r.right,n);if(r.type===`record`||r.type===`map`)return Mi(r.keyType,n)||Mi(r.valueType,n);if(r.type===`pipe`)return Mi(r.in,n)||Mi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Mi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Mi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Mi(e,n))return!0;return!!(r.rest&&Mi(r.rest,n))}return!1}const Ni=(e,t={})=>n=>{let r=ki({...n,processors:t});return P(e,r),Ai(r,e),ji(r,e)},Pi=(e,t)=>n=>{let{libraryOptions:r,target:i}=n??{},a=ki({...r??{},target:i,io:t,processors:{}});return P(e,a),Ai(a,e),ji(a,e)},Fi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ii=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fi[s]??s,i.format===``&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Li=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Ri=(e,t,n,r)=>{n.type=`boolean`},zi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Bi=(e,t,n,r)=>{n.not={}},Vi=(e,t,n,r)=>{let i=e._zod.def,a=fe(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Hi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Ui=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Gi=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},Ki=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},qi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ji=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Yi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})},Xi=(e,t,n,r)=>{let i=e._zod.def,a=P(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Zi=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Qi=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},$i=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ea=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ta=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;P(a,t,r);let o=t.seen.get(e);o.ref=a},na=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ra=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};function ia(e){return!!e._zod}function aa(e,t){return ia(e)?et(e,t):e.safeParse(t)}function oa(e){if(!e)return;let t;if(t=ia(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function sa(e){if(ia(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}const ca=O(`ZodISODateTime`,(e,t)=>{yn.init(e,t),L.init(e,t)});function la(e){return Kr(ca,e)}const ua=O(`ZodISODate`,(e,t)=>{bn.init(e,t),L.init(e,t)});function da(e){return qr(ua,e)}const fa=O(`ZodISOTime`,(e,t)=>{xn.init(e,t),L.init(e,t)});function pa(e){return Jr(fa,e)}const ma=O(`ZodISODuration`,(e,t)=>{Sn.init(e,t),L.init(e,t)});function ha(e){return Yr(ma,e)}const ga=(e,t)=>{qe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Xe(e,t)},flatten:{value:t=>Ye(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,pe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,pe,2)}},isEmpty:{get(){return e.issues.length===0}}})};O(`ZodError`,ga);const _a=O(`ZodError`,ga,{Parent:Error}),va=Ze(_a),ya=Qe(_a),ba=$e(_a),xa=tt(_a),Sa=rt(_a),Ca=it(_a),wa=at(_a),Ta=ot(_a),Ea=st(_a),Da=ct(_a),Oa=lt(_a),ka=ut(_a),F=O(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Pi(e,`input`),output:Pi(e,`output`)}}),e.toJSONSchema=Ni(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(be(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>Ae(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>va(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ba(e,t,n),e.parseAsync=async(t,n)=>ya(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xa(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Sa(e,t,n),e.decode=(t,n)=>Ca(e,t,n),e.encodeAsync=async(t,n)=>wa(e,t,n),e.decodeAsync=async(t,n)=>Ta(e,t,n),e.safeEncode=(t,n)=>Ea(e,t,n),e.safeDecode=(t,n)=>Da(e,t,n),e.safeEncodeAsync=async(t,n)=>Oa(e,t,n),e.safeDecodeAsync=async(t,n)=>ka(e,t,n),e.refine=(t,n)=>e.check(Bo(t,n)),e.superRefine=t=>e.check(Vo(t)),e.overwrite=t=>e.check(vi(t)),e.optional=()=>q(e),e.nullable=()=>To(e),e.nullish=()=>q(To(e)),e.nonoptional=t=>jo(e,t),e.array=()=>V(e),e.or=t=>W([e,t]),e.and=t=>go(e,t),e.transform=t=>Fo(e,So(t)),e.default=t=>Do(e,t),e.prefault=t=>ko(e,t),e.catch=t=>No(e,t),e.pipe=t=>Fo(e,t),e.readonly=()=>Lo(e),e.describe=t=>{let n=e.clone();return Sr.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Sr.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Sr.get(e);let n=e.clone();return Sr.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Aa=O(`_ZodString`,(e,t)=>{sn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(fi(...t)),e.includes=(...t)=>e.check(hi(...t)),e.startsWith=(...t)=>e.check(gi(...t)),e.endsWith=(...t)=>e.check(_i(...t)),e.min=(...t)=>e.check(ui(...t)),e.max=(...t)=>e.check(li(...t)),e.length=(...t)=>e.check(di(...t)),e.nonempty=(...t)=>e.check(ui(1,...t)),e.lowercase=t=>e.check(pi(t)),e.uppercase=t=>e.check(mi(t)),e.trim=()=>e.check(bi()),e.normalize=(...t)=>e.check(yi(...t)),e.toLowerCase=()=>e.check(xi()),e.toUpperCase=()=>e.check(Si()),e.slugify=()=>e.check(Ci())}),ja=O(`ZodString`,(e,t)=>{sn.init(e,t),Aa.init(e,t),e.email=t=>e.check(wr(Ma,t)),e.url=t=>e.check(Ar(Fa,t)),e.jwt=t=>e.check(Gr(Za,t)),e.emoji=t=>e.check(jr(La,t)),e.guid=t=>e.check(Tr(Na,t)),e.uuid=t=>e.check(Er(Pa,t)),e.uuidv4=t=>e.check(Dr(Pa,t)),e.uuidv6=t=>e.check(Or(Pa,t)),e.uuidv7=t=>e.check(kr(Pa,t)),e.nanoid=t=>e.check(Mr(Ra,t)),e.guid=t=>e.check(Tr(Na,t)),e.cuid=t=>e.check(Nr(za,t)),e.cuid2=t=>e.check(Pr(Ba,t)),e.ulid=t=>e.check(Fr(Va,t)),e.base64=t=>e.check(Hr(Ja,t)),e.base64url=t=>e.check(Ur(Ya,t)),e.xid=t=>e.check(Ir(Ha,t)),e.ksuid=t=>e.check(Lr(Ua,t)),e.ipv4=t=>e.check(Rr(Wa,t)),e.ipv6=t=>e.check(zr(Ga,t)),e.cidrv4=t=>e.check(Br(Ka,t)),e.cidrv6=t=>e.check(Vr(qa,t)),e.e164=t=>e.check(Wr(Xa,t)),e.datetime=t=>e.check(la(t)),e.date=t=>e.check(da(t)),e.time=t=>e.check(pa(t)),e.duration=t=>e.check(ha(t))});function I(e){return Cr(ja,e)}const L=O(`ZodStringFormat`,(e,t)=>{N.init(e,t),Aa.init(e,t)}),Ma=O(`ZodEmail`,(e,t)=>{un.init(e,t),L.init(e,t)}),Na=O(`ZodGUID`,(e,t)=>{cn.init(e,t),L.init(e,t)}),Pa=O(`ZodUUID`,(e,t)=>{ln.init(e,t),L.init(e,t)}),Fa=O(`ZodURL`,(e,t)=>{dn.init(e,t),L.init(e,t)});function Ia(e){return Ar(Fa,e)}const La=O(`ZodEmoji`,(e,t)=>{fn.init(e,t),L.init(e,t)}),Ra=O(`ZodNanoID`,(e,t)=>{pn.init(e,t),L.init(e,t)}),za=O(`ZodCUID`,(e,t)=>{mn.init(e,t),L.init(e,t)}),Ba=O(`ZodCUID2`,(e,t)=>{hn.init(e,t),L.init(e,t)}),Va=O(`ZodULID`,(e,t)=>{gn.init(e,t),L.init(e,t)}),Ha=O(`ZodXID`,(e,t)=>{_n.init(e,t),L.init(e,t)}),Ua=O(`ZodKSUID`,(e,t)=>{vn.init(e,t),L.init(e,t)}),Wa=O(`ZodIPv4`,(e,t)=>{Cn.init(e,t),L.init(e,t)}),Ga=O(`ZodIPv6`,(e,t)=>{wn.init(e,t),L.init(e,t)}),Ka=O(`ZodCIDRv4`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),qa=O(`ZodCIDRv6`,(e,t)=>{En.init(e,t),L.init(e,t)}),Ja=O(`ZodBase64`,(e,t)=>{On.init(e,t),L.init(e,t)}),Ya=O(`ZodBase64URL`,(e,t)=>{An.init(e,t),L.init(e,t)}),Xa=O(`ZodE164`,(e,t)=>{jn.init(e,t),L.init(e,t)}),Za=O(`ZodJWT`,(e,t)=>{Nn.init(e,t),L.init(e,t)}),Qa=O(`ZodNumber`,(e,t)=>{Pn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.gt=(t,n)=>e.check(oi(t,n)),e.gte=(t,n)=>e.check(si(t,n)),e.min=(t,n)=>e.check(si(t,n)),e.lt=(t,n)=>e.check(ii(t,n)),e.lte=(t,n)=>e.check(ai(t,n)),e.max=(t,n)=>e.check(ai(t,n)),e.int=t=>e.check(eo(t)),e.safe=t=>e.check(eo(t)),e.positive=t=>e.check(oi(0,t)),e.nonnegative=t=>e.check(si(0,t)),e.negative=t=>e.check(ii(0,t)),e.nonpositive=t=>e.check(ai(0,t)),e.multipleOf=(t,n)=>e.check(ci(t,n)),e.step=(t,n)=>e.check(ci(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return Xr(Qa,e)}const $a=O(`ZodNumberFormat`,(e,t)=>{Fn.init(e,t),Qa.init(e,t)});function eo(e){return Qr($a,e)}const to=O(`ZodBoolean`,(e,t)=>{In.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r)});function z(e){return $r(to,e)}const no=O(`ZodNull`,(e,t)=>{Ln.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r)});function ro(e){return ei(no,e)}const io=O(`ZodAny`,(e,t)=>{Rn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ao(){return ti(io)}const oo=O(`ZodUnknown`,(e,t)=>{zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function B(){return ni(oo)}const so=O(`ZodNever`,(e,t)=>{Bn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r)});function co(e){return ri(so,e)}const lo=O(`ZodArray`,(e,t)=>{Hn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gi(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(ui(t,n)),e.nonempty=t=>e.check(ui(1,t)),e.max=(t,n)=>e.check(li(t,n)),e.length=(t,n)=>e.check(di(t,n)),e.unwrap=()=>e.element});function V(e,t){return wi(lo,e,t)}const uo=O(`ZodObject`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ki(e,t,n,r),A(e,`shape`,()=>t.shape),e.keyof=()=>yo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:B()}),e.loose=()=>e.clone({...e._zod.def,catchall:B()}),e.strict=()=>e.clone({...e._zod.def,catchall:co()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Fe(e,t),e.safeExtend=t=>Ie(e,t),e.merge=t=>Le(e,t),e.pick=t=>Ne(e,t),e.omit=t=>Pe(e,t),e.partial=(...t)=>Re(Co,e,t[0]),e.required=(...t)=>ze(Ao,e,t[0])});function H(e,t){return new uo({type:`object`,shape:e??{},...j(t)})}function U(e,t){return new uo({type:`object`,shape:e,catchall:B(),...j(t)})}const fo=O(`ZodUnion`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qi(e,t,n,r),e.options=t.options});function W(e,t){return new fo({type:`union`,options:e,...j(t)})}const po=O(`ZodDiscriminatedUnion`,(e,t)=>{fo.init(e,t),Xn.init(e,t)});function mo(e,t,n){return new po({type:`union`,options:t,discriminator:e,...j(n)})}const ho=O(`ZodIntersection`,(e,t)=>{Zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ji(e,t,n,r)});function go(e,t){return new ho({type:`intersection`,left:e,right:t})}const _o=O(`ZodRecord`,(e,t)=>{er.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function G(e,t,n){return new _o({type:`record`,keyType:e,valueType:t,...j(n)})}const vo=O(`ZodEnum`,(e,t)=>{tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new vo({...t,checks:[],...j(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new vo({...t,checks:[],...j(r),entries:i})}});function yo(e,t){return new vo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...j(t)})}const bo=O(`ZodLiteral`,(e,t)=>{nr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function K(e,t){return new bo({type:`literal`,values:Array.isArray(e)?e:[e],...j(t)})}const xo=O(`ZodTransform`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new k(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ge(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ge(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function So(e){return new xo({type:`transform`,transform:e})}const Co=O(`ZodOptional`,(e,t)=>{ar.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function q(e){return new Co({type:`optional`,innerType:e})}const wo=O(`ZodNullable`,(e,t)=>{or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function To(e){return new wo({type:`nullable`,innerType:e})}const Eo=O(`ZodDefault`,(e,t)=>{sr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Do(e,t){return new Eo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Oo=O(`ZodPrefault`,(e,t)=>{lr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$i(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ko(e,t){return new Oo({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Ao=O(`ZodNonOptional`,(e,t)=>{ur.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jo(e,t){return new Ao({type:`nonoptional`,innerType:e,...j(t)})}const Mo=O(`ZodCatch`,(e,t)=>{fr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function No(e,t){return new Mo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Po=O(`ZodPipe`,(e,t)=>{pr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.in=t.in,e.out=t.out});function Fo(e,t){return new Po({type:`pipe`,in:e,out:t})}const Io=O(`ZodReadonly`,(e,t)=>{hr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lo(e){return new Io({type:`readonly`,innerType:e})}const Ro=O(`ZodCustom`,(e,t)=>{_r.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r)});function zo(e,t){return Ti(Ro,e??(()=>!0),t)}function Bo(e,t={}){return Ei(Ro,e,t)}function Vo(e){return Di(e)}function Ho(e,t){return Fo(So(e),t)}const Uo={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var Wo;(function(e){})(Wo||={});function Go(e){return Zr(Qa,e)}const Ko=`2025-11-25`,qo=[Ko,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Jo=`io.modelcontextprotocol/related-task`,J=zo(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),Yo=W([I(),R().int()]),Xo=I();U({ttl:W([R(),ro()]).optional(),pollInterval:R().optional()});const Zo=H({ttl:R().optional()}),Qo=H({taskId:I()}),$o=U({progressToken:Yo.optional(),[Jo]:Qo.optional()}),es=H({_meta:$o.optional()}),ts=es.extend({task:Zo.optional()}),ns=e=>ts.safeParse(e).success,rs=H({method:I(),params:es.loose().optional()}),is=H({_meta:$o.optional()}),as=H({method:I(),params:is.loose().optional()}),os=U({_meta:$o.optional()}),ss=W([I(),R().int()]),cs=H({jsonrpc:K(`2.0`),id:ss,...rs.shape}).strict(),ls=e=>cs.safeParse(e).success,us=H({jsonrpc:K(`2.0`),...as.shape}).strict(),ds=e=>us.safeParse(e).success,fs=H({jsonrpc:K(`2.0`),id:ss,result:os}).strict(),ps=e=>fs.safeParse(e).success;var Y;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Y||={});const ms=H({jsonrpc:K(`2.0`),id:ss.optional(),error:H({code:R().int(),message:I(),data:B().optional()})}).strict(),hs=e=>ms.safeParse(e).success,gs=W([cs,us,fs,ms]);W([fs,ms]);const _s=os.strict(),vs=is.extend({requestId:ss.optional(),reason:I().optional()}),ys=as.extend({method:K(`notifications/cancelled`),params:vs}),bs=H({icons:V(H({src:I(),mimeType:I().optional(),sizes:V(I()).optional(),theme:yo([`light`,`dark`]).optional()})).optional()}),xs=H({name:I(),title:I().optional()}),Ss=xs.extend({...xs.shape,...bs.shape,version:I(),websiteUrl:I().optional(),description:I().optional()}),Cs=Ho(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,go(H({form:go(H({applyDefaults:z().optional()}),G(I(),B())).optional(),url:J.optional()}),G(I(),B()).optional())),ws=U({list:J.optional(),cancel:J.optional(),requests:U({sampling:U({createMessage:J.optional()}).optional(),elicitation:U({create:J.optional()}).optional()}).optional()}),Ts=U({list:J.optional(),cancel:J.optional(),requests:U({tools:U({call:J.optional()}).optional()}).optional()}),Es=H({experimental:G(I(),J).optional(),sampling:H({context:J.optional(),tools:J.optional()}).optional(),elicitation:Cs.optional(),roots:H({listChanged:z().optional()}).optional(),tasks:ws.optional()}),Ds=es.extend({protocolVersion:I(),capabilities:Es,clientInfo:Ss}),Os=rs.extend({method:K(`initialize`),params:Ds}),ks=H({experimental:G(I(),J).optional(),logging:J.optional(),completions:J.optional(),prompts:H({listChanged:z().optional()}).optional(),resources:H({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:H({listChanged:z().optional()}).optional(),tasks:Ts.optional()}),As=os.extend({protocolVersion:I(),capabilities:ks,serverInfo:Ss,instructions:I().optional()}),js=as.extend({method:K(`notifications/initialized`),params:is.optional()}),Ms=e=>js.safeParse(e).success,Ns=rs.extend({method:K(`ping`),params:es.optional()}),Ps=H({progress:R(),total:q(R()),message:q(I())}),Fs=H({...is.shape,...Ps.shape,progressToken:Yo}),Is=as.extend({method:K(`notifications/progress`),params:Fs}),Ls=es.extend({cursor:Xo.optional()}),Rs=rs.extend({params:Ls.optional()}),zs=os.extend({nextCursor:Xo.optional()}),Bs=yo([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Vs=H({taskId:I(),status:Bs,ttl:W([R(),ro()]),createdAt:I(),lastUpdatedAt:I(),pollInterval:q(R()),statusMessage:q(I())}),Hs=os.extend({task:Vs}),Us=is.merge(Vs),Ws=as.extend({method:K(`notifications/tasks/status`),params:Us}),Gs=rs.extend({method:K(`tasks/get`),params:es.extend({taskId:I()})}),Ks=os.merge(Vs),qs=rs.extend({method:K(`tasks/result`),params:es.extend({taskId:I()})});os.loose();const Js=Rs.extend({method:K(`tasks/list`)}),Ys=zs.extend({tasks:V(Vs)}),Xs=rs.extend({method:K(`tasks/cancel`),params:es.extend({taskId:I()})}),Zs=os.merge(Vs),Qs=H({uri:I(),mimeType:q(I()),_meta:G(I(),B()).optional()}),$s=Qs.extend({text:I()}),ec=I().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),tc=Qs.extend({blob:ec}),nc=yo([`user`,`assistant`]),rc=H({audience:V(nc).optional(),priority:R().min(0).max(1).optional(),lastModified:la({offset:!0}).optional()}),ic=H({...xs.shape,...bs.shape,uri:I(),description:q(I()),mimeType:q(I()),annotations:rc.optional(),_meta:q(U({}))}),ac=H({...xs.shape,...bs.shape,uriTemplate:I(),description:q(I()),mimeType:q(I()),annotations:rc.optional(),_meta:q(U({}))}),oc=Rs.extend({method:K(`resources/list`)}),sc=zs.extend({resources:V(ic)}),cc=Rs.extend({method:K(`resources/templates/list`)}),lc=zs.extend({resourceTemplates:V(ac)}),uc=es.extend({uri:I()}),dc=uc,fc=rs.extend({method:K(`resources/read`),params:dc}),pc=os.extend({contents:V(W([$s,tc]))}),mc=as.extend({method:K(`notifications/resources/list_changed`),params:is.optional()}),hc=uc,gc=rs.extend({method:K(`resources/subscribe`),params:hc}),_c=uc,vc=rs.extend({method:K(`resources/unsubscribe`),params:_c}),yc=is.extend({uri:I()}),bc=as.extend({method:K(`notifications/resources/updated`),params:yc}),xc=H({name:I(),description:q(I()),required:q(z())}),Sc=H({...xs.shape,...bs.shape,description:q(I()),arguments:q(V(xc)),_meta:q(U({}))}),Cc=Rs.extend({method:K(`prompts/list`)}),wc=zs.extend({prompts:V(Sc)}),Tc=es.extend({name:I(),arguments:G(I(),I()).optional()}),Ec=rs.extend({method:K(`prompts/get`),params:Tc}),Dc=H({type:K(`text`),text:I(),annotations:rc.optional(),_meta:G(I(),B()).optional()}),Oc=H({type:K(`image`),data:ec,mimeType:I(),annotations:rc.optional(),_meta:G(I(),B()).optional()}),kc=H({type:K(`audio`),data:ec,mimeType:I(),annotations:rc.optional(),_meta:G(I(),B()).optional()}),Ac=H({type:K(`tool_use`),name:I(),id:I(),input:G(I(),B()),_meta:G(I(),B()).optional()}),jc=H({type:K(`resource`),resource:W([$s,tc]),annotations:rc.optional(),_meta:G(I(),B()).optional()}),Mc=W([Dc,Oc,kc,ic.extend({type:K(`resource_link`)}),jc]),Nc=H({role:nc,content:Mc}),Pc=os.extend({description:I().optional(),messages:V(Nc)}),Fc=as.extend({method:K(`notifications/prompts/list_changed`),params:is.optional()}),Ic=H({title:I().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),Lc=H({taskSupport:yo([`required`,`optional`,`forbidden`]).optional()}),Rc=H({...xs.shape,...bs.shape,description:I().optional(),inputSchema:H({type:K(`object`),properties:G(I(),J).optional(),required:V(I()).optional()}).catchall(B()),outputSchema:H({type:K(`object`),properties:G(I(),J).optional(),required:V(I()).optional()}).catchall(B()).optional(),annotations:Ic.optional(),execution:Lc.optional(),_meta:G(I(),B()).optional()}),zc=Rs.extend({method:K(`tools/list`)}),Bc=zs.extend({tools:V(Rc)}),Vc=os.extend({content:V(Mc).default([]),structuredContent:G(I(),B()).optional(),isError:z().optional()});Vc.or(os.extend({toolResult:B()}));const Hc=ts.extend({name:I(),arguments:G(I(),B()).optional()}),Uc=rs.extend({method:K(`tools/call`),params:Hc}),Wc=as.extend({method:K(`notifications/tools/list_changed`),params:is.optional()}),Gc=H({autoRefresh:z().default(!0),debounceMs:R().int().nonnegative().default(300)}),Kc=yo([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),qc=es.extend({level:Kc}),Jc=rs.extend({method:K(`logging/setLevel`),params:qc}),Yc=is.extend({level:Kc,logger:I().optional(),data:B()}),Xc=as.extend({method:K(`notifications/message`),params:Yc}),Zc=H({hints:V(H({name:I().optional()})).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),Qc=H({mode:yo([`auto`,`required`,`none`]).optional()}),$c=H({type:K(`tool_result`),toolUseId:I().describe(`The unique identifier for the corresponding tool call.`),content:V(Mc).default([]),structuredContent:H({}).loose().optional(),isError:z().optional(),_meta:G(I(),B()).optional()}),el=mo(`type`,[Dc,Oc,kc]),tl=mo(`type`,[Dc,Oc,kc,Ac,$c]),nl=H({role:nc,content:W([tl,V(tl)]),_meta:G(I(),B()).optional()}),rl=ts.extend({messages:V(nl),modelPreferences:Zc.optional(),systemPrompt:I().optional(),includeContext:yo([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:V(I()).optional(),metadata:J.optional(),tools:V(Rc).optional(),toolChoice:Qc.optional()}),il=rs.extend({method:K(`sampling/createMessage`),params:rl}),al=os.extend({model:I(),stopReason:q(yo([`endTurn`,`stopSequence`,`maxTokens`]).or(I())),role:nc,content:el}),ol=os.extend({model:I(),stopReason:q(yo([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(I())),role:nc,content:W([tl,V(tl)])}),sl=H({type:K(`boolean`),title:I().optional(),description:I().optional(),default:z().optional()}),cl=H({type:K(`string`),title:I().optional(),description:I().optional(),minLength:R().optional(),maxLength:R().optional(),format:yo([`email`,`uri`,`date`,`date-time`]).optional(),default:I().optional()}),ll=H({type:yo([`number`,`integer`]),title:I().optional(),description:I().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),ul=H({type:K(`string`),title:I().optional(),description:I().optional(),enum:V(I()),default:I().optional()}),dl=H({type:K(`string`),title:I().optional(),description:I().optional(),oneOf:V(H({const:I(),title:I()})),default:I().optional()}),fl=W([W([H({type:K(`string`),title:I().optional(),description:I().optional(),enum:V(I()),enumNames:V(I()).optional(),default:I().optional()}),W([ul,dl]),W([H({type:K(`array`),title:I().optional(),description:I().optional(),minItems:R().optional(),maxItems:R().optional(),items:H({type:K(`string`),enum:V(I())}),default:V(I()).optional()}),H({type:K(`array`),title:I().optional(),description:I().optional(),minItems:R().optional(),maxItems:R().optional(),items:H({anyOf:V(H({const:I(),title:I()}))}),default:V(I()).optional()})])]),sl,cl,ll]),pl=W([ts.extend({mode:K(`form`).optional(),message:I(),requestedSchema:H({type:K(`object`),properties:G(I(),fl),required:V(I()).optional()})}),ts.extend({mode:K(`url`),message:I(),elicitationId:I(),url:I().url()})]),ml=rs.extend({method:K(`elicitation/create`),params:pl}),hl=is.extend({elicitationId:I()}),gl=as.extend({method:K(`notifications/elicitation/complete`),params:hl}),_l=os.extend({action:yo([`accept`,`decline`,`cancel`]),content:Ho(e=>e===null?void 0:e,G(I(),W([I(),R(),z(),V(I())])).optional())}),vl=H({type:K(`ref/resource`),uri:I()}),yl=H({type:K(`ref/prompt`),name:I()}),bl=es.extend({ref:W([yl,vl]),argument:H({name:I(),value:I()}),context:H({arguments:G(I(),I()).optional()}).optional()}),xl=rs.extend({method:K(`completion/complete`),params:bl}),Sl=os.extend({completion:U({values:V(I()).max(100),total:q(R().int()),hasMore:q(z())})}),Cl=H({uri:I().startsWith(`file://`),name:I().optional(),_meta:G(I(),B()).optional()}),wl=rs.extend({method:K(`roots/list`),params:es.optional()}),Tl=os.extend({roots:V(Cl)}),El=as.extend({method:K(`notifications/roots/list_changed`),params:is.optional()});W([Ns,Os,xl,Jc,Ec,Cc,oc,cc,fc,gc,vc,Uc,zc,Gs,qs,Js,Xs]),W([ys,Is,js,El,Ws]),W([_s,al,ol,_l,Tl,Ks,Ys,Hs]),W([Ns,il,ml,wl,Gs,qs,Js,Xs]),W([ys,Is,Xc,bc,mc,Wc,Fc,Ws,gl]),W([_s,As,Sl,Pc,wc,sc,lc,pc,Vc,Bc,Ks,Ys,Hs]);var X=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===Y.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Dl(e.elicitations,n)}return new e(t,n,r)}},Dl=class extends X{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Y.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Ol(e){return e===`completed`||e===`failed`||e===`cancelled`}function kl(e){let t=oa(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=sa(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Al(e,t){let n=aa(e,t);if(!n.success)throw n.error;return n.data}var jl=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(ys,e=>{this._oncancel(e)}),this.setNotificationHandler(Is,e=>{this._onprogress(e)}),this.setRequestHandler(Ns,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Gs,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new X(Y.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(qs,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new X(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new X(Y.InvalidParams,`Task not found: ${r}`);if(!Ol(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Ol(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[Jo]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Js,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new X(Y.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Xs,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new X(Y.InvalidParams,`Task not found: ${e.params.taskId}`);if(Ol(n.status))throw new X(Y.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new X(Y.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof X?e:new X(Y.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),X.fromError(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),ps(e)||hs(e)?this._onresponse(e):ls(e)?this._onrequest(e,t):ds(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let t=X.fromError(Y.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Jo]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:Y.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=ns(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{let a={...r,relatedRequestId:e.id};i&&!a.relatedTask&&(a.relatedTask={taskId:i});let o=a.relatedTask?.taskId??i;return o&&s&&await s.updateTaskStatus(o,`input_required`),await this.request(t,n,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Y.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),ps(e)?n(e):n(new X(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(ps(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),ps(e)?r(e):r(X.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof X?e:new X(Y.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Hs,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new X(Y.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Ol(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new X(Y.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new X(Y.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof X?e:new X(Y.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Jo]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof X?e:new X(Y.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=aa(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(X.fromError(Y.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},Ks,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},Ys,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},Zs,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[Jo]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.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 n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[Jo]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[Jo]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=kl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Al(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=kl(e);this._notificationHandlers.set(n,n=>{let r=Al(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&ls(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new X(Y.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new X(Y.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new X(Y.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new X(Y.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=Ws.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Ol(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new X(Y.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Ol(a.status))throw new X(Y.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=Ws.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Ol(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Ml(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nl(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];Ml(a)&&Ml(i)?n[r]={...a,...i}:n[r]=i}return n}var Pl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{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(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Fl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Pl();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Z=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Pl(),n=Fl();var r=Pl();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=Fl();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=E(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=E(this.rhs,e,n),this}get names(){return ne(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=E(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(D(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(re(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=E(this.condition,e,t),this}get names(){let e=super.names;return ne(e,this.condition),this.else&&T(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=E(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}},ee=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return ne(ne(super.names,this.from),this.to)}},b=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=E(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}},te=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};te.kind=`func`;var x=class extends p{render(e){return`return `+super.render(e)}};x.kind=`return`;var S=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}},C=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};C.kind=`catch`;var w=class extends m{render(e){return`finally`+super.render(e)}};w.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
132
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new ee(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new b(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new b(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new x;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(x)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new S;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new C(e),t(e)}return n&&(this._currNode=r.finally=new w,this.code(n)),this._endBlockNode(C,w)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new te(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(te)}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,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function T(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function ne(e,n){return n instanceof t._CodeOrName?T(e,n.names):e}function E(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function D(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function re(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${O(e)}`}e.not=re;let ie=ce(e.operators.AND);function ae(...e){return e.reduce(ie)}e.and=ae;let oe=ce(e.operators.OR);function se(...e){return e.reduce(oe)}e.or=se;function ce(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${O(n)} ${e} ${O(r)}`}function O(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Q=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=Z(),n=Pl();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||b(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function ee(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=ee;function b(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=b})),Il=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Ll=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=Z(),n=Q(),r=Il();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Rl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Ll(),n=Z(),r=Il(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),zl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Bl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Vl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=zl(),n=Bl(),r=Ll(),i=Z(),a=Q();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
133
- || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
134
- || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
135
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;for(let e in s.number&&delete s.integer,s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Hl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=Z(),n=Q();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Ul=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=Z(),n=Q(),r=Il(),i=Q();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Wl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=Z(),n=Il(),r=Ul(),i=Ll();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)ee(),i.modifying&&s(e),b(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),b(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>ee((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),ee(t.nil),e}function ee(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function b(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Gl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=Z(),n=Q();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Kl=n(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),ql=n(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Jl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Q(),n=Kl(),r=ql(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Yl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Rl(),n=Vl(),r=Bl(),i=Vl(),a=Hl(),o=Wl(),s=Gl(),c=Z(),l=Il(),u=Jl(),d=Q(),f=Ll();function p(e){if(te(e)&&(S(e),b(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&D(e),T(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),C(e),re(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function ee(e,n){if(te(e)&&(S(e),b(e))){x(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function b({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function te(e){return typeof e.schema!=`boolean`}function x(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&D(e),ne(e),E(e);let a=r.const(`_errs`,l.default.errors);C(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function S(e){(0,d.checkUnknownRules)(e),w(e)}function C(e,t){if(e.opts.jtd)return ae(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ae(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function w(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function T(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function ne(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function E(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function D({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function re(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&ie(e),t.return((0,c._)`${l.default.errors} === 0`))}function ie({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ae(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>me(e,`$ref`,h.all.$ref.definition));return}p.jtd||se(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),oe(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):oe(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function oe(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&me(e,n.keyword,n.definition,t.type)})}function se(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ce(e,t),e.opts.allowUnionTypes||O(e,t),le(e,e.dataTypes))}function ce(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ue(e.dataTypes,t)||fe(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),de(e,t)}}function O(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&fe(e,`use allowUnionTypes to allow union type keyword`)}function le(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>k(t,e))&&fe(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function k(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ue(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function de(e,t){let n=[];for(let r of e.dataTypes)ue(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function fe(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var pe=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,_e(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}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:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return ee(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=pe;function me(e,t,n,r){let i=new pe(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let he=/^\/(?:[^~]|~0|~1)*$/,ge=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function _e(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!he.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ge.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=_e})),Xl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Zl=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Jl();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Ql=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=Z(),n=Xl(),r=Il(),i=Jl(),a=Q(),o=Yl();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),$l=n(((e,t)=>{t.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}})),eu=n(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function i(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let a=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){let r=i(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function c(e){let t=0,n={error:!1,address:``,zone:``},r=[],a=[],c=!1,l=!1,u=s;for(let i=0;i<e.length;i++){let s=e[i];if(!(s===`[`||s===`]`))if(s===`:`){if(c===!0&&(l=!0),!u(a,r,n))break;if(++t>7){n.error=!0;break}i>0&&e[i-1]===`:`&&(c=!0),r.push(`:`);continue}else if(s===`%`){if(!u(a,r,n))break;u=o}else{a.push(s);continue}}return a.length&&(u===o?n.zone=a.join(``):l?r.push(a.join(``)):r.push(i(a))),n.address=r.join(``),n}function l(e){if(u(e,`:`)<2)return{host:e,isIPV6:!1};let t=c(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function u(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function d(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}function f(e,t){let n=t===!0?unescape:escape;return e.scheme!==void 0&&(e.scheme=n(e.scheme)),e.userinfo!==void 0&&(e.userinfo=n(e.userinfo)),e.host!==void 0&&(e.host=n(e.host)),e.path!==void 0&&(e.path=n(e.path)),e.query!==void 0&&(e.query=n(e.query)),e.fragment!==void 0&&(e.fragment=n(e.fragment)),e}function p(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let t=l(n);n=t.isIPV6===!0?`[${t.escapedHost}]`:e.host}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:a,recomposeAuthority:p,normalizeComponentEncoding:f,removeDotSegments:d,isIPv4:r,isUUID:n,normalizeIPv6:l,stringArrayToHexStripped:i}})),tu=n(((e,t)=>{let{isUUID:n}=eu(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=te(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=te(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},y={scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},ee={scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0},b={http:h,https:g,ws:_,wss:v,urn:y,"urn:uuid":ee};Object.setPrototypeOf(b,null);function te(e){return e&&(b[e]||b[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:b,isValidSchemeName:a,getSchemeHandler:te}})),nu=n(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizeComponentEncoding:a,isIPv4:o,nonSimpleDomain:s}=eu(),{SCHEMES:c,getSchemeHandler:l}=tu();function u(e,t){return typeof e==`string`?e=m(g(e,t),t):typeof e==`object`&&(e=g(m(e,t),t)),e}function d(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=f(g(e,r),g(t,r),r,!0);return r.skipEscape=!0,m(i,r)}function f(e,t,n,i){let a={};return i||(e=g(m(e,n),n),t=g(m(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function p(e,t,n){return typeof e==`string`?(e=unescape(e),e=m(a(g(e,n),!0),{...n,skipEscape:!0})):typeof e==`object`&&(e=m(a(e,!0),{...n,skipEscape:!0})),typeof t==`string`?(t=unescape(t),t=m(a(g(t,n),!0),{...n,skipEscape:!0})):typeof t==`object`&&(t=m(a(t,!0),{...n,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function m(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},a=Object.assign({},t),o=[],s=l(a.scheme||n.scheme);s&&s.serialize&&s.serialize(n,a),n.path!==void 0&&(a.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),a.reference!==`suffix`&&n.scheme&&o.push(n.scheme,`:`);let c=i(n);if(c!==void 0&&(a.reference!==`suffix`&&o.push(`//`),o.push(c),n.path&&n.path[0]!==`/`&&o.push(`/`)),n.path!==void 0){let e=n.path;!a.absolutePath&&(!s||!s.absolutePath)&&(e=r(e)),c===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),o.push(e)}return n.query!==void 0&&o.push(`?`,n.query),n.fragment!==void 0&&o.push(`#`,n.fragment),o.join(``)}let h=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function g(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let c=e.match(h);if(c){if(i.scheme=c[1],i.userinfo=c[3],i.host=c[4],i.port=parseInt(c[5],10),i.path=c[6]||``,i.query=c[7],i.fragment=c[8],isNaN(i.port)&&(i.port=c[5]),i.host)if(o(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),a=e.isIPV6}else a=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let t=l(r.scheme||i.scheme);if(!r.unicodeSupport&&(!t||!t.unicodeSupport)&&i.host&&(r.domainHost||t&&t.domainHost)&&a===!1&&s(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}(!t||t&&!t.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=unescape(i.host))),i.path&&=escape(unescape(i.path)),i.fragment&&=encodeURI(decodeURIComponent(i.fragment))),t&&t.parse&&t.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return i}let _={SCHEMES:c,normalize:u,resolve:d,resolveComponent:f,equal:p,serialize:m,parse:g};t.exports=_,t.exports.default=_,t.exports.fastUri=_})),ru=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=nu();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),iu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Yl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Z();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let r=Xl(),i=Zl(),a=zl(),o=Ql(),s=Z(),c=Jl(),l=Vl(),u=Q(),d=$l(),f=ru(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=T(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),ee.call(this,g,e,`NOT SUPPORTED`),ee.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=C.call(this),e.formats&&x.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&S.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),te.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw 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 r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=b.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}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 t=b.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(E.call(this,n,t),!t)return(0,u.eachItem)(n,e=>D.call(this,e)),this;ie.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>D.call(this,e,r):e=>r.type.forEach(t=>D.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=oe(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function ee(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function b(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function te(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function x(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function S(e){if(Array.isArray(e)){this.addVocabulary(e);return}for(let t in this.logger.warn(`keywords option as map is deprecated, pass array`),e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function C(){let e={...this.opts};for(let t of m)delete e[t];return e}let w={log(){},warn(){},error(){}};function T(e){if(e===!1)return w;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let ne=/^[a-z_$][a-z0-9_$:-]*$/i;function E(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!ne.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function D(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?re.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function re(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ie(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=oe(t)),e.validateSchema=this.compile(t,!0))}let ae={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function oe(e){return{anyOf:[e,ae]}}})),au=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),ou=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=Zl(),n=Ul(),r=Z(),i=Il(),a=Ql(),o=Q(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}if(l.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}e.callRef=l,e.default=s})),su=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=au(),n=ou();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),cu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),lu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),uu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),du=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=uu();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),fu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul(),n=Z();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,n.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,n._)`{pattern: ${e}}`},code(e){let{data:r,$data:i,schema:a,schemaCode:o,it:s}=e,c=s.opts.unicodeRegExp?`u`:``,l=i?(0,n._)`(new RegExp(${o}, ${c}))`:(0,t.usePattern)(e,a);e.fail$data((0,n._)`!${l}.test(${r})`)}}})),pu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),mu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul(),n=Z(),r=Q();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),hu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),gu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Kl();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),_u=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Vl(),n=Z(),r=Q(),i=gu();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),vu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=gu();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),yu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=gu();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),bu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=cu(),n=lu(),r=du(),i=fu(),a=pu(),o=mu(),s=hu(),c=_u(),l=vu(),u=yu();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),xu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=Z(),n=Q(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Su=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=Z(),n=Q(),r=Ul(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),Cu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Su();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),wu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r=Ul(),i=xu();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Tu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),Eu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=Z(),n=Q(),r=Ul();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
136
- missingProperty: ${i},
137
- depsCount: ${n},
138
- deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Du=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Ou=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul(),n=Z(),r=Il(),i=Q();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),ku=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Yl(),n=Ul(),r=Q(),i=Ou();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),Au=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ul(),n=Z(),r=Q(),i=Q();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),ju=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Mu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Ul().validateUnion,error:{message:`must match a schema in anyOf`}}})),Nu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Pu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Fu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Q(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),Iu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Q();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Lu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=xu(),n=Cu(),r=Su(),i=wu(),a=Tu(),o=Eu(),s=Du(),c=Ou(),l=ku(),u=Au(),d=ju(),f=Mu(),p=Nu(),m=Pu(),h=Fu(),g=Iu();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Ru=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),zu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Ru().default]})),Bu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Vu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=su(),n=bu(),r=Lu(),i=zu(),a=Bu();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Hu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Uu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Z(),n=Hu(),r=Ql(),i=Zl(),a=Q();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();for(let e in o.if(!1),r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Wu=n(((e,t)=>{t.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}})),Gu=n(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=iu(),r=Vu(),i=Uu(),a=Wu(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.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(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=c;var l=Yl();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Z();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return u.CodeGen}});var d=Xl();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=Zl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})})),Ku=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:w,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:y,int32:{type:`number`,validate:te},int64:{type:`number`,validate:x},float:{type:`number`,validate:S},double:{type:`number`,validate:S},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\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,m),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},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[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 _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let ee=-(2**31),b=2**31-1;function te(e){return Number.isInteger(e)&&e<=b&&e>=ee}function x(e){return Number.isInteger(e)}function S(){return!0}let C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),qu=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.formatLimitDefinition=void 0;let t=Gu(),n=Z(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),Ju=n(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});let n=Ku(),r=qu(),i=Z(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=s})),Yu=t(Gu(),1),Xu=t(Ju(),1);function Zu(){let e=new Yu.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Xu.default)(e),e}var Qu=class{constructor(e){this._ajv=e??Zu()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},$u=class{constructor(e){this._client=e}async*callToolStream(e,t=Vc,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new X(Y.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new X(Y.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof X){yield{type:`error`,error:e};return}yield{type:`error`,error:new X(Y.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function ed(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`tools/call`:if(!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function td(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function nd(e,t){if(!(!e||typeof t!=`object`||!t)){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&nd(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&nd(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&nd(n,t)}}function rd(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var id=class extends jl{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Qu,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,Wc,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,Fc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,mc,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new $u(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Nl(this._capabilities,e)}setRequestHandler(e,t){let n=oa(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(ia(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=aa(ml,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new X(Y.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=rd(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new X(Y.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new X(Y.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=aa(Hs,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new X(Y.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=aa(_l,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new X(Y.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{nd(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=aa(il,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new X(Y.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=aa(Hs,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new X(Y.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=aa(al,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new X(Y.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:Ko,capabilities:this._capabilities,clientInfo:this._clientInfo}},As,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!qo.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`initialize`:break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/roots/list_changed`:if(!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`);break;case`notifications/initialized`:break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`);break;case`ping`:break}}assertTaskCapability(e){ed(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&td(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},_s,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},Sl,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},_s,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},Pc,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},wc,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},sc,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},lc,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},pc,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},_s,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},_s,t)}async callTool(e,t=Vc,n){if(this.isToolTaskRequired(e.name))throw new X(Y.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new X(Y.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new X(Y.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof X?e:new X(Y.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},Bc,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=Gc.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{s(null,await r())}catch(e){s(e instanceof Error?e:Error(String(e)),null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}},ad=n(((t,n)=>{n.exports=o,o.sync=s;var r=e(`fs`);function i(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function a(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:i(t,n)}function o(e,t,n){r.stat(e,function(r,i){n(r,r?!1:a(i,e,t))})}function s(e,t){return a(r.statSync(e),e,t)}})),od=n(((t,n)=>{n.exports=i,i.sync=a;var r=e(`fs`);function i(e,t,n){r.stat(e,function(e,r){n(e,e?!1:o(r,t))})}function a(e,t){return o(r.statSync(e),t)}function o(e,t){return e.isFile()&&s(e,t)}function s(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),sd=n(((t,n)=>{e(`fs`);var r=process.platform===`win32`||global.TESTING_WINDOWS?ad():od();n.exports=i,i.sync=a;function i(e,t,n){if(typeof t==`function`&&(n=t,t={}),!n){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,r){i(e,t||{},function(e,t){e?r(e):n(t)})})}r(e,t||{},function(e,r){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)})}function a(e,t){try{return r.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),cd=n(((t,n)=>{let r=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,i=e(`path`),a=r?`;`:`:`,o=sd(),s=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),c=(e,t)=>{let n=t.colon||a,i=e.match(/\//)||r&&e.match(/\\/)?[``]:[...r?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(n)],o=r?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=r?o.split(n):[``];return r&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:i,pathExt:s,pathExtExe:o}},l=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:r,pathExt:a,pathExtExe:l}=c(e,t),u=[],d=n=>new Promise((a,o)=>{if(n===r.length)return t.all&&u.length?a(u):o(s(e));let c=r[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,s)=>{if(r===a.length)return i(d(n+1));let c=a[r];o(e+c,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+c);else return i(e+c);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};n.exports=l,l.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:r,pathExtExe:a}=c(e,t),l=[];for(let s=0;s<n.length;s++){let c=n[s],u=/^".*"$/.test(c)?c.slice(1,-1):c,d=i.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<r.length;e++){let n=f+r[e];try{if(o.sync(n,{pathExt:a}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw s(e)}})),ld=n(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),ud=n(((t,n)=>{let r=e(`path`),i=cd(),a=ld();function o(e,t){let n=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=i.sync(e.command,{path:n[a({env:n})],pathExt:t?r.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=r.resolve(s?e.options.cwd:``,l),l}function s(e){return o(e)||o(e,!0)}n.exports=s})),dd=n(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),fd=n(((e,t)=>{t.exports=/^#!(.*)/})),pd=n(((e,t)=>{let n=fd();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),md=n(((t,n)=>{let r=e(`fs`),i=pd();function a(e){let t=Buffer.alloc(150),n;try{n=r.openSync(e,`r`),r.readSync(n,t,0,150,0),r.closeSync(n)}catch{}return i(t.toString())}n.exports=a})),hd=n(((t,n)=>{let r=e(`path`),i=ud(),a=dd(),o=md(),s=process.platform===`win32`,c=/\.(?:com|exe)$/i,l=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(e){e.file=i(e);let t=e.file&&o(e.file);return t?(e.args.unshift(e.file),e.command=t,i(e)):e.file}function d(e){if(!s)return e;let t=u(e),n=!c.test(t);if(e.options.forceShell||n){let n=l.test(t);e.command=r.normalize(e.command),e.command=a.command(e.command),e.args=e.args.map(e=>a.argument(e,n)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function f(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:d(r)}n.exports=f})),gd=n(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),_d=t(n(((t,n)=>{let r=e(`child_process`),i=hd(),a=gd();function o(e,t,n){let o=i(e,t,n),s=r.spawn(o.command,o.args,o.options);return a.hookChildProcess(s,o),s}function s(e,t,n){let o=i(e,t,n),s=r.spawnSync(o.command,o.args,o.options);return s.error=s.error||a.verifyENOENTSync(s.status,o),s}n.exports=o,n.exports.spawn=o,n.exports.sync=s,n.exports._parse=i,n.exports._enoent=a}))(),1),vd=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
139
- `);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);return this._buffer=this._buffer.subarray(e+1),yd(t)}clear(){this._buffer=void 0}};function yd(e){return gs.parse(JSON.parse(e))}function bd(e){return JSON.stringify(e)+`
140
- `}const xd=v.platform===`win32`?[`APPDATA`,`HOMEDRIVE`,`HOMEPATH`,`LOCALAPPDATA`,`PATH`,`PROCESSOR_ARCHITECTURE`,`SYSTEMDRIVE`,`SYSTEMROOT`,`TEMP`,`USERNAME`,`USERPROFILE`,`PROGRAMFILES`]:[`HOME`,`LOGNAME`,`PATH`,`SHELL`,`TERM`,`USER`];function Sd(){let e={};for(let t of xd){let n=v.env[t];n!==void 0&&(n.startsWith(`()`)||(e[t]=n))}return e}var Cd=class{constructor(e){this._readBuffer=new vd,this._stderrStream=null,this._serverParams=e,(e.stderr===`pipe`||e.stderr===`overlapped`)&&(this._stderrStream=new y)}async start(){if(this._process)throw Error(`StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return new Promise((e,t)=>{this._process=(0,_d.default)(this._serverParams.command,this._serverParams.args??[],{env:{...Sd(),...this._serverParams.env},stdio:[`pipe`,`pipe`,this._serverParams.stderr??`inherit`],shell:!1,windowsHide:v.platform===`win32`&&wd(),cwd:this._serverParams.cwd}),this._process.on(`error`,e=>{t(e),this.onerror?.(e)}),this._process.on(`spawn`,()=>{e()}),this._process.on(`close`,e=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on(`error`,e=>{this.onerror?.(e)}),this._process.stdout?.on(`data`,e=>{this._readBuffer.append(e),this.processReadBuffer()}),this._process.stdout?.on(`error`,e=>{this.onerror?.(e)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let t=new Promise(t=>{e.once(`close`,()=>{t()})});try{e.stdin?.end()}catch{}if(await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())]),e.exitCode===null){try{e.kill(`SIGTERM`)}catch{}await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())])}if(e.exitCode===null)try{e.kill(`SIGKILL`)}catch{}}this._readBuffer.clear()}send(e){return new Promise(t=>{if(!this._process?.stdin)throw Error(`Not connected`);let n=bd(e);this._process.stdin.write(n)?t():this._process.stdin.once(`drain`,t)})}};function wd(){return`type`in v}function Td(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Ed(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...Td(t.headers),...Td(r.headers)}:t.headers}):e}let Dd;Dd=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Od(e){return(await Dd).getRandomValues(new Uint8Array(e))}async function kd(e){let t=``;for(;t.length<e;){let n=await Od(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Ad(e){return await kd(e)}async function jd(e){let t=await(await Dd).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Md(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Ad(e);return{code_verifier:t,code_challenge:await jd(t)}}const Nd=Ia().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Uo.custom,message:`URL must be parseable`,fatal:!0}),ce}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Pd=U({resource:I().url(),authorization_servers:V(Nd).optional(),jwks_uri:I().url().optional(),scopes_supported:V(I()).optional(),bearer_methods_supported:V(I()).optional(),resource_signing_alg_values_supported:V(I()).optional(),resource_name:I().optional(),resource_documentation:I().optional(),resource_policy_uri:I().url().optional(),resource_tos_uri:I().url().optional(),tls_client_certificate_bound_access_tokens:z().optional(),authorization_details_types_supported:V(I()).optional(),dpop_signing_alg_values_supported:V(I()).optional(),dpop_bound_access_tokens_required:z().optional()}),Fd=U({issuer:I(),authorization_endpoint:Nd,token_endpoint:Nd,registration_endpoint:Nd.optional(),scopes_supported:V(I()).optional(),response_types_supported:V(I()),response_modes_supported:V(I()).optional(),grant_types_supported:V(I()).optional(),token_endpoint_auth_methods_supported:V(I()).optional(),token_endpoint_auth_signing_alg_values_supported:V(I()).optional(),service_documentation:Nd.optional(),revocation_endpoint:Nd.optional(),revocation_endpoint_auth_methods_supported:V(I()).optional(),revocation_endpoint_auth_signing_alg_values_supported:V(I()).optional(),introspection_endpoint:I().optional(),introspection_endpoint_auth_methods_supported:V(I()).optional(),introspection_endpoint_auth_signing_alg_values_supported:V(I()).optional(),code_challenge_methods_supported:V(I()).optional(),client_id_metadata_document_supported:z().optional()}),Id=H({...U({issuer:I(),authorization_endpoint:Nd,token_endpoint:Nd,userinfo_endpoint:Nd.optional(),jwks_uri:Nd,registration_endpoint:Nd.optional(),scopes_supported:V(I()).optional(),response_types_supported:V(I()),response_modes_supported:V(I()).optional(),grant_types_supported:V(I()).optional(),acr_values_supported:V(I()).optional(),subject_types_supported:V(I()),id_token_signing_alg_values_supported:V(I()),id_token_encryption_alg_values_supported:V(I()).optional(),id_token_encryption_enc_values_supported:V(I()).optional(),userinfo_signing_alg_values_supported:V(I()).optional(),userinfo_encryption_alg_values_supported:V(I()).optional(),userinfo_encryption_enc_values_supported:V(I()).optional(),request_object_signing_alg_values_supported:V(I()).optional(),request_object_encryption_alg_values_supported:V(I()).optional(),request_object_encryption_enc_values_supported:V(I()).optional(),token_endpoint_auth_methods_supported:V(I()).optional(),token_endpoint_auth_signing_alg_values_supported:V(I()).optional(),display_values_supported:V(I()).optional(),claim_types_supported:V(I()).optional(),claims_supported:V(I()).optional(),service_documentation:I().optional(),claims_locales_supported:V(I()).optional(),ui_locales_supported:V(I()).optional(),claims_parameter_supported:z().optional(),request_parameter_supported:z().optional(),request_uri_parameter_supported:z().optional(),require_request_uri_registration:z().optional(),op_policy_uri:Nd.optional(),op_tos_uri:Nd.optional(),client_id_metadata_document_supported:z().optional()}).shape,...Fd.pick({code_challenge_methods_supported:!0}).shape}),Ld=H({access_token:I(),id_token:I().optional(),token_type:I(),expires_in:Go().optional(),scope:I().optional(),refresh_token:I().optional()}).strip(),Rd=H({error:I(),error_description:I().optional(),error_uri:I().optional()}),zd=Nd.optional().or(K(``).transform(()=>void 0)),Bd=H({redirect_uris:V(Nd),token_endpoint_auth_method:I().optional(),grant_types:V(I()).optional(),response_types:V(I()).optional(),client_name:I().optional(),client_uri:Nd.optional(),logo_uri:zd,scope:I().optional(),contacts:V(I()).optional(),tos_uri:zd,policy_uri:I().optional(),jwks_uri:Nd.optional(),jwks:ao().optional(),software_id:I().optional(),software_version:I().optional(),software_statement:I().optional()}).strip(),Vd=H({client_id:I(),client_secret:I().optional(),client_id_issued_at:R().optional(),client_secret_expires_at:R().optional()}).strip(),Hd=Bd.merge(Vd);H({error:I(),error_description:I().optional()}).strip(),H({token:I(),token_type_hint:I().optional()}).strip();function Ud(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function Wd({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var $=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Gd=class extends ${};Gd.errorCode=`invalid_request`;var Kd=class extends ${};Kd.errorCode=`invalid_client`;var qd=class extends ${};qd.errorCode=`invalid_grant`;var Jd=class extends ${};Jd.errorCode=`unauthorized_client`;var Yd=class extends ${};Yd.errorCode=`unsupported_grant_type`;var Xd=class extends ${};Xd.errorCode=`invalid_scope`;var Zd=class extends ${};Zd.errorCode=`access_denied`;var Qd=class extends ${};Qd.errorCode=`server_error`;var $d=class extends ${};$d.errorCode=`temporarily_unavailable`;var ef=class extends ${};ef.errorCode=`unsupported_response_type`;var tf=class extends ${};tf.errorCode=`unsupported_token_type`;var nf=class extends ${};nf.errorCode=`invalid_token`;var rf=class extends ${};rf.errorCode=`method_not_allowed`;var af=class extends ${};af.errorCode=`too_many_requests`;var of=class extends ${};of.errorCode=`invalid_client_metadata`;var sf=class extends ${};sf.errorCode=`insufficient_scope`;var cf=class extends ${};cf.errorCode=`invalid_target`;const lf={[Gd.errorCode]:Gd,[Kd.errorCode]:Kd,[qd.errorCode]:qd,[Jd.errorCode]:Jd,[Yd.errorCode]:Yd,[Xd.errorCode]:Xd,[Zd.errorCode]:Zd,[Qd.errorCode]:Qd,[$d.errorCode]:$d,[ef.errorCode]:ef,[tf.errorCode]:tf,[nf.errorCode]:nf,[rf.errorCode]:rf,[af.errorCode]:af,[of.errorCode]:of,[sf.errorCode]:sf,[cf.errorCode]:cf};var uf=class extends Error{constructor(e){super(e??`Unauthorized`)}};function df(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const ff=`code`,pf=`S256`;function mf(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&df(e.token_endpoint_auth_method)&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function hf(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:gf(i,a,n);return;case`client_secret_post`:_f(i,a,r);return;case`none`:vf(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function gf(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function _f(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function vf(e,t){t.set(`client_id`,e)}async function yf(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Rd.parse(JSON.parse(n));return new(lf[e]||Qd)(t||``,r)}catch(e){return new Qd(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function bf(e,t){try{return await xf(e,t)}catch(n){if(n instanceof Kd||n instanceof Jd)return await e.invalidateCredentials?.(`all`),await xf(e,t);if(n instanceof qd)return await e.invalidateCredentials?.(`tokens`),await xf(e,t);throw n}}async function xf(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o,s;try{o=await Ef(t,{resourceMetadataUrl:i},a),o.authorization_servers&&o.authorization_servers.length>0&&(s=o.authorization_servers[0])}catch{}s||=new URL(`/`,t);let c=await Cf(t,e,o),l=await Nf(s,{fetchFn:a}),u=await Promise.resolve(e.clientInformation());if(!u){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!Sf(r))throw new of(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)u={client_id:r},await e.saveClientInformation?.(u);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await zf(s,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),u=t}}let d=!e.redirectUrl;if(n!==void 0||d){let t=await Rf(e,s,{metadata:l,resource:c,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let f=await e.tokens();if(f?.refresh_token)try{let t=await Lf(s,{metadata:l,clientInformation:u,refreshToken:f.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof $)||e instanceof Qd))throw e}let p=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:h}=await Pf(s,{metadata:l,clientInformation:u,state:p,redirectUrl:e.redirectUrl,scope:r||o?.scopes_supported?.join(` `)||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(m),`REDIRECT`}function Sf(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function Cf(e,t,n){let r=Ud(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!Wd({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function wf(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=Tf(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=Tf(e,`scope`)||void 0,s=Tf(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function Tf(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function Ef(e,t,n=fetch){let r=await jf(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return Pd.parse(await r.json())}async function Df(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Df(e,void 0,n):void 0;throw r}}function Of(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function kf(e,t,n=fetch){return await Df(e,{"MCP-Protocol-Version":t},n)}function Af(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function jf(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??Ko,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Of(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await kf(o,a,n);return!r?.metadataUrl&&Af(s,i.pathname)&&(s=await kf(new URL(`/.well-known/${t}`,i),a,n)),s}function Mf(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Nf(e,{fetchFn:t=fetch,protocolVersion:n=Ko}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=Mf(e);for(let{url:e,type:n}of i){let i=await Df(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?Fd.parse(await i.json()):Id.parse(await i.json())}}}async function Pf(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(ff))throw Error(`Incompatible auth server: does not support response type ${ff}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(pf))throw Error(`Incompatible auth server: does not support code challenge method ${pf}`)}else s=new URL(`/authorize`,e);let c=await Md(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,ff),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,pf),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function Ff(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function If(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&hf(mf(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await yf(l);return Ld.parse(await l.json())}async function Lf(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await If(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function Rf(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=Ff(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return If(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function zf(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await yf(a);return Hd.parse(await a.json())}var Bf=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Vf(e){}function Hf(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Vf,onError:n=Vf,onRetry:r=Vf,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=Uf(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
141
- `;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Bf(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Bf(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
142
- `)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function Uf(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
143
- `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
144
- `&&r++}}return[t,n]}var Wf=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Hf({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const Gf={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Kf=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},qf=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Ed(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Gf}async _authThenStart(){if(!this._authProvider)throw new uf(`No auth provider`);let e;try{e=await bf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new uf;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=Td(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Kf(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Wf({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=gs.parse(JSON.parse(e.data));ps(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new uf(`No auth provider`);if(await bf(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new uf(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:ls(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Kf(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=wf(o);if(this._resourceMetadataUrl=t,this._scope=n,await bf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new uf;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=wf(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Kf(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await bf(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new uf;return this.send(e)}}throw new Kf(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Ms(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c)if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>gs.parse(e)):[gs.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Kf(-1,`Unexpected content type: ${l}`);else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Kf(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}},Jf=class{registry;accessRef;servers=new Map;constructor(e){this.registry=e.registry,this.accessRef=e.accessRef}allowNetwork(){return i(r(this.accessRef?.get()?.approvalMode)).allowNetwork}normalizeToolName(e,t){let n=e=>e.trim().replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``),r=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t>>>0},i=`mcp__${n(e)}__${n(t)}`||`mcp__tool`;if(i.length<=64)return i;let a=r(`${e}\u0000${t}`).toString(36).slice(0,8);return`${i.slice(0,Math.max(1,64-(1+a.length)))}_${a}`.slice(0,64)}unregisterServerTools(e){for(let t of e.registeredToolNames)try{this.registry.unregister(t)}catch{}e.registeredToolNames=[],e.remoteTools=[]}async connectServer(e){let t=String(e?.name??``).trim();if(!t)throw Error(`MCP server missing name`);if(e.enabled===!1)return{toolCount:0};let n=this.servers.get(t);if(n){this.unregisterServerTools(n);let e=await n.client.listTools();return this.registerTools({serverName:t,state:n,tools:e}),{toolCount:n.registeredToolNames.length}}let r=await this.createTransport(e),i=new id({name:`GoatChain CLI`,version:`0.0.0`});await i.connect(r);let a=await i.listTools(),o={config:e,client:i,transport:r,registeredToolNames:[],remoteTools:[]};return this.servers.set(t,o),this.registerTools({serverName:t,state:o,tools:a}),{toolCount:o.registeredToolNames.length}}async disconnectServer(e){let t=String(e??``).trim(),n=this.servers.get(t);if(n){this.unregisterServerTools(n);try{await n.transport.close()}catch{}this.servers.delete(t)}}async disconnectAll(){let e=[...this.servers.keys()];for(let t of e)await this.disconnectServer(t)}listConnected(){let e=[];for(let[t,n]of this.servers.entries())e.push({name:t,toolCount:n.registeredToolNames.length,transport:this.serverTransportName(n.config)});return e}listRegisteredTools(){let e=[];for(let t of this.servers.values())e.push(...t.registeredToolNames);return e}listRemoteTools(e){let t=String(e??``).trim(),n=this.servers.get(t);return n?[...n.remoteTools]:[]}async connectFromConfig(e){let t=Array.isArray(e?.servers)?e.servers:[],n=0,r=0;for(let e of t){let t=String(e?.name??``).trim();try{let i=await this.connectServer(e);t&&this.servers.has(t)&&n++,r+=i.toolCount}catch{}}return{connected:n,toolCount:r}}async createTransport(e){if((e.transport??`stdio`)===`http`){if(!this.allowNetwork())throw Error(`MCP HTTP transport requires Approval Mode: Agent (full access)`);let t=String(e.url??``).trim();if(!t)throw Error(`MCP http server missing url`);let n=e.headers??{},r=Object.keys(n).length>0?{headers:n}:void 0;return new qf(new URL(t),{requestInit:r})}let t=String(e.command??``).trim();if(!t)throw Error(`MCP stdio server missing command`);return new Cd({command:t,args:Array.isArray(e.args)?e.args.map(String):void 0,env:e.env??void 0,cwd:typeof e.cwd==`string`?String(e.cwd):void 0})}serverTransportName(e){return e.transport===`http`?`http`:`stdio`}registerTools(e){let t=Array.isArray(e.tools?.tools)?e.tools.tools:[];e.state.remoteTools=t;for(let n of t){let t=String(n.name??``).trim();if(!t)continue;let r=this.normalizeToolName(e.serverName,t);if(typeof this.registry?.has==`function`&&this.registry.has(r))try{this.registry.unregister(r)}catch{}let i=`[mcp:${e.serverName}/${t}]\n${String(n.description??``).trim()}`,a=n.inputSchema??{type:`object`},o=String(n?.annotations?.riskLevel??`high`).trim().toLowerCase(),s=o===`safe`||o===`low`||o===`medium`||o===`high`||o===`critical`?o:`high`;this.registry.register({name:r,description:i,parameters:a,riskLevel:s,execute:async n=>{let r=await e.state.client.callTool({name:t,arguments:n??{}});return r.content?r:{content:[],isError:r.isError,_meta:r._meta}}}),e.state.registeredToolNames.push(r)}}};function Yf(e){let t=e?.tools?.webSearch??e?.webSearch??{};return t&&typeof t==`object`?t:{}}function Xf(e,t){let n={...Yf(e),...t};for(let e of Object.keys(n))n[e]===void 0&&delete n[e];return{...e??{},tools:{...e?.tools??{},webSearch:n}}}async function Zf(){try{let e=new URL(`../package.json`,import.meta.url),{readFile:t}=await import(`node:fs/promises`),n=JSON.parse(await t(e,`utf8`));return typeof n?.version==`string`?n.version:`0.0.0`}catch{return`0.0.0`}}async function Qf(e){let{agent:t}=e,n=[],i=await t.createSession({maxIterations:50});i.messages=n;let a=o({mode:r(e.approvalMode??`read_only`),envAutoApprove:process.env.GOATCHAIN_AUTO_APPROVE});i.send(e.prompt,{toolContext:{approval:{strategy:a.strategy,autoApprove:a.autoApprove}}});for await(let e of i.receive())if(e.type===`text_delta`)process.stdout.write(e.delta);else if(e.type===`requires_action`){process.stderr.write(`\n[requires action] ${e.kind??``} (${e.toolName??`unknown tool`})\n`);break}else if(e.type===`done`)break;process.stdout.write(`
145
- `)}async function $f(e){let t=await Zf(),n=a(e,t),i=process.cwd(),o=ne(i),c=await ie(o),l=n.apiKey,u=n.modelId??process.env.GOATCHAIN_MODEL??c?.defaults?.modelId??`gpt-4o`,d=n.system,p=n.baseUrl??process.env.GOATCHAIN_OPENAI_BASE_URL??c?.openai?.baseUrl,h={},g=(e,t)=>{let n={...e?.defaults?.requestDefaults??{},temperature:t?.temperature??e?.defaults?.requestDefaults?.temperature,maxOutputTokens:t?.maxTokens??e?.defaults?.requestDefaults?.maxOutputTokens,topP:t?.topP??e?.defaults?.requestDefaults?.topP,presencePenalty:t?.presencePenalty??e?.defaults?.requestDefaults?.presencePenalty,frequencyPenalty:t?.frequencyPenalty??e?.defaults?.requestDefaults?.frequencyPenalty,seed:t?.seed??e?.defaults?.requestDefaults?.seed,timeoutMs:t?.timeoutMs??e?.defaults?.requestDefaults?.timeoutMs};for(let e of Object.keys(h))delete h[e];Object.assign(h,n)};g(c,n);let _=()=>l??process.env.OPENAI_API_KEY??c?.openai?.apiKey,v=e=>{let t=e?.tools?.webSearch??e?.webSearch??{},n=typeof t.apiKey==`string`?t.apiKey:typeof t.serperApiKey==`string`?t.serperApiKey:void 0,r=typeof t.apiEndpoint==`string`?t.apiEndpoint:void 0,i=typeof t.numResults==`number`?t.numResults:void 0;return{webSearch:{...n?{apiKey:n}:{},...r?{apiEndpoint:r}:{},...typeof i==`number`?{numResults:i}:{}}}};(n.webSearchApiKey||n.webSearchApiEndpoint||typeof n.webSearchNumResults==`number`)&&(c=Xf(c,{...n.webSearchApiKey?{apiKey:n.webSearchApiKey}:{},...n.webSearchApiEndpoint?{apiEndpoint:n.webSearchApiEndpoint}:{},...typeof n.webSearchNumResults==`number`?{numResults:n.webSearchNumResults}:{}}));let y={},ee=e=>{let t=e?.openai?.compat,n={requireReasoningContentForToolCalls:typeof t?.requireReasoningContentForToolCalls==`boolean`?t.requireReasoningContentForToolCalls:void 0};for(let e of Object.keys(y))delete y[e];Object.assign(y,n)};ee(c);let b={},te=e=>{let t=process.env.GOATCHAIN_EMOJI,n=t===`1`?!0:t===`0`?!1:process.stdout.isTTY&&process.env.TERM!==`dumb`,i={toolStyle:e?.ui?.toolStyle??process.env.GOATCHAIN_TOOL_STYLE??`inline`,showTools:typeof e?.ui?.showTools==`boolean`?e.ui.showTools:process.env.GOATCHAIN_SHOW_TOOLS!==`0`,showStatus:typeof e?.ui?.showStatus==`boolean`?e.ui.showStatus:process.env.GOATCHAIN_SHOW_STATUS!==`0`,showStatusLine:typeof e?.ui?.showStatusLine==`boolean`?e.ui.showStatusLine:process.env.GOATCHAIN_SHOW_STATUSLINE!==`0`,promptContinue:typeof e?.ui?.promptContinue==`boolean`?e.ui.promptContinue:process.env.GOATCHAIN_PROMPT_CONTINUE!==`0`,autoContinue:typeof e?.ui?.autoContinue==`boolean`?e.ui.autoContinue:process.env.GOATCHAIN_AUTO_CONTINUE===`1`,planMode:typeof e?.ui?.planMode==`boolean`?e.ui.planMode:process.env.GOATCHAIN_PLAN_MODE===`1`,sessionsUi:e?.ui?.sessionsUi??process.env.GOATCHAIN_SESSIONS_UI??`auto`,approvalMode:r(process.env.GOATCHAIN_APPROVAL_MODE??e?.ui?.approvalMode??`read_only`),emoji:typeof e?.ui?.emoji==`boolean`?e.ui.emoji:n,attachImages:(()=>{let t=e?.ui?.attachImages??{},n=process.env.GOATCHAIN_ATTACH_IMAGES_MAX_DATA_URL_CHARS,r=typeof n==`string`&&n.trim()?Number(n):void 0,i=typeof t.maxDataUrlChars==`number`&&Number.isFinite(t.maxDataUrlChars)?t.maxDataUrlChars:typeof r==`number`&&Number.isFinite(r)?r:void 0;return{noteTemplate:typeof t.noteTemplate==`string`?t.noteTemplate:void 0,notePosition:typeof t.notePosition==`string`?t.notePosition:void 0,imagesPosition:typeof t.imagesPosition==`string`?t.imagesPosition:void 0,dataUrlMode:typeof t.dataUrlMode==`string`?t.dataUrlMode:void 0,maxDataUrlChars:i}})()};for(let e of Object.keys(b))delete b[e];Object.assign(b,i)};if(te(c),n.prompt){let{agent:e}=await T({getApiKey:_,modelId:u,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:{get:()=>v(c)},accessRef:{get:()=>({approvalMode:b.approvalMode})}});await Qf({agent:e,prompt:n.prompt,approvalMode:b.approvalMode});return}let x=n.sessionId??c?.lastSessionId??s(),S=[],C=Date.now(),w,E,D=!1,re={get:()=>v(c)},oe={get:()=>({approvalMode:b.approvalMode})},{agent:ce,model:O,tools:le,sessionManager:k}=await T({getApiKey:_,modelId:u,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:re,accessRef:oe}),ue=null,de=async()=>{if(r(b.approvalMode)===`read_only`)return;let e=c?.mcp??{};e.autoConnect!==!1&&(Array.isArray(e.servers)?e.servers:[]).length!==0&&(ue||=new Jf({registry:le.registry,accessRef:oe}),await ue.connectFromConfig(e))};await de();let fe=await k.get(x);if(fe){C=fe.createdAt,S=fe.messages;let e=fe.metadata;if(e){w=typeof e.title==`string`?e.title:void 0,E=typeof e.summary==`string`?e.summary:void 0,D=!!e.pinned;let t=typeof e.modelId==`string`?e.modelId:void 0;t&&typeof O?.setModelId==`function`&&O.setModelId(t)}}else{let e=await se(o,x);if(e){C=e.createdAt??C,w=e.title,E=e.summary,D=!!e.pinned,S=Array.isArray(e.messages)?e.messages:[],e.modelId&&typeof O?.setModelId==`function`&&O.setModelId(e.modelId);let t=await k.create(x);t.messages=S,t.metadata={title:w,summary:E,pinned:D,modelId:e.modelId},await t.save()}}let pe=async(e={})=>{c=await ae(o,{...c,...e,openai:{...c?.openai??{},baseUrl:p,apiKey:_()},defaults:{...c?.defaults??{},modelId:O.modelId,requestDefaults:h},ui:b})},me=async()=>{let e=await k.get(x);if(e)e.messages=S,e.metadata={title:w,summary:E,pinned:D,modelId:O.modelId},await e.save();else{let e=await k.create(x);e.messages=S,e.metadata={title:w,summary:E,pinned:D,modelId:O.modelId},await e.save()}await pe({lastSessionId:x})},he=Promise.resolve(),ge=()=>{let e=()=>me();return he=he.then(e,e),he};await ge();let{runRepl:_e}=await import(`./repl-DW3WSeYc.js`);await _e({version:t,provider:`openai`,system:d,agentRef:{get:()=>ce},modelRef:{get:()=>O},toolsInfo:le,requestDefaults:h,baseUrlRef:{get:()=>p},setBaseUrl:async e=>{if(p=e,typeof O?.setBaseUrl==`function`){O.setBaseUrl(p),await ge();return}({agent:ce,model:O,tools:le}=await T({getApiKey:_,modelId:O.modelId,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:re,accessRef:oe})),ue&&=(await ue.disconnectAll(),null),await de(),await ge()},setApiKey:e=>{l=e},setWebSearchConfig:e=>{c=Xf(c,e)},saveAll:ge,getConfigPath:()=>o.configPath,getLocalConfig:()=>c,getApiKeyStatus:()=>{let e=typeof l==`string`&&!!l.trim(),t=typeof process.env.OPENAI_API_KEY==`string`&&!!process.env.OPENAI_API_KEY.trim(),n=typeof c?.openai?.apiKey==`string`&&!!String(c.openai.apiKey).trim();return{present:e||t||n,source:e?`cli`:t?`env`:n?`config`:null}},listSessions:async()=>(await k.list()).map(e=>({sessionId:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,title:e.title,summary:e.summary,pinned:!!e.metadata?.pinned,messages:e.messages})),loadSessionById:async e=>{let t=await k.get(e);if(!t)return;let n=t.metadata;return{sessionId:t.id,createdAt:t.createdAt,updatedAt:t.updatedAt,modelId:typeof n?.modelId==`string`?n.modelId:void 0,title:t.title,summary:t.summary,pinned:!!n?.pinned,messages:t.messages}},saveSessionByData:async e=>{let t=await k.get(e.sessionId);if(t)t.messages=e.messages,t.metadata={title:e.title,summary:e.summary,pinned:e.pinned,modelId:e.modelId},await t.save();else{let t=await k.create(e.sessionId);t.messages=e.messages,t.metadata={title:e.title,summary:e.summary,pinned:e.pinned,modelId:e.modelId},await t.save()}},renameSessionById:async(e,t)=>{let n=await k.get(e);n&&(n.title=t,await n.save())},setPinnedSessionsById:async(e,t)=>{for(let n of e){let e=await k.get(n);if(e){let n=e.metadata||{};n.pinned=t,e.metadata=n,await e.save()}}},deleteSessionById:async e=>{await k.destroy(e)},deleteSessionsById:async e=>{for(let t of e)await k.destroy(t)},uiPrefs:b,mcpManagerRef:{get:()=>ue},switchWorkspace:async e=>{let t=m.resolve(process.cwd(),String(e??``));if(!(await f(t)).isDirectory())throw Error(`Not a directory: ${t}`);process.chdir(t),i=process.cwd(),o=ne(i),c=await ie(o),te(c),g(c,null),ee(c),p=process.env.GOATCHAIN_OPENAI_BASE_URL??c?.openai?.baseUrl??p,x=c?.lastSessionId??s(),S=[],C=Date.now(),w=void 0,E=void 0,D=!1;let n=c?.defaults?.modelId??O.modelId??`gpt-4o`;({agent:ce,model:O,tools:le,sessionManager:k}=await T({getApiKey:_,modelId:n,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:re,accessRef:oe})),ue&&=(await ue.disconnectAll(),null),await de();let r=await k.get(x);if(r){C=r.createdAt,S=r.messages;let e=r.metadata;if(e){w=typeof e.title==`string`?e.title:void 0,E=typeof e.summary==`string`?e.summary:void 0,D=!!e.pinned;let t=typeof e.modelId==`string`?e.modelId:void 0;t&&typeof O?.setModelId==`function`&&O.setModelId(t)}}else{let e=await se(o,x);if(e){C=e.createdAt??C,w=e.title,E=e.summary,D=!!e.pinned,S=Array.isArray(e.messages)?e.messages:[],e.modelId&&typeof O?.setModelId==`function`&&O.setModelId(e.modelId);let t=await k.create(x);t.messages=S,t.metadata={title:w,summary:E,pinned:D,modelId:e.modelId},await t.save()}}await ge()},getWorkspaceCwd:()=>process.cwd(),session:{get sessionId(){return x},set sessionId(e){x=e},get createdAt(){return C},set createdAt(e){C=e},get history(){return S},set history(e){S=e},get title(){return w},set title(e){w=e},get summary(){return E},set summary(e){E=e},get pinned(){return D},set pinned(e){D=!!e}}})}export{$f as main};
144
+ </example>`,model:_,tools:g.registry,stateStore:v,...b.length>0?{middleware:b}:{}});return{agent:x,model:_,tools:g,stateStore:v,sessionManager:x.sessionManager}}function Vf(e){let t=m.join(e,`.goatchain`);return{workspaceCwd:e,cacheDir:t,sessionsDir:m.join(t,`sessions`),configPath:m.join(t,`config.json`)}}async function Hf(e){await c(e,{recursive:!0})}async function Uf(e){try{let t=await l(e,`utf8`);return JSON.parse(t)}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)return;throw e}}async function Wf(e,t){await Hf(m.dirname(e));let n=`${e}.tmp.${s()}`;await p(n,`${JSON.stringify(t,null,2)}\n`,{mode:384}),await d(n,e)}async function Gf(e){let t=await Uf(e.configPath);return!t||typeof t!=`object`?{schemaVersion:1}:t}async function Kf(e,t){let n={schemaVersion:1,...t,updatedAt:Date.now()};return await Wf(e.configPath,n),n}function qf(e,t){return m.join(e.sessionsDir,`${t}.json`)}async function Jf(e,t){let n=await Uf(qf(e,t));if(!n||typeof n!=`object`)return;let r=Array.isArray(n.messages)?n.messages:[];return{sessionId:typeof n.sessionId==`string`?n.sessionId:t,createdAt:typeof n.createdAt==`number`?n.createdAt:Date.now(),updatedAt:typeof n.updatedAt==`number`?n.updatedAt:Date.now(),modelId:typeof n.modelId==`string`?n.modelId:void 0,systemPrompt:typeof n.systemPrompt==`string`?n.systemPrompt:void 0,title:typeof n.title==`string`?n.title:void 0,summary:typeof n.summary==`string`?n.summary:void 0,pinned:!!n.pinned,messages:r}}function Yf(e){let t=e?.tools?.webSearch??e?.webSearch??{};return t&&typeof t==`object`?t:{}}function Xf(e,t){let n={...Yf(e),...t};for(let e of Object.keys(n))n[e]===void 0&&delete n[e];return{...e??{},tools:{...e?.tools??{},webSearch:n}}}async function Zf(){try{let e=new URL(`../../package.json`,import.meta.url),{readFile:t}=await import(`node:fs/promises`),n=JSON.parse(await t(e,`utf8`));return typeof n?.version==`string`?n.version:`0.0.0`}catch{return`0.0.0`}}async function Qf(e){let{agent:t}=e,n=[],r=await t.createSession({maxIterations:50});r.messages=n;let a=i({mode:o(e.approvalMode??`read_only`),envAutoApprove:process.env.GOATCHAIN_AUTO_APPROVE});r.send(e.prompt,{toolContext:{approval:{strategy:a.strategy,autoApprove:a.autoApprove}}});for await(let e of r.receive())if(e.type===`text_delta`)process.stdout.write(e.delta);else if(e.type===`requires_action`){process.stderr.write(`\n[requires action] ${e.kind??``} (${e.toolName??`unknown tool`})\n`);break}else if(e.type===`done`)break;process.stdout.write(`
145
+ `)}async function $f(e){let t=await Zf(),n=a(e,t),r=process.cwd(),i=Vf(r),c=await Gf(i),l=n.apiKey,u=n.modelId??process.env.GOATCHAIN_MODEL??c?.defaults?.modelId??`glm-4.7`,d=n.system,p=n.baseUrl??process.env.GOATCHAIN_OPENAI_BASE_URL??c?.openai?.baseUrl,h={},g=(e,t)=>{let n={...e?.defaults?.requestDefaults??{},temperature:t?.temperature??e?.defaults?.requestDefaults?.temperature,maxOutputTokens:t?.maxTokens??e?.defaults?.requestDefaults?.maxOutputTokens,topP:t?.topP??e?.defaults?.requestDefaults?.topP,presencePenalty:t?.presencePenalty??e?.defaults?.requestDefaults?.presencePenalty,frequencyPenalty:t?.frequencyPenalty??e?.defaults?.requestDefaults?.frequencyPenalty,seed:t?.seed??e?.defaults?.requestDefaults?.seed,timeoutMs:t?.timeoutMs??e?.defaults?.requestDefaults?.timeoutMs};for(let e of Object.keys(h))delete h[e];Object.assign(h,n)};g(c,n);let _=()=>l??process.env.OPENAI_API_KEY??c?.openai?.apiKey,v=e=>{let t=e?.tools?.webSearch??e?.webSearch??{},n=typeof t.apiKey==`string`?t.apiKey:typeof t.serperApiKey==`string`?t.serperApiKey:void 0,r=typeof t.apiEndpoint==`string`?t.apiEndpoint:void 0,i=typeof t.numResults==`number`?t.numResults:void 0;return{webSearch:{...n?{apiKey:n}:{},...r?{apiEndpoint:r}:{},...typeof i==`number`?{numResults:i}:{}}}};(n.webSearchApiKey||n.webSearchApiEndpoint||typeof n.webSearchNumResults==`number`)&&(c=Xf(c,{...n.webSearchApiKey?{apiKey:n.webSearchApiKey}:{},...n.webSearchApiEndpoint?{apiEndpoint:n.webSearchApiEndpoint}:{},...typeof n.webSearchNumResults==`number`?{numResults:n.webSearchNumResults}:{}}));let y={},b=e=>{let t=e?.openai?.compat,n={requireReasoningContentForToolCalls:typeof t?.requireReasoningContentForToolCalls==`boolean`?t.requireReasoningContentForToolCalls:void 0};for(let e of Object.keys(y))delete y[e];Object.assign(y,n)};b(c);let x={},S=e=>{let t=process.env.GOATCHAIN_EMOJI,n=t===`1`?!0:t===`0`?!1:process.stdout.isTTY&&process.env.TERM!==`dumb`,r={toolStyle:e?.ui?.toolStyle??process.env.GOATCHAIN_TOOL_STYLE??`inline`,showTools:typeof e?.ui?.showTools==`boolean`?e.ui.showTools:process.env.GOATCHAIN_SHOW_TOOLS!==`0`,showStatus:typeof e?.ui?.showStatus==`boolean`?e.ui.showStatus:process.env.GOATCHAIN_SHOW_STATUS!==`0`,showStatusLine:typeof e?.ui?.showStatusLine==`boolean`?e.ui.showStatusLine:process.env.GOATCHAIN_SHOW_STATUSLINE!==`0`,showFileChanges:typeof e?.ui?.showFileChanges==`boolean`?e.ui.showFileChanges:process.env.GOATCHAIN_SHOW_FILE_CHANGES!==`0`,promptContinue:typeof e?.ui?.promptContinue==`boolean`?e.ui.promptContinue:process.env.GOATCHAIN_PROMPT_CONTINUE!==`0`,autoContinue:typeof e?.ui?.autoContinue==`boolean`?e.ui.autoContinue:process.env.GOATCHAIN_AUTO_CONTINUE===`1`,planMode:typeof e?.ui?.planMode==`boolean`?e.ui.planMode:process.env.GOATCHAIN_PLAN_MODE===`1`,sessionsUi:e?.ui?.sessionsUi??process.env.GOATCHAIN_SESSIONS_UI??`auto`,approvalMode:o(process.env.GOATCHAIN_APPROVAL_MODE??e?.ui?.approvalMode??`read_only`),emoji:typeof e?.ui?.emoji==`boolean`?e.ui.emoji:n,theme:(()=>{let t=e?.ui?.theme;if(t!==void 0)return t;let n=process.env.GOATCHAIN_THEME;return typeof n==`string`&&n.trim()?n.trim():`dark`})(),attachImages:(()=>{let t=e?.ui?.attachImages??{},n=process.env.GOATCHAIN_ATTACH_IMAGES_MAX_DATA_URL_CHARS,r=typeof n==`string`&&n.trim()?Number(n):void 0,i=typeof t.maxDataUrlChars==`number`&&Number.isFinite(t.maxDataUrlChars)?t.maxDataUrlChars:typeof r==`number`&&Number.isFinite(r)?r:void 0;return{noteTemplate:typeof t.noteTemplate==`string`?t.noteTemplate:void 0,notePosition:typeof t.notePosition==`string`?t.notePosition:void 0,imagesPosition:typeof t.imagesPosition==`string`?t.imagesPosition:void 0,dataUrlMode:typeof t.dataUrlMode==`string`?t.dataUrlMode:void 0,maxDataUrlChars:i}})()};for(let e of Object.keys(x))delete x[e];Object.assign(x,r)};if(S(c),n.prompt){let{agent:e}=await Bf({getApiKey:_,modelId:u,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:{get:()=>v(c)},accessRef:{get:()=>({approvalMode:x.approvalMode})}});await Qf({agent:e,prompt:n.prompt,approvalMode:x.approvalMode});return}let C=n.sessionId??c?.lastSessionId??s(),w=[],T=[],E=Date.now(),D,O,k=!1,A={get:()=>v(c)},ee={get:()=>({approvalMode:x.approvalMode})},{agent:te,model:j,tools:ne,sessionManager:M}=await Bf({getApiKey:_,modelId:u,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:A,accessRef:ee}),re=null,ie=async()=>{if(o(x.approvalMode)===`read_only`)return;let e=c?.mcp??{};e.autoConnect!==!1&&(Array.isArray(e.servers)?e.servers:[]).length!==0&&(re||=new Mf({registry:ne.registry,accessRef:ee}),await re.connectFromConfig(e))};await ie();let ae=await M.get(C);if(ae){E=ae.createdAt,w=ae.messages;let e=ae.metadata;if(e){D=typeof e.title==`string`?e.title:void 0,O=typeof e.summary==`string`?e.summary:void 0,k=!!e.pinned,T=Array.isArray(e.inputs)?e.inputs.map(e=>String(e??``)).filter(e=>e.trim().length>0):[];let t=typeof e.modelId==`string`?e.modelId:void 0;t&&typeof j?.setModelId==`function`&&j.setModelId(t)}}else{let e=await Jf(i,C);if(e){E=e.createdAt??E,D=e.title,O=e.summary,k=!!e.pinned,w=Array.isArray(e.messages)?e.messages:[],e.modelId&&typeof j?.setModelId==`function`&&j.setModelId(e.modelId);let t=await M.create(C);t.messages=w,t.metadata={title:D,summary:O,pinned:k,modelId:e.modelId},await t.save()}}let oe=async(e={})=>{c=await Kf(i,{...c,...e,openai:{...c?.openai??{},baseUrl:p,apiKey:_()},defaults:{...c?.defaults??{},modelId:j.modelId,requestDefaults:h},ui:x})},se=async()=>{let e=await M.get(C);if(e)e.messages=w,e.metadata={title:D,summary:O,pinned:k,modelId:j.modelId,inputs:T},await e.save();else{let e=await M.create(C);e.messages=w,e.metadata={title:D,summary:O,pinned:k,modelId:j.modelId,inputs:T},await e.save()}await oe({lastSessionId:C})},ce=Promise.resolve(),le=()=>{let e=()=>se();return ce=ce.then(e,e),ce};await le();let{runRepl:ue}=await import(`./repl-lWj9AUT_.js`);await ue({version:t,provider:`openai`,system:d,agentRef:{get:()=>te},modelRef:{get:()=>j},toolsInfo:ne,requestDefaults:h,baseUrlRef:{get:()=>p},setBaseUrl:async e=>{if(p=e,typeof j?.setBaseUrl==`function`){j.setBaseUrl(p),await le();return}({agent:te,model:j,tools:ne}=await Bf({getApiKey:_,modelId:j.modelId,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:A,accessRef:ee})),re&&=(await re.disconnectAll(),null),await ie(),await le()},setApiKey:e=>{l=e},setWebSearchConfig:e=>{c=Xf(c,e)},saveAll:le,getConfigPath:()=>i.configPath,getLocalConfig:()=>c,getApiKeyStatus:()=>{let e=typeof l==`string`&&!!l.trim(),t=typeof process.env.OPENAI_API_KEY==`string`&&!!process.env.OPENAI_API_KEY.trim(),n=typeof c?.openai?.apiKey==`string`&&!!String(c.openai.apiKey).trim();return{present:e||t||n,source:e?`cli`:t?`env`:n?`config`:null}},listSessions:async()=>(await M.list()).map(e=>({sessionId:e.id,createdAt:e.createdAt,updatedAt:e.updatedAt,title:e.title,summary:e.summary,pinned:!!e.metadata?.pinned,inputs:Array.isArray(e.metadata?.inputs)?e.metadata.inputs:void 0,messages:e.messages})),loadSessionById:async e=>{let t=await M.get(e);if(!t)return;let n=t.metadata;return{sessionId:t.id,createdAt:t.createdAt,updatedAt:t.updatedAt,modelId:typeof n?.modelId==`string`?n.modelId:void 0,title:t.title,summary:t.summary,pinned:!!n?.pinned,inputs:Array.isArray(n?.inputs)?n.inputs:void 0,messages:t.messages}},saveSessionByData:async e=>{let t=await M.get(e.sessionId);if(t)t.messages=e.messages,t.metadata={title:e.title,summary:e.summary,pinned:e.pinned,modelId:e.modelId,inputs:e.inputs},await t.save();else{let t=await M.create(e.sessionId);t.messages=e.messages,t.metadata={title:e.title,summary:e.summary,pinned:e.pinned,modelId:e.modelId,inputs:e.inputs},await t.save()}},renameSessionById:async(e,t)=>{let n=await M.get(e);n&&(n.title=t,await n.save())},setPinnedSessionsById:async(e,t)=>{for(let n of e){let e=await M.get(n);if(e){let n=e.metadata||{};n.pinned=t,e.metadata=n,await e.save()}}},deleteSessionById:async e=>{await M.destroy(e)},deleteSessionsById:async e=>{for(let t of e)await M.destroy(t)},uiPrefs:x,mcpManagerRef:{get:()=>re},switchWorkspace:async e=>{let t=m.resolve(process.cwd(),String(e??``));if(!(await f(t)).isDirectory())throw Error(`Not a directory: ${t}`);process.chdir(t),r=process.cwd(),i=Vf(r),c=await Gf(i),S(c),g(c,null),b(c),p=process.env.GOATCHAIN_OPENAI_BASE_URL??c?.openai?.baseUrl??p,C=c?.lastSessionId??s(),w=[],E=Date.now(),D=void 0,O=void 0,k=!1;let n=c?.defaults?.modelId??j.modelId??`glm-4.7`;({agent:te,model:j,tools:ne,sessionManager:M}=await Bf({getApiKey:_,modelId:n,system:d,baseUrl:p,requestDefaults:h,openaiCompat:y,toolsConfigRef:A,accessRef:ee})),re&&=(await re.disconnectAll(),null),await ie();let a=await M.get(C);if(a){E=a.createdAt,w=a.messages;let e=a.metadata;if(e){D=typeof e.title==`string`?e.title:void 0,O=typeof e.summary==`string`?e.summary:void 0,k=!!e.pinned;let t=typeof e.modelId==`string`?e.modelId:void 0;t&&typeof j?.setModelId==`function`&&j.setModelId(t)}}else{let e=await Jf(i,C);if(e){E=e.createdAt??E,D=e.title,O=e.summary,k=!!e.pinned,w=Array.isArray(e.messages)?e.messages:[],e.modelId&&typeof j?.setModelId==`function`&&j.setModelId(e.modelId);let t=await M.create(C);t.messages=w,t.metadata={title:D,summary:O,pinned:k,modelId:e.modelId},await t.save()}}await le()},getWorkspaceCwd:()=>process.cwd(),session:{get sessionId(){return C},set sessionId(e){C=e},get createdAt(){return E},set createdAt(e){E=e},get history(){return w},set history(e){w=e},get inputs(){return T},set inputs(e){T=Array.isArray(e)?e.map(e=>String(e??``)).filter(e=>e.trim().length>0):[]},get title(){return D},set title(e){D=e},get summary(){return O},set summary(e){O=e},get pinned(){return k},set pinned(e){k=!!e}}})}export{$f as main};