bailian-cli-runtime 1.11.1 → 1.11.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.d.mts CHANGED
@@ -199,6 +199,13 @@ declare const BAILIAN_CONSOLE = "https://bailian.console.aliyun.com/cn-beijing";
199
199
  declare const API_KEY_PAGE = "https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key";
200
200
  /** Direct deep link to the Token Plan subscription overview and API key entry. */
201
201
  declare const TOKEN_PLAN_PAGE = "https://bailian.console.aliyun.com/cn-beijing?tab=plan#/efm/subscription/overview";
202
+ /** MCP marketplace detail page for a server code (e.g. WebSearch, market-cmapi00073529). */
203
+ declare function mcpMarketplaceDetailPage(serverCode: string): string;
204
+ /**
205
+ * MCP marketplace detail for the built-in WebSearch server.
206
+ * Users must activate (or re-activate for Streamable HTTP) before `search web` works.
207
+ */
208
+ declare const MCP_WEBSEARCH_PAGE: string;
202
209
  /** Voice TTS experience center — browse system and custom voices. */
203
210
  declare const VOICE_TTS_PAGE = "https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list";
204
211
  //#endregion
@@ -686,4 +693,4 @@ declare function collectPipelineHints(pipeline: PipelineDefinition, dispatcher?:
686
693
  declare function executePipeline(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: ExecutePipelineOptions): Promise<PipelineExecutionReport>;
687
694
  declare function streamPipelineEvents(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: Pick<ExecutePipelineOptions, "concurrency" | "basePath" | "dryRun" | "signal" | "timeoutSeconds" | "blRequestTimeoutSeconds" | "stepDispatcher">): AsyncGenerator<PipelineLifecycleEvent>;
688
695
  //#endregion
689
- export { API_KEY_PAGE, type AnsiStyles, BAILIAN_CONSOLE, BAILIAN_CONSOLE_ROOT, BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT, BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE, BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE, BOOL_FLAG_WATERMARK, type BarColumn, type BoxTableOptions, CLI_VERSION, type Cli, type CliOptions, type Command, type CommandPackCredentialAccess, type CommandPackDefinition, type CommandPackPolicy, CommandRegistry, type FlagDef, type LocateResult, type Middleware, NPM_PACKAGE, NPM_REGISTRY, type ParsePathResult, type PipelineDefinition, type PipelineLifecycleEvent, type Resolution, type RunContext, TOKEN_PLAN_PAGE, type TextStyle, VOICE_TTS_PAGE, ansi, checkForUpdate, collectPipelineHints, collectPipelineIssues, compose, createCli, createProgressBar, createSpinner, displayWidth, downloadFile, downloadParallel, emitBare, emitResult, executePipeline, fetchLatestVersion, formatBytes, formatTable, getConcurrency, getPendingUpdateNotification, handleError, initPipelineSteps, isTerminal, maybeShowStatusBar, padEnd, parseFlags, parsePath, poll, printQuickStart, printWelcomeBanner, renderBoxTable, resolve, resolveImageSize, runConcurrent, setupProxyFromEnv, streamPipelineEvents, supportsColor };
696
+ export { API_KEY_PAGE, type AnsiStyles, BAILIAN_CONSOLE, BAILIAN_CONSOLE_ROOT, BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT, BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE, BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE, BOOL_FLAG_WATERMARK, type BarColumn, type BoxTableOptions, CLI_VERSION, type Cli, type CliOptions, type Command, type CommandPackCredentialAccess, type CommandPackDefinition, type CommandPackPolicy, CommandRegistry, type FlagDef, type LocateResult, MCP_WEBSEARCH_PAGE, type Middleware, NPM_PACKAGE, NPM_REGISTRY, type ParsePathResult, type PipelineDefinition, type PipelineLifecycleEvent, type Resolution, type RunContext, TOKEN_PLAN_PAGE, type TextStyle, VOICE_TTS_PAGE, ansi, checkForUpdate, collectPipelineHints, collectPipelineIssues, compose, createCli, createProgressBar, createSpinner, displayWidth, downloadFile, downloadParallel, emitBare, emitResult, executePipeline, fetchLatestVersion, formatBytes, formatTable, getConcurrency, getPendingUpdateNotification, handleError, initPipelineSteps, isTerminal, maybeShowStatusBar, mcpMarketplaceDetailPage, padEnd, parseFlags, parsePath, poll, printQuickStart, printWelcomeBanner, renderBoxTable, resolve, resolveImageSize, runConcurrent, setupProxyFromEnv, streamPipelineEvents, supportsColor };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import{BailianError as e,COMMAND_PACK_API_VERSION as t,CONSOLE_AUTH_FLAGS as n,Client as r,ExitCode as i,GLOBAL_FLAGS as a,MODEL_AUTH_FLAGS as o,OPENAPI_AUTH_FLAGS as s,UsageError as c,buildSettings as l,buildSources as u,chatPath as d,credentialFlagDefs as f,describeAuthState as p,detectOutputFormat as m,flushTelemetry as h,formatOutput as g,getConfigDir as _,isLocalFile as v,makeAuthStore as y,makeConfigStore as b,maskToken as x,resolveApiKey as S,resolveBooleanFlag as C,resolveConsole as w,resolveImageEditApi as T,resolveImageGenerateApi as E,resolveModelBaseUrl as D,resolveOpenApi as O,resolveWatermark as k,speechRecognizePath as A,speechSynthesizePath as ee,stripUndefined as j,taskPath as te,trackCommandExecution as ne,trackingHeaders as re,videoGeneratePath as ie}from"bailian-cli-core";import{homedir as ae}from"os";import{dirname as oe,join as se}from"path";import{createWriteStream as ce,mkdirSync as le,readFileSync as ue,unlinkSync as de,writeFileSync as fe}from"fs";import{EnvHttpProxyAgent as pe,setGlobalDispatcher as me}from"undici";import{existsSync as he}from"node:fs";import{access as ge,mkdir as _e,open as ve,readFile as ye,realpath as be,stat as xe,unlink as Se,writeFile as Ce}from"node:fs/promises";import{isAbsolute as we,join as M,relative as Te,resolve as Ee}from"node:path";import{pathToFileURL as De}from"node:url";import{spawn as Oe}from"node:child_process";var ke=Object.create,Ae=Object.defineProperty,je=Object.getOwnPropertyDescriptor,Me=Object.getOwnPropertyNames,Ne=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,N=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Fe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Me(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Pe.call(e,s)&&s!==n&&Ae(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=je(t,s))||r.enumerable});return e},Ie=(e,t,n)=>(n=e==null?{}:ke(Ne(e)),Fe(t||!e||!e.__esModule?Ae(n,`default`,{value:e,enumerable:!0}):n,e));function Le(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Re(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function ze(e){let t=0;for(;t<e.length&&!e[t].startsWith(`-`);)t++;let n=e.slice(t);return{path:e.slice(0,t),rest:n,hasHelpFlag:n.includes(`--help`),hasVersionFlag:n.includes(`--version`)}}function Be(e,t){let n={},r=new Set;for(let[e,r]of Object.entries(t))r.type===`switch`&&(n[e]=!1);let i=0;for(;i<e.length;){let a=e[i];if(!a.startsWith(`-`))throw new c(`Unexpected argument: ${a}`);if(!a.startsWith(`--`))throw new c(`Unknown flag "${a}". Use the --long form.`);let o=a.indexOf(`=`),s=o===-1?a.slice(2):a.slice(2,o),l=o===-1?void 0:a.slice(o+1);if(s===``)throw new c(`Unknown flag "${a}".`);let u=Le(s),d=t[u];if(!d)throw new c(`Unknown flag "--${s}". Run with --help to see available options.`);if(d.type===`switch`){if(l!==void 0)throw new c(`Flag --${s} is a switch and takes no value.`);n[u]=!0,i++;continue}if(l===void 0){let t=e[i+1];if(t===void 0||t.startsWith(`--`))throw new c(`Flag --${s} requires a value.`);l=t,i+=2}else i+=1;if(d.choices&&!d.choices.includes(l))throw new c(`Flag --${s} must be one of: ${d.choices.join(`, `)}.`);if(d.type===`array`){let e=n[u];e?e.push(l):n[u]=[l];continue}if(r.has(u))throw new c(`Flag --${s} given more than once.`);if(r.add(u),d.type===`number`){let e=Number(l);if(!Number.isFinite(e))throw new c(`Flag --${s} requires a finite number.`);n[u]=e}else if(d.type===`boolean`){let e=l.trim().toLowerCase();if(e===`true`)n[u]=!0;else if(e===`false`)n[u]=!1;else throw new c(`Flag --${s} requires true or false.`)}else n[u]=l}let a=Object.entries(t).filter(([e,t])=>t.type!==`switch`&&t.required===!0&&n[e]===void 0).map(([e])=>`--${Re(e)}`);if(a.length>0)throw new c(`Missing required ${a.length>1?`flags`:`flag`}: ${a.join(`, `)}`);return n}const Ve=e=>e;function P(e,t){return e?e=>`\x1b[${t}m${e}\x1b[0m`:Ve}function He(e){return e.isTTY===!0}function Ue(e){return!(`NO_COLOR`in process.env)&&He(e)}function F(e){let t=Ue(e);return{bold:P(t,`1`),dim:P(t,`2`),green:P(t,`32`),yellow:P(t,`33`),red:P(t,`31`),cyan:P(t,`36`),blue:P(t,`34`),magenta:P(t,`35`),white:P(t,`37`),accent:P(t,`38;2;59;130;246`),logo:P(t,`38;2;97;92;237`),purple:P(t,`38;2;147;51;234`),brandBlue:P(t,`1;38;2;43;82;255`),keyPink:P(t,`38;2;236;72;153`),reset:t?`\x1B[0m`:``}}function We(e,t){let n=`--${Re(e)}`;return t.type===`switch`?n:`${n} ${t.choices?`<${t.choices.join(`|`)}>`:t.valueHint}`}var Ge=class{root={children:new Map};cliName;authRequirements=new Set;constructor(e,t){this.cliName=t;for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n={...a,...f(t)};for(let r of Object.keys(t.flags??{}))if(r in n)throw Error(`Command "${e}" redeclares reserved flag "${r}".`);let r=e.split(` `),i=this.root;for(let e of r)i.children.has(e)||i.children.set(e,{children:new Map}),i=i.children.get(e);i.command=t,this.authRequirements.add(t.auth)}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}helpExample(){let e=(t,n)=>{for(let[r,i]of t.children){if(i.command)return[...n,r].join(` `);let t=e(i,[...n,r]);if(t)return t}return null};return e(this.root,[])??`<resource> <command>`}locate(e){let t=this.root,n=[];for(let r of e){let e=t.children.get(r);if(!e)break;t=e,n.push(r)}if(t.command){let r=e.slice(n.length);return r.length===0?{kind:`leaf`,command:t.command,matched:n}:{kind:`unknown`,error:new c(`Unexpected argument: ${r.join(` `)}`,`${this.cliName} ${n.join(` `)} --help`)}}if(n.length===e.length&&t.children.size>0)return{kind:`group`,matched:n};if(n.length>0&&t.children.size>0){let r=Array.from(t.children.entries()).map(([e,t])=>{if(t.command)return` ${n.join(` `)} ${e} ${t.command.description}`;let r=Array.from(t.children.keys()).join(`, `);return` ${n.join(` `)} ${e} [${r}]`}).join(`
1
+ import{BailianError as e,COMMAND_PACK_API_VERSION as t,CONSOLE_AUTH_FLAGS as n,Client as r,ExitCode as i,GLOBAL_FLAGS as a,MODEL_AUTH_FLAGS as o,OPENAPI_AUTH_FLAGS as s,UsageError as c,buildSettings as l,buildSources as u,chatPath as d,credentialFlagDefs as f,describeAuthState as p,detectOutputFormat as m,flushTelemetry as h,formatOutput as g,getConfigDir as _,isLocalFile as v,makeAuthStore as y,makeConfigStore as b,maskToken as x,resolveApiKey as S,resolveBooleanFlag as C,resolveConsole as w,resolveImageEditApi as T,resolveImageGenerateApi as E,resolveModelBaseUrl as D,resolveOpenApi as O,resolveWatermark as k,speechRecognizePath as A,speechSynthesizePath as ee,stripUndefined as j,taskPath as te,trackCommandExecution as M,trackingHeaders as ne,videoGeneratePath as re}from"bailian-cli-core";import{homedir as ie}from"os";import{dirname as ae,join as oe}from"path";import{createWriteStream as se,mkdirSync as ce,readFileSync as le,unlinkSync as ue,writeFileSync as de}from"fs";import{EnvHttpProxyAgent as fe,setGlobalDispatcher as pe}from"undici";import{existsSync as me}from"node:fs";import{access as he,mkdir as ge,open as _e,readFile as ve,realpath as ye,stat as be,unlink as xe,writeFile as Se}from"node:fs/promises";import{isAbsolute as Ce,join as N,relative as we,resolve as Te}from"node:path";import{pathToFileURL as Ee}from"node:url";import{spawn as De}from"node:child_process";var Oe=Object.create,ke=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,je=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty,P=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Pe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=je(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ne.call(e,s)&&s!==n&&ke(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ae(t,s))||r.enumerable});return e},Fe=(e,t,n)=>(n=e==null?{}:Oe(Me(e)),Pe(t||!e||!e.__esModule?ke(n,`default`,{value:e,enumerable:!0}):n,e));function Ie(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Le(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Re(e){let t=0;for(;t<e.length&&!e[t].startsWith(`-`);)t++;let n=e.slice(t);return{path:e.slice(0,t),rest:n,hasHelpFlag:n.includes(`--help`),hasVersionFlag:n.includes(`--version`)}}function ze(e,t){let n={},r=new Set;for(let[e,r]of Object.entries(t))r.type===`switch`&&(n[e]=!1);let i=0;for(;i<e.length;){let a=e[i];if(!a.startsWith(`-`))throw new c(`Unexpected argument: ${a}`);if(!a.startsWith(`--`))throw new c(`Unknown flag "${a}". Use the --long form.`);let o=a.indexOf(`=`),s=o===-1?a.slice(2):a.slice(2,o),l=o===-1?void 0:a.slice(o+1);if(s===``)throw new c(`Unknown flag "${a}".`);let u=Ie(s),d=t[u];if(!d)throw new c(`Unknown flag "--${s}". Run with --help to see available options.`);if(d.type===`switch`){if(l!==void 0)throw new c(`Flag --${s} is a switch and takes no value.`);n[u]=!0,i++;continue}if(l===void 0){let t=e[i+1];if(t===void 0||t.startsWith(`--`))throw new c(`Flag --${s} requires a value.`);l=t,i+=2}else i+=1;if(d.choices&&!d.choices.includes(l))throw new c(`Flag --${s} must be one of: ${d.choices.join(`, `)}.`);if(d.type===`array`){let e=n[u];e?e.push(l):n[u]=[l];continue}if(r.has(u))throw new c(`Flag --${s} given more than once.`);if(r.add(u),d.type===`number`){let e=Number(l);if(!Number.isFinite(e))throw new c(`Flag --${s} requires a finite number.`);n[u]=e}else if(d.type===`boolean`){let e=l.trim().toLowerCase();if(e===`true`)n[u]=!0;else if(e===`false`)n[u]=!1;else throw new c(`Flag --${s} requires true or false.`)}else n[u]=l}let a=Object.entries(t).filter(([e,t])=>t.type!==`switch`&&t.required===!0&&n[e]===void 0).map(([e])=>`--${Le(e)}`);if(a.length>0)throw new c(`Missing required ${a.length>1?`flags`:`flag`}: ${a.join(`, `)}`);return n}const Be=e=>e;function F(e,t){return e?e=>`\x1b[${t}m${e}\x1b[0m`:Be}function Ve(e){return e.isTTY===!0}function He(e){return!(`NO_COLOR`in process.env)&&Ve(e)}function I(e){let t=He(e);return{bold:F(t,`1`),dim:F(t,`2`),green:F(t,`32`),yellow:F(t,`33`),red:F(t,`31`),cyan:F(t,`36`),blue:F(t,`34`),magenta:F(t,`35`),white:F(t,`37`),accent:F(t,`38;2;59;130;246`),logo:F(t,`38;2;97;92;237`),purple:F(t,`38;2;147;51;234`),brandBlue:F(t,`1;38;2;43;82;255`),keyPink:F(t,`38;2;236;72;153`),reset:t?`\x1B[0m`:``}}function Ue(e,t){let n=`--${Le(e)}`;return t.type===`switch`?n:`${n} ${t.choices?`<${t.choices.join(`|`)}>`:t.valueHint}`}var We=class{root={children:new Map};cliName;authRequirements=new Set;constructor(e,t){this.cliName=t;for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n={...a,...f(t)};for(let r of Object.keys(t.flags??{}))if(r in n)throw Error(`Command "${e}" redeclares reserved flag "${r}".`);let r=e.split(` `),i=this.root;for(let e of r)i.children.has(e)||i.children.set(e,{children:new Map}),i=i.children.get(e);i.command=t,this.authRequirements.add(t.auth)}getAllCommands(){let e=[],t=n=>{n.command&&e.push(n.command);for(let e of n.children.values())t(e)};return t(this.root),e}helpExample(){let e=(t,n)=>{for(let[r,i]of t.children){if(i.command)return[...n,r].join(` `);let t=e(i,[...n,r]);if(t)return t}return null};return e(this.root,[])??`<resource> <command>`}locate(e){let t=this.root,n=[];for(let r of e){let e=t.children.get(r);if(!e)break;t=e,n.push(r)}if(t.command){let r=e.slice(n.length);return r.length===0?{kind:`leaf`,command:t.command,matched:n}:{kind:`unknown`,error:new c(`Unexpected argument: ${r.join(` `)}`,`${this.cliName} ${n.join(` `)} --help`)}}if(n.length===e.length&&t.children.size>0)return{kind:`group`,matched:n};if(n.length>0&&t.children.size>0){let r=Array.from(t.children.entries()).map(([e,t])=>{if(t.command)return` ${n.join(` `)} ${e} ${t.command.description}`;let r=Array.from(t.children.keys()).join(`, `);return` ${n.join(` `)} ${e} [${r}]`}).join(`
2
2
  `);return{kind:`unknown`,error:new c(`Unknown command: ${this.cliName} ${e.join(` `)}\n\nAvailable commands:\n${r}`,`${this.cliName} ${n.join(` `)} --help`)}}return{kind:`unknown`,error:new c(`Unknown command: ${this.cliName} ${e.join(` `)}`,`${this.cliName} --help`)}}buildResourceLines(e,t){let n=[],r=(e,t)=>{for(let[i,a]of e.children){let e=t?`${t} ${i}`:i;a.command&&n.push({path:e,desc:a.command.description}),a.children.size>0&&r(a,e)}};r(this.root,``);let i=Math.max(...n.map(e=>e.path.length));return n.map(n=>` ${e(n.path.padEnd(i+2))} ${t(n.desc)}`).join(`
3
- `)}buildFlagLines(e,t,n){let r=Object.entries(e).map(([e,t])=>({flag:We(e,t),desc:t.description})),i=Math.max(...r.map(e=>e.flag.length));return r.map(e=>` ${t(e.flag.padEnd(i+2))} ${n(e.desc)}`).join(`
4
- `)}buildAuthFlagSection(e,t,n,r,i,a,o){return this.authRequirements.has(e)?`${i(t)} ${o(n)}\n${this.buildFlagLines(r,a,o)}`:null}bold=(e,t)=>F(t).bold(e);accent=(e,t)=>F(t).accent(e);dim=(e,t)=>F(t).dim(e);printHelp(e,t=process.stdout){if(e.length===0){this.printRootHelp(t);return}let n=this.root;for(let r of e){let e=n.children.get(r);if(!e){this.printRootHelp(t);return}n=e}if(n.command){this.printCommandHelp(n.command,e,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} ${this.cliName} ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
3
+ `)}buildFlagLines(e,t,n){let r=Object.entries(e).map(([e,t])=>({flag:Ue(e,t),desc:t.description})),i=Math.max(...r.map(e=>e.flag.length));return r.map(e=>` ${t(e.flag.padEnd(i+2))} ${n(e.desc)}`).join(`
4
+ `)}buildAuthFlagSection(e,t,n,r,i,a,o){return this.authRequirements.has(e)?`${i(t)} ${o(n)}\n${this.buildFlagLines(r,a,o)}`:null}bold=(e,t)=>I(t).bold(e);accent=(e,t)=>I(t).accent(e);dim=(e,t)=>I(t).dim(e);printHelp(e,t=process.stdout){if(e.length===0){this.printRootHelp(t);return}let n=this.root;for(let r of e){let e=n.children.get(r);if(!e){this.printRootHelp(t);return}n=e}if(n.command){this.printCommandHelp(n.command,e,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} ${this.cliName} ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
5
5
  `)}printPipelineQuickStart(e){let t=t=>this.bold(t,e),n=t=>this.dim(t,e);e.write(`
6
6
  ${t(`Minimal workflow.yaml:`)}
7
7
  ${n(` version: workflow/v1`)}
@@ -15,7 +15,7 @@ ${n(` system: "You are a concise assistant."`)}
15
15
  ${t(`Try it:`)}
16
16
  ${n(` ${this.cliName} pipeline validate workflow.yaml`)}
17
17
  ${n(` ${this.cliName} pipeline run workflow.yaml --dry-run --output json`)}
18
- `)}printRootHelp(e){let t=[`██████╗ █████╗ ██╗██╗ ██╗ █████╗ ███╗ ██╗`,`██╔══██╗██╔══██╗██║██║ ██║██╔══██╗████╗ ██║`,`██████╔╝███████║██║██║ ██║███████║██╔██╗ ██║`,`██╔══██╗██╔══██║██║██║ ██║██╔══██║██║╚██╗██║`,`██████╔╝██║ ██║██║███████╗██║██║ ██║██║ ╚████║`,`╚═════╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝`],r=F(e);e.write(`
18
+ `)}printRootHelp(e){let t=[`██████╗ █████╗ ██╗██╗ ██╗ █████╗ ███╗ ██╗`,`██╔══██╗██╔══██╗██║██║ ██║██╔══██╗████╗ ██║`,`██████╔╝███████║██║██║ ██║███████║██╔██╗ ██║`,`██╔══██╗██╔══██║██║██║ ██║██╔══██║██║╚██╗██║`,`██████╔╝██║ ██║██║███████╗██║██║ ██║██║ ╚████║`,`╚═════╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝`],r=I(e);e.write(`
19
19
  `);for(let n of t)e.write(`${r.logo(n)}\n`);let i=t=>this.bold(t,e),c=t=>this.accent(t,e),l=t=>this.dim(t,e),u=this.buildResourceLines(c,l),d=this.buildFlagLines(a,c,l),f=[this.buildAuthFlagSection(`apiKey`,`Model Auth Flags:`,`(model-domain commands)`,o,i,c,l),this.buildAuthFlagSection(`console`,`Console Auth Flags:`,`(console-domain commands)`,n,i,c,l),this.buildAuthFlagSection(`openapi`,`OpenAPI Auth Flags:`,`(openapi-domain commands)`,s,i,c,l)].filter(e=>e!==null).join(`
20
20
 
21
21
  `);e.write(`
@@ -30,30 +30,30 @@ ${d}
30
30
  ${f?`${f}\n\n`:``}${i(`Getting Help:`)}
31
31
  ${l(`Add --help after any command to see its full list of flags, defaults,`)}
32
32
  ${l(`and usage examples. For example:`)} ${this.cliName} ${this.helpExample()} --help
33
- `)}printCommandHelp(e,t,n){let r=e=>this.bold(e,n),i=e=>this.accent(e,n),o=e=>this.dim(e,n),s=[this.cliName,...t].join(` `);n.write(`\n${e.description}\n`),n.write(`${r(`Usage:`)} ${s}${e.usageArgs?` ${e.usageArgs}`:``}\n`);let c=[...Object.entries(e.flags??{}),...Object.entries(f(e))];if(c.length>0){let e=c.map(([e,t])=>({flag:We(e,t),desc:t.description})),t=Math.max(...e.map(e=>e.flag.length));n.write(`\n${r(`Flags:`)}\n`);for(let r of e)n.write(` ${i(r.flag.padEnd(t+2))} ${o(r.desc)}\n`)}if(n.write(`\n${r(`Global Flags:`)}\n`),n.write(this.buildFlagLines(a,i,o)+`
34
- `),e.notes&&e.notes.length>0){n.write(`\n${r(`Notes:`)}\n`);for(let t of e.notes)n.write(` ${t}\n`)}if(e.exampleArgs&&e.exampleArgs.length>0){n.write(`\n${r(`Examples:`)}\n`);for(let t of e.exampleArgs)n.write(` ${o(t?`${s} ${t}`:s)}\n`)}}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}};function Ke(e,t){let{path:n,rest:r,hasHelpFlag:i,hasVersionFlag:a}=ze(e);if(a)return{kind:`version`};let o=t.locate(n);switch(o.kind){case`leaf`:return i?{kind:`help`,path:o.matched}:{kind:`run`,path:o.matched,command:o.command,rest:r};case`group`:return{kind:`help`,path:o.matched};case`unknown`:return{kind:`usageError`,error:o.error}}}function qe(e){return e.startsWith(ae())?e.replace(ae(),`~`):e}function Je(e,t,n){if(e.quiet||!He(process.stderr))return;let r=e.configPath?qe(e.configPath):`~/.bailian/config.json`,i=`${n.source} · api-key`,a=x(t),o=F(process.stderr);process.stderr.write(`${o.brandBlue(`BAILIAN`)} ${o.dim(r)} ${o.dim(`|`)} ${o.dim(`Auth:`)} ${o.keyPink(a)} ${o.dim(i)}\n`)}const Ye=`https://registry.npmjs.org`,Xe=`bailian-cli`,Ze=()=>se(_(),`update-state.json`),Qe=3e3;function I(e){let t=String(e).split(`+`)[0].split(`-`)[0].trim().split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0});return[t[0]??0,t[1]??0,t[2]??0]}function $e(e){let t=String(e).split(`+`)[0],n=t.indexOf(`-`);return n>=0?t.slice(n+1):``}function et(e){return $e(e)!==``}function tt(e){return e.length>0&&/^[0-9]+$/.test(e)}function nt(e,t){let n=e?e.split(`.`):[],r=t?t.split(`.`):[];if(n.length===0&&r.length===0)return 0;if(n.length===0)return 1;if(r.length===0)return-1;let i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=tt(t),o=tt(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e>0?1:-1}else if(a!==o)return a?-1:1;else if(t!==i)return t>i?1:-1}return 0}function rt(e,t){let[n,r,i]=I(e),[a,o,s]=I(t);return n===a?r===o?i===s?nt($e(e),$e(t)):i>s?1:-1:r>o?1:-1:n>a?1:-1}function it(e,t){return rt(e,t)>0}function at(e,t){return dt(e,t)&&!et(e)}function ot(){try{let e=ue(Ze(),`utf-8`);return JSON.parse(e)}catch{return null}}function st(e){try{fe(Ze(),JSON.stringify(e))}catch{}}async function ct(e=Qe,t=Xe){try{let n=t.replace(`/`,`%2f`),r=await fetch(`${Ye}/${n}/latest`,{headers:{Accept:`application/json`,...re()},signal:AbortSignal.timeout(e)});return r.ok?(await r.json()).version??null:null}catch{return null}}let lt=null;function ut(){return lt}function dt(e,t){let[n,r]=I(e),[i,a]=I(t);return n>i||n===i&&r-a>3}function ft(e){return e instanceof Error?e.message:String(e)}async function pt(e,t,n=Xe){let r=process.stderr.isTTY,i=r?`\x1B[32m`:``,a=r?`\x1B[33m`:``,o=r?`\x1B[36m`:``,s=r?`\x1B[2m`:``,c=r?`\x1B[0m`:``,[l]=I(t),[u]=I(e),d=l>u;process.stderr.write(`
35
- `),process.stderr.write(` ${a}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c}\n`),d?process.stderr.write(` ${a}⚡ Major update detected: ${e} → ${t}${c}\n`):process.stderr.write(` ${a}⚡ Significant update detected: ${e} → ${t}${c}\n`),process.stderr.write(` ${s}Auto-updating to keep your CLI up to date...${c}\n`),process.stderr.write(` ${a}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c}\n\n`);let f=`npm install -g ${n}@latest`;try{let{execSync:r}=await import(`child_process`);r(f,{stdio:`inherit`});let l=null;try{let e=ue(se(r(`npm root -g`,{encoding:`utf-8`}).trim(),n,`package.json`),`utf-8`);l=JSON.parse(e).version??null}catch(e){process.stderr.write(` ${a}⚠ Could not verify installed version: ${ft(e)}${c}\n`)}st({lastChecked:Date.now(),latestVersion:l??t}),process.stderr.write(` ${i}✓ Update complete: ${e} → ${l??t}${c}\n`),process.stderr.write(` ${s}Run ${o}bl --version${c}${s} to verify.${c}\n\n`);try{process.stderr.write(` ${s}Syncing agent skill...${c}\n`),r(`npx skills add modelstudioai/cli --all -g -y`,{stdio:`inherit`}),process.stderr.write(` ${i}✓ Agent skill updated.${c}\n\n`)}catch(e){process.stderr.write(` ${a}⚠ Agent skill sync failed: ${ft(e)}${c}\n`),process.stderr.write(` ${a} Run manually: npx skills add modelstudioai/cli --all -g -y${c}\n\n`)}return lt=null,!0}catch(e){return process.stderr.write(` ${a}⚠ Auto-update failed: ${ft(e)}${c}\n`),process.stderr.write(` ${a} If this is a permissions error (EACCES), retry with sudo or fix npm perms.${c}\n`),process.stderr.write(` ${a} Run manually:${c} ${o}${f}${c}\n\n`),!1}}async function mt(e,t=Xe){let n=ot(),r=Date.now();if(n&&r-n.lastChecked<864e5)return;let i=await ct(Qe,t);i&&(st({lastChecked:r,latestVersion:i}),i&&it(i,e)&&(lt=i))}function ht(e){return t=>{let n=r=>{let i=e[r];return i?i(t,()=>n(r+1)):Promise.resolve()};return n(0)}}const gt=async(e,t)=>{let{command:n,settings:i,sources:a}=e,o={identity:e.identity,settings:i,baseUrl:D(a)};if(n.auth===`apiKey`){let t;try{t=S(a)}catch(e){if(!i.dryRun)throw e}e.client=new r({...o,apiCred:t}),t&&Je(i,t.token,t)}else if(n.auth===`console`){let t;try{t=w(a)}catch(e){if(!i.dryRun)throw e}t&&(e.client=new r({...o,consoleCred:t}))}else if(n.auth===`openapi`){let t;try{t=O(a)}catch(e){if(!i.dryRun)throw e}e.client=new r({...o,openApiCred:t})}await t()},_t=(e,t)=>ne({identity:e.identity,settings:e.settings,authMethod:e.command.auth},e.path,e.flags,t),vt=async(e,t)=>{let n=mt(e.identity.version,e.identity.npmPackage).catch(()=>{});await t(),await n;let r=e.path.length===1&&e.path[0]===`update`,i=ut();if(i&&!e.settings.quiet&&!r)if(at(i,e.identity.version))await pt(e.identity.version,i,e.identity.npmPackage);else{let t=F(process.stderr);process.stderr.write(`\n ${t.yellow(`Update available: ${e.identity.version} → ${i}`)}\n`),process.stderr.write(` Run ${t.cyan(`${e.identity.binName} update`)} to upgrade\n\n`)}},yt=e=>e.command.run(e);function bt(e,t){return e[t]?.trim()||void 0}function xt(e=process.env){return{httpProxy:bt(e,`HTTP_PROXY`),httpsProxy:bt(e,`HTTPS_PROXY`),noProxy:bt(e,`NO_PROXY`)}}function St(){let{httpProxy:t,httpsProxy:n,noProxy:r}=xt();if(!(!t&&!n))try{me(new pe({httpProxy:t,httpsProxy:n,noProxy:r}))}catch(t){throw new e(`Invalid proxy configuration: ${t instanceof Error?t.message:String(t)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:t})}}const Ct=`https://bailian.console.aliyun.com`,wt=`${Ct}/cn-beijing`,Tt=`${wt}/?tab=app#/api-key`,Et=`${Ct}/cn-beijing?tab=plan#/efm/subscription/overview`,Dt=`https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list`;let L;function Ot(){return`If the DashScope host is wrong, check baseUrl (--base-url, ${L} config show, or DASHSCOPE_BASE_URL).`}function R(e){return e.padEnd(13)}function kt(e){return e.split(`
33
+ `)}printCommandHelp(e,t,n){let r=e=>this.bold(e,n),i=e=>this.accent(e,n),o=e=>this.dim(e,n),s=[this.cliName,...t].join(` `);n.write(`\n${e.description}\n`),n.write(`${r(`Usage:`)} ${s}${e.usageArgs?` ${e.usageArgs}`:``}\n`);let c=[...Object.entries(e.flags??{}),...Object.entries(f(e))];if(c.length>0){let e=c.map(([e,t])=>({flag:Ue(e,t),desc:t.description})),t=Math.max(...e.map(e=>e.flag.length));n.write(`\n${r(`Flags:`)}\n`);for(let r of e)n.write(` ${i(r.flag.padEnd(t+2))} ${o(r.desc)}\n`)}if(n.write(`\n${r(`Global Flags:`)}\n`),n.write(this.buildFlagLines(a,i,o)+`
34
+ `),e.notes&&e.notes.length>0){n.write(`\n${r(`Notes:`)}\n`);for(let t of e.notes)n.write(` ${t}\n`)}if(e.exampleArgs&&e.exampleArgs.length>0){n.write(`\n${r(`Examples:`)}\n`);for(let t of e.exampleArgs)n.write(` ${o(t?`${s} ${t}`:s)}\n`)}}printChildren(e,t,n){let r=[],i=(e,t)=>{for(let[n,a]of e.children)a.command&&r.push({fullName:`${t} ${n}`,description:a.command.description}),a.children.size>0&&i(a,`${t} ${n}`)};i(e,t);let a=Math.max(...r.map(e=>e.fullName.length));for(let{fullName:e,description:t}of r)n.write(` ${this.accent(e.padEnd(a),n)} ${this.dim(t,n)}\n`)}};function Ge(e,t){let{path:n,rest:r,hasHelpFlag:i,hasVersionFlag:a}=Re(e);if(a)return{kind:`version`};let o=t.locate(n);switch(o.kind){case`leaf`:return i?{kind:`help`,path:o.matched}:{kind:`run`,path:o.matched,command:o.command,rest:r};case`group`:return{kind:`help`,path:o.matched};case`unknown`:return{kind:`usageError`,error:o.error}}}function Ke(e){return e.startsWith(ie())?e.replace(ie(),`~`):e}function qe(e,t,n){if(e.quiet||!Ve(process.stderr))return;let r=e.configPath?Ke(e.configPath):`~/.bailian/config.json`,i=`${n.source} · api-key`,a=x(t),o=I(process.stderr);process.stderr.write(`${o.brandBlue(`BAILIAN`)} ${o.dim(r)} ${o.dim(`|`)} ${o.dim(`Auth:`)} ${o.keyPink(a)} ${o.dim(i)}\n`)}const Je=`https://registry.npmjs.org`,Ye=`bailian-cli`,Xe=()=>oe(_(),`update-state.json`),Ze=3e3;function L(e){let t=String(e).split(`+`)[0].split(`-`)[0].trim().split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0});return[t[0]??0,t[1]??0,t[2]??0]}function Qe(e){let t=String(e).split(`+`)[0],n=t.indexOf(`-`);return n>=0?t.slice(n+1):``}function $e(e){return Qe(e)!==``}function et(e){return e.length>0&&/^[0-9]+$/.test(e)}function tt(e,t){let n=e?e.split(`.`):[],r=t?t.split(`.`):[];if(n.length===0&&r.length===0)return 0;if(n.length===0)return 1;if(r.length===0)return-1;let i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=et(t),o=et(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e>0?1:-1}else if(a!==o)return a?-1:1;else if(t!==i)return t>i?1:-1}return 0}function nt(e,t){let[n,r,i]=L(e),[a,o,s]=L(t);return n===a?r===o?i===s?tt(Qe(e),Qe(t)):i>s?1:-1:r>o?1:-1:n>a?1:-1}function rt(e,t){return nt(e,t)>0}function it(e,t){return ut(e,t)&&!$e(e)}function at(){try{let e=le(Xe(),`utf-8`);return JSON.parse(e)}catch{return null}}function ot(e){try{de(Xe(),JSON.stringify(e))}catch{}}async function st(e=Ze,t=Ye){try{let n=t.replace(`/`,`%2f`),r=await fetch(`${Je}/${n}/latest`,{headers:{Accept:`application/json`,...ne()},signal:AbortSignal.timeout(e)});return r.ok?(await r.json()).version??null:null}catch{return null}}let ct=null;function lt(){return ct}function ut(e,t){let[n,r]=L(e),[i,a]=L(t);return n>i||n===i&&r-a>3}function dt(e){return e instanceof Error?e.message:String(e)}async function ft(e,t,n=Ye){let r=process.stderr.isTTY,i=r?`\x1B[32m`:``,a=r?`\x1B[33m`:``,o=r?`\x1B[36m`:``,s=r?`\x1B[2m`:``,c=r?`\x1B[0m`:``,[l]=L(t),[u]=L(e),d=l>u;process.stderr.write(`
35
+ `),process.stderr.write(` ${a}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c}\n`),d?process.stderr.write(` ${a}⚡ Major update detected: ${e} → ${t}${c}\n`):process.stderr.write(` ${a}⚡ Significant update detected: ${e} → ${t}${c}\n`),process.stderr.write(` ${s}Auto-updating to keep your CLI up to date...${c}\n`),process.stderr.write(` ${a}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${c}\n\n`);let f=`npm install -g ${n}@latest`;try{let{execSync:r}=await import(`child_process`);r(f,{stdio:`inherit`});let l=null;try{let e=le(oe(r(`npm root -g`,{encoding:`utf-8`}).trim(),n,`package.json`),`utf-8`);l=JSON.parse(e).version??null}catch(e){process.stderr.write(` ${a}⚠ Could not verify installed version: ${dt(e)}${c}\n`)}ot({lastChecked:Date.now(),latestVersion:l??t}),process.stderr.write(` ${i}✓ Update complete: ${e} → ${l??t}${c}\n`),process.stderr.write(` ${s}Run ${o}bl --version${c}${s} to verify.${c}\n\n`);try{process.stderr.write(` ${s}Syncing agent skill...${c}\n`),r(`npx skills add modelstudioai/cli --all -g -y`,{stdio:`inherit`}),process.stderr.write(` ${i}✓ Agent skill updated.${c}\n\n`)}catch(e){process.stderr.write(` ${a}⚠ Agent skill sync failed: ${dt(e)}${c}\n`),process.stderr.write(` ${a} Run manually: npx skills add modelstudioai/cli --all -g -y${c}\n\n`)}return ct=null,!0}catch(e){return process.stderr.write(` ${a}⚠ Auto-update failed: ${dt(e)}${c}\n`),process.stderr.write(` ${a} If this is a permissions error (EACCES), retry with sudo or fix npm perms.${c}\n`),process.stderr.write(` ${a} Run manually:${c} ${o}${f}${c}\n\n`),!1}}async function pt(e,t=Ye){let n=at(),r=Date.now();if(n&&r-n.lastChecked<864e5)return;let i=await st(Ze,t);i&&(ot({lastChecked:r,latestVersion:i}),i&&rt(i,e)&&(ct=i))}function mt(e){return t=>{let n=r=>{let i=e[r];return i?i(t,()=>n(r+1)):Promise.resolve()};return n(0)}}const ht=async(e,t)=>{let{command:n,settings:i,sources:a}=e,o={identity:e.identity,settings:i,baseUrl:D(a)};if(n.auth===`apiKey`){let t;try{t=S(a)}catch(e){if(!i.dryRun)throw e}e.client=new r({...o,apiCred:t}),t&&qe(i,t.token,t)}else if(n.auth===`console`){let t;try{t=w(a)}catch(e){if(!i.dryRun)throw e}t&&(e.client=new r({...o,consoleCred:t}))}else if(n.auth===`openapi`){let t;try{t=O(a)}catch(e){if(!i.dryRun)throw e}e.client=new r({...o,openApiCred:t})}await t()},gt=(e,t)=>M({identity:e.identity,settings:e.settings,authMethod:e.command.auth},e.path,e.flags,t),_t=async(e,t)=>{let n=pt(e.identity.version,e.identity.npmPackage).catch(()=>{});await t(),await n;let r=e.path.length===1&&e.path[0]===`update`,i=lt();if(i&&!e.settings.quiet&&!r)if(it(i,e.identity.version))await ft(e.identity.version,i,e.identity.npmPackage);else{let t=I(process.stderr);process.stderr.write(`\n ${t.yellow(`Update available: ${e.identity.version} → ${i}`)}\n`),process.stderr.write(` Run ${t.cyan(`${e.identity.binName} update`)} to upgrade\n\n`)}},vt=e=>e.command.run(e);function yt(e,t){return e[t]?.trim()||void 0}function bt(e=process.env){return{httpProxy:yt(e,`HTTP_PROXY`),httpsProxy:yt(e,`HTTPS_PROXY`),noProxy:yt(e,`NO_PROXY`)}}function xt(){let{httpProxy:t,httpsProxy:n,noProxy:r}=bt();if(!(!t&&!n))try{pe(new fe({httpProxy:t,httpsProxy:n,noProxy:r}))}catch(t){throw new e(`Invalid proxy configuration: ${t instanceof Error?t.message:String(t)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:t})}}const St=`https://bailian.console.aliyun.com`,Ct=`${St}/cn-beijing`,wt=`${Ct}/?tab=app#/api-key`,Tt=`${St}/cn-beijing?tab=plan#/efm/subscription/overview`;function Et(e){return`${Ct}?tab=mcp#/mcp-market/detail/${e}`}const Dt=Et(`WebSearch`),Ot=`https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list`;let R;function kt(){return`If the DashScope host is wrong, check baseUrl (--base-url, ${R} config show, or DASHSCOPE_BASE_URL).`}function z(e){return e.padEnd(13)}function At(e){return e.split(`
36
36
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
37
- `)}function At(e){return e.exitCode===i.AUTH?jt(e.hint)?e.hint:[e.hint,``,`${L} auth login --api-key <your-key>`,`${L} auth status`,`Get API Key: ${Tt}`].filter(e=>e!==void 0).join(`
38
- `):e.hint}function jt(e){return e?e.includes(`auth login --console`)||e.includes(`auth login --open-api`)||e.includes(`--access-key-id`)||e.includes(`ALIBABA_CLOUD_ACCESS_KEY_`):!1}function Mt(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return m(e[n+1]||t);if(r?.startsWith(`--output=`))return m(r.slice(9))}return m(t)}function Nt(t){let n=t.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new e(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Pt(r),{cause:t})}function Pt(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DNS / network. ${Ot()}`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.
39
- If you are behind a VPN or corporate proxy, route ${L} through it:\nexport HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network. ${Ot()}`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network and proxy (HTTP_PROXY / HTTPS_PROXY). ${Ot()}`}}function Ft(t){let n=t.code,r=`Check the file path and permissions.`;return n===`ENOENT`?r=`File or directory not found.`:n===`EACCES`||n===`EPERM`?r=`Permission denied — check file or directory permissions.`:n===`ENOSPC`&&(r=`Disk full — free up space and try again.`),new e(`File system error: ${t.message}`,i.GENERAL,r,{cause:t})}function It(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${R(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Lt(e){process.stderr.write(`\n${R(`Error:`)}${e.message}\n`);let t=At(e);t&&process.stderr.write(`${R(`Hint:`)}${kt(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${R(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${R(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${R(`Request ID:`)}${n.requestId}\n`)}It(e),process.stderr.write(`${R(`Exit code:`)}${e.exitCode}\n`)}function z(t,n){if(L=n,t instanceof e&&(Mt()===`json`?process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
40
- `):Lt(t),process.exit(t.exitCode)),t instanceof Error){if(t.name===`AbortError`||t.name===`TimeoutError`||t.message.includes(`timed out`))return z(new e(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
41
- ${Ot()}\nRun: ${L} auth status — to check credentials.`,{cause:t}),L);if(t instanceof TypeError&&t.message===`fetch failed`)return z(Nt(t),L);let n=t.code;if(typeof n==`string`&&n.startsWith(`E`))return z(Ft(t),L);process.stderr.write(`\n${R(`Error:`)}${t.message}\n`),It(t),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${t.stack}\n`)}else process.stderr.write(`\n${R(`Error:`)}${String(t)}\n`);process.exit(i.GENERAL)}function Rt(e){let t=F(process.stderr);process.stderr.write(`\n Welcome to ${t.purple(`Bailian`)} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
42
- `),process.stderr.write(` 1. Get your API Key: ${Tt}\n`),process.stderr.write(` 2. Login: ${e} auth login --api-key <your-key>\n\n`),process.stderr.write(` Token Plan:
43
- `),process.stderr.write(` 1. Get your API Key: ${Et}\n`),process.stderr.write(` 2. Login: ${e} auth login --config token-plan --api-key <your-key>\n\n`)}function zt(e){let t=F(process.stderr);process.stderr.write(`
37
+ `)}function jt(e){return e.exitCode===i.AUTH?Mt(e.hint)?e.hint:[e.hint,``,`${R} auth login --api-key <your-key>`,`${R} auth status`,`Get API Key: ${wt}`].filter(e=>e!==void 0).join(`
38
+ `):e.hint}function Mt(e){return e?e.includes(`auth login --console`)||e.includes(`auth login --open-api`)||e.includes(`--access-key-id`)||e.includes(`ALIBABA_CLOUD_ACCESS_KEY_`):!1}function Nt(e=process.argv.slice(2),t=process.env.DASHSCOPE_OUTPUT){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--output`)return m(e[n+1]||t);if(r?.startsWith(`--output=`))return m(r.slice(9))}return m(t)}function Pt(t){let n=t.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new e(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Ft(r),{cause:t})}function Ft(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DNS / network. ${kt()}`;case`ECONNREFUSED`:return`Connection refused. Check the target host/port and proxy settings.`;case`ECONNRESET`:return`Connection reset by peer. Retry, or check proxy / firewall.
39
+ If you are behind a VPN or corporate proxy, route ${R} through it:\nexport HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network. ${kt()}`;case`CERT_HAS_EXPIRED`:case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`DEPTH_ZERO_SELF_SIGNED_CERT`:return`TLS certificate error. Check system clock and CA bundle.`;default:return`Check network and proxy (HTTP_PROXY / HTTPS_PROXY). ${kt()}`}}function It(t){let n=t.code,r=`Check the file path and permissions.`;return n===`ENOENT`?r=`File or directory not found.`:n===`EACCES`||n===`EPERM`?r=`Permission denied — check file or directory permissions.`:n===`ENOSPC`&&(r=`Disk full — free up space and try again.`),new e(`File system error: ${t.message}`,i.GENERAL,r,{cause:t})}function Lt(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${z(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Rt(e){process.stderr.write(`\n${z(`Error:`)}${e.message}\n`);let t=jt(e);t&&process.stderr.write(`${z(`Hint:`)}${At(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${z(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${z(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${z(`Request ID:`)}${n.requestId}\n`)}Lt(e),process.stderr.write(`${z(`Exit code:`)}${e.exitCode}\n`)}function B(t,n){if(R=n,t instanceof e&&(Nt()===`json`?process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
40
+ `):Rt(t),process.exit(t.exitCode)),t instanceof Error){if(t.name===`AbortError`||t.name===`TimeoutError`||t.message.includes(`timed out`))return B(new e(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
41
+ ${kt()}\nRun: ${R} auth status — to check credentials.`,{cause:t}),R);if(t instanceof TypeError&&t.message===`fetch failed`)return B(Pt(t),R);let n=t.code;if(typeof n==`string`&&n.startsWith(`E`))return B(It(t),R);process.stderr.write(`\n${z(`Error:`)}${t.message}\n`),Lt(t),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${t.stack}\n`)}else process.stderr.write(`\n${z(`Error:`)}${String(t)}\n`);process.exit(i.GENERAL)}function zt(e){let t=I(process.stderr);process.stderr.write(`\n Welcome to ${t.purple(`Bailian`)} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
42
+ `),process.stderr.write(` 1. Get your API Key: ${wt}\n`),process.stderr.write(` 2. Login: ${e} auth login --api-key <your-key>\n\n`),process.stderr.write(` Token Plan:
43
+ `),process.stderr.write(` 1. Get your API Key: ${Tt}\n`),process.stderr.write(` 2. Login: ${e} auth login --config token-plan --api-key <your-key>\n\n`)}function Bt(e){let t=I(process.stderr);process.stderr.write(`
44
44
  🎯 Try these with your AI coding assistant:
45
45
 
46
46
  `),e.forEach((e,n)=>{process.stderr.write(`${t.dim(String(n+1))} ${e}\n`)}),process.stderr.write(`
47
- `)}function Bt(e){return M(_(),`plugins`,e.npmPackage)}function Vt(e){return M(Bt(e),`package.json`)}function Ht(e,t){return M(Bt(e),`node_modules`,...t.split(`/`))}async function Ut(t){try{return JSON.parse(await ye(t,`utf8`))}catch(n){throw new e(`Could not parse JSON file: ${t}`,i.GENERAL,`Repair or remove the invalid file and try again.`,{cause:n})}}async function Wt(e){let t=Vt(e);return he(t)?Ut(t):{dependencies:{}}}async function Gt(e,t){return Kt(Ht(e,t))}async function Kt(e){return Ut(M(e,`package.json`))}const qt=new Set([`none`,`apiKey`,`console`,`openapi`]),Jt=/^[a-z0-9][a-z0-9-]*$/;function Yt(e,n,r){if(n.name!==e)throw Error(`Package name mismatch: expected "${e}", received "${n.name??``}".`);let i=n.bailianCli;if(!i||i.type!==`command-pack`)throw Error(`Package "${e}" is missing bailianCli.type="command-pack".`);if(i.apiVersion!==t)throw Error(`Command Pack API ${i.apiVersion} is not supported; this CLI supports API ${t}.`);if(i.minCliVersion&&rt(r.version,i.minCliVersion)<0)throw Error(`Command Pack requires ${r.npmPackage} ${i.minCliVersion} or newer; current version is ${r.version}.`);if(!i.entry||we(i.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return i}function Xt(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>Jt.test(e)))throw Error(`Invalid command path "${e}".`);if(!t.commandPrefixes.some(t=>e===t||e.startsWith(`${t} `)))throw Error(`Command "${e}" is outside the allowed prefixes: ${t.commandPrefixes.join(`, `)}.`)}function Zt(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!n.description||typeof n.description!=`string`)throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!qt.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function Qt(t,n,r){return Object.fromEntries(Object.entries(n).map(([n,a])=>[n,{description:a.description,auth:a.auth,usageArgs:a.usageArgs,exampleArgs:a.exampleArgs,notes:a.notes,flags:a.flags,validate:a.validate,run:o=>{let s={identity:o.identity,settings:o.settings,flags:o.flags,client:o.client,output:{result(e,t){let n=o.settings.output===`text`&&t?.text!==void 0?t.text:g(e,o.settings.output);process.stdout.write(`${n}\n`)},line(e){process.stdout.write(`${e}\n`)},write(e){process.stdout.write(e)}},errors:{general(t,n){return new e(t,i.GENERAL,n?.hint,{cause:n?.cause})},usage(e,t){return new c(e,t)},timeout(t=`Request timed out.`,n){return new e(t,i.TIMEOUT,n?.hint,{cause:n?.cause})}},credentials:{apiKey(){if(!r.credentialAccess?.includes(`apiKey`))throw new e(`Command Pack "${t}" is not allowed to access API-key credentials.`,i.GENERAL);if(a.auth!==`apiKey`)throw new e(`Command "${n}" must declare auth="apiKey" before accessing API-key credentials.`,i.GENERAL);let s=o.authStore.describe().apiKey;if(!s)throw new e(`No API key available to the Command Pack.`,i.AUTH);return s}}};return a.run(s)}}]))}async function $t(e,t,n,r,i=Ht(r,e)){let a=Yt(e,t,r),o=await be(i),s=await be(Ee(o,a.entry)),c=Te(o,s);if(!c||c.startsWith(`..`)||we(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(De(s).href)).default;if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`Command Pack "${e}" must default-export a command map.`);let u=Object.entries(l);if(u.length===0)throw Error(`Command Pack "${e}" does not export any commands.`);for(let[e,t]of u)Xt(e,n),Zt(e,t);let d=Qt(e,l,n);return new Ge(d,r.binName),d}function en(e){return e.startsWith(`file:`)?`linked`:`installed`}async function tn(e,t,n){let r={...e},i=[],a;try{a=await Wt(t)}catch(e){return{commands:r,reports:[{name:`(plugin sandbox)`,source:`installed`,status:`failed`,commands:[],error:e instanceof Error?e.message:String(e)}]}}for(let[e,o]of Object.entries(a.dependencies??{}).sort(([e],[t])=>e.localeCompare(t))){let a=en(o),s=n.supported[e];if(!s){i.push({name:e,source:a,status:`failed`,commands:[],error:`Command Pack "${e}" is not supported by ${t.binName}.`});continue}try{let n=await Gt(t,e),o=await $t(e,n,s,t),c=Object.keys(o).filter(e=>e in r);if(c.length>0)throw Error(`Command conflicts: ${c.join(`, `)}.`);Object.assign(r,o),i.push({name:e,version:n.version,source:a,status:`loaded`,commands:Object.keys(o).sort()})}catch(t){i.push({name:e,source:a,status:`failed`,commands:[],error:t instanceof Error?t.message:String(t)})}}return{commands:r,reports:i}}const nn={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},rn=new Set(`PATH.HOME.USER.LOGNAME.SHELL.TMPDIR.TEMP.TMP.LANG.TERM.NODE.NODE_PATH.NODE_OPTIONS.FORCE_COLOR.NO_COLOR.NPM_TOKEN.NODE_AUTH_TOKEN.HTTP_PROXY.HTTPS_PROXY.NO_PROXY.http_proxy.https_proxy.no_proxy.SystemRoot.ComSpec.APPDATA.PATHEXT`.split(`.`)),an=new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function on(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&an.has(t[1].toLowerCase())}function sn(e,t){let n=Object.keys(t.supported);return n.length>0?`Allowed packages: ${n.join(`, `)}`:`${e.binName} does not currently support any Command Packs.`}function cn(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(rn.has(n)||n.startsWith(`LC_`)||on(n))&&(t[n]=r);return t}async function ln(e){await _e(e,{recursive:!0,mode:448});let t=M(e,`package.json`);he(t)||await Ce(t,`${JSON.stringify(nn,null,2)}\n`,{mode:384})}async function un(t,n){await new Promise((r,a)=>{let o=Oe(`npm`,t,{cwd:n,env:cn(),stdio:[`inherit`,`pipe`,`pipe`]});o.stdout.on(`data`,e=>process.stderr.write(e)),o.stderr.on(`data`,e=>process.stderr.write(e)),o.once(`error`,a),o.once(`close`,(n,o)=>{if(n===0){r();return}a(new e(`npm ${t[0]} failed${o?` with signal ${o}`:` with exit code ${n}`}.`,i.GENERAL))})})}async function dn(t){let n=Bt(t);await ln(n);let r=M(n,`.lock`);for(let t=0;t<2;t++)try{let e=await ve(r,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await Se(r)}catch{}}}catch(t){if(t.code!==`EEXIST`)throw t;try{let e=await xe(r);if(Date.now()-e.mtimeMs>6e5){await Se(r);continue}}catch{continue}throw new e(`Another Command Pack install, link, or remove operation is already running.`,i.GENERAL,`Wait for it to finish and try again.`)}throw new e(`Could not acquire the Command Pack operation lock.`,i.GENERAL)}async function fn(e,t){let n=await dn(e);try{return await t()}finally{await n()}}function pn(t,n,r){let a=t.trim(),o=/^(@[^/\s]+\/[^@/\s]+)(?:@([a-zA-Z0-9][a-zA-Z0-9._-]*))?$/.exec(a);if(!o)throw new e(`Unsupported Command Pack package spec: "${t}".`,i.USAGE,`Use an allowlisted scoped package name with an optional version or tag.`);let s=o[1];if(!r.supported[s])throw new e(`Command Pack "${s}" is not allowlisted for ${n.binName}.`,i.USAGE,sn(n,r));return{name:s,requested:a}}async function mn(e,t,n,r){let i=r.supported[e],a=await Kt(t);return{pjson:a,commands:await $t(e,a,i,n,t)}}function hn(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function gn(e,t,n){if(t){await un([`install`,hn(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await un([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function _n(t,n,r){let{name:a,requested:o}=pn(t,n,r);return fn(n,async()=>{let t=Bt(n),s=(await Wt(n)).dependencies?.[a];try{await un([`install`,o,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],t);let s=await mn(a,Ht(n,a),n,r);if(!s.pjson.version)throw new e(`Command Pack "${a}" has no package version.`,i.USAGE);return{name:a,version:s.pjson.version,commands:Object.keys(s.commands).sort()}}catch(e){try{await gn(a,s,t)}catch{}throw e}})}async function vn(t,n,r){let a=Ee(t);if(!he(M(a,`package.json`)))throw new e(`Command Pack path does not exist: ${a}`,i.USAGE);let o=(await Kt(a)).name;if(!o||!r.supported[o])throw new e(`Local package "${o??`(unnamed)`}" is not an allowlisted Command Pack for ${n.binName}.`,i.USAGE,sn(n,r));let s=await mn(o,a,n,r);return fn(n,async()=>{await un([`install`,`file:${a}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],Bt(n));let e=await mn(o,Ht(n,o),n,r);return{name:o,version:e.pjson.version??s.pjson.version,commands:Object.keys(e.commands).sort()}})}async function yn(t,n,r){if(!r.supported[t])throw new e(`Command Pack "${t}" is not allowlisted for ${n.binName}.`,i.USAGE,sn(n,r));if(!(t in((await Wt(n)).dependencies??{})))throw new e(`Command Pack "${t}" is not installed.`,i.USAGE);await fn(n,()=>un([`uninstall`,t,`--ignore-scripts`,`--no-fund`,`--no-audit`],Bt(n)))}async function bn(e,t){return(await tn({},e,t)).reports}function xn(e,t){return{install:n=>_n(n,e,t),link:n=>vn(n,e,t),list:()=>bn(e,t),remove:n=>yn(n,e,t)}}function Sn(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Cn(e){try{St()}catch(t){z(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
47
+ `)}function Vt(e){return N(_(),`plugins`,e.npmPackage)}function Ht(e){return N(Vt(e),`package.json`)}function Ut(e,t){return N(Vt(e),`node_modules`,...t.split(`/`))}async function Wt(t){try{return JSON.parse(await ve(t,`utf8`))}catch(n){throw new e(`Could not parse JSON file: ${t}`,i.GENERAL,`Repair or remove the invalid file and try again.`,{cause:n})}}async function Gt(e){let t=Ht(e);return me(t)?Wt(t):{dependencies:{}}}async function Kt(e,t){return qt(Ut(e,t))}async function qt(e){return Wt(N(e,`package.json`))}const Jt=new Set([`none`,`apiKey`,`console`,`openapi`]),Yt=/^[a-z0-9][a-z0-9-]*$/;function Xt(e,n,r){if(n.name!==e)throw Error(`Package name mismatch: expected "${e}", received "${n.name??``}".`);let i=n.bailianCli;if(!i||i.type!==`command-pack`)throw Error(`Package "${e}" is missing bailianCli.type="command-pack".`);if(i.apiVersion!==t)throw Error(`Command Pack API ${i.apiVersion} is not supported; this CLI supports API ${t}.`);if(i.minCliVersion&&nt(r.version,i.minCliVersion)<0)throw Error(`Command Pack requires ${r.npmPackage} ${i.minCliVersion} or newer; current version is ${r.version}.`);if(!i.entry||Ce(i.entry))throw Error(`Command Pack "${e}" must declare a relative bailianCli.entry.`);return i}function Zt(e,t){let n=e.split(/\s+/).filter(Boolean).join(` `);if(!e||e!==n||!e.split(` `).every(e=>Yt.test(e)))throw Error(`Invalid command path "${e}".`);if(!t.commandPrefixes.some(t=>e===t||e.startsWith(`${t} `)))throw Error(`Command "${e}" is outside the allowed prefixes: ${t.commandPrefixes.join(`, `)}.`)}function Qt(e,t){if(!t||typeof t!=`object`)throw Error(`Command "${e}" must export an object.`);let n=t;if(!n.description||typeof n.description!=`string`)throw Error(`Command "${e}" is missing a description.`);if(!n.auth||!Jt.has(n.auth))throw Error(`Command "${e}" has an invalid auth requirement.`);if(typeof n.run!=`function`)throw Error(`Command "${e}" is missing run(ctx).`)}function $t(t,n,r){return Object.fromEntries(Object.entries(n).map(([n,a])=>[n,{description:a.description,auth:a.auth,usageArgs:a.usageArgs,exampleArgs:a.exampleArgs,notes:a.notes,flags:a.flags,validate:a.validate,run:o=>{let s={identity:o.identity,settings:o.settings,flags:o.flags,client:o.client,output:{result(e,t){let n=o.settings.output===`text`&&t?.text!==void 0?t.text:g(e,o.settings.output);process.stdout.write(`${n}\n`)},line(e){process.stdout.write(`${e}\n`)},write(e){process.stdout.write(e)}},errors:{general(t,n){return new e(t,i.GENERAL,n?.hint,{cause:n?.cause})},usage(e,t){return new c(e,t)},timeout(t=`Request timed out.`,n){return new e(t,i.TIMEOUT,n?.hint,{cause:n?.cause})}},credentials:{apiKey(){if(!r.credentialAccess?.includes(`apiKey`))throw new e(`Command Pack "${t}" is not allowed to access API-key credentials.`,i.GENERAL);if(a.auth!==`apiKey`)throw new e(`Command "${n}" must declare auth="apiKey" before accessing API-key credentials.`,i.GENERAL);let s=o.authStore.describe().apiKey;if(!s)throw new e(`No API key available to the Command Pack.`,i.AUTH);return s}}};return a.run(s)}}]))}async function en(e,t,n,r,i=Ut(r,e)){let a=Xt(e,t,r),o=await ye(i),s=await ye(Te(o,a.entry)),c=we(o,s);if(!c||c.startsWith(`..`)||Ce(c))throw Error(`Command Pack entry must stay inside the package root: ${a.entry}`);let l=(await import(Ee(s).href)).default;if(!l||typeof l!=`object`||Array.isArray(l))throw Error(`Command Pack "${e}" must default-export a command map.`);let u=Object.entries(l);if(u.length===0)throw Error(`Command Pack "${e}" does not export any commands.`);for(let[e,t]of u)Zt(e,n),Qt(e,t);let d=$t(e,l,n);return new We(d,r.binName),d}function tn(e){return e.startsWith(`file:`)?`linked`:`installed`}async function nn(e,t,n){let r={...e},i=[],a;try{a=await Gt(t)}catch(e){return{commands:r,reports:[{name:`(plugin sandbox)`,source:`installed`,status:`failed`,commands:[],error:e instanceof Error?e.message:String(e)}]}}for(let[e,o]of Object.entries(a.dependencies??{}).sort(([e],[t])=>e.localeCompare(t))){let a=tn(o),s=n.supported[e];if(!s){i.push({name:e,source:a,status:`failed`,commands:[],error:`Command Pack "${e}" is not supported by ${t.binName}.`});continue}try{let n=await Kt(t,e),o=await en(e,n,s,t),c=Object.keys(o).filter(e=>e in r);if(c.length>0)throw Error(`Command conflicts: ${c.join(`, `)}.`);Object.assign(r,o),i.push({name:e,version:n.version,source:a,status:`loaded`,commands:Object.keys(o).sort()})}catch(t){i.push({name:e,source:a,status:`failed`,commands:[],error:t instanceof Error?t.message:String(t)})}}return{commands:r,reports:i}}const rn={name:`bailian-cli-command-packs`,private:!0,dependencies:{}},an=new Set(`PATH.HOME.USER.LOGNAME.SHELL.TMPDIR.TEMP.TMP.LANG.TERM.NODE.NODE_PATH.NODE_OPTIONS.FORCE_COLOR.NO_COLOR.NPM_TOKEN.NODE_AUTH_TOKEN.HTTP_PROXY.HTTPS_PROXY.NO_PROXY.http_proxy.https_proxy.no_proxy.SystemRoot.ComSpec.APPDATA.PATHEXT`.split(`.`)),on=new Set([`registry`,`userconfig`,`globalconfig`,`cache`,`proxy`,`https_proxy`,`noproxy`,`strict_ssl`,`ca`,`cafile`]);function sn(e){let t=/^(?:npm_config_|NPM_CONFIG_)(.+)$/.exec(e);return!!t&&on.has(t[1].toLowerCase())}function cn(e,t){let n=Object.keys(t.supported);return n.length>0?`Allowed packages: ${n.join(`, `)}`:`${e.binName} does not currently support any Command Packs.`}function ln(e=process.env){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(an.has(n)||n.startsWith(`LC_`)||sn(n))&&(t[n]=r);return t}async function un(e){await ge(e,{recursive:!0,mode:448});let t=N(e,`package.json`);me(t)||await Se(t,`${JSON.stringify(rn,null,2)}\n`,{mode:384})}async function dn(t,n){await new Promise((r,a)=>{let o=De(`npm`,t,{cwd:n,env:ln(),stdio:[`inherit`,`pipe`,`pipe`]});o.stdout.on(`data`,e=>process.stderr.write(e)),o.stderr.on(`data`,e=>process.stderr.write(e)),o.once(`error`,a),o.once(`close`,(n,o)=>{if(n===0){r();return}a(new e(`npm ${t[0]} failed${o?` with signal ${o}`:` with exit code ${n}`}.`,i.GENERAL))})})}async function fn(t){let n=Vt(t);await un(n);let r=N(n,`.lock`);for(let t=0;t<2;t++)try{let e=await _e(r,`wx`,384);return await e.writeFile(`${process.pid} ${Date.now()}\n`),await e.close(),async()=>{try{await xe(r)}catch{}}}catch(t){if(t.code!==`EEXIST`)throw t;try{let e=await be(r);if(Date.now()-e.mtimeMs>6e5){await xe(r);continue}}catch{continue}throw new e(`Another Command Pack install, link, or remove operation is already running.`,i.GENERAL,`Wait for it to finish and try again.`)}throw new e(`Could not acquire the Command Pack operation lock.`,i.GENERAL)}async function pn(e,t){let n=await fn(e);try{return await t()}finally{await n()}}function mn(t,n,r){let a=t.trim(),o=/^(@[^/\s]+\/[^@/\s]+)(?:@([a-zA-Z0-9][a-zA-Z0-9._-]*))?$/.exec(a);if(!o)throw new e(`Unsupported Command Pack package spec: "${t}".`,i.USAGE,`Use an allowlisted scoped package name with an optional version or tag.`);let s=o[1];if(!r.supported[s])throw new e(`Command Pack "${s}" is not allowlisted for ${n.binName}.`,i.USAGE,cn(n,r));return{name:s,requested:a}}async function hn(e,t,n,r){let i=r.supported[e],a=await qt(t);return{pjson:a,commands:await en(e,a,i,n,t)}}function gn(e,t){return t.startsWith(`file:`)?t:`${e}@${t}`}async function _n(e,t,n){if(t){await dn([`install`,gn(e,t),`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],n);return}await dn([`uninstall`,e,`--ignore-scripts`,`--no-fund`,`--no-audit`],n)}async function vn(t,n,r){let{name:a,requested:o}=mn(t,n,r);return pn(n,async()=>{let t=Vt(n),s=(await Gt(n)).dependencies?.[a];try{await dn([`install`,o,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],t);let s=await hn(a,Ut(n,a),n,r);if(!s.pjson.version)throw new e(`Command Pack "${a}" has no package version.`,i.USAGE);return{name:a,version:s.pjson.version,commands:Object.keys(s.commands).sort()}}catch(e){try{await _n(a,s,t)}catch{}throw e}})}async function yn(t,n,r){let a=Te(t);if(!me(N(a,`package.json`)))throw new e(`Command Pack path does not exist: ${a}`,i.USAGE);let o=(await qt(a)).name;if(!o||!r.supported[o])throw new e(`Local package "${o??`(unnamed)`}" is not an allowlisted Command Pack for ${n.binName}.`,i.USAGE,cn(n,r));let s=await hn(o,a,n,r);return pn(n,async()=>{await dn([`install`,`file:${a}`,`--save-exact`,`--ignore-scripts`,`--no-fund`,`--no-audit`],Vt(n));let e=await hn(o,Ut(n,o),n,r);return{name:o,version:e.pjson.version??s.pjson.version,commands:Object.keys(e.commands).sort()}})}async function bn(t,n,r){if(!r.supported[t])throw new e(`Command Pack "${t}" is not allowlisted for ${n.binName}.`,i.USAGE,cn(n,r));if(!(t in((await Gt(n)).dependencies??{})))throw new e(`Command Pack "${t}" is not installed.`,i.USAGE);await pn(n,()=>dn([`uninstall`,t,`--ignore-scripts`,`--no-fund`,`--no-audit`],Vt(n)))}async function xn(e,t){return(await nn({},e,t)).reports}function Sn(e,t){return{install:n=>vn(n,e,t),link:n=>yn(n,e,t),list:()=>xn(e,t),remove:n=>bn(n,e,t)}}function Cn(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function wn(e){try{xt()}catch(t){B(t,e)}process.on(`SIGINT`,()=>{process.stderr.write(`
48
48
  Interrupted. Exiting.
49
- `),h(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function wn(e,t){let{binName:i,version:d,npmPackage:m,clientName:g}=t,_={binName:i,version:d,npmPackage:m,clientName:g},v=t.commandPacks??{supported:{}},x=xn(_,v),S;Cn(i);let C=ht([vt,_t,gt,yt]);function w(){return S||=tn(e,_,v).then(e=>new Ge(e.commands,i)),S}function T(e,r,c){if(e.printHelp(r,process.stderr),r.length>0)return;let l=!1;try{let e=p(u(Be(c,{...a,...o,...n,...s})));l=!!(e.apiKey||e.console)}catch{}l?t.quickStartTasks?.length&&zt(t.quickStartTasks):Rt(i)}async function E(e,t){let n=Ke(t,e);switch(n.kind){case`version`:process.stdout.write(`${i} ${d}\n`);return;case`help`:T(e,n.path,t);return;case`usageError`:z(n.error,i);return;case`run`:try{let e=f(n.command),t=Be(n.rest,{...a,...e,...n.command.flags}),i=Sn(t,[...Object.keys(a),...Object.keys(e)]),o=Sn(t,Object.keys(n.command.flags??{})),s=n.command.validate?.(o);if(s)throw new c(s);let d=u(i),p=l(d);await C({identity:_,path:n.path,command:n.command,flags:o,settings:p,sources:d,configStore:b(d.configName),authStore:y(d),commandPacks:x,client:new r({identity:_,settings:p,baseUrl:D(d)})}),await h(1e3)}catch(t){if(t instanceof c&&n.rest.length===0){e.printHelp(n.path,process.stderr);return}await h(1e3),z(t,i)}return}}return{run(e=process.argv.slice(2)){return w().then(t=>E(t,e)).catch(e=>h(1e3).finally(()=>z(e,i)))}}}const Tn=`1.11.1`;function En(e,t){process.stdout.write(g(e,t)+`
50
- `)}function Dn(e){process.stdout.write(e+`
51
- `)}function On(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}function kn(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function B(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=kn(e)?2:1}return t}function An(e,t){let n=t-B(e);return n>0?e+` `.repeat(n):e}const jn=` │ `,Mn=[0,150,160],Nn=[176,205,250],Pn=[160,160,170];function Fn(e){if(`NO_COLOR`in process.env)return 0;let t=process.env.FORCE_COLOR;if(t!=null){if(t===`0`||t===`false`)return 0;if(t===`3`||t===`truecolor`)return 3;if(t===`2`)return 2;if(t===`1`||t===`true`||t===``)return 1}if(!He(e))return 0;let n=process.env.COLORTERM;if(n===`truecolor`||n===`24bit`)return 3;let r=process.env.TERM??``;return r===`dumb`?1:/-256(color)?$/i.test(r)?2:1}function In(e,t,n){return e===t&&t===n?e<8?16:e>248?231:232+Math.round((e-8)/247*24):16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)}function Ln(e,t,n,r){let i=Math.max(e,t,n)>127,a=i?128:64;return(r===48?i?100:40:i?90:30)+(e>=a|(t>=a?2:0)|(n>=a?4:0))}function Rn(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${In(t,n,r)}`:String(Ln(t,n,r,i))}function zn(e,[t,n,r],i){return e<=0?i:`\x1b[${Rn(e,t,n,r)}m${i}\x1b[0m`}function Bn(e,t,n){return t<=0?e:`\x1b[1;${Rn(t,255,255,255,38)};${Rn(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function Vn(e,t){let n=t-B(e);return n>0?` `.repeat(n)+e:e}function Hn(e,t,n,r){let i=e==null?0:Math.max(0,Math.min(100,e)),a=e!=null,o=a?Math.round(i/100*n):0,s=``,c=``;for(let e=0;e<n;e++)a&&e<o?(s+=`█`,c+=zn(r,Mn,`█`)):(s+=` `,c+=` `);let l=a?Nn:Pn;return s+=` ${t}`,c+=` ${zn(r,l,t)}`,{plain:s,colored:c}}function Un(e){let t=Fn(e.out??process.stdout),n=e.align??[],r=e.barColumns??[],i=e.headers.length,a={};for(let n of r){let r=n.width??20,i=[];for(let a=0;a<e.rows.length;a++){let e=n.percents[a]??null,o=n.labels?.[a]??(e==null?`-`:`${Number.isInteger(e)?e:e.toFixed(1)}%`);i.push(Hn(e,o,r,t))}a[n.index]=i}let o=(t,n)=>a[n]?a[n][t].plain:e.rows[t][n]??``,s=e.headers.map((t,n)=>{let r=B(t);for(let t=0;t<e.rows.length;t++){let e=B(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?Vn(e,s[t]):An(e,s[t])).join(jn),u=Math.max(B(l),...e.rows.map((e,t)=>B(Array.from({length:i},(e,n)=>o(t,n)).join(jn))));c.push(Bn(` ${An(l,u)} `,t,Mn));let d=` ${zn(t,Mn,`│`)} `;for(let t=0;t<e.rows.length;t++){let r=[];for(let o=0;o<i;o++){let i=s[o];if(a[o]){let e=a[o][t],n=i-B(e.plain);r.push(n>0?e.colored+` `.repeat(n):e.colored);continue}let c=e.rows[t][o]??``,l=e.cellColor?.(t,o,c),u=n[o]===`right`?Vn(c,i):An(c,i);l?r.push(n[o]===`right`?u.slice(0,u.length-c.length)+l:l+u.slice(c.length)):r.push(u)}let o=` `;for(let e=0;e<i;e++)o+=r[e],e<i-1&&(o+=d);c.push(o)}return c}const Wn=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Gn(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Wn[n%Wn.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function Kn(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`█`.repeat(a)+`░`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
52
- `)}}}async function qn(t,n,r){let a=Date.now()+r.timeoutSec*1e3,o=Gn(`Polling...`);n.quiet||o.start();try{for(;Date.now()<a;){let a=await t.requestJson({path:r.url});if(r.getStatus&&!n.quiet&&o.update(`Status: ${r.getStatus(a)}`),r.isComplete(a))return o.stop(`Done.`),a;if(r.isFailed(a)){o.stop(`Failed.`),n.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(a,null,2)}\n`);let t=r.getErrorMessage?.(a);throw new e(t?`Task failed: ${t}`:`Task failed.`,i.GENERAL,t?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,r.intervalSec*1e3))}}finally{o.stop()}throw new e(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function Jn(t,n,r){let a=await fetch(t,{headers:re()});if(!a.ok)throw new e(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new e(`No response body`,i.GENERAL);le(oe(n),{recursive:!0});let c=ce(n),l=o>0&&!r?.quiet?Kn(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{de(n)}catch{}}return{size:u}}function Yn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Xn(e){return Math.max(1,e.concurrent??1)}async function Zn(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function Qn(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const $n={"qwen-image-2.0":{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"qwen-image-fixed":{"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},wan27:{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"z-image":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`,"3:2":`1248*832`,"2:3":`832*1248`},wan26:{"1:1":`1280*1280`,"16:9":`1696*960`,"9:16":`960*1696`,"4:3":`1472*1104`,"3:4":`1104*1472`},"wan-legacy":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"3:4":`768*1152`,"4:3":`1152*768`},"wanx-v1":{"1:1":`1024*1024`,"9:16":`720*1280`,"3:4":`768*1152`,"16:9":`1280*720`},"wan25-i2i":{"1:1":`1280*1280`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`}};function er(e,t){if(e)return $n[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}const tr=`Enable watermark (true/false). Omit flag to use CLI default (true).`,nr=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,rr=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,ir=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`;var V=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}};function ar(e,t){return e instanceof V?e:new V(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var or=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new V(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}};const sr=new or;function cr(){return sr}function lr(e,t,n,r){let i,a;n instanceof or?(i=n,a=r):(i=sr,a=n??r),i.registerStep(e,t,a)}function ur(){let e=u({}),t={...l(e),output:`json`,outputExplicit:!0,quiet:!0},n={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},i;try{i=S(e)}catch{}return{client:new r({identity:n,settings:t,baseUrl:D(e),apiCred:i}),settings:t}}const dr=[`download`,`out-dir`,`output`];function fr(e){return e.startsWith(`./`)||e.startsWith(`../`)}function pr(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&fr(a)?(n[i]=Ee(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function mr(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await ge(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function hr(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function H(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function U(e,t){if(Array.isArray(e)){e.forEach(e=>U(e,t));return}if(H(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))U(n,t)}}async function gr(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(dr.includes(e)||typeof i!=`string`||!fr(i))continue;let a=Ee(t,i);await ge(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function _r(e,t,n){if(!t.message)throw new V(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`]));let o=d();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function vr(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;v(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;v(t)&&(i=await e.client.uploadFile(t,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]},l=d();return await e.client.requestJson({path:l,method:`POST`,body:c,signal:n.signal})}async function yr(e,t,n){if(!t.prompt)throw new V(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=E(r),a=t.n??1,o=C(t[`prompt-extend`],i.promptExtendDefault,`prompt-extend`),s={size:er(t.size,i.sizeProfile),n:a,seed:t.seed,prompt_extend:o,watermark:k(t.watermark)},c=i.inputStyle===`prompt`?{model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0},parameters:s}:{model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{...s,negative_prompt:t[`negative-prompt`]||void 0}};if(i.useSync){let r=await e.client.requestJson({path:i.path,method:`POST`,body:c,signal:n.signal}),a=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await xr(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:r.request_id,...o?{saved:o}:{}}}let l=(await e.client.requestJson({path:i.path,method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await Er(e,l,n),d=await xr(Array.isArray(u.urls)?u.urls:[],t[`out-dir`],t[`out-prefix`]);return d&&(u.saved=d),u}async function br(e,t,n){if(!t.prompt)throw new V(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=T(i),o=t.n??1,s=C(t[`prompt-extend`],a.promptExtendDefault,`prompt-extend`),c=[];for(let t of r){let r=t;v(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push(r)}let l={size:er(t.size,a.sizeProfile),n:o,seed:t.seed,prompt_extend:s,watermark:k(t.watermark)},u;if(a.inputStyle===`function-base-image`){let e=c[0];if(!e)throw new V(`missing_input`,`image/edit with wanx*-imageedit requires at least one image`,{step:`image/edit`});u={model:i,input:{function:t.function||`description_edit`,prompt:t.prompt,base_image_url:e},parameters:l}}else if(a.inputStyle===`prompt-images`)u={model:i,input:{prompt:t.prompt,images:c,negative_prompt:t[`negative-prompt`]||void 0},parameters:l};else{let e=c.map(e=>({image:e}));e.push({text:t.prompt}),u={model:i,input:{messages:[{role:`user`,content:e}]},parameters:{...l,negative_prompt:t[`negative-prompt`]||void 0}}}if(a.useSync){let r=await e.client.requestJson({path:a.path,method:`POST`,body:u,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await xr(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...o?{saved:o}:{}}}let d=(await e.client.requestJson({path:a.path,method:`POST`,body:u,async:!0,signal:n.signal})).output.task_id,f=await Er(e,d,n),p=await xr(Array.isArray(f.urls)?f.urls:[],t[`out-dir`],t[`out-prefix`]);return p&&(f.saved=p),f}async function xr(e,t,n){if(!t||e.length===0)return;await _e(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:M(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:M(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Jn(e,t,{quiet:!0}),a.push(t);return a}async function Sr(e,t,n){if(!t.prompt)throw new V(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;t.image&&(i=v(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):t.image);let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:C(t[`prompt-extend`],void 0,`prompt-extend`),watermark:k(t.watermark),seed:t.seed}};j(a.parameters);let o=ie(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Dr(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Cr(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new V(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};j(a.input);let o=ee(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function wr(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new V(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)v(a)?i.push(await e.client.uploadFile(a,t.model||`fun-asr`,{signal:n.signal})):i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};j(a.parameters);let o=A(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Dr(e,s,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Tr(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function Er(e,t,n){return await Dr(e,t,3e3,e.settings.timeout*1e3,n)}async function Dr(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new V(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Or(n,i?.signal),o++;let s=te(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return Tr(c);if(l===`FAILED`)throw new V(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new V(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Or(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new V(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}const kr={"text/chat":(e,t,n)=>_r(e,t,n),"vision/describe":(e,t,n)=>vr(e,t,n),"image/generate":(e,t,n)=>yr(e,t,n),"image/edit":(e,t,n)=>br(e,t,n),"video/generate":(e,t,n)=>Sr(e,t,n),"speech/synthesize":(e,t,n)=>Cr(e,t,n),"speech/recognize":(e,t,n)=>wr(e,t,n)},Ar={"image/generate":e=>({data:e,artifacts:Pr(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Pr(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Pr(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:Fr(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:Fr(e,`transcript`),warnings:[],metadata:{}})},jr={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}};function Mr(e){for(let t of Object.keys(kr))lr(t,async(e,n)=>await Nr(t,e,n),e,jr[t])}async function Nr(e,t,n){if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:t},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let r=kr[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blEnv??ur(),t,n),a=Ar[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Pr(e){if(!H(e))return;let t=[],n=W(e.task_id)??W(e.taskId);for(let r of Rr(e.urls))t.push({url:r,taskId:n,kind:zr(r)});for(let r of Rr(e.saved))t.push({path:r,taskId:n,kind:Br(r)});let r=W(e.video_url)??W(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=W(e.saved);if(i&&t.push({path:i,taskId:n,kind:Br(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!H(n))continue;let e=W(n.task_id)??W(n.taskId),r=W(n.video_url)??W(n.videoUrl),i=W(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(W).filter(Lr):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function Fr(e,t){if(!H(e))return;let n=[],r=W(e.task_id)??W(e.taskId),i=[W(e.url),W(e.audio_url),W(e.audioUrl),W(e.output_url),W(e.outputUrl)].filter(Lr);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[W(e.saved),W(e.path),W(e.output_path),W(e.outputPath)].filter(Lr);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?Ir(n):void 0}function Ir(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function Lr(e){return typeof e==`string`}function W(e){return typeof e==`string`&&e.length>0?e:void 0}function Rr(e){return Array.isArray(e)?e.map(W).filter(Lr):[]}function zr(e){try{return Br(new URL(e).pathname)}catch{return`artifact`}}function Br(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var Vr=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})),Hr=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Vr();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}}})),G=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=Vr(),n=Hr();var r=Vr();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=Hr();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?`
53
- `:``},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._)`!${ae(e)}`}e.not=ee;let j=ie(e.operators.AND);function te(...e){return e.reduce(j)}e.and=te;let ne=ie(e.operators.OR);function re(...e){return e.reduce(ne)}e.or=re;function ie(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ae(n)} ${e} ${ae(r)}`}function ae(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),K=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=G(),n=Vr();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})),q=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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`)}})),Ur=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=G(),n=K(),r=q();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])}})),Wr=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Ur(),n=G(),r=q(),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)}})),Gr=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})),Kr=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})),qr=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=Gr(),n=Kr(),r=Ur(),i=G(),a=K();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
49
+ `),h(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e})}function Tn(e,t){let{binName:i,version:d,npmPackage:m,clientName:g}=t,_={binName:i,version:d,npmPackage:m,clientName:g},v=t.commandPacks??{supported:{}},x=Sn(_,v),S;wn(i);let C=mt([_t,gt,ht,vt]);function w(){return S||=nn(e,_,v).then(e=>new We(e.commands,i)),S}function T(e,r,c){if(e.printHelp(r,process.stderr),r.length>0)return;let l=!1;try{let e=p(u(ze(c,{...a,...o,...n,...s})));l=!!(e.apiKey||e.console)}catch{}l?t.quickStartTasks?.length&&Bt(t.quickStartTasks):zt(i)}async function E(e,t){let n=Ge(t,e);switch(n.kind){case`version`:process.stdout.write(`${i} ${d}\n`);return;case`help`:T(e,n.path,t);return;case`usageError`:B(n.error,i);return;case`run`:try{let e=f(n.command),t=ze(n.rest,{...a,...e,...n.command.flags}),i=Cn(t,[...Object.keys(a),...Object.keys(e)]),o=Cn(t,Object.keys(n.command.flags??{})),s=n.command.validate?.(o);if(s)throw new c(s);let d=u(i),p=l(d);await C({identity:_,path:n.path,command:n.command,flags:o,settings:p,sources:d,configStore:b(d.configName),authStore:y(d),commandPacks:x,client:new r({identity:_,settings:p,baseUrl:D(d)})}),await h(1e3)}catch(t){if(t instanceof c&&n.rest.length===0){e.printHelp(n.path,process.stderr);return}await h(1e3),B(t,i)}return}}return{run(e=process.argv.slice(2)){return w().then(t=>E(t,e)).catch(e=>h(1e3).finally(()=>B(e,i)))}}}const En=`1.11.2`;function Dn(e,t){process.stdout.write(g(e,t)+`
50
+ `)}function On(e){process.stdout.write(e+`
51
+ `)}function kn(e,t,{gap:n=2}={}){let r=e.map((e,n)=>{let r=e.length;for(let e of t){let t=e[n]??``;t.length>r&&(r=t.length)}return r}),i=` `.repeat(n),a=e=>e.map((e,t)=>(e??``).padEnd(r[t])).join(i),o=[];o.push(a(e));for(let e of t)o.push(a(e));return o}function An(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=131072&&e<=195103}function V(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=An(e)?2:1}return t}function jn(e,t){let n=t-V(e);return n>0?e+` `.repeat(n):e}const Mn=` │ `,Nn=[0,150,160],Pn=[176,205,250],Fn=[160,160,170];function In(e){if(`NO_COLOR`in process.env)return 0;let t=process.env.FORCE_COLOR;if(t!=null){if(t===`0`||t===`false`)return 0;if(t===`3`||t===`truecolor`)return 3;if(t===`2`)return 2;if(t===`1`||t===`true`||t===``)return 1}if(!Ve(e))return 0;let n=process.env.COLORTERM;if(n===`truecolor`||n===`24bit`)return 3;let r=process.env.TERM??``;return r===`dumb`?1:/-256(color)?$/i.test(r)?2:1}function Ln(e,t,n){return e===t&&t===n?e<8?16:e>248?231:232+Math.round((e-8)/247*24):16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)}function Rn(e,t,n,r){let i=Math.max(e,t,n)>127,a=i?128:64;return(r===48?i?100:40:i?90:30)+(e>=a|(t>=a?2:0)|(n>=a?4:0))}function zn(e,t,n,r,i=38){return e>=3?`${i};2;${t};${n};${r}`:e===2?`${i};5;${Ln(t,n,r)}`:String(Rn(t,n,r,i))}function Bn(e,[t,n,r],i){return e<=0?i:`\x1b[${zn(e,t,n,r)}m${i}\x1b[0m`}function Vn(e,t,n){return t<=0?e:`\x1b[1;${zn(t,255,255,255,38)};${zn(t,n[0],n[1],n[2],48)}m${e}\x1b[0m`}function Hn(e,t){let n=t-V(e);return n>0?` `.repeat(n)+e:e}function Un(e,t,n,r){let i=e==null?0:Math.max(0,Math.min(100,e)),a=e!=null,o=a?Math.round(i/100*n):0,s=``,c=``;for(let e=0;e<n;e++)a&&e<o?(s+=`█`,c+=Bn(r,Nn,`█`)):(s+=` `,c+=` `);let l=a?Pn:Fn;return s+=` ${t}`,c+=` ${Bn(r,l,t)}`,{plain:s,colored:c}}function Wn(e){let t=In(e.out??process.stdout),n=e.align??[],r=e.barColumns??[],i=e.headers.length,a={};for(let n of r){let r=n.width??20,i=[];for(let a=0;a<e.rows.length;a++){let e=n.percents[a]??null,o=n.labels?.[a]??(e==null?`-`:`${Number.isInteger(e)?e:e.toFixed(1)}%`);i.push(Un(e,o,r,t))}a[n.index]=i}let o=(t,n)=>a[n]?a[n][t].plain:e.rows[t][n]??``,s=e.headers.map((t,n)=>{let r=V(t);for(let t=0;t<e.rows.length;t++){let e=V(o(t,n));e>r&&(r=e)}return r}),c=[],l=e.headers.map((e,t)=>n[t]===`right`?Hn(e,s[t]):jn(e,s[t])).join(Mn),u=Math.max(V(l),...e.rows.map((e,t)=>V(Array.from({length:i},(e,n)=>o(t,n)).join(Mn))));c.push(Vn(` ${jn(l,u)} `,t,Nn));let d=` ${Bn(t,Nn,`│`)} `;for(let t=0;t<e.rows.length;t++){let r=[];for(let o=0;o<i;o++){let i=s[o];if(a[o]){let e=a[o][t],n=i-V(e.plain);r.push(n>0?e.colored+` `.repeat(n):e.colored);continue}let c=e.rows[t][o]??``,l=e.cellColor?.(t,o,c),u=n[o]===`right`?Hn(c,i):jn(c,i);l?r.push(n[o]===`right`?u.slice(0,u.length-c.length)+l:l+u.slice(c.length)):r.push(u)}let o=` `;for(let e=0;e<i;e++)o+=r[e],e<i-1&&(o+=d);c.push(o)}return c}const Gn=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function Kn(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Gn[n%Gn.length]} ${i}`),n++},80))},update(e){i=e},stop(e){r&&=(clearInterval(r),null),t&&(process.stderr.write(`\r\x1B[K`),e&&process.stderr.write(`${e}\n`))}}}function qn(e,t=``){let n=process.stderr.isTTY;return{update(r){if(!n)return;let i=Math.min(1,r/e),a=Math.round(30*i),o=30-a,s=`█`.repeat(a)+`░`.repeat(o),c=`${Math.round(i*100)}%`;process.stderr.write(`\r${t} ${s} ${c}`)},finish(){n&&process.stderr.write(`
52
+ `)}}}async function Jn(t,n,r){let a=Date.now()+r.timeoutSec*1e3,o=Kn(`Polling...`);n.quiet||o.start();try{for(;Date.now()<a;){let a=await t.requestJson({path:r.url});if(r.getStatus&&!n.quiet&&o.update(`Status: ${r.getStatus(a)}`),r.isComplete(a))return o.stop(`Done.`),a;if(r.isFailed(a)){o.stop(`Failed.`),n.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(a,null,2)}\n`);let t=r.getErrorMessage?.(a);throw new e(t?`Task failed: ${t}`:`Task failed.`,i.GENERAL,t?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,r.intervalSec*1e3))}}finally{o.stop()}throw new e(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}async function Yn(t,n,r){let a=await fetch(t,{headers:ne()});if(!a.ok)throw new e(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new e(`No response body`,i.GENERAL);ce(ae(n),{recursive:!0});let c=se(n),l=o>0&&!r?.quiet?qn(o,`Downloading`):null,u=0,d=!1;try{let e=new Promise((e,t)=>{c.on(`error`,t)});for(;;){let{done:t,value:n}=await Promise.race([s.read(),e]);if(t)break;c.write(n)||await new Promise(e=>c.once(`drain`,()=>e())),u+=n.byteLength,l?.update(u)}d=!0}finally{if(s.releaseLock(),l?.finish(),await new Promise((e,t)=>{c.on(`finish`,e),c.on(`error`,t),c.end()}),!d)try{ue(n)}catch{}}return{size:u}}function Xn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Zn(e){return Math.max(1,e.concurrent??1)}async function Qn(e,t,n,r=`requests`){if(e<=1)return[await n(0)];t.quiet||process.stderr.write(`[Concurrent: ${e} ${r}]\n`);let i=Array.from({length:e},(e,t)=>n(t));return Promise.all(i)}async function $n(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}const er={"qwen-image-2.0":{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"qwen-image-fixed":{"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`},wan27:{"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},"z-image":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`,"3:2":`1248*832`,"2:3":`832*1248`},wan26:{"1:1":`1280*1280`,"16:9":`1696*960`,"9:16":`960*1696`,"4:3":`1472*1104`,"3:4":`1104*1472`},"wan-legacy":{"1:1":`1024*1024`,"16:9":`1280*720`,"9:16":`720*1280`,"3:4":`768*1152`,"4:3":`1152*768`},"wanx-v1":{"1:1":`1024*1024`,"9:16":`720*1280`,"3:4":`768*1152`,"16:9":`1280*720`},"wan25-i2i":{"1:1":`1280*1280`,"16:9":`1280*720`,"9:16":`720*1280`,"4:3":`1152*864`,"3:4":`864*1152`}};function tr(e,t){if(e)return er[typeof t==`boolean`?t?`qwen-image-2.0`:`qwen-image-fixed`:t][e]??e}const nr=`Enable watermark (true/false). Omit flag to use CLI default (true).`,rr=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,ir=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,ar=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`;var H=class extends Error{code;step;details;constructor(e,t,n){super(t),this.name=`PipelineError`,this.code=e,this.step=n?.step,this.details=n?.details}toJSON(){return{code:this.code,message:this.message,...this.step?{step:this.step}:{},...this.details?{details:this.details}:{}}}};function or(e,t){return e instanceof H?e:new H(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var sr=class{handlers=new Map;outputSchemas=new Map;registerStep(e,t,n){this.handlers.set(e,t),n&&this.outputSchemas.set(e,n)}executeStep(e,t,n){let r=this.handlers.get(e);if(!r)throw new H(`unknown_step`,`Unknown step type: ${e}`,{details:{available:this.listSteps()}});return r(t,n)}hasStep(e){return this.handlers.has(e)}listSteps(){return Array.from(this.handlers.keys()).sort()}getOutputSchema(e){return this.outputSchemas.get(e)}};const cr=new sr;function lr(){return cr}function ur(e,t,n,r){let i,a;n instanceof sr?(i=n,a=r):(i=cr,a=n??r),i.registerStep(e,t,a)}function dr(){let e=u({}),t={...l(e),output:`json`,outputExplicit:!0,quiet:!0},n={binName:`bl`,version:`0.0.0-dev`,npmPackage:`bailian-cli`,clientName:`bailian-cli`},i;try{i=S(e)}catch{}return{client:new r({identity:n,settings:t,baseUrl:D(e),apiCred:i}),settings:t}}const fr=[`download`,`out-dir`,`output`];function pr(e){return e.startsWith(`./`)||e.startsWith(`../`)}function mr(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&pr(a)?(n[i]=Te(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function hr(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await he(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function gr(e){if(e===void 0)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m)?$/);if(!t)return;let n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return;let r=t[2]??`s`;return r===`ms`?n/1e3:r===`m`?n*60:n}function U(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function _r(e,t){if(Array.isArray(e)){e.forEach(e=>_r(e,t));return}if(U(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))_r(n,t)}}async function vr(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(fr.includes(e)||typeof i!=`string`||!pr(i))continue;let a=Te(t,i);await he(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}async function yr(e,t,n){if(!t.message)throw new H(`missing_input`,`text/chat requires 'message' input`,{step:`text/chat`});let r=t.model||`qwen3.7-max`,i=[];t.system&&i.push({role:`system`,content:t.system}),i.push({role:`user`,content:t.message});let a={model:r,messages:i,max_tokens:t[`max-tokens`]??4096,stream:!1};t.temperature!==void 0&&(a.temperature=t.temperature),t[`top-p`]!==void 0&&(a.top_p=t[`top-p`]),t[`enable-thinking`]&&(a.enable_thinking=!0,t[`thinking-budget`]!==void 0&&(a.thinking_budget=t[`thinking-budget`]));let o=d();return await e.client.requestJson({path:o,method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function br(e,t,n){let r=t.model||`qwen3-vl-plus`,i=Array.isArray(t.image)?t.image:t.image?[t.image]:[],a=t.video?`Describe the video.`:`Describe the image.`,o=t.prompt||a,s=[];if(t.video){let i=t.video;v(i)&&(i=await e.client.uploadFile(i,r,{signal:n.signal})),s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;v(t)&&(i=await e.client.uploadFile(t,r,{signal:n.signal})),s.push({type:`image_url`,image_url:{url:i}})}s.push({type:`text`,text:o});let c={model:r,messages:[{role:`user`,content:s}]},l=d();return await e.client.requestJson({path:l,method:`POST`,body:c,signal:n.signal})}async function xr(e,t,n){if(!t.prompt)throw new H(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=E(r),a=t.n??1,o=C(t[`prompt-extend`],i.promptExtendDefault,`prompt-extend`),s={size:tr(t.size,i.sizeProfile),n:a,seed:t.seed,prompt_extend:o,watermark:k(t.watermark)},c=i.inputStyle===`prompt`?{model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0},parameters:s}:{model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{...s,negative_prompt:t[`negative-prompt`]||void 0}};if(i.useSync){let r=await e.client.requestJson({path:i.path,method:`POST`,body:c,signal:n.signal}),a=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Cr(a,t[`out-dir`],t[`out-prefix`]);return{urls:a,request_id:r.request_id,...o?{saved:o}:{}}}let l=(await e.client.requestJson({path:i.path,method:`POST`,body:c,async:!0,signal:n.signal})).output.task_id,u=await Or(e,l,n),d=await Cr(Array.isArray(u.urls)?u.urls:[],t[`out-dir`],t[`out-prefix`]);return d&&(u.saved=d),u}async function Sr(e,t,n){if(!t.prompt)throw new H(`missing_input`,`image/edit requires 'prompt' input`,{step:`image/edit`});let r=Array.isArray(t.image)?t.image:t.image?[t.image]:[],i=t.model||`qwen-image-2.0`,a=T(i),o=t.n??1,s=C(t[`prompt-extend`],a.promptExtendDefault,`prompt-extend`),c=[];for(let t of r){let r=t;v(t)&&(r=await e.client.uploadFile(t,i,{signal:n.signal})),c.push(r)}let l={size:tr(t.size,a.sizeProfile),n:o,seed:t.seed,prompt_extend:s,watermark:k(t.watermark)},u;if(a.inputStyle===`function-base-image`){let e=c[0];if(!e)throw new H(`missing_input`,`image/edit with wanx*-imageedit requires at least one image`,{step:`image/edit`});u={model:i,input:{function:t.function||`description_edit`,prompt:t.prompt,base_image_url:e},parameters:l}}else if(a.inputStyle===`prompt-images`)u={model:i,input:{prompt:t.prompt,images:c,negative_prompt:t[`negative-prompt`]||void 0},parameters:l};else{let e=c.map(e=>({image:e}));e.push({text:t.prompt}),u={model:i,input:{messages:[{role:`user`,content:e}]},parameters:{...l,negative_prompt:t[`negative-prompt`]||void 0}}}if(a.useSync){let r=await e.client.requestJson({path:a.path,method:`POST`,body:u,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),o=await Cr(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...o?{saved:o}:{}}}let d=(await e.client.requestJson({path:a.path,method:`POST`,body:u,async:!0,signal:n.signal})).output.task_id,f=await Or(e,d,n),p=await Cr(Array.isArray(f.urls)?f.urls:[],t[`out-dir`],t[`out-prefix`]);return p&&(f.saved=p),f}async function Cr(e,t,n){if(!t||e.length===0)return;await ge(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:N(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:N(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Yn(e,t,{quiet:!0}),a.push(t);return a}async function wr(e,t,n){if(!t.prompt)throw new H(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.1-i2v`:`happyhorse-1.1-t2v`),i;t.image&&(i=v(t.image)?await e.client.uploadFile(t.image,r,{signal:n.signal}):t.image);let a={model:r,input:{prompt:t.prompt,negative_prompt:t[`negative-prompt`]||void 0,...i?{media:[{type:`first_frame`,url:i}]}:{}},parameters:{resolution:t.resolution||void 0,ratio:t.ratio||void 0,duration:t.duration,prompt_extend:C(t[`prompt-extend`],void 0,`prompt-extend`),watermark:k(t.watermark),seed:t.seed}};j(a.parameters);let o=re(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await kr(e,s,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Tr(e,t,n){let r=t.text;if(!r&&t[`text-file`]){let{readFileSync:e}=await import(`node:fs`);r=e(t[`text-file`],`utf-8`).trim()}if(!r)throw new H(`missing_input`,`speech/synthesize requires 'text' input`,{step:`speech/synthesize`});let i=t.model||`cosyvoice-v3-flash`,a={model:i,input:{text:r,voice:t.voice,format:t.format,sample_rate:t[`sample-rate`],volume:t.volume,rate:t.rate,pitch:t.pitch,seed:t.seed,language_hints:t.language?[t.language]:void 0,instruction:t.instruction,enable_ssml:t[`enable-ssml`]}};j(a.input);let o=ee(),s=await e.client.requestJson({path:o,method:`POST`,body:a,signal:n.signal});return{audio_url:s.output.audio.url,url_expires_at:s.output.audio.expires_at,model:i,voice:t.voice,request_id:s.request_id}}async function Er(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new H(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)v(a)?i.push(await e.client.uploadFile(a,t.model||`fun-asr`,{signal:n.signal})):i.push(a);let a={model:t.model||`fun-asr`,input:{file_urls:i},parameters:{channel_id:t[`channel-id`]===void 0?void 0:[t[`channel-id`]],language_hints:t.language?[t.language]:void 0,diarization_enabled:t.diarization,speaker_count:t[`speaker-count`],vocabulary_id:t[`vocabulary-id`]}};j(a.parameters);let o=A(),s=(await e.client.requestJson({path:o,method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await kr(e,s,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Dr(e){let{output:t,request_id:n,usage:r}=e,i={task_id:t.task_id,task_status:t.task_status,request_id:n};if(t.video_url&&(i.video_url=t.video_url),t.choices){let e=t.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);e.length>0&&(i.urls=e)}if(t.results){let e=t.results.map(e=>e.url).filter(Boolean);e.length>0&&!i.urls&&(i.urls=e)}return t.task_metrics&&(i.task_metrics=t.task_metrics),r&&(i.usage=r),i}async function Or(e,t,n){return await kr(e,t,3e3,e.settings.timeout*1e3,n)}async function kr(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new H(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Ar(n,i?.signal),o++;let s=te(t),c=await e.client.requestJson({path:s,method:`GET`,signal:i?.signal}),l=c.output.task_status;if(l===`SUCCEEDED`)return Dr(c);if(l===`FAILED`)throw new H(`async_task_failed`,c.output.message||c.output.code||`Task failed`,{details:{taskId:t,data:c}});let u=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:l,elapsedMs:u,pollAttempt:o}),u>r)throw new H(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Ar(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new H(`aborted`,`Poll delay was aborted`))},o=()=>{clearTimeout(i),t.removeEventListener(`abort`,a)};t.aborted?a():t.addEventListener(`abort`,a,{once:!0})}):new Promise(t=>setTimeout(t,e))}const jr={"text/chat":(e,t,n)=>yr(e,t,n),"vision/describe":(e,t,n)=>br(e,t,n),"image/generate":(e,t,n)=>xr(e,t,n),"image/edit":(e,t,n)=>Sr(e,t,n),"video/generate":(e,t,n)=>wr(e,t,n),"speech/synthesize":(e,t,n)=>Tr(e,t,n),"speech/recognize":(e,t,n)=>Er(e,t,n)},Mr={"image/generate":e=>({data:e,artifacts:Ir(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Ir(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Ir(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:Lr(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:Lr(e,`transcript`),warnings:[],metadata:{}})},Nr={"text/chat":{description:`LLM text completion via chat API`,paths:[{path:`/data/choices/0/message/content`,description:`Generated text content`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"vision/describe":{description:`Multimodal vision understanding (image/video to text)`,paths:[{path:`/data/choices/0/message/content`,description:`Generated description text`},{path:`/data/choices/0/message/role`,description:`Message role (assistant)`},{path:`/data/usage/total_tokens`,description:`Total token usage`}]},"image/generate":{description:`Text-to-image generation`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"image/edit":{description:`Image editing with reference image(s)`,paths:[{path:`/data/urls`,description:`Array of generated image URLs`},{path:`/data/urls/0`,description:`First generated image URL`},{path:`/data/task_id`,description:`Async task ID (if applicable)`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"video/generate":{description:`Video generation (text-to-video or image-to-video)`,paths:[{path:`/data/video_url`,description:`Generated video URL`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/url`,description:`First artifact URL`},{path:`/artifacts/0/path`,description:`First artifact local path (if saved)`}]},"speech/synthesize":{description:`Text-to-speech synthesis`,paths:[{path:`/data/audio_url`,description:`Generated audio URL`},{path:`/data/url_expires_at`,description:`Audio URL expiration time`},{path:`/artifacts/0/url`,description:`First artifact URL`}]},"speech/recognize":{description:`Speech recognition (ASR)`,paths:[{path:`/data/text`,description:`Full transcribed text`},{path:`/data/task_id`,description:`Async task ID`},{path:`/artifacts/0/taskId`,description:`Task ID from artifact`}]}};function Pr(e){for(let t of Object.keys(jr))ur(t,async(e,n)=>await Fr(t,e,n),e,Nr[t])}async function Fr(e,t,n){if(n.dryRun)return{metadata:{dryRun:!0,step:e,plannedInput:t},warnings:[{code:`dry_run_skipped`,message:`Step ${e} was not executed in dry-run mode`}]};let r=jr[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blEnv??dr(),t,n),a=Mr[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Ir(e){if(!U(e))return;let t=[],n=W(e.task_id)??W(e.taskId);for(let r of Br(e.urls))t.push({url:r,taskId:n,kind:Vr(r)});for(let r of Br(e.saved))t.push({path:r,taskId:n,kind:Hr(r)});let r=W(e.video_url)??W(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=W(e.saved);if(i&&t.push({path:i,taskId:n,kind:Hr(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!U(n))continue;let e=W(n.task_id)??W(n.taskId),r=W(n.video_url)??W(n.videoUrl),i=W(n.saved);r&&t.push({url:r,taskId:e,kind:`video`}),i&&t.push({path:i,taskId:e,kind:`video`})}let a=Array.isArray(e.task_ids)?e.task_ids.map(W).filter(zr):[];for(let e of a)t.push({taskId:e,kind:`task`});return t.length===0&&n&&t.push({taskId:n,kind:`task`}),t.length>0?t:void 0}function Lr(e,t){if(!U(e))return;let n=[],r=W(e.task_id)??W(e.taskId),i=[W(e.url),W(e.audio_url),W(e.audioUrl),W(e.output_url),W(e.outputUrl)].filter(zr);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[W(e.saved),W(e.path),W(e.output_path),W(e.outputPath)].filter(zr);for(let e of a)n.push({path:e,taskId:r,kind:t});return n.length===0&&r&&n.push({taskId:r,kind:`task`}),n.length>0?Rr(n):void 0}function Rr(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind??``}:${r.taskId??``}:${r.url??``}:${r.path??``}`;t.has(e)||(t.add(e),n.push(r))}return n}function zr(e){return typeof e==`string`}function W(e){return typeof e==`string`&&e.length>0?e:void 0}function Br(e){return Array.isArray(e)?e.map(W).filter(zr):[]}function Vr(e){try{return Hr(new URL(e).pathname)}catch{return`artifact`}}function Hr(e){let t=e.toLowerCase();return t.endsWith(`.mp4`)||t.endsWith(`.mov`)||t.endsWith(`.webm`)?`video`:t.endsWith(`.png`)||t.endsWith(`.jpg`)||t.endsWith(`.jpeg`)||t.endsWith(`.webp`)?`image`:`artifact`}var Ur=P((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})),Wr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Ur();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}}})),G=P((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=Ur(),n=Wr();var r=Ur();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=Wr();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?`
53
+ `:``},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 j=re(e.operators.AND);function te(...e){return e.reduce(j)}e.and=te;let M=re(e.operators.OR);function ne(...e){return e.reduce(M)}e.or=ne;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})`}})),K=P((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=G(),n=Ur();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})),q=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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`)}})),Gr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=G(),n=K(),r=q();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])}})),Kr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Gr(),n=G(),r=q(),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)}})),qr=P((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})),Jr=P((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})),Yr=P((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=qr(),n=Jr(),r=Gr(),i=G(),a=K();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
54
54
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
55
55
  || (${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"
56
- || ${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;s.number&&delete s.integer;for(let e in 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}}})),Jr=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=G(),n=K();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)}`)}})),J=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=G(),n=K(),r=q(),i=K();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})),Yr=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=G(),n=q(),r=J(),i=Ur();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})),Xr=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=G(),n=K();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})),Zr=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}})),Qr=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`)}})),$r=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=K(),n=Zr(),r=Qr(),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})),ei=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Wr(),n=qr(),r=Kr(),i=qr(),a=Jr(),o=Yr(),s=Xr(),c=G(),l=q(),u=$r(),d=K(),f=Ur();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 te(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);te(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&&j(e),t.return((0,c._)`${l.default.errors} === 0`))}function j({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 te(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(()=>fe(e,`$ref`,h.all.$ref.definition));return}p.jtd||re(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)&&fe(e,n.keyword,n.definition,t.type)})}function re(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ie(e,t),e.opts.allowUnionTypes||ae(e,t),oe(e,e.dataTypes))}function ie(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ce(e.dataTypes,t)||ue(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),le(e,t)}}function ae(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&ue(e,`use allowUnionTypes to allow union type keyword`)}function oe(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=>se(t,e))&&ue(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function se(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ce(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function le(e,t){let n=[];for(let r of e.dataTypes)ce(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function ue(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var de=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`,he(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=de;function fe(e,t,n,r){let i=new de(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 pe=/^\/(?:[^~]|~0|~1)*$/,me=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function he(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!pe.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=me.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=he})),ti=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}}})),ni=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=$r();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))}}})),ri=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=G(),n=ti(),r=q(),i=$r(),a=K(),o=ei();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}})),ii=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}})),ai=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),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(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 c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(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 p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(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(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(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 e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}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:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),oi=N(((e,t)=>{let{isUUID:n}=ai(),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=y(`${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=y(`${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={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),si=N(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=ai(),{SCHEMES:d,getSchemeHandler:f}=oi();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(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 g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(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:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(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,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!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 p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(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}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),ci=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=si();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),li=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=ei();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=G();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=ti(),i=ni(),a=Gr(),o=ri(),s=G(),c=$r(),l=qr(),u=K(),d=ii(),f=ci(),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=Object.create(null),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;j.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}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in 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 j(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ne(t)),e.validateSchema=this.compile(t,!0))}let te={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ne(e){return{anyOf:[e,te]}}})),ui=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),di=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=ni(),n=J(),r=G(),i=q(),a=ri(),o=K(),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})),fi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ui(),n=di();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),pi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),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})`)}}})),mi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}))`)}}})),hi=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`})),gi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=hi();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}`)}}})),_i=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=K(),r=G();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),vi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),yi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K();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)}}}})),bi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),xi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Zr();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Si=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=qr(),n=G(),r=K(),i=xi();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)})))}}}})),Ci=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=xi();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}`)}}})),wi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=xi();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}`}}}})),Ti=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pi(),n=mi(),r=gi(),i=_i(),a=vi(),o=yi(),s=bi(),c=Si(),l=Ci(),u=wi();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]})),Ei=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=G(),n=K(),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})),Di=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=G(),n=K(),r=J(),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})),Oi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Di();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),ki=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=J(),i=Ei();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)))}}})),Ai=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)))}}}})),ji=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=G(),n=K(),r=J();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},
56
+ || ${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;s.number&&delete s.integer;for(let e in 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}}})),Xr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=G(),n=K();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)}`)}})),J=P((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=G(),n=K(),r=q(),i=K();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})),Zr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=G(),n=q(),r=J(),i=Gr();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})),Qr=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=G(),n=K();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})),$r=P(((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}})),ei=P(((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`)}})),ti=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=K(),n=$r(),r=ei(),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})),ni=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Kr(),n=Yr(),r=Jr(),i=Yr(),a=Xr(),o=Zr(),s=Qr(),c=G(),l=q(),u=ti(),d=K(),f=Gr();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 te(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);te(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&&j(e),t.return((0,c._)`${l.default.errors} === 0`))}function j({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 te(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||ne(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)),M(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):M(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function M(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 ne(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`,me(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)*$/,pe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function me(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=pe.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=me})),ri=P((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}}})),ii=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ti();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))}}})),ai=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=G(),n=ri(),r=q(),i=ti(),a=K(),o=ni();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}})),oi=P(((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}})),si=P(((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),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(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 c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(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 p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(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(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(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 e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}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:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),ci=P(((e,t)=>{let{isUUID:n}=si(),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=y(`${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=y(`${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={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),li=P(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=si(),{SCHEMES:d,getSchemeHandler:f}=ci();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(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 g(e,t,n){let r=w(e,n),i=w(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(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:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(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,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!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 p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(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}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return C(e,t).normalized}function C(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function w(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=C(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let T={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=T,t.exports.default=T,t.exports.fastUri=T})),ui=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=li();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),di=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=ni();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=G();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=ri(),i=ii(),a=qr(),o=ai(),s=G(),c=ti(),l=Yr(),u=K(),d=oi(),f=ui(),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=Object.create(null),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;j.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]=M(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}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in 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 j(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=M(t)),e.validateSchema=this.compile(t,!0))}let te={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function M(e){return{anyOf:[e,te]}}})),fi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),pi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=ii(),n=J(),r=G(),i=q(),a=ai(),o=K(),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})),mi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fi(),n=pi();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),hi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),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})`)}}})),gi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}))`)}}})),_i=P((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`})),vi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=_i();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}`)}}})),yi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=K(),r=G();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),bi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),xi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K();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)}}}})),Si=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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}`)}}})),Ci=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=$r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),wi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Yr(),n=G(),r=K(),i=Ci();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)})))}}}})),Ti=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Ci();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}`)}}})),Ei=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=Ci();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}`}}}})),Di=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=hi(),n=gi(),r=vi(),i=yi(),a=bi(),o=xi(),s=Si(),c=wi(),l=Ti(),u=Ei();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]})),Oi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=G(),n=K(),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})),ki=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=G(),n=K(),r=J(),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})),Ai=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ki();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),ji=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),r=J(),i=Oi();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)))}}})),Mi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)))}}}})),Ni=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=G(),n=K(),r=J();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},
57
57
  missingProperty: ${i},
58
58
  depsCount: ${n},
59
- 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})),Mi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)}}})),Ni=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=q(),i=K();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)}}}})),Pi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ei(),n=J(),r=K(),i=Ni();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)}}}})),Fi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K(),i=K();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())})})}}}})),Ii=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`}}})),Li=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:J().validateUnion,error:{message:`must match a schema in anyOf`}}})),Ri=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)})})}}}})),zi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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)})}}})),Bi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),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})),Vi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`)}}})),Hi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ei(),n=Oi(),r=Di(),i=ki(),a=Ai(),o=ji(),s=Mi(),c=Ni(),l=Pi(),u=Fi(),d=Ii(),f=Li(),p=Ri(),m=zi(),h=Bi(),g=Vi();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=_})),Ui=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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})`}}}}})),Wi=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Ui().default]})),Gi=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`]})),Ki=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fi(),n=Ti(),r=Hi(),i=Wi(),a=Gi();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),qi=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={}))})),Ji=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=qi(),r=ri(),i=ni(),a=K();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=_();o.if(!1);for(let e in 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}}}}})),Yi=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}}));const Xi=Ie(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=li(),r=Ki(),i=Ji(),a=Yi(),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=ei();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=G();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=ti();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=ni();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}))(),1).default,Zi=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Qi=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),$i=new Xi({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1});function ea(e,t=`schema`){let n=[];return ia(e,t,n),n.length===0&&!$i.validateSchema(e)&&n.push(...aa($i.errors,t)),n}function ta(e,t){let n=sa(t,e,`input`);return n.ok?H(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function na(e){if(e===``)return{ok:!0,segments:[]};if(!e.startsWith(`/`))return{ok:!1,segments:[],issue:`must start with /`};let t=e.slice(1).split(`/`),n=[];for(let e of t){if(e.match(/~(?![01])/))return{ok:!1,segments:[],issue:`contains invalid escape sequence`};n.push(e.replace(/~1/g,`/`).replace(/~0/g,`~`))}return{ok:!0,segments:n}}function ra(e,t){let n=na(t);if(!n.ok)return;let r=e;for(let e of n.segments){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(H(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function ia(e,t,n){if(!H(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))Zi.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&oa(e.type,`${t}.type`,n),`properties`in e)if(!H(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))ia(i,`${t}.properties.${r}`,n);if(`items`in e&&ia(e.items,`${t}.items`,n),`required`in e&&(!Array.isArray(e.required)||!e.required.every(e=>typeof e==`string`))&&n.push(`${t}.required must be an array of strings`),`enum`in e&&!Array.isArray(e.enum)&&n.push(`${t}.enum must be an array`),`description`in e&&typeof e.description!=`string`&&n.push(`${t}.description must be a string`),`format`in e&&typeof e.format!=`string`&&n.push(`${t}.format must be a string`),`additionalProperties`in e){let r=e.additionalProperties;r!==!0&&r!==!1&&!H(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):H(r)&&ia(r,`${t}.additionalProperties`,n)}}function aa(e,t){return!e||e.length===0?[`${t} is invalid`]:e.map(e=>`${e.instancePath?`${t}${e.instancePath.replace(/\//g,`.`)}`:t} ${e.message??`is invalid`}${e.keyword?` (${e.keyword})`:``}`)}function oa(e,t,n){let r=Array.isArray(e)?e:[e];if(r.length===0){n.push(`${t} must not be empty`);return}for(let e of r)Qi.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function sa(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(la);if(!r.includes(la(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=ca(t);if(r.size===0)return{ok:!0,value:e};if(r.size>1){if(Array.isArray(e)&&r.has(`array`)){if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=sa(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(!(H(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!H(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!H(e))return{ok:!1,issues:[`${n} must be an object`]};let r={...e},i=[];for(let e of t.required??[]){let t=r[e];(t==null||t===``)&&i.push(`Missing required input "${e}"`)}for(let[e,a]of Object.entries(t.properties??{})){let t=r[e];if((t==null||t===``)&&a.default===void 0)continue;let o=sa(t,a,`${n}.${e}`);o.ok?r[e]=o.value:i.push(...o.issues)}if(t.additionalProperties===!1)for(let e of Object.keys(r))t.properties?.[e]||i.push(`Unknown input "${e}"`);return i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`array`)){if(!Array.isArray(e))return{ok:!1,issues:[`${n} must be an array`]};if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=sa(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`string`))return{ok:!0,value:String(e)};if(r.has(`number`)||r.has(`integer`)){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?r.has(`integer`)&&!Number.isInteger(t)?{ok:!1,issues:[`${n} must be an integer`]}:{ok:!0,value:t}:{ok:!1,issues:[`${n} must be a number`]}}return r.has(`boolean`)?typeof e==`boolean`?{ok:!0,value:e}:e===`true`||e===`1`?{ok:!0,value:!0}:e===`false`||e===`0`?{ok:!0,value:!1}:{ok:!1,issues:[`${n} must be a boolean`]}:r.has(`null`)?e===null?{ok:!0,value:e}:{ok:!1,issues:[`${n} must be null`]}:{ok:!0,value:e}}function ca(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function la(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}const Y=`[redacted]`;function ua(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function da(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=X(l,t,n,r);i[c]=e.value,a[c]=e.redacted,e.sensitive&&(s=!0,o.push(c))}return{value:i,redacted:a,sensitiveKeys:o,sensitive:s}}function fa(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=_a(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function pa(e,t,n,r){return ba(e,e=>X(e,t,n,r))}function ma(e){return ba(e,e=>Z(e,e,!1,e!==void 0))}function ha(e){return{...e.data===void 0?{}:{data:Y},...e.artifacts?{artifacts:e.artifacts.map(Ta)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function ga(e){return{code:e.code,message:Y,...e.step?{step:e.step}:{},details:{redacted:!0}}}function X(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>X(e,t,n,r));return Z(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Ea(e)){if(!H(e))return Z(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=X(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return Z(i,a,o)}if(`$input`in e){let t=ra(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new V(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=ra(n,i);if(a===void 0)throw new V(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return Z(a,a,!1,!0)}if(`$env`in e){let n=va(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e){let n=va(t.secrets,e.$secret,!0);return Z(n,Y,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>X(e,t,n,r)),a=i.map(e=>ua(e.value)).join(``),o=i.some(e=>e.sensitive);return Z(a,i.map(e=>e.sensitive?Y:ua(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=X(e,t,n,r);if(i.exists&&i.value!==void 0&&i.value!==null)return i}catch(e){a=e;continue}if(a)throw a;return Z(void 0,void 0,!1,!1)}if(`$js`in e){let i=e.$js,a=e.args??{},o={},s={},c=!1;for(let[e,i]of Object.entries(a)){let a=X(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return Z(e,c?Y:e,c)}catch(e){throw new V(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return Z(e,e,!1)}function _a(e,t,n){if(Array.isArray(e)){let r=e.map(e=>_a(e,t,n));return Z(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Ea(e)){if(!H(e))return Z(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=_a(o,t,n);r[a]=e.redacted,i||=e.sensitive}return Z(r,r,i)}if(`$input`in e){let t=ra(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e)return Z({...e},{...e},!1);if(`$env`in e){let n=va(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e)return va(t.secrets,e.$secret,!0),Z(Y,Y,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>_a(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return H(r)&&`$from`in r}))return Z({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>ua(e.value)).join(``),a=r.some(e=>e.sensitive);return Z(i,r.map(e=>e.sensitive?Y:ua(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>H(e)&&`$from`in e))return Z({...e},{...e},!1);for(let e of r){let r=_a(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return Z(void 0,void 0,!1,!1)}return`$js`in e?Z({...e},{...e},!1):Z(e,e,!1)}function va(e,t,n){if(!ya(e,t))throw new V(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding is not declared: ${t}`);let r=e[t],i=typeof r==`string`?{from:`env`,name:r,required:!0}:r,a=i.from===`env`||i.from===void 0?process.env[i.name]:void 0;if(a!==void 0&&a!==``)return a;if(i.default!==void 0)return i.default;if(i.required!==!1)throw new V(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function ya(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Z(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function ba(e,t){if(typeof e==`boolean`)return e;if(H(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof V&&e.code===`pipeline_reference_error`)return!1;throw e}if(H(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw wa(`$and must be a non-empty array`);return e.$and.every(e=>ba(e,t))}if(H(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw wa(`$or must be a non-empty array`);return e.$or.some(e=>ba(e,t))}if(H(e)&&`$not`in e)return!ba(e.$not,t);let n=xa(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Sa(i,a);case`$ne`:return!Sa(i,a);case`$gt`:return Ca(i,a,n.operator)>0;case`$gte`:return Ca(i,a,n.operator)>=0;case`$lt`:return Ca(i,a,n.operator)<0;case`$lte`:return Ca(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw wa(`$in right operand must be an array`);return a.some(e=>Sa(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Sa(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw wa(`$contains left operand must be an array or string`)}}return!!t(e).value}function xa(e){if(H(e)){for(let t of[`$eq`,`$ne`,`$gt`,`$gte`,`$lt`,`$lte`,`$in`,`$contains`])if(t in e){if(!Array.isArray(e[t])||e[t].length!==2)throw wa(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Sa(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ca(e,t,n){if(typeof e==`number`&&Number.isFinite(e)&&typeof t==`number`&&Number.isFinite(t))return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);throw wa(`${n} operands must both be finite numbers or both be strings`)}function wa(e){return new V(`pipeline_condition_error`,e)}function Ta(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Ea(e){return H(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}const Da={description:`Conditional branch selection from a list of cases`,paths:[{path:`/data/selected`,description:`Key of the matched case`},{path:`/data/value`,description:`Value of the matched case`},{path:`/data/matched`,description:`Whether a case was matched (boolean)`}]},Oa={description:`Select first available value from candidates`,paths:[{path:`/data/source`,description:`Source identifier of the selected candidate`},{path:`/data/value`,description:`Value of the selected candidate`},{path:`/data/matched`,description:`Whether a candidate was matched (boolean)`}]},ka={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]};function Aa(e){lr(`logic/switch`,e=>{let t=ja(e.cases);for(let e of t)if(ma(e.condition))return{data:{selected:e.key,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{selected:typeof e.defaultKey==`string`?e.defaultKey:`default`,value:e.defaultValue,matched:!1}};throw new V(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,Da),lr(`logic/select`,e=>{let t=Ma(e.candidates);for(let e of t)if(!(e.available!==void 0&&!ma(e.available))&&e.value!==void 0&&e.value!==null)return{data:{source:e.source,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{source:typeof e.defaultSource==`string`?e.defaultSource:`default`,value:e.defaultValue,matched:!1}};throw new V(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Oa),lr(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=H(e.metadata)?e.metadata:void 0;if(!ma(Na(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new V(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,ka)}function ja(e){if(!Array.isArray(e))throw new V(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Ma(e){if(!Array.isArray(e))throw new V(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Na(e){if(e===void 0)throw new V(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}const Pa={description:`Execute inline JavaScript; output shape is user-defined by the return value`,paths:[{path:`/data`,description:`Return value of the script (user-defined structure)`}]};function Fa(e){lr(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new V(`script_js_error`,`script/js requires a 'code' string input`,{step:`script/js`});let n=e.args??{};try{return{data:Function(`args`,t)(n)??{}}}catch(e){throw new V(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,Pa)}const Ia=new WeakSet;function La(e=cr()){return Ia.has(e)?e:(Ia.add(e),Mr(e),Aa(e),Fa(e),e)}function Ra(e){let t=e.steps.map((t,n)=>({step:t,dependencies:[],dependents:[],index:n+1,total:e.steps.length})),n=new Map(t.map(e=>[e.step.id,e]));for(let r of t){let t=new Set(r.step.dependsOn??[]);U(r.step.input,t),r.step.when!==void 0&&U(r.step.when,t),r.dependencies=Array.from(t).sort((t,n)=>e.steps.findIndex(e=>e.id===t)-e.steps.findIndex(e=>e.id===n));for(let e of r.dependencies)n.get(e)?.dependents.push(r.step.id)}return t}function za(e){let t=new Set(e.map(e=>e.step.id)),n=new Set,r=[];for(;t.size>0;){let i=!1;for(let a of e)t.has(a.step.id)&&a.dependencies.every(e=>n.has(e))&&(r.push(a),n.add(a.step.id),t.delete(a.step.id),i=!0);if(!i)break}return r}function Ba(e,t,n){return e.filter(e=>t.has(e.step.id)?e.dependencies.every(e=>{let t=n.get(e);return t?.status===`succeeded`||t?.status===`failed`||t?.status===`skipped`}):!1)}function Va(e,t){let n=new Map(e.map((e,t)=>[e.step.id,t]));return[...t].sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0))}function Ha(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new V(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,64)}const Ua=`workflow/v1`;function Wa(e,t=cr()){let n=qa(e);return n.length>0?n:Ja(e,t)}function Ga(e,t=cr()){if(qa(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)Za(i.input,i.id,r,t,n);return n}function Ka(e,t){if(!e.inputs)return t;let n=ta(e.inputs,t);if(n.ok)return n.value;throw new V(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function qa(e){let t=[];if(!H(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${Ua}"`),!Array.isArray(e.steps))return t.push(`structural: pipeline.steps must be an array`),t;e.steps.length===0&&t.push(`structural: pipeline.steps must contain at least one step`);for(let[n,r]of e.steps.entries()){if(!H(r)){t.push(`structural: step at index ${n} must be an object`);continue}(!r.id||typeof r.id!=`string`)&&t.push(`structural: step at index ${n} must have a string id`),(!r.type||typeof r.type!=`string`)&&t.push(`structural: step at index ${n} must have a string type`),H(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function Ja(e,t){let n=[];e.inputs&&n.push(...ea(e.inputs,`pipeline.inputs`));let r=e.steps,i=new Set;for(let[e,a]of r.entries()){let r=a.id||`#${e}`;i.has(a.id)&&n.push(`duplicate step id "${a.id}"`),i.add(a.id),t.hasStep(a.type)||n.push(`semantic: step "${r}" references unknown type "${a.type}"`),a.dependsOn!==void 0&&(!Array.isArray(a.dependsOn)||!a.dependsOn.every(e=>typeof e==`string`))&&n.push(`semantic: step "${r}" dependsOn must be an array of step id strings`),a.retry!==void 0&&Xa(a.retry,r,n),a.timeout!==void 0&&hr(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`),a.type===`script/js`&&typeof(H(a.input)?a.input.code:void 0)!=`string`&&n.push(`semantic: step "${r}" (script/js) requires a literal string "code"; code sourced from another step ($from) or an expression is not allowed, since it would execute untrusted text as host code`)}for(let e of r){for(let t of e.dependsOn??[])i.has(t)||n.push(`semantic: step "${e.id}" references missing step "${t}"`),t===e.id&&n.push(`semantic: step "${e.id}" references itself`);Ya(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);U(e.input,t),e.when!==void 0&&U(e.when,t),a.set(e.id,t)}for(let e of Qa(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function Ya(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>Ya(e,t,n,r));return}if(H(e)){`$from`in e&&typeof e.$from==`string`&&(n.has(e.$from)||r.push(`semantic: step "${t}" $from references missing step "${e.$from}"`));for(let i of Object.values(e))Ya(i,t,n,r)}}function Xa(e,t,n){if(!H(e)){n.push(`step "${t}" retry must be an object`);return}let r=e.maxAttempts;r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1)&&n.push(`step "${t}" retry.maxAttempts must be a positive integer`),e.backoff!==void 0&&e.backoff!==`none`&&e.backoff!==`linear`&&e.backoff!==`exponential`&&n.push(`step "${t}" retry.backoff must be none, linear, or exponential`)}function Za(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>Za(e,t,n,r,i));return}if(H(e)){if(`$from`in e&&typeof e.$from==`string`&&typeof e.path==`string`){let a=n.get(e.$from);if(a){let n=r.getOutputSchema(a);if(n){let r=e.path;if(!n.paths.some(e=>r===e.path||r.startsWith(e.path+`/`))){let o=n.paths.map(e=>e.path).join(`, `);i.push(`hint: step "${t}" references path "${r}" from "${e.$from}" (${a}), which is not a known output path. Known paths: ${o}`)}}}return}for(let a of Object.values(e))Za(a,t,n,r,i)}}function Qa(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(n.has(o)){let e=i.indexOf(o);t.push([...i.slice(e),o]);return}if(!r.has(o)){n.add(o),i.push(o);for(let t of e.get(o)??[])e.has(t)&&a(t);i.pop(),n.delete(o),r.add(o)}};for(let t of e.keys())a(t);return t}async function $a(e,t={},n={}){return await to(e,t,n)}async function*eo(e,t={},n={}){let r=new fo(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;to(e,t,{...n,signal:i.signal,onEvent:async e=>{await r.push(e)}}).then(()=>{o=!0,r.close()},e=>{s=e,o=!0,r.close()});try{for(;!o||r.size>0;){let e=await r.shift();if(e){yield e;continue}if(s)throw s}if(s)throw s}finally{i.abort(),n.signal?.removeEventListener(`abort`,a),r.close()}}async function to(e,t,n){let r=n.stepDispatcher??cr(),i=Wa(e,r);if(i.length>0)throw new V(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=Ka(e,t);if(n.basePath){let t=await gr(e.steps,n.basePath);if(t.length>0)throw new V(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=ur(),s=Ra(e),c=Ha(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Q(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of za(s)){let n=fa(t.step,e,a),r={id:t.step.id,type:t.step.type,status:`planned`,dependencies:t.dependencies,input:n.redacted,...t.step.when===void 0?{}:{condition:`pending`}};l.push(r),await p({type:`step.input.resolved`,timestamp:Q(),status:`planned`,step:$(t),input:ao(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Q(),status:`planned`,step:$(t),input:ao(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Q(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:Ua,steps:l,artifacts:f}}let m=new Set(s.map(e=>e.step.id)),h=new Map;for(;m.size>0||h.size>0;){let t=!1;for(let i of Ba(s,m,u)){if(h.size>=c)break;if(!m.has(i.step.id))continue;let s=i.dependencies.map(e=>u.get(e)),g=s.find(e=>e?.status===`failed`);if(g){let e=`dependency ${g.id} failed`;io(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(s.length>0&&s.every(e=>e?.status===`skipped`)){let e=`all dependencies skipped`;io(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||pa(i.step.when,e,a,d))){let e=`condition evaluated to false`;io(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e,condition:`false`}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=no(i,e,a,d,f,p,n,o,r);h.set(i.step.id,_),m.delete(i.step.id),t=!0}if(h.size>0){let e=await Promise.race(h.values());h.delete(e.id),io(l,u,e),t=!0}if(!t)throw new V(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=Va(s,l),_=g.find(e=>e.status===`failed`);if(_?.error){let e=s.find(e=>e.step.id===_.id);return await p({type:`pipeline.failed`,timestamp:Q(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?$(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:Ua,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Q(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:Ua,steps:g,artifacts:f}}async function no(e,t,n,r,i,a,o,s,c){let l=Math.max(1,Math.floor(e.step.retry?.maxAttempts??1)),u,d,f=!1,p=new Date().toISOString(),m=p;for(let h=1;h<=l;h++){p=new Date().toISOString(),await a({type:`step.started`,timestamp:Q(),status:`running`,step:$(e),timing:{startedAt:p},attempt:h});try{let l=da(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=pr(u,o.basePath);u=t.input,g=pr(l.redacted,o.basePath).input;let n=await mr(u,t.resolvedKeys.filter(e=>!dr.includes(e)),e.step.id);if(n.length>0)throw new V(`pipeline_file_not_found`,n.join(`; `),{step:e.step.type,details:{issues:n}})}d=g,f=l.sensitive,await a({type:`step.input.resolved`,timestamp:Q(),status:`running`,step:$(e),input:ao(g,l.sensitiveKeys)});let _=await ro(e.step,u,o,$(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?ha(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Q(),status:`running`,step:$(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Q(),status:`running`,step:$(e),timing:co(p,m),output:oo(v),attempt:h,...v.warnings&&v.warnings.length>0?{warnings:v.warnings}:{}}),{id:e.step.id,type:e.step.type,status:`succeeded`,dependencies:e.dependencies,input:l.redacted,output:v,startedAt:p,finishedAt:m,attempts:h,...e.step.when===void 0?{}:{condition:`true`}}}catch(t){let n=ar(t,e.step.type);if(u=f?ga(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Q(),status:`running`,step:$(e),attempt:h,nextAttempt:h+1,error:u});let t=lo(e.step.retry?.backoff,h,o.retryDelayBaseMs??100);t>0&&await(o.sleep??uo)(t);continue}}}let h=u??{code:`pipeline_step_failed`,message:`Step ${e.step.id} failed`,step:e.step.type,details:{}};return await a({type:`step.failed`,timestamp:Q(),status:`failed`,step:$(e),timing:co(p,m),attempt:l,error:h}),{id:e.step.id,type:e.step.type,status:`failed`,dependencies:e.dependencies,...d?{input:d}:{},error:h,startedAt:p,finishedAt:m,attempts:l}}async function ro(e,t,n,r,i,a,o){let s=hr(e.timeout)??n.timeoutSeconds,c={dryRun:!1,signal:n.signal,timeoutSeconds:s,blRequestTimeoutSeconds:n.blRequestTimeoutSeconds,emitEvent:async e=>{e.type===`step.polling`&&await i({...e,type:`step.polling`,timestamp:e.timestamp??Q(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blEnv:a};if(!s)return await o.executeStep(e.type,t,c);let l=new AbortController,u=()=>l.abort();n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0});let d=s*1e3,f=setTimeout(()=>l.abort(),d);c.signal=l.signal;try{return await Promise.race([o.executeStep(e.type,t,c),new Promise((t,n)=>{l.signal.addEventListener(`abort`,()=>{n(new V(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function io(e,t,n){e.push(n),t.set(n.id,n)}function Q(){return new Date().toISOString()}function $(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function ao(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function oo(e){return{...e.data===void 0?{}:{dataType:so(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function so(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function co(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function lo(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function uo(e){return new Promise(t=>setTimeout(t,e))}var fo=class{items=[];takers=[];pushWaiters=[];closed=!1;maxSize;constructor(e){this.maxSize=e}get size(){return this.items.length}async push(e){for(;!this.closed&&this.items.length>=this.maxSize;)await new Promise(e=>this.pushWaiters.push(e));if(this.closed)return;let t=this.takers.shift();if(t){t(e);return}this.items.push(e)}async shift(){let e=this.items.shift();if(e!==void 0)return this.wakePushWaiter(),e;if(!this.closed)return await new Promise(e=>this.takers.push(e))}close(){if(!this.closed){this.closed=!0;for(let e of this.takers.splice(0))e(void 0);for(let e of this.pushWaiters.splice(0))e()}}wakePushWaiter(){this.pushWaiters.shift()?.()}};export{Tt as API_KEY_PAGE,wt as BAILIAN_CONSOLE,Ct as BAILIAN_CONSOLE_ROOT,ir as BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,nr as BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,rr as BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,tr as BOOL_FLAG_WATERMARK,Tn as CLI_VERSION,Ge as CommandRegistry,Xe as NPM_PACKAGE,Ye as NPM_REGISTRY,Et as TOKEN_PLAN_PAGE,Dt as VOICE_TTS_PAGE,F as ansi,mt as checkForUpdate,Ga as collectPipelineHints,Wa as collectPipelineIssues,ht as compose,wn as createCli,Kn as createProgressBar,Gn as createSpinner,B as displayWidth,Jn as downloadFile,Qn as downloadParallel,Dn as emitBare,En as emitResult,$a as executePipeline,ct as fetchLatestVersion,Yn as formatBytes,On as formatTable,Xn as getConcurrency,ut as getPendingUpdateNotification,z as handleError,La as initPipelineSteps,He as isTerminal,Je as maybeShowStatusBar,An as padEnd,Be as parseFlags,ze as parsePath,qn as poll,zt as printQuickStart,Rt as printWelcomeBanner,Un as renderBoxTable,Ke as resolve,er as resolveImageSize,Zn as runConcurrent,St as setupProxyFromEnv,eo as streamPipelineEvents,Ue as supportsColor};
59
+ 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})),Pi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)}}})),Fi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=q(),i=K();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)}}}})),Ii=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ni(),n=J(),r=K(),i=Fi();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)}}}})),Li=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=G(),r=K(),i=K();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())})})}}}})),Ri=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`}}})),zi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:J().validateUnion,error:{message:`must match a schema in anyOf`}}})),Bi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K();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)})})}}}})),Vi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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)})}}})),Hi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=K(),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})),Ui=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=K();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`)}}})),Wi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Oi(),n=Ai(),r=ki(),i=ji(),a=Mi(),o=Ni(),s=Pi(),c=Fi(),l=Ii(),u=Li(),d=Ri(),f=zi(),p=Bi(),m=Vi(),h=Hi(),g=Ui();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=_})),Gi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();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})`}}}}})),Ki=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[Gi().default]})),qi=P((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`]})),Ji=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=mi(),n=Di(),r=Wi(),i=Ki(),a=qi();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),Yi=P((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={}))})),Xi=P((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G(),n=Yi(),r=ai(),i=ii(),a=K();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=_();o.if(!1);for(let e in 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}}}}})),Zi=P(((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}}));const Qi=Fe(P(((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=di(),r=Ji(),i=Xi(),a=Zi(),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=ni();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=G();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=ri();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=ii();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}))(),1).default,$i=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),ea=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),ta=new Qi({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1});function na(e,t=`schema`){let n=[];return oa(e,t,n),n.length===0&&!ta.validateSchema(e)&&n.push(...sa(ta.errors,t)),n}function ra(e,t){let n=la(t,e,`input`);return n.ok?U(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function ia(e){if(e===``)return{ok:!0,segments:[]};if(!e.startsWith(`/`))return{ok:!1,segments:[],issue:`must start with /`};let t=e.slice(1).split(`/`),n=[];for(let e of t){if(e.match(/~(?![01])/))return{ok:!1,segments:[],issue:`contains invalid escape sequence`};n.push(e.replace(/~1/g,`/`).replace(/~0/g,`~`))}return{ok:!0,segments:n}}function aa(e,t){let n=ia(t);if(!n.ok)return;let r=e;for(let e of n.segments){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(U(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function oa(e,t,n){if(!U(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))$i.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&ca(e.type,`${t}.type`,n),`properties`in e)if(!U(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))oa(i,`${t}.properties.${r}`,n);if(`items`in e&&oa(e.items,`${t}.items`,n),`required`in e&&(!Array.isArray(e.required)||!e.required.every(e=>typeof e==`string`))&&n.push(`${t}.required must be an array of strings`),`enum`in e&&!Array.isArray(e.enum)&&n.push(`${t}.enum must be an array`),`description`in e&&typeof e.description!=`string`&&n.push(`${t}.description must be a string`),`format`in e&&typeof e.format!=`string`&&n.push(`${t}.format must be a string`),`additionalProperties`in e){let r=e.additionalProperties;r!==!0&&r!==!1&&!U(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):U(r)&&oa(r,`${t}.additionalProperties`,n)}}function sa(e,t){return!e||e.length===0?[`${t} is invalid`]:e.map(e=>`${e.instancePath?`${t}${e.instancePath.replace(/\//g,`.`)}`:t} ${e.message??`is invalid`}${e.keyword?` (${e.keyword})`:``}`)}function ca(e,t,n){let r=Array.isArray(e)?e:[e];if(r.length===0){n.push(`${t} must not be empty`);return}for(let e of r)ea.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function la(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(da);if(!r.includes(da(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=ua(t);if(r.size===0)return{ok:!0,value:e};if(r.size>1){if(Array.isArray(e)&&r.has(`array`)){if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=la(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(!(U(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!U(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!U(e))return{ok:!1,issues:[`${n} must be an object`]};let r={...e},i=[];for(let e of t.required??[]){let t=r[e];(t==null||t===``)&&i.push(`Missing required input "${e}"`)}for(let[e,a]of Object.entries(t.properties??{})){let t=r[e];if((t==null||t===``)&&a.default===void 0)continue;let o=la(t,a,`${n}.${e}`);o.ok?r[e]=o.value:i.push(...o.issues)}if(t.additionalProperties===!1)for(let e of Object.keys(r))t.properties?.[e]||i.push(`Unknown input "${e}"`);return i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`array`)){if(!Array.isArray(e))return{ok:!1,issues:[`${n} must be an array`]};if(!t.items)return{ok:!0,value:e};let r=[],i=[];return e.forEach((e,a)=>{let o=la(e,t.items,`${n}.${a}`);o.ok?r[a]=o.value:i.push(...o.issues)}),i.length>0?{ok:!1,issues:i}:{ok:!0,value:r}}if(r.has(`string`))return{ok:!0,value:String(e)};if(r.has(`number`)||r.has(`integer`)){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?r.has(`integer`)&&!Number.isInteger(t)?{ok:!1,issues:[`${n} must be an integer`]}:{ok:!0,value:t}:{ok:!1,issues:[`${n} must be a number`]}}return r.has(`boolean`)?typeof e==`boolean`?{ok:!0,value:e}:e===`true`||e===`1`?{ok:!0,value:!0}:e===`false`||e===`0`?{ok:!0,value:!1}:{ok:!1,issues:[`${n} must be a boolean`]}:r.has(`null`)?e===null?{ok:!0,value:e}:{ok:!1,issues:[`${n} must be null`]}:{ok:!0,value:e}}function ua(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function da(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}const Y=`[redacted]`;function fa(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function pa(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=X(l,t,n,r);i[c]=e.value,a[c]=e.redacted,e.sensitive&&(s=!0,o.push(c))}return{value:i,redacted:a,sensitiveKeys:o,sensitive:s}}function ma(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=ya(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function ha(e,t,n,r){return Sa(e,e=>X(e,t,n,r))}function ga(e){return Sa(e,e=>Z(e,e,!1,e!==void 0))}function _a(e){return{...e.data===void 0?{}:{data:Y},...e.artifacts?{artifacts:e.artifacts.map(Da)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function va(e){return{code:e.code,message:Y,...e.step?{step:e.step}:{},details:{redacted:!0}}}function X(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>X(e,t,n,r));return Z(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Oa(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=X(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return Z(i,a,o)}if(`$input`in e){let t=aa(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new H(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=aa(n,i);if(a===void 0)throw new H(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return Z(a,a,!1,!0)}if(`$env`in e){let n=ba(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e){let n=ba(t.secrets,e.$secret,!0);return Z(n,Y,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>X(e,t,n,r)),a=i.map(e=>fa(e.value)).join(``),o=i.some(e=>e.sensitive);return Z(a,i.map(e=>e.sensitive?Y:fa(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=X(e,t,n,r);if(i.exists&&i.value!==void 0&&i.value!==null)return i}catch(e){a=e;continue}if(a)throw a;return Z(void 0,void 0,!1,!1)}if(`$js`in e){let i=e.$js,a=e.args??{},o={},s={},c=!1;for(let[e,i]of Object.entries(a)){let a=X(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return Z(e,c?Y:e,c)}catch(e){throw new H(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return Z(e,e,!1)}function ya(e,t,n){if(Array.isArray(e)){let r=e.map(e=>ya(e,t,n));return Z(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Oa(e)){if(!U(e))return Z(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=ya(o,t,n);r[a]=e.redacted,i||=e.sensitive}return Z(r,r,i)}if(`$input`in e){let t=aa(n,e.$input);return Z(t,t,!1,t!==void 0)}if(`$from`in e)return Z({...e},{...e},!1);if(`$env`in e){let n=ba(t.env,e.$env,!1);return Z(n,n,!1,n!==void 0)}if(`$secret`in e)return ba(t.secrets,e.$secret,!0),Z(Y,Y,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>ya(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return U(r)&&`$from`in r}))return Z({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>fa(e.value)).join(``),a=r.some(e=>e.sensitive);return Z(i,r.map(e=>e.sensitive?Y:fa(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>U(e)&&`$from`in e))return Z({...e},{...e},!1);for(let e of r){let r=ya(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return Z(void 0,void 0,!1,!1)}return`$js`in e?Z({...e},{...e},!1):Z(e,e,!1)}function ba(e,t,n){if(!xa(e,t))throw new H(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding is not declared: ${t}`);let r=e[t],i=typeof r==`string`?{from:`env`,name:r,required:!0}:r,a=i.from===`env`||i.from===void 0?process.env[i.name]:void 0;if(a!==void 0&&a!==``)return a;if(i.default!==void 0)return i.default;if(i.required!==!1)throw new H(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function xa(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Z(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Sa(e,t){if(typeof e==`boolean`)return e;if(U(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof H&&e.code===`pipeline_reference_error`)return!1;throw e}if(U(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Ea(`$and must be a non-empty array`);return e.$and.every(e=>Sa(e,t))}if(U(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Ea(`$or must be a non-empty array`);return e.$or.some(e=>Sa(e,t))}if(U(e)&&`$not`in e)return!Sa(e.$not,t);let n=Ca(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return wa(i,a);case`$ne`:return!wa(i,a);case`$gt`:return Ta(i,a,n.operator)>0;case`$gte`:return Ta(i,a,n.operator)>=0;case`$lt`:return Ta(i,a,n.operator)<0;case`$lte`:return Ta(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Ea(`$in right operand must be an array`);return a.some(e=>wa(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>wa(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Ea(`$contains left operand must be an array or string`)}}return!!t(e).value}function Ca(e){if(U(e)){for(let t of[`$eq`,`$ne`,`$gt`,`$gte`,`$lt`,`$lte`,`$in`,`$contains`])if(t in e){if(!Array.isArray(e[t])||e[t].length!==2)throw Ea(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function wa(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ta(e,t,n){if(typeof e==`number`&&Number.isFinite(e)&&typeof t==`number`&&Number.isFinite(t))return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);throw Ea(`${n} operands must both be finite numbers or both be strings`)}function Ea(e){return new H(`pipeline_condition_error`,e)}function Da(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Oa(e){return U(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}const ka={description:`Conditional branch selection from a list of cases`,paths:[{path:`/data/selected`,description:`Key of the matched case`},{path:`/data/value`,description:`Value of the matched case`},{path:`/data/matched`,description:`Whether a case was matched (boolean)`}]},Aa={description:`Select first available value from candidates`,paths:[{path:`/data/source`,description:`Source identifier of the selected candidate`},{path:`/data/value`,description:`Value of the selected candidate`},{path:`/data/matched`,description:`Whether a candidate was matched (boolean)`}]},ja={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]};function Ma(e){ur(`logic/switch`,e=>{let t=Na(e.cases);for(let e of t)if(ga(e.condition))return{data:{selected:e.key,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{selected:typeof e.defaultKey==`string`?e.defaultKey:`default`,value:e.defaultValue,matched:!1}};throw new H(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,ka),ur(`logic/select`,e=>{let t=Pa(e.candidates);for(let e of t)if(!(e.available!==void 0&&!ga(e.available))&&e.value!==void 0&&e.value!==null)return{data:{source:e.source,value:e.value,matched:!0}};if(`defaultValue`in e)return{data:{source:typeof e.defaultSource==`string`?e.defaultSource:`default`,value:e.defaultValue,matched:!1}};throw new H(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Aa),ur(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=U(e.metadata)?e.metadata:void 0;if(!ga(Fa(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new H(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,ja)}function Na(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Pa(e){if(!Array.isArray(e))throw new H(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Fa(e){if(e===void 0)throw new H(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}const Ia={description:`Execute inline JavaScript; output shape is user-defined by the return value`,paths:[{path:`/data`,description:`Return value of the script (user-defined structure)`}]};function La(e){ur(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new H(`script_js_error`,`script/js requires a 'code' string input`,{step:`script/js`});let n=e.args??{};try{return{data:Function(`args`,t)(n)??{}}}catch(e){throw new H(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,Ia)}const Ra=new WeakSet;function za(e=lr()){return Ra.has(e)?e:(Ra.add(e),Pr(e),Ma(e),La(e),e)}function Ba(e){let t=e.steps.map((t,n)=>({step:t,dependencies:[],dependents:[],index:n+1,total:e.steps.length})),n=new Map(t.map(e=>[e.step.id,e]));for(let r of t){let t=new Set(r.step.dependsOn??[]);_r(r.step.input,t),r.step.when!==void 0&&_r(r.step.when,t),r.dependencies=Array.from(t).sort((t,n)=>e.steps.findIndex(e=>e.id===t)-e.steps.findIndex(e=>e.id===n));for(let e of r.dependencies)n.get(e)?.dependents.push(r.step.id)}return t}function Va(e){let t=new Set(e.map(e=>e.step.id)),n=new Set,r=[];for(;t.size>0;){let i=!1;for(let a of e)t.has(a.step.id)&&a.dependencies.every(e=>n.has(e))&&(r.push(a),n.add(a.step.id),t.delete(a.step.id),i=!0);if(!i)break}return r}function Ha(e,t,n){return e.filter(e=>t.has(e.step.id)?e.dependencies.every(e=>{let t=n.get(e);return t?.status===`succeeded`||t?.status===`failed`||t?.status===`skipped`}):!1)}function Ua(e,t){let n=new Map(e.map((e,t)=>[e.step.id,t]));return[...t].sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0))}function Wa(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new H(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,64)}const Ga=`workflow/v1`;function Ka(e,t=lr()){let n=Ya(e);return n.length>0?n:Xa(e,t)}function qa(e,t=lr()){if(Ya(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)$a(i.input,i.id,r,t,n);return n}function Ja(e,t){if(!e.inputs)return t;let n=ra(e.inputs,t);if(n.ok)return n.value;throw new H(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function Ya(e){let t=[];if(!U(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${Ga}"`),!Array.isArray(e.steps))return t.push(`structural: pipeline.steps must be an array`),t;e.steps.length===0&&t.push(`structural: pipeline.steps must contain at least one step`);for(let[n,r]of e.steps.entries()){if(!U(r)){t.push(`structural: step at index ${n} must be an object`);continue}(!r.id||typeof r.id!=`string`)&&t.push(`structural: step at index ${n} must have a string id`),(!r.type||typeof r.type!=`string`)&&t.push(`structural: step at index ${n} must have a string type`),U(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function Xa(e,t){let n=[];e.inputs&&n.push(...na(e.inputs,`pipeline.inputs`));let r=e.steps,i=new Set;for(let[e,a]of r.entries()){let r=a.id||`#${e}`;i.has(a.id)&&n.push(`duplicate step id "${a.id}"`),i.add(a.id),t.hasStep(a.type)||n.push(`semantic: step "${r}" references unknown type "${a.type}"`),a.dependsOn!==void 0&&(!Array.isArray(a.dependsOn)||!a.dependsOn.every(e=>typeof e==`string`))&&n.push(`semantic: step "${r}" dependsOn must be an array of step id strings`),a.retry!==void 0&&Qa(a.retry,r,n),a.timeout!==void 0&&gr(a.timeout)===void 0&&n.push(`semantic: step "${r}" timeout must be a positive number of seconds or duration string`),a.type===`script/js`&&typeof(U(a.input)?a.input.code:void 0)!=`string`&&n.push(`semantic: step "${r}" (script/js) requires a literal string "code"; code sourced from another step ($from) or an expression is not allowed, since it would execute untrusted text as host code`)}for(let e of r){for(let t of e.dependsOn??[])i.has(t)||n.push(`semantic: step "${e.id}" references missing step "${t}"`),t===e.id&&n.push(`semantic: step "${e.id}" references itself`);Za(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);_r(e.input,t),e.when!==void 0&&_r(e.when,t),a.set(e.id,t)}for(let e of eo(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function Za(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>Za(e,t,n,r));return}if(U(e)){`$from`in e&&typeof e.$from==`string`&&(n.has(e.$from)||r.push(`semantic: step "${t}" $from references missing step "${e.$from}"`));for(let i of Object.values(e))Za(i,t,n,r)}}function Qa(e,t,n){if(!U(e)){n.push(`step "${t}" retry must be an object`);return}let r=e.maxAttempts;r!==void 0&&(typeof r!=`number`||!Number.isInteger(r)||r<1)&&n.push(`step "${t}" retry.maxAttempts must be a positive integer`),e.backoff!==void 0&&e.backoff!==`none`&&e.backoff!==`linear`&&e.backoff!==`exponential`&&n.push(`step "${t}" retry.backoff must be none, linear, or exponential`)}function $a(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>$a(e,t,n,r,i));return}if(U(e)){if(`$from`in e&&typeof e.$from==`string`&&typeof e.path==`string`){let a=n.get(e.$from);if(a){let n=r.getOutputSchema(a);if(n){let r=e.path;if(!n.paths.some(e=>r===e.path||r.startsWith(e.path+`/`))){let o=n.paths.map(e=>e.path).join(`, `);i.push(`hint: step "${t}" references path "${r}" from "${e.$from}" (${a}), which is not a known output path. Known paths: ${o}`)}}}return}for(let a of Object.values(e))$a(a,t,n,r,i)}}function eo(e){let t=[],n=new Set,r=new Set,i=[],a=o=>{if(n.has(o)){let e=i.indexOf(o);t.push([...i.slice(e),o]);return}if(!r.has(o)){n.add(o),i.push(o);for(let t of e.get(o)??[])e.has(t)&&a(t);i.pop(),n.delete(o),r.add(o)}};for(let t of e.keys())a(t);return t}async function to(e,t={},n={}){return await ro(e,t,n)}async function*no(e,t={},n={}){let r=new mo(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;ro(e,t,{...n,signal:i.signal,onEvent:async e=>{await r.push(e)}}).then(()=>{o=!0,r.close()},e=>{s=e,o=!0,r.close()});try{for(;!o||r.size>0;){let e=await r.shift();if(e){yield e;continue}if(s)throw s}if(s)throw s}finally{i.abort(),n.signal?.removeEventListener(`abort`,a),r.close()}}async function ro(e,t,n){let r=n.stepDispatcher??lr(),i=Ka(e,r);if(i.length>0)throw new H(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=Ja(e,t);if(n.basePath){let t=await vr(e.steps,n.basePath);if(t.length>0)throw new H(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=dr(),s=Ba(e),c=Wa(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Q(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of Va(s)){let n=ma(t.step,e,a),r={id:t.step.id,type:t.step.type,status:`planned`,dependencies:t.dependencies,input:n.redacted,...t.step.when===void 0?{}:{condition:`pending`}};l.push(r),await p({type:`step.input.resolved`,timestamp:Q(),status:`planned`,step:$(t),input:so(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Q(),status:`planned`,step:$(t),input:so(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Q(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:Ga,steps:l,artifacts:f}}let m=new Set(s.map(e=>e.step.id)),h=new Map;for(;m.size>0||h.size>0;){let t=!1;for(let i of Ha(s,m,u)){if(h.size>=c)break;if(!m.has(i.step.id))continue;let s=i.dependencies.map(e=>u.get(e)),g=s.find(e=>e?.status===`failed`);if(g){let e=`dependency ${g.id} failed`;oo(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(s.length>0&&s.every(e=>e?.status===`skipped`)){let e=`all dependencies skipped`;oo(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||ha(i.step.when,e,a,d))){let e=`condition evaluated to false`;oo(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e,condition:`false`}),await p({type:`step.skipped`,timestamp:Q(),status:`running`,step:$(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=io(i,e,a,d,f,p,n,o,r);h.set(i.step.id,_),m.delete(i.step.id),t=!0}if(h.size>0){let e=await Promise.race(h.values());h.delete(e.id),oo(l,u,e),t=!0}if(!t)throw new H(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=Ua(s,l),_=g.find(e=>e.status===`failed`);if(_?.error){let e=s.find(e=>e.step.id===_.id);return await p({type:`pipeline.failed`,timestamp:Q(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?$(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:Ga,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Q(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:Ga,steps:g,artifacts:f}}async function io(e,t,n,r,i,a,o,s,c){let l=Math.max(1,Math.floor(e.step.retry?.maxAttempts??1)),u,d,f=!1,p=new Date().toISOString(),m=p;for(let h=1;h<=l;h++){p=new Date().toISOString(),await a({type:`step.started`,timestamp:Q(),status:`running`,step:$(e),timing:{startedAt:p},attempt:h});try{let l=pa(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=mr(u,o.basePath);u=t.input,g=mr(l.redacted,o.basePath).input;let n=await hr(u,t.resolvedKeys.filter(e=>!fr.includes(e)),e.step.id);if(n.length>0)throw new H(`pipeline_file_not_found`,n.join(`; `),{step:e.step.type,details:{issues:n}})}d=g,f=l.sensitive,await a({type:`step.input.resolved`,timestamp:Q(),status:`running`,step:$(e),input:so(g,l.sensitiveKeys)});let _=await ao(e.step,u,o,$(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?_a(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Q(),status:`running`,step:$(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Q(),status:`running`,step:$(e),timing:uo(p,m),output:co(v),attempt:h,...v.warnings&&v.warnings.length>0?{warnings:v.warnings}:{}}),{id:e.step.id,type:e.step.type,status:`succeeded`,dependencies:e.dependencies,input:l.redacted,output:v,startedAt:p,finishedAt:m,attempts:h,...e.step.when===void 0?{}:{condition:`true`}}}catch(t){let n=or(t,e.step.type);if(u=f?va(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Q(),status:`running`,step:$(e),attempt:h,nextAttempt:h+1,error:u});let t=fo(e.step.retry?.backoff,h,o.retryDelayBaseMs??100);t>0&&await(o.sleep??po)(t);continue}}}let h=u??{code:`pipeline_step_failed`,message:`Step ${e.step.id} failed`,step:e.step.type,details:{}};return await a({type:`step.failed`,timestamp:Q(),status:`failed`,step:$(e),timing:uo(p,m),attempt:l,error:h}),{id:e.step.id,type:e.step.type,status:`failed`,dependencies:e.dependencies,...d?{input:d}:{},error:h,startedAt:p,finishedAt:m,attempts:l}}async function ao(e,t,n,r,i,a,o){let s=gr(e.timeout)??n.timeoutSeconds,c={dryRun:!1,signal:n.signal,timeoutSeconds:s,blRequestTimeoutSeconds:n.blRequestTimeoutSeconds,emitEvent:async e=>{e.type===`step.polling`&&await i({...e,type:`step.polling`,timestamp:e.timestamp??Q(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blEnv:a};if(!s)return await o.executeStep(e.type,t,c);let l=new AbortController,u=()=>l.abort();n.signal?.aborted?u():n.signal?.addEventListener(`abort`,u,{once:!0});let d=s*1e3,f=setTimeout(()=>l.abort(),d);c.signal=l.signal;try{return await Promise.race([o.executeStep(e.type,t,c),new Promise((t,n)=>{l.signal.addEventListener(`abort`,()=>{n(new H(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function oo(e,t,n){e.push(n),t.set(n.id,n)}function Q(){return new Date().toISOString()}function $(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function so(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function co(e){return{...e.data===void 0?{}:{dataType:lo(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function lo(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function uo(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function fo(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function po(e){return new Promise(t=>setTimeout(t,e))}var mo=class{items=[];takers=[];pushWaiters=[];closed=!1;maxSize;constructor(e){this.maxSize=e}get size(){return this.items.length}async push(e){for(;!this.closed&&this.items.length>=this.maxSize;)await new Promise(e=>this.pushWaiters.push(e));if(this.closed)return;let t=this.takers.shift();if(t){t(e);return}this.items.push(e)}async shift(){let e=this.items.shift();if(e!==void 0)return this.wakePushWaiter(),e;if(!this.closed)return await new Promise(e=>this.takers.push(e))}close(){if(!this.closed){this.closed=!0;for(let e of this.takers.splice(0))e(void 0);for(let e of this.pushWaiters.splice(0))e()}}wakePushWaiter(){this.pushWaiters.shift()?.()}};export{wt as API_KEY_PAGE,Ct as BAILIAN_CONSOLE,St as BAILIAN_CONSOLE_ROOT,ar as BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT,rr as BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE,ir as BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE,nr as BOOL_FLAG_WATERMARK,En as CLI_VERSION,We as CommandRegistry,Dt as MCP_WEBSEARCH_PAGE,Ye as NPM_PACKAGE,Je as NPM_REGISTRY,Tt as TOKEN_PLAN_PAGE,Ot as VOICE_TTS_PAGE,I as ansi,pt as checkForUpdate,qa as collectPipelineHints,Ka as collectPipelineIssues,mt as compose,Tn as createCli,qn as createProgressBar,Kn as createSpinner,V as displayWidth,Yn as downloadFile,$n as downloadParallel,On as emitBare,Dn as emitResult,to as executePipeline,st as fetchLatestVersion,Xn as formatBytes,kn as formatTable,Zn as getConcurrency,lt as getPendingUpdateNotification,B as handleError,za as initPipelineSteps,Ve as isTerminal,qe as maybeShowStatusBar,Et as mcpMarketplaceDetailPage,jn as padEnd,ze as parseFlags,Re as parsePath,Jn as poll,Bt as printQuickStart,zt as printWelcomeBanner,Wn as renderBoxTable,Ge as resolve,tr as resolveImageSize,Qn as runConcurrent,xt as setupProxyFromEnv,no as streamPipelineEvents,He as supportsColor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bailian-cli-runtime",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Runtime framework for bailian-cli (createCli, registry, args, output, pipeline). See https://www.npmjs.com/package/bailian-cli for usage.",
5
5
  "homepage": "https://bailian.console.aliyun.com/cli",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "boxen": "^8.0.1",
31
31
  "chalk": "^5.6.2",
32
32
  "undici": "^6.27.0",
33
- "bailian-cli-core": "1.11.1"
33
+ "bailian-cli-core": "1.11.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@clack/prompts": "^0.7.0",