bailian-cli 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bailian.mjs CHANGED
@@ -1,185 +1,201 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{createRequire as e}from"node:module";import{BailianError as t,CONSOLE_GATEWAY_NO_TOKEN_MESSAGE as n,DOCS_HOSTS as r,ExitCode as i,GLOBAL_OPTIONS as a,McpClient as o,analyzeIntent as s,appCompletionEndpoint as c,bailianMcpUrl as l,buildDocLink as u,callConsoleGateway as d,chatEndpoint as f,clearApiKey as p,defineCommand as m,detectOutputFormat as h,flushTelemetry as g,formatOutput as _,generateFilename as v,generateToolSchema as y,getConfigDir as b,getConfigPath as x,getModels as S,imageEndpoint as C,imageSyncEndpoint as w,isInteractive as T,isLocalFile as E,loadConfig as ee,maskToken as D,mcpWebSearchEndpoint as te,memoryAddEndpoint as ne,memoryListEndpoint as re,memoryNodeEndpoint as ie,memorySearchEndpoint as ae,parseSSE as oe,profileSchemaEndpoint as se,rankModels as ce,readConfigFile as le,recallSemantic as ue,request as de,requestJson as O,resolveBooleanFlag as fe,resolveConsoleGatewayCredential as pe,resolveCredential as k,resolveFileUrl as A,resolveOutputDir as me,resolveWatermark as he,signRequest as ge,speechRecognizeEndpoint as _e,speechSynthesizeEndpoint as ve,stripUndefined as ye,taskEndpoint as be,trackCommandExecution as xe,trackingHeaders as Se,uploadFile as Ce,userProfileEndpoint as we,videoGenerateEndpoint as Te,writeConfigFile as Ee}from"bailian-cli-core";import De,{stdin as Oe,stdout as ke}from"node:process";import*as Ae from"node:readline";import je from"node:readline";import{WriteStream as Me}from"node:tty";import{execFile as Ne}from"node:child_process";import{randomBytes as Pe}from"node:crypto";import Fe from"node:http";import{createWriteStream as Ie,existsSync as Le,mkdirSync as Re,readFileSync as ze,unlinkSync as Be,writeFileSync as Ve}from"fs";import{dirname as He,extname as Ue,join as We}from"path";import{execSync as Ge}from"child_process";import{access as Ke,mkdir as qe,readFile as Je}from"node:fs/promises";import{dirname as Ye,extname as Xe,join as Ze,resolve as Qe}from"node:path";import $e from"boxen";import et,{Chalk as tt}from"chalk";import{homedir as nt}from"os";var rt=Object.create,it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ot=Object.getOwnPropertyNames,st=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty,j=(e,t)=>()=>(e&&(t=e(e=0)),t),M=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),lt=(e,t)=>{let n={};for(var r in e)it(n,r,{get:e[r],enumerable:!0});return t||it(n,Symbol.toStringTag,{value:`Module`}),n},ut=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ot(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ct.call(e,s)&&s!==n&&it(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=at(t,s))||r.enumerable});return e},dt=(e,t,n)=>(n=e==null?{}:rt(st(e)),ut(t||!e||!e.__esModule?it(n,`default`,{value:e,enumerable:!0}):n,e)),ft=e(import.meta.url);function pt(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function mt(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?pt(t[1]):null}function ht(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function gt(e){let t=new Set;for(let n of e){let e=mt(n);e&&t.add(e)}return t}function _t(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=mt(i);e&&(ht(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function vt(e,t=[]){let n=_t(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=pt(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function yt(e,n){let r=gt(n),a=_t(n),o={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},s=0;for(;s<e.length;){let n=e[s];if(n===`--help`||n===`-h`){o.help=!0,s++;continue}if(n===`--`)break;if(n.startsWith(`--`)){let c=n.indexOf(`=`),l,u;c===-1?l=n.slice(2):(l=n.slice(2,c),u=n.slice(c+1));let d=pt(l);if(!r.has(d))throw new t(`Unknown flag "--${l}". Run with --help to see available options.`,i.USAGE);if(a.booleans.has(d)){o[d]=!0,s++;continue}if(u===void 0){s++;let n=e[s];if(n===void 0||n.startsWith(`-`))throw new t(`Flag --${l} requires a value.`,i.USAGE);u=n}if(a.arrays.has(d)){let e=o[d];e?e.push(u):o[d]=[u]}else if(a.numbers.has(d)){let e=Number(u);if(!Number.isFinite(e))throw new t(`Flag --${l} requires a finite number.`,i.USAGE);o[d]=e}else o[d]=u}s++}return o}var bt,xt,St,Ct=j((()=>{bt=`https://bailian.console.aliyun.com`,xt=`${bt}/cn-beijing`,St=`${xt}/?tab=app#/api-key`}));function wt(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function Tt(){let{purple:e,reset:t}=wt();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
- `),process.stderr.write(` 1. Get your API Key: ${St}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
3
+ import{createRequire as e}from"node:module";import{BailianError as t,CONSOLE_GATEWAY_NO_TOKEN_MESSAGE as n,DOCS_HOSTS as r,ExitCode as i,GLOBAL_OPTIONS as a,McpClient as o,analyzeIntent as s,appCompletionEndpoint as c,bailianMcpUrl as l,buildDocLink as u,callConsoleGateway as d,chatEndpoint as f,clearApiKey as p,defineCommand as m,detectOutputFormat as h,fetchModelList as g,flushTelemetry as _,formatOutput as v,generateFilename as y,generateToolSchema as b,getConfigDir as x,getConfigPath as S,getModels as C,imageEndpoint as w,imageSyncEndpoint as T,isInteractive as E,isLocalFile as D,knowledgeRetrieveEndpoint as ee,loadConfig as te,maskToken as O,mcpWebSearchEndpoint as ne,memoryAddEndpoint as re,memoryListEndpoint as ie,memoryNodeEndpoint as ae,memorySearchEndpoint as oe,parseSSE as se,profileSchemaEndpoint as ce,rankModels as le,readConfigFile as ue,recallSemantic as de,request as fe,requestJson as k,resolveBooleanFlag as pe,resolveConsoleGatewayCredential as me,resolveCredential as A,resolveFileUrl as j,resolveOutputDir as he,resolveWatermark as ge,signRequest as _e,speechRecognizeEndpoint as ve,speechSynthesizeEndpoint as ye,stripUndefined as be,taskEndpoint as xe,trackCommandExecution as Se,trackingHeaders as Ce,uploadFile as we,userProfileEndpoint as Te,videoGenerateEndpoint as Ee,writeConfigFile as De}from"bailian-cli-core";import Oe,{stdin as ke,stdout as Ae}from"node:process";import*as je from"node:readline";import Me from"node:readline";import{WriteStream as Ne}from"node:tty";import{execFile as Pe}from"node:child_process";import{randomBytes as Fe}from"node:crypto";import Ie from"node:http";import{createWriteStream as Le,existsSync as Re,mkdirSync as ze,readFileSync as Be,unlinkSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,extname as We,join as Ge}from"path";import{execSync as Ke}from"child_process";import{access as qe,mkdir as Je,readFile as Ye}from"node:fs/promises";import{dirname as Xe,extname as Ze,join as Qe,resolve as $e}from"node:path";import et from"boxen";import tt,{Chalk as nt}from"chalk";import{EnvHttpProxyAgent as rt,setGlobalDispatcher as it}from"undici";import{homedir as at}from"os";var ot=Object.create,st=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyNames,ut=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty,M=(e,t)=>()=>(e&&(t=e(e=0)),t),N=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ft=(e,t)=>{let n={};for(var r in e)st(n,r,{get:e[r],enumerable:!0});return t||st(n,Symbol.toStringTag,{value:`Module`}),n},pt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=lt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!dt.call(e,s)&&s!==n&&st(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ct(t,s))||r.enumerable});return e},mt=(e,t,n)=>(n=e==null?{}:ot(ut(e)),pt(t||!e||!e.__esModule?st(n,`default`,{value:e,enumerable:!0}):n,e)),ht=e(import.meta.url);function gt(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function _t(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?gt(t[1]):null}function vt(e){return e.type===`boolean`?!0:e.type===`string`||e.type===`number`||e.type===`array`?!1:!e.flag.includes(`<`)&&!e.flag.includes(`[`)}function yt(e){let t=new Set;for(let n of e){let e=_t(n);e&&t.add(e)}return t}function bt(e){let t=new Set,n=new Set,r=new Set;for(let i of e){let e=_t(i);e&&(vt(i)?t.add(e):i.type===`number`?n.add(e):i.type===`array`&&r.add(e))}return{booleans:t,numbers:n,arrays:r}}function xt(e,t=[]){let n=bt(t),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`--`)break;if(t.startsWith(`--`)){let r=t.indexOf(`=`),a=gt(r===-1?t.slice(2):t.slice(2,r));if(!n.booleans.has(a)&&r===-1){let t=e[i+1];t===void 0||t.startsWith(`-`)?i+=1:i+=2}else i+=1;continue}if(t.startsWith(`-`)){i++;continue}r.push(t),i++}return r}function St(e,n){let r=yt(n),a=bt(n),o={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},s=0;for(;s<e.length;){let n=e[s];if(n===`--help`||n===`-h`){o.help=!0,s++;continue}if(n===`--`)break;if(n.startsWith(`--`)){let c=n.indexOf(`=`),l,u;c===-1?l=n.slice(2):(l=n.slice(2,c),u=n.slice(c+1));let d=gt(l);if(!r.has(d))throw new t(`Unknown flag "--${l}". Run with --help to see available options.`,i.USAGE);if(a.booleans.has(d)){o[d]=!0,s++;continue}if(u===void 0){s++;let n=e[s];if(n===void 0||n.startsWith(`-`))throw new t(`Flag --${l} requires a value.`,i.USAGE);u=n}if(a.arrays.has(d)){let e=o[d];e?e.push(u):o[d]=[u]}else if(a.numbers.has(d)){let e=Number(u);if(!Number.isFinite(e))throw new t(`Flag --${l} requires a finite number.`,i.USAGE);o[d]=e}else o[d]=u}s++}return o}var Ct,wt,Tt,Et=M((()=>{Ct=`https://bailian.console.aliyun.com`,wt=`${Ct}/cn-beijing`,Tt=`${wt}/?tab=app#/api-key`}));function Dt(){let e=process.stderr.isTTY;return{purple:e?`\x1B[38;2;147;51;234m`:``,dim:e?`\x1B[2m`:``,reset:e?`\x1B[0m`:``}}function Ot(){let{purple:e,reset:t}=Dt();process.stderr.write(`\n Welcome to ${e}Bailian${t} CLI!\n\n`),process.stderr.write(` Get started in 2 steps:
4
+ `),process.stderr.write(` 1. Get your API Key: ${Tt}\n`),process.stderr.write(` 2. Login: bl auth login --api-key <your-key>
5
5
 
6
- `)}function Et(){let{dim:e,reset:t}=wt();process.stderr.write(`
6
+ `)}function kt(){let{dim:e,reset:t}=Dt();process.stderr.write(`
7
7
  🎯 Try these with your AI coding assistant:
8
8
 
9
- `),Dt.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
- `)}var Dt,Ot=j((()=>{Ct(),Dt=[`帮我生成一套鸭舌帽的亚马逊电商主图(白底 + 场景图 + 模特上身图)`,`帮我生成一段 3 分钟的幽默相声音频`,`帮我生成一套小红帽故事绘本 PDF(含插图)`,`帮我分析这个视频的内容并写一篇小红书文案`]}));function N(e,t){process.stdout.write(_(e,t)+`
11
- `)}function P(e){process.stdout.write(e+`
12
- `)}var F=j((()=>{}));function kt(e){Nt=e}function At(){return Nt}function jt(e){Pt=e}function Mt(e=process.stderr){Pt&&Nt.length>0&&Pt(Nt,e)}var Nt,Pt,Ft=j((()=>{Nt=[],Pt=null})),It=M(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Lt=M(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function Rt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function zt(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Yt,``)}function Bt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function Vt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=zt(e),e.length===0))return 0;e=e.replace(en(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Qt.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function Ht(){let e=new Map;for(let[t,n]of Object.entries(L)){for(let[t,r]of Object.entries(n))L[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=L[t],e.set(r[0],r[1]);Object.defineProperty(L,t,{value:n,enumerable:!1})}return Object.defineProperty(L,`codes`,{value:e,enumerable:!1}),L.color.close=`\x1B[39m`,L.bgColor.close=`\x1B[49m`,L.color.ansi=nn(),L.color.ansi256=rn(),L.color.ansi16m=an(),L.bgColor.ansi=nn(tn),L.bgColor.ansi256=rn(tn),L.bgColor.ansi16m=an(tn),Object.defineProperties(L,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>L.rgbToAnsi256(...L.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>L.ansi256ToAnsi(L.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>L.ansi256ToAnsi(L.hexToAnsi256(e)),enumerable:!1}}),L}function Ut(e,t,n){return String(e).normalize().replace(/\r\n/g,`
9
+ `),At.forEach((n,r)=>{process.stderr.write(`${e}${r+1}${t} ${n}\n`)}),process.stderr.write(`
10
+ `)}var At,jt=M((()=>{Et(),At=[`帮我生成一套鸭舌帽的亚马逊电商主图(白底 + 场景图 + 模特上身图)`,`帮我生成一段 3 分钟的幽默相声音频`,`帮我生成一套小红帽故事绘本 PDF(含插图)`,`帮我分析这个视频的内容并写一篇小红书文案`]}));function P(e,t){process.stdout.write(v(e,t)+`
11
+ `)}function F(e){process.stdout.write(e+`
12
+ `)}var I=M((()=>{}));function Mt(e){It=e}function Nt(){return It}function Pt(e){Lt=e}function Ft(e=process.stderr){Lt&&It.length>0&&Lt(It,e)}var It,Lt,Rt=M((()=>{It=[],Lt=null})),zt=N(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),Bt=N(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}));function Vt({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function Ht(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace($t,``)}function Ut(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function Wt(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Ht(e),e.length===0))return 0;e=e.replace(an(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(nn.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function Gt(){let e=new Map;for(let[t,n]of Object.entries(L)){for(let[t,r]of Object.entries(n))L[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=L[t],e.set(r[0],r[1]);Object.defineProperty(L,t,{value:n,enumerable:!1})}return Object.defineProperty(L,`codes`,{value:e,enumerable:!1}),L.color.close=`\x1B[39m`,L.bgColor.close=`\x1B[49m`,L.color.ansi=sn(),L.color.ansi256=cn(),L.color.ansi16m=ln(),L.bgColor.ansi=sn(on),L.bgColor.ansi256=cn(on),L.bgColor.ansi16m=ln(on),Object.defineProperties(L,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>L.rgbToAnsi256(...L.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>L.ansi256ToAnsi(L.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>L.ansi256ToAnsi(L.hexToAnsi256(e)),enumerable:!1}}),L}function Kt(e,t,n){return String(e).normalize().replace(/\r\n/g,`
13
13
  `).split(`
14
- `).map(e=>xn(e,t,n)).join(`
15
- `)}function Wt(e,t){if(e===t)return;let n=e.split(`
14
+ `).map(e=>Tn(e,t,n)).join(`
15
+ `)}function qt(e,t){if(e===t)return;let n=e.split(`
16
16
  `),r=t.split(`
17
- `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Gt(e){return e===Tn}function Kt(e,t){e.isTTY&&e.setRawMode(t)}function qt({input:e=Oe,output:t=ke,overwrite:n=!0,hideCursor:r=!0}={}){let i=Ae.createInterface({input:e,output:t,prompt:``,tabSize:1});Ae.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(I.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;Ae.moveCursor(t,s,c,()=>{Ae.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(I.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(I.cursor.show),e.isTTY&&!er&&e.setRawMode(!1),i.terminal=!1,i.close()}}var I,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,L,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr=j((()=>{I=It(),Jt=dt(Lt(),1),Yt=Rt(),Xt={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(Xt),Zt=Xt.exports,Qt=Bt(Zt),$t=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},en=Bt($t),tn=10,nn=(e=0)=>t=>`\x1B[${t+e}m`,rn=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,an=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,L={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(L.modifier),on=Object.keys(L.color),sn=Object.keys(L.bgColor),[...on,...sn],cn=Ht(),ln=new Set([`\x1B`,`›`]),un=39,dn=`\x07`,fn=`[`,pn=`]`,mn=`m`,hn=`${pn}8;;`,gn=e=>`${ln.values().next().value}${fn}${e}${mn}`,_n=e=>`${ln.values().next().value}${hn}${e}${dn}`,vn=e=>e.split(` `).map(e=>Vt(e)),yn=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Vt(zt(e[e.length-1]));for(let[t,s]of r.entries()){let c=Vt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),ln.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(hn)),i){a?s===dn&&(i=!1,a=!1):s===mn&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},bn=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Vt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},xn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=vn(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Vt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),yn(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){yn(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){yn(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>bn(e)));let c=[...s.join(`
18
- `)];for(let[e,t]of c.entries()){if(r+=t,ln.has(t)){let{groups:t}=RegExp(`(?:\\${fn}(?<code>\\d+)m|\\${hn}(?<uri>.*)${dn})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===un?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=cn.codes.get(Number(i));c[e+1]===`
19
- `?(a&&(r+=_n(``)),i&&n&&(r+=gn(n))):t===`
20
- `&&(i&&n&&(r+=gn(i)),a&&(r+=_n(a)))}return r},Sn=Object.defineProperty,Cn=(e,t,n)=>t in e?Sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wn=(e,t,n)=>(Cn(e,typeof t==`symbol`?t:t+``,n),n),Tn=Symbol(`clack:cancel`),En=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),Dn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),On=class{constructor({render:e,input:t=Oe,output:n=ke,...r},i=!0){wn(this,`input`),wn(this,`output`),wn(this,`rl`),wn(this,`opts`),wn(this,`_track`,!1),wn(this,`_render`),wn(this,`_cursor`,0),wn(this,`state`,`initial`),wn(this,`value`),wn(this,`error`,``),wn(this,`subscribers`,new Map),wn(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Me(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=je.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),je.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Kt(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(I.cursor.show),this.output.off(`resize`,this.render),Kt(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(I.cursor.show),this.output.off(`resize`,this.render),Kt(this.input,!1),e(Tn)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&En.has(t.name)&&this.emit(`cursor`,En.get(t.name)),t?.name&&Dn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
- `),Kt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Ut(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
- `).length-1;this.output.write(I.cursor.move(-999,e*-1))}render(){let e=Ut(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(I.cursor.hide);else{let t=Wt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(I.cursor.move(0,n)),this.output.write(I.erase.lines(1));let r=e.split(`
23
- `);this.output.write(r[n]),this._prevFrame=e,this.output.write(I.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(I.cursor.move(0,n)),this.output.write(I.erase.down());let r=e.split(`
17
+ `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Jt(e){return e===kn}function Yt(e,t){e.isTTY&&e.setRawMode(t)}function Xt({input:e=ke,output:t=Ae,overwrite:n=!0,hideCursor:r=!0}={}){let i=je.createInterface({input:e,output:t,prompt:``,tabSize:1});je.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o})=>{if(String(i)===``){r&&t.write(Zt.cursor.show),process.exit(0);return}if(!n)return;let s=o===`return`?0:-1,c=o===`return`?-1:0;je.moveCursor(t,s,c,()=>{je.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(Zt.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(Zt.cursor.show),e.isTTY&&!ir&&e.setRawMode(!1),i.terminal=!1,i.close()}}var Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,L,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar=M((()=>{Zt=zt(),Qt=mt(Bt(),1),$t=Vt(),en={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2))if(o+u<=i)a+=l;else break;o+=u}return a}})(en),tn=en.exports,nn=Ut(tn),rn=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},an=Ut(rn),on=10,sn=(e=0)=>t=>`\x1B[${t+e}m`,cn=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,ln=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,L={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(L.modifier),un=Object.keys(L.color),dn=Object.keys(L.bgColor),[...un,...dn],fn=Gt(),pn=new Set([`\x1B`,`›`]),mn=39,hn=`\x07`,gn=`[`,_n=`]`,vn=`m`,yn=`${_n}8;;`,bn=e=>`${pn.values().next().value}${gn}${e}${vn}`,xn=e=>`${pn.values().next().value}${yn}${e}${hn}`,Sn=e=>e.split(` `).map(e=>Wt(e)),Cn=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Wt(Ht(e[e.length-1]));for(let[t,s]of r.entries()){let c=Wt(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),pn.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(yn)),i){a?s===hn&&(i=!1,a=!1):s===vn&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},wn=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Wt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Tn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Sn(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Wt(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Cn(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Cn(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Cn(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>wn(e)));let c=[...s.join(`
18
+ `)];for(let[e,t]of c.entries()){if(r+=t,pn.has(t)){let{groups:t}=RegExp(`(?:\\${gn}(?<code>\\d+)m|\\${yn}(?<uri>.*)${hn})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===mn?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=fn.codes.get(Number(i));c[e+1]===`
19
+ `?(a&&(r+=xn(``)),i&&n&&(r+=bn(n))):t===`
20
+ `&&(i&&n&&(r+=bn(i)),a&&(r+=xn(a)))}return r},En=Object.defineProperty,Dn=(e,t,n)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,On=(e,t,n)=>(Dn(e,typeof t==`symbol`?t:t+``,n),n),kn=Symbol(`clack:cancel`),An=new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`]]),jn=new Set([`up`,`down`,`left`,`right`,`space`,`enter`]),Mn=class{constructor({render:e,input:t=ke,output:n=Ae,...r},i=!0){On(this,`input`),On(this,`output`),On(this,`rl`),On(this,`opts`),On(this,`_track`,!1),On(this,`_render`),On(this,`_cursor`,0),On(this,`state`,`initial`),On(this,`value`),On(this,`error`,``),On(this,`subscribers`,new Map),On(this,`_prevFrame`,``),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=n}prompt(){let e=new Ne(0);return e._write=(e,t,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,``),this._cursor=this.rl.cursor,this.emit(`value`,this.value)),n()},this.input.pipe(e),this.rl=Me.createInterface({input:this.input,output:e,tabSize:2,prompt:``,escapeCodeTimeout:50}),Me.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Yt(this.input,!0),this.output.on(`resize`,this.render),this.render(),new Promise((e,t)=>{this.once(`submit`,()=>{this.output.write(Zt.cursor.show),this.output.off(`resize`,this.render),Yt(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(Zt.cursor.show),this.output.off(`resize`,this.render),Yt(this.input,!1),e(kn)})})}on(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t}),this.subscribers.set(e,n)}once(e,t){let n=this.subscribers.get(e)??[];n.push({cb:t,once:!0}),this.subscribers.set(e,n)}emit(e,...t){let n=this.subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&!this._track&&An.has(t.name)&&this.emit(`cursor`,An.get(t.name)),t?.name&&jn.has(t.name)&&this.emit(`cursor`,t.name),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e,this.state=`error`,this.rl.write(this.value))}this.state!==`error`&&(this.state=`submit`)}e===``&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
21
+ `),Yt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Kt(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
22
+ `).length-1;this.output.write(Zt.cursor.move(-999,e*-1))}render(){let e=Kt(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(Zt.cursor.hide);else{let t=qt(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(Zt.cursor.move(0,n)),this.output.write(Zt.erase.lines(1));let r=e.split(`
23
+ `);this.output.write(r[n]),this._prevFrame=e,this.output.write(Zt.cursor.move(0,r.length-n-1));return}else if(t&&t?.length>1){let n=t[0];this.output.write(Zt.cursor.move(0,n)),this.output.write(Zt.erase.down());let r=e.split(`
24
24
  `).slice(n);this.output.write(r.join(`
25
- `)),this._prevFrame=e;return}this.output.write(I.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},kn=class extends On{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(I.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},An=Object.defineProperty,jn=(e,t,n)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>(jn(e,typeof t==`symbol`?t:t+``,n),n),Nn=class extends On{constructor(e){super(e,!1),Mn(this,`options`),Mn(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},Pn=Object.defineProperty,Fn=(e,t,n)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t,n)=>(Fn(e,typeof t==`symbol`?t:t+``,n),n),Ln=class extends On{constructor(e){super(e,!1),In(this,`options`),In(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},Rn=Object.defineProperty,zn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>(zn(e,typeof t==`symbol`?t:t+``,n),n),Vn=class extends On{constructor({mask:e,...t}){super(t),Bn(this,`valueWithCursor`,``),Bn(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${Jt.default.inverse(Jt.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${Jt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},Hn=Object.defineProperty,Un=(e,t,n)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wn=(e,t,n)=>(Un(e,typeof t==`symbol`?t:t+``,n),n),Gn=class extends On{constructor(e){super(e,!1),Wn(this,`options`),Wn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Kn=Object.defineProperty,qn=(e,t,n)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jn=(e,t,n)=>(qn(e,typeof t==`symbol`?t:t+``,n),n),Yn=class extends On{constructor(e){super(e,!1),Jn(this,`options`),Jn(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},Xn=Object.defineProperty,Zn=(e,t,n)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qn=(e,t,n)=>(Zn(e,typeof t==`symbol`?t:t+``,n),n),$n=class extends On{constructor(e){super(e),Qn(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${Jt.default.inverse(Jt.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${Jt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},er=globalThis.process.platform.startsWith(`win`)})),nr=lt({cancel:()=>Ir,confirm:()=>kr,group:()=>Vr,groupMultiselect:()=>Nr,intro:()=>Lr,isCancel:()=>Gt,log:()=>zr,multiselect:()=>Mr,note:()=>Fr,outro:()=>Rr,password:()=>Or,select:()=>Ar,selectKey:()=>jr,spinner:()=>Br,text:()=>Dr});function rr(){return De.platform===`win32`?!!De.env.CI||!!De.env.WT_SESSION||!!De.env.TERMINUS_SUBLIME||De.env.ConEmuTask===`{cmd::Cmder}`||De.env.TERM_PROGRAM===`Terminus-Sublime`||De.env.TERM_PROGRAM===`vscode`||De.env.TERM===`xterm-256color`||De.env.TERM===`alacritty`||De.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:De.env.TERM!==`linux`}function ir(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var R,ar,or,z,sr,cr,lr,ur,dr,B,V,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr=j((()=>{tr(),R=dt(Lt(),1),ar=It(),or=rr(),z=(e,t)=>or?e:t,sr=z(`◆`,`*`),cr=z(`■`,`x`),lr=z(`▲`,`x`),ur=z(`◇`,`o`),dr=z(`┌`,`T`),B=z(`│`,`|`),V=z(`└`,`—`),fr=z(`●`,`>`),pr=z(`○`,` `),mr=z(`◻`,`[•]`),hr=z(`◼`,`[+]`),gr=z(`◻`,`[ ]`),_r=z(`▪`,`•`),vr=z(`─`,`-`),yr=z(`╮`,`+`),br=z(`├`,`+`),xr=z(`╯`,`+`),Sr=z(`●`,`•`),Cr=z(`◆`,`*`),wr=z(`▲`,`!`),Tr=z(`■`,`x`),Er=e=>{switch(e){case`initial`:case`active`:return R.default.cyan(sr);case`cancel`:return R.default.red(cr);case`error`:return R.default.yellow(lr);case`submit`:return R.default.green(ur)}},Dr=e=>new $n({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${R.default.gray(B)}
26
- ${Er(this.state)} ${e.message}
25
+ `)),this._prevFrame=e;return}this.output.write(Zt.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Nn=class extends Mn{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(Zt.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Pn=Object.defineProperty,Fn=(e,t,n)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t,n)=>(Fn(e,typeof t==`symbol`?t:t+``,n),n),Ln=class extends Mn{constructor(e){super(e,!1),In(this,`options`),In(this,`cursor`,0);let{options:t}=e;this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter(t=>t!==e.value):[...this.value,e.value]}}},Rn=Object.defineProperty,zn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bn=(e,t,n)=>(zn(e,typeof t==`symbol`?t:t+``,n),n),Vn=class extends Mn{constructor(e){super(e,!1),Bn(this,`options`),Bn(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},Hn=Object.defineProperty,Un=(e,t,n)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wn=(e,t,n)=>(Un(e,typeof t==`symbol`?t:t+``,n),n),Gn=class extends Mn{constructor({mask:e,...t}){super(t),Wn(this,`valueWithCursor`,``),Wn(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${Qt.default.inverse(Qt.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${Qt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},Kn=Object.defineProperty,qn=(e,t,n)=>t in e?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jn=(e,t,n)=>(qn(e,typeof t==`symbol`?t:t+``,n),n),Yn=class extends Mn{constructor(e){super(e,!1),Jn(this,`options`),Jn(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Xn=Object.defineProperty,Zn=(e,t,n)=>t in e?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qn=(e,t,n)=>(Zn(e,typeof t==`symbol`?t:t+``,n),n),$n=class extends Mn{constructor(e){super(e,!1),Qn(this,`options`),Qn(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},er=Object.defineProperty,tr=(e,t,n)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nr=(e,t,n)=>(tr(e,typeof t==`symbol`?t:t+``,n),n),rr=class extends Mn{constructor(e){super(e),nr(this,`valueWithCursor`,``),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.valueWithCursor=this.value}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${Qt.default.inverse(Qt.default.hidden(`_`))}`;else{let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${e}${Qt.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}},ir=globalThis.process.platform.startsWith(`win`)})),or=ft({cancel:()=>Vr,confirm:()=>Pr,group:()=>Kr,groupMultiselect:()=>Rr,intro:()=>Hr,isCancel:()=>Jt,log:()=>Wr,multiselect:()=>Lr,note:()=>Br,outro:()=>Ur,password:()=>Nr,select:()=>Fr,selectKey:()=>Ir,spinner:()=>Gr,text:()=>Mr});function sr(){return Oe.platform===`win32`?!!Oe.env.CI||!!Oe.env.WT_SESSION||!!Oe.env.TERMINUS_SUBLIME||Oe.env.ConEmuTask===`{cmd::Cmder}`||Oe.env.TERM_PROGRAM===`Terminus-Sublime`||Oe.env.TERM_PROGRAM===`vscode`||Oe.env.TERM===`xterm-256color`||Oe.env.TERM===`alacritty`||Oe.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:Oe.env.TERM!==`linux`}function cr(){let e=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(e,`g`)}var R,lr,ur,z,dr,fr,pr,mr,hr,B,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr=M((()=>{ar(),R=mt(Bt(),1),lr=zt(),ur=sr(),z=(e,t)=>ur?e:t,dr=z(`◆`,`*`),fr=z(`■`,`x`),pr=z(`▲`,`x`),mr=z(`◇`,`o`),hr=z(`┌`,`T`),B=z(`│`,`|`),gr=z(`└`,`—`),_r=z(`●`,`>`),vr=z(`○`,` `),yr=z(`◻`,`[•]`),br=z(`◼`,`[+]`),xr=z(`◻`,`[ ]`),Sr=z(`▪`,`•`),Cr=z(`─`,`-`),wr=z(`╮`,`+`),Tr=z(`├`,`+`),Er=z(`╯`,`+`),Dr=z(`●`,`•`),Or=z(`◆`,`*`),kr=z(`▲`,`!`),Ar=z(`■`,`x`),jr=e=>{switch(e){case`initial`:case`active`:return R.default.cyan(dr);case`cancel`:return R.default.red(fr);case`error`:return R.default.yellow(pr);case`submit`:return R.default.green(mr)}},Mr=e=>new rr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${R.default.gray(B)}
26
+ ${jr(this.state)} ${e.message}
27
27
  `,n=e.placeholder?R.default.inverse(e.placeholder[0])+R.default.dim(e.placeholder.slice(1)):R.default.inverse(R.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
28
28
  ${R.default.yellow(B)} ${r}
29
- ${R.default.yellow(V)} ${R.default.yellow(this.error)}
29
+ ${R.default.yellow(gr)} ${R.default.yellow(this.error)}
30
30
  `;case`submit`:return`${t}${R.default.gray(B)} ${R.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(this.value??``))}${this.value?.trim()?`
31
31
  `+R.default.gray(B):``}`;default:return`${t}${R.default.cyan(B)} ${r}
32
- ${R.default.cyan(V)}
33
- `}}}).prompt(),Or=e=>new Vn({validate:e.validate,mask:e.mask??_r,render(){let t=`${R.default.gray(B)}
34
- ${Er(this.state)} ${e.message}
32
+ ${R.default.cyan(gr)}
33
+ `}}}).prompt(),Nr=e=>new Gn({validate:e.validate,mask:e.mask??Sr,render(){let t=`${R.default.gray(B)}
34
+ ${jr(this.state)} ${e.message}
35
35
  `,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
36
36
  ${R.default.yellow(B)} ${r}
37
- ${R.default.yellow(V)} ${R.default.yellow(this.error)}
37
+ ${R.default.yellow(gr)} ${R.default.yellow(this.error)}
38
38
  `;case`submit`:return`${t}${R.default.gray(B)} ${R.default.dim(r)}`;case`cancel`:return`${t}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(r??``))}${r?`
39
39
  `+R.default.gray(B):``}`;default:return`${t}${R.default.cyan(B)} ${n}
40
- ${R.default.cyan(V)}
41
- `}}}).prompt(),kr=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new kn({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${R.default.gray(B)}
42
- ${Er(this.state)} ${e.message}
40
+ ${R.default.cyan(gr)}
41
+ `}}}).prompt(),Pr=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Nn({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${R.default.gray(B)}
42
+ ${jr(this.state)} ${e.message}
43
43
  `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${R.default.gray(B)} ${R.default.dim(i)}`;case`cancel`:return`${r}${R.default.gray(B)} ${R.default.strikethrough(R.default.dim(i))}
44
- ${R.default.gray(B)}`;default:return`${r}${R.default.cyan(B)} ${this.value?`${R.default.green(fr)} ${t}`:`${R.default.dim(pr)} ${R.default.dim(t)}`} ${R.default.dim(`/`)} ${this.value?`${R.default.dim(pr)} ${R.default.dim(n)}`:`${R.default.green(fr)} ${n}`}
45
- ${R.default.cyan(V)}
46
- `}}}).prompt()},Ar=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.green(fr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:`${R.default.dim(pr)} ${R.default.dim(n)}`},n=0;return new Gn({options:e.options,initialValue:e.initialValue,render(){let r=`${R.default.gray(B)}
47
- ${Er(this.state)} ${e.message}
44
+ ${R.default.gray(B)}`;default:return`${r}${R.default.cyan(B)} ${this.value?`${R.default.green(_r)} ${t}`:`${R.default.dim(vr)} ${R.default.dim(t)}`} ${R.default.dim(`/`)} ${this.value?`${R.default.dim(vr)} ${R.default.dim(n)}`:`${R.default.green(_r)} ${n}`}
45
+ ${R.default.cyan(gr)}
46
+ `}}}).prompt()},Fr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.green(_r)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:`${R.default.dim(vr)} ${R.default.dim(n)}`},n=0;return new Yn({options:e.options,initialValue:e.initialValue,render(){let r=`${R.default.gray(B)}
47
+ ${jr(this.state)} ${e.message}
48
48
  `;switch(this.state){case`submit`:return`${r}${R.default.gray(B)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${r}${R.default.gray(B)} ${t(this.options[this.cursor],`cancelled`)}
49
49
  ${R.default.gray(B)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=n+i-3?n=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<n+2&&(n=Math.max(this.cursor-2,0));let a=i<this.options.length&&n>0,o=i<this.options.length&&n+i<this.options.length;return`${r}${R.default.cyan(B)} ${this.options.slice(n,n+i).map((e,r,i)=>r===0&&a||r===i.length-1&&o?R.default.dim(`...`):t(e,r+n===this.cursor?`active`:`inactive`)).join(`
50
50
  ${R.default.cyan(B)} `)}
51
- ${R.default.cyan(V)}
52
- `}}}}).prompt()},jr=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active`?`${R.default.bgCyan(R.default.gray(` ${e.value} `))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:`${R.default.gray(R.default.bgWhite(R.default.inverse(` ${e.value} `)))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`};return new Yn({options:e.options,initialValue:e.initialValue,render(){let n=`${R.default.gray(B)}
53
- ${Er(this.state)} ${e.message}
51
+ ${R.default.cyan(gr)}
52
+ `}}}}).prompt()},Ir=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active`?`${R.default.bgCyan(R.default.gray(` ${e.value} `))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:`${R.default.gray(R.default.bgWhite(R.default.inverse(` ${e.value} `)))} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`};return new $n({options:e.options,initialValue:e.initialValue,render(){let n=`${R.default.gray(B)}
53
+ ${jr(this.state)} ${e.message}
54
54
  `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${t(this.options.find(e=>e.value===this.value),`selected`)}`;case`cancel`:return`${n}${R.default.gray(B)} ${t(this.options[0],`cancelled`)}
55
55
  ${R.default.gray(B)}`;default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
56
56
  ${R.default.cyan(B)} `)}
57
- ${R.default.cyan(V)}
58
- `}}}).prompt()},Mr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.cyan(mr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.green(hr)} ${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active-selected`?`${R.default.green(hr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(n)}`:`${R.default.dim(gr)} ${R.default.dim(n)}`};return new Ln({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
57
+ ${R.default.cyan(gr)}
58
+ `}}}).prompt()},Lr=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${R.default.cyan(yr)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`selected`?`${R.default.green(br)} ${R.default.dim(n)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(n))}`:t===`active-selected`?`${R.default.green(br)} ${n} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(n)}`:`${R.default.dim(xr)} ${R.default.dim(n)}`};return new Vn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
59
59
  ${R.default.reset(R.default.dim(`Press ${R.default.gray(R.default.bgWhite(R.default.inverse(` space `)))} to select, ${R.default.gray(R.default.bgWhite(R.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${R.default.gray(B)}
60
- ${Er(this.state)} ${e.message}
60
+ ${jr(this.state)} ${e.message}
61
61
  `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(R.default.dim(`, `))||R.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(R.default.dim(`, `));return`${n}${R.default.gray(B)} ${e.trim()?`${e}
62
62
  ${R.default.gray(B)}`:``}`}case`error`:{let e=this.error.split(`
63
- `).map((e,t)=>t===0?`${R.default.yellow(V)} ${R.default.yellow(e)}`:` ${e}`).join(`
63
+ `).map((e,t)=>t===0?`${R.default.yellow(gr)} ${R.default.yellow(e)}`:` ${e}`).join(`
64
64
  `);return n+R.default.yellow(B)+` `+this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
65
65
  ${R.default.yellow(B)} `)+`
66
66
  `+e+`
67
67
  `}default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n)=>{let r=this.value.includes(e.value),i=n===this.cursor;return i&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,i?`active`:`inactive`)}).join(`
68
68
  ${R.default.cyan(B)} `)}
69
- ${R.default.cyan(V)}
70
- `}}}).prompt()},Nr=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?V:B} `:``;return t===`active`?`${R.default.dim(s)}${R.default.cyan(mr)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${R.default.cyan(mr)} ${R.default.dim(r)}`:t===`group-active-selected`?`${s}${R.default.green(hr)} ${R.default.dim(r)}`:t===`selected`?`${R.default.dim(s)}${R.default.green(hr)} ${R.default.dim(r)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(r))}`:t===`active-selected`?`${R.default.dim(s)}${R.default.green(hr)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(r)}`:`${R.default.dim(s)}${R.default.dim(gr)} ${R.default.dim(r)}`};return new Nn({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
69
+ ${R.default.cyan(gr)}
70
+ `}}}).prompt()},Rr=e=>{let t=(e,t,n=[])=>{let r=e.label??String(e.value),i=typeof e.group==`string`,a=i&&(n[n.indexOf(e)+1]??{group:!0}),o=i&&a.group===!0,s=i?`${o?gr:B} `:``;return t===`active`?`${R.default.dim(s)}${R.default.cyan(yr)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`group-active`?`${s}${R.default.cyan(yr)} ${R.default.dim(r)}`:t===`group-active-selected`?`${s}${R.default.green(br)} ${R.default.dim(r)}`:t===`selected`?`${R.default.dim(s)}${R.default.green(br)} ${R.default.dim(r)}`:t===`cancelled`?`${R.default.strikethrough(R.default.dim(r))}`:t===`active-selected`?`${R.default.dim(s)}${R.default.green(br)} ${r} ${e.hint?R.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${R.default.dim(r)}`:`${R.default.dim(s)}${R.default.dim(xr)} ${R.default.dim(r)}`};return new Ln({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
71
71
  ${R.default.reset(R.default.dim(`Press ${R.default.gray(R.default.bgWhite(R.default.inverse(` space `)))} to select, ${R.default.gray(R.default.bgWhite(R.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${R.default.gray(B)}
72
- ${Er(this.state)} ${e.message}
72
+ ${jr(this.state)} ${e.message}
73
73
  `;switch(this.state){case`submit`:return`${n}${R.default.gray(B)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(R.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(R.default.dim(`, `));return`${n}${R.default.gray(B)} ${e.trim()?`${e}
74
74
  ${R.default.gray(B)}`:``}`}case`error`:{let e=this.error.split(`
75
- `).map((e,t)=>t===0?`${R.default.yellow(V)} ${R.default.yellow(e)}`:` ${e}`).join(`
75
+ `).map((e,t)=>t===0?`${R.default.yellow(gr)} ${R.default.yellow(e)}`:` ${e}`).join(`
76
76
  `);return`${n}${R.default.yellow(B)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
77
77
  ${R.default.yellow(B)} `)}
78
78
  ${e}
79
79
  `}default:return`${n}${R.default.cyan(B)} ${this.options.map((e,n,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=n===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?t(e,i?`group-active-selected`:`group-active`,r):a&&i?t(e,`active-selected`,r):i?t(e,`selected`,r):t(e,a?`active`:`inactive`,r)}).join(`
80
80
  ${R.default.cyan(B)} `)}
81
- ${R.default.cyan(V)}
82
- `}}}).prompt()},Pr=e=>e.replace(ir(),``),Fr=(e=``,t=``)=>{let n=`
81
+ ${R.default.cyan(gr)}
82
+ `}}}).prompt()},zr=e=>e.replace(cr(),``),Br=(e=``,t=``)=>{let n=`
83
83
  ${e}
84
84
  `.split(`
85
- `),r=Pr(t).length,i=Math.max(n.reduce((e,t)=>(t=Pr(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${R.default.gray(B)} ${R.default.dim(e)}${` `.repeat(i-Pr(e).length)}${R.default.gray(B)}`).join(`
85
+ `),r=zr(t).length,i=Math.max(n.reduce((e,t)=>(t=zr(t),t.length>e?t.length:e),0),r)+2,a=n.map(e=>`${R.default.gray(B)} ${R.default.dim(e)}${` `.repeat(i-zr(e).length)}${R.default.gray(B)}`).join(`
86
86
  `);process.stdout.write(`${R.default.gray(B)}
87
- ${R.default.green(ur)} ${R.default.reset(t)} ${R.default.gray(vr.repeat(Math.max(i-r-1,1))+yr)}
87
+ ${R.default.green(mr)} ${R.default.reset(t)} ${R.default.gray(Cr.repeat(Math.max(i-r-1,1))+wr)}
88
88
  ${a}
89
- ${R.default.gray(br+vr.repeat(i+2)+xr)}
90
- `)},Ir=(e=``)=>{process.stdout.write(`${R.default.gray(V)} ${R.default.red(e)}
89
+ ${R.default.gray(Tr+Cr.repeat(i+2)+Er)}
90
+ `)},Vr=(e=``)=>{process.stdout.write(`${R.default.gray(gr)} ${R.default.red(e)}
91
91
 
92
- `)},Lr=(e=``)=>{process.stdout.write(`${R.default.gray(dr)} ${e}
93
- `)},Rr=(e=``)=>{process.stdout.write(`${R.default.gray(B)}
94
- ${R.default.gray(V)} ${e}
92
+ `)},Hr=(e=``)=>{process.stdout.write(`${R.default.gray(hr)} ${e}
93
+ `)},Ur=(e=``)=>{process.stdout.write(`${R.default.gray(B)}
94
+ ${R.default.gray(gr)} ${e}
95
95
 
96
- `)},zr={message:(e=``,{symbol:t=R.default.gray(B)}={})=>{let n=[`${R.default.gray(B)}`];if(e){let[r,...i]=e.split(`
96
+ `)},Wr={message:(e=``,{symbol:t=R.default.gray(B)}={})=>{let n=[`${R.default.gray(B)}`];if(e){let[r,...i]=e.split(`
97
97
  `);n.push(`${t} ${r}`,...i.map(e=>`${R.default.gray(B)} ${e}`))}process.stdout.write(`${n.join(`
98
98
  `)}
99
- `)},info:e=>{zr.message(e,{symbol:R.default.blue(Sr)})},success:e=>{zr.message(e,{symbol:R.default.green(Cr)})},step:e=>{zr.message(e,{symbol:R.default.green(ur)})},warn:e=>{zr.message(e,{symbol:R.default.yellow(wr)})},warning:e=>{zr.warn(e)},error:e=>{zr.message(e,{symbol:R.default.red(Tr)})}},Br=()=>{let e=or?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],t=or?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=qt(),a=o.replace(/\.+$/,``),process.stdout.write(`${R.default.gray(B)}
100
- `);let s=0,c=0;r=setInterval(()=>{let t=R.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(ar.cursor.move(-999,0)),process.stdout.write(ar.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?R.default.green(ur):t===1?R.default.red(cr):R.default.red(lr);process.stdout.write(ar.cursor.move(-999,0)),process.stdout.write(ar.erase.down(1)),process.stdout.write(`${o} ${a}
101
- `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},Vr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Gt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function H(e){if(!T())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(Hr(),nr))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function Ur(e){if(!T())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(Hr(),nr))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function Wr(e){if(!T())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(Hr(),nr))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function U(e,n){throw At().length>0&&(Mt(process.stderr),process.exit(0)),new t(`Missing required argument: --${e}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${e} and the CLI will prompt for it.`,i.USAGE,n)}var W=j((()=>{Ft()}));function Gr(){return process.env.BAILIAN_CONSOLE_ORIGIN||ci}function Kr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>si){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function qr(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function Jr(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function Yr(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function Xr(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Zr(e){for(let t of[`api_key`,`apiKey`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function Qr(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Xr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Xr(a);if(e)return e}return null}function $r(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=Jr(t);if(n){let t=Yr(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=Qr(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=Qr(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=Jr(t);if(i){let t=Yr(e,i);if(t)return t}return null}function ei(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Zr(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Zr(a);if(e)return e}return null}function ti(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`application/json`)||n.includes(`text/json`)){let t=ei(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}let r=ei(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}return null}async function ni(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`),r=t.searchParams.get(`api_key`)??t.searchParams.get(`apiKey`),i=e.method??`GET`;if(i!==`POST`&&i!==`PUT`&&i!==`PATCH`)return{accessToken:n?.trim()||null,apiKey:r?.trim()||null};let a=qr(e),o;try{o=await Kr(e)}catch{return{accessToken:n?.trim()||null,apiKey:r?.trim()||null}}return{accessToken:n?.trim()||$r(o,a),apiKey:r?.trim()||ti(o,a)}}function ri(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function ii(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{Ne(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function ai(e,n){let r=Pe(16).toString(`hex`),a,o=Fe.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==r){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
102
- `);return}let{accessToken:i,apiKey:s}=await ni(e);if(i||s)try{if(i){let e=le();e.access_token=i,await Ee(e),process.stderr.write(`access_token saved to ${x()}\n`)}s&&n?.onApiKey&&await n.onApiKey(s)}catch(e){a=e,t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save credentials
99
+ `)},info:e=>{Wr.message(e,{symbol:R.default.blue(Dr)})},success:e=>{Wr.message(e,{symbol:R.default.green(Or)})},step:e=>{Wr.message(e,{symbol:R.default.green(mr)})},warn:e=>{Wr.message(e,{symbol:R.default.yellow(kr)})},warning:e=>{Wr.warn(e)},error:e=>{Wr.message(e,{symbol:R.default.red(Ar)})}},Gr=()=>{let e=ur?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],t=ur?80:120,n,r,i=!1,a=``,o=(o=``)=>{i=!0,n=Xt(),a=o.replace(/\.+$/,``),process.stdout.write(`${R.default.gray(B)}
100
+ `);let s=0,c=0;r=setInterval(()=>{let t=R.default.magenta(e[s]),n=`.`.repeat(Math.floor(c)).slice(0,3);process.stdout.write(lr.cursor.move(-999,0)),process.stdout.write(lr.erase.down(1)),process.stdout.write(`${t} ${a}${n}`),s=s+1<e.length?s+1:0,c=c<e.length?c+.125:0},t)},s=(e=``,t=0)=>{a=e??a,i=!1,clearInterval(r);let o=t===0?R.default.green(mr):t===1?R.default.red(fr):R.default.red(pr);process.stdout.write(lr.cursor.move(-999,0)),process.stdout.write(lr.erase.down(1)),process.stdout.write(`${o} ${a}
101
+ `),n()},c=(e=``)=>{a=e??a},l=e=>{i&&s(e>1?`Something went wrong`:`Canceled`,e)};return process.on(`uncaughtExceptionMonitor`,()=>l(2)),process.on(`unhandledRejection`,()=>l(2)),process.on(`SIGINT`,()=>l(1)),process.on(`SIGTERM`,()=>l(1)),process.on(`exit`,l),{start:o,stop:s,message:c}},Kr=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&Jt(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n}}));async function Jr(e){if(!E())return;let{defaultValue:t,message:n}=e,r=await(await Promise.resolve().then(()=>(qr(),or))).text({message:n,default:t,placeholder:t});if(typeof r!=`symbol`)return r}async function Yr(e){if(!E())return;let{message:t,initialValue:n}=e,r=await(await Promise.resolve().then(()=>(qr(),or))).confirm({message:t,initialValue:n});if(typeof r!=`symbol`)return r}async function Xr(e){if(!E())return;let{message:t,choices:n,defaultValue:r}=e,i=await(await Promise.resolve().then(()=>(qr(),or))).select({message:t,initialValue:r,options:n});if(typeof i!=`symbol`)return i}function V(e,n){throw Nt().length>0&&(Ft(process.stderr),process.exit(0)),new t(`Missing required argument: --${e}\nHint: In non-interactive (CI / agent) environments all required flags must be provided.\n In an interactive terminal, run without --${e} and the CLI will prompt for it.`,i.USAGE,n)}var H=M((()=>{Rt()}));function Zr(){return process.env.BAILIAN_CONSOLE_ORIGIN||mi}function Qr(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,e=>{if(r+=e.length,r>pi){n(Error(`payload too large`));return}i.push(e)}),e.on(`end`,()=>t(Buffer.concat(i).toString(`utf8`))),e.on(`error`,n)})}function $r(e){let t=e.headers[`content-type`];return Array.isArray(t)?t[0]??``:typeof t==`string`?t:``}function ei(e){let t=e.split(`;`);for(let e of t){let t=e.trim();if(!t.toLowerCase().startsWith(`boundary=`))continue;let n=t.slice(9).trim();return(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n.length>0?n:null}return null}function ti(e,t){let n=`--${t}`,r=e.split(n);for(let e=1;e<r.length;e++){let t=r[e];if(!/name\s*=\s*["'](?:access_token|accessToken)["']/i.test(t))continue;let n=t.match(/\r\n\r\n|\n\n/);if(!n||n.index===void 0)continue;let i=t.slice(n.index+n[0].length);if(i=i.replace(/(?:\r\n)+$/g,``).replace(/\n+$/g,``).trim(),i)return i}return null}function ni(e){for(let t of[`access_token`,`accessToken`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function ri(e){for(let t of[`api_key`,`apiKey`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return null}function ii(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=ni(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=ni(a);if(e)return e}return null}function ai(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`multipart/form-data`)){let n=ei(t);if(n){let t=ti(e,n);if(t)return t}}if(n.includes(`application/json`)||n.includes(`text/json`)){let t=ii(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let r=ii(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`access_token`)??t.get(`accessToken`);if(n?.trim())return n.trim()}catch{}let i=ei(t);if(i){let t=ti(e,i);if(t)return t}return null}function oi(e){let t=e.trim();if(t.charCodeAt(0)===65279&&(t=t.slice(1)),!t)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=ri(r);if(i)return i;let a=r.data;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=ri(a);if(e)return e}return null}function si(e,t){let n=t.toLowerCase();if(!e.trim())return null;if(n.includes(`application/json`)||n.includes(`text/json`)){let t=oi(e);if(t)return t}if(n.includes(`application/x-www-form-urlencoded`))try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}let r=oi(e);if(r)return r;try{let t=new URLSearchParams(e.trim()),n=t.get(`api_key`)??t.get(`apiKey`);if(n?.trim())return n.trim()}catch{}return null}async function ci(e){let t=new URL(e.url??`/`,`http://127.0.0.1`),n=t.searchParams.get(`access_token`)??t.searchParams.get(`accessToken`),r=t.searchParams.get(`api_key`)??t.searchParams.get(`apiKey`),i=e.method??`GET`;if(i!==`POST`&&i!==`PUT`&&i!==`PATCH`)return{accessToken:n?.trim()||null,apiKey:r?.trim()||null};let a=$r(e),o;try{o=await Qr(e)}catch{return{accessToken:n?.trim()||null,apiKey:r?.trim()||null}}return{accessToken:n?.trim()||ai(o,a),apiKey:r?.trim()||si(o,a)}}function li(e){return new Promise((t,n)=>{let r=e=>n(e);e.once(`error`,r),e.listen({port:0,host:`127.0.0.1`,exclusive:!0},()=>{e.off(`error`,r);let i=e.address();if(!i||typeof i==`string`){n(Error(`Expected TCP socket address`));return}t(i.port)})})}function ui(e){let t=process.platform,n=t===`darwin`?`open`:t===`win32`?`cmd`:`xdg-open`,r=t===`win32`?[`/c`,`start`,``,e]:[e];return new Promise((e,t)=>{Pe(n,r,{windowsHide:!0},n=>{n?t(n):e()})})}async function di(e,n){let r=Fe(16).toString(`hex`),a,o=Ie.createServer(async(e,t)=>{try{if(e.method===`OPTIONS`){t.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, PATCH, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),t.end();return}if(new URL(e.url??`/`,`http://127.0.0.1`).searchParams.get(`state`)!==r){t.writeHead(400,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`bad state
102
+ `);return}let{accessToken:i,apiKey:s}=await ci(e);if(i||s)try{if(i){let e=ue();e.access_token=i,await De(e),process.stderr.write(`access_token saved to ${S()}\n`)}s&&n?.onApiKey&&await n.onApiKey(s)}catch(e){a=e,t.writeHead(500,{"Content-Type":`text/plain; charset=utf-8`}),t.end(`Failed to save credentials
103
103
  `),o.close();return}t.writeHead(200,{"Content-Type":`text/plain; charset=utf-8`,"Access-Control-Allow-Origin":`*`}),t.end(`OK
104
- `),(i||s)&&o.close()}catch{t.statusCode=500,t.end()}}),s;try{s=await ri(o)}catch(e){throw new t(`Could not bind to 127.0.0.1 (no free port or permission denied): ${e instanceof Error?e.message:String(e)}`,i.USAGE)}let c=`${e}/console-login?notice=127.0.0.1:${s}?state=${encodeURIComponent(r)}`;n?.needApiKey&&(c+=`&needapikey=true`);try{await ii(c),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
104
+ `),(i||s)&&o.close()}catch{t.statusCode=500,t.end()}}),s;try{s=await li(o)}catch(e){throw new t(`Could not bind to 127.0.0.1 (no free port or permission denied): ${e instanceof Error?e.message:String(e)}`,i.USAGE)}let c=`${e}/console-login?notice=127.0.0.1:${s}?state=${encodeURIComponent(r)}`;n?.needApiKey&&(c+=`&needapikey=true`);try{await ui(c),process.stderr.write(`Opened the login page in your default browser. This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
105
105
  `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`Could not open the default browser (${t}). Open this URL manually:\n\n`),process.stdout.write(`${c}\n`),process.stderr.write(`
106
106
  This process keeps the local port open for the console; press Ctrl+C when finished (or wait for idle timeout).
107
- `)}if(await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),e())},i=setTimeout(()=>{o.close()},oi);o.once(`close`,r),o.once(`error`,e=>{clearTimeout(i),n||(n=!0,t(e))})}),a)throw a}var oi,si,ci,li=j((()=>{oi=900*1e3,si=65536,ci=`https://bailian.console.aliyun.com`}));function ui(e){if(e instanceof t){if(e.exitCode===i.NETWORK||e.exitCode===i.TIMEOUT)return!0;let t=e.api?.httpStatus;return t===401||t!==void 0&&t>=500}return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`)||e.message===`fetch failed`:!1}async function di(e,n){process.stderr.write(`Testing key... `);let r={...e,apiKey:n},a={url:f(r.baseUrl),method:`POST`,timeout:Math.min(e.timeout,30),body:{model:`qwen3.7-max`,messages:[{role:`user`,content:`hi`}],max_tokens:1}};for(let e=1;e<=3;e++)try{await O(r,a);break}catch(n){if(e>=3||!ui(n))throw process.stderr.write(`
108
- `),new t(`API key validation failed`,i.AUTH,`Invalid API key.`,{cause:n});let r=fi*2**(e-1);await new Promise(e=>setTimeout(e,r))}process.stderr.write(`Valid
109
- `);let o=le();o.api_key=n,await Ee(o),process.stderr.write(`Saved to ${x()}\n`)}var fi,pi,mi=j((()=>{Ot(),F(),W(),Ft(),li(),fi=500,pi=m({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){P(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}let t=!!(e.apiKey||e.fileApiKey);await ai(Gr(),{needApiKey:!t,onApiKey:t=>di(e,t)});return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=D(n);T({nonInteractive:e.nonInteractive})?await Ur({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
107
+ `)}if(await new Promise((e,t)=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),e())},i=setTimeout(()=>{o.close()},fi);o.once(`close`,r),o.once(`error`,e=>{clearTimeout(i),n||(n=!0,t(e))})}),a)throw a}var fi,pi,mi,hi=M((()=>{fi=900*1e3,pi=65536,mi=`https://bailian.console.aliyun.com`}));function gi(e){if(e instanceof t){if(e.exitCode===i.NETWORK||e.exitCode===i.TIMEOUT)return!0;let t=e.api?.httpStatus;return t===401||t!==void 0&&t>=500}return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`)||e.message===`fetch failed`:!1}async function _i(e,n){process.stderr.write(`Testing key... `);let r={...e,apiKey:n},a={url:f(r.baseUrl),method:`POST`,timeout:Math.min(e.timeout,30),body:{model:`qwen3.7-max`,messages:[{role:`user`,content:`hi`}],max_tokens:1}};for(let e=1;e<=3;e++)try{await k(r,a);break}catch(n){if(e>=3||!gi(n))throw process.stderr.write(`
108
+ `),new t(`API key validation failed`,i.AUTH,`Invalid API key.`,{cause:n});let r=vi*2**(e-1);await new Promise(e=>setTimeout(e,r))}process.stderr.write(`Valid
109
+ `);let o=ue();o.api_key=n,await De(o),process.stderr.write(`Saved to ${S()}\n`)}var vi,yi,bi=M((()=>{jt(),I(),H(),Rt(),hi(),vi=500,yi=m({name:`auth login`,description:`Authenticate with API key or console browser login (credentials can coexist)`,usage:`bl auth login --api-key <key> | bl auth login --console`,options:[{flag:`--api-key <key>`,description:`DashScope API key to store`},{flag:`--console`,description:`Sign in via browser; opens the console login URL in your default browser`,type:`boolean`}],examples:[`bl auth login --api-key sk-xxxxx`,`bl auth login --console`],async run(e,t){if(t.console){if(e.dryRun){F(`Would bind a free port on 127.0.0.1 and open the console login URL in your browser.`);return}let t=!!(e.apiKey||e.fileApiKey);await di(Zr(),{needApiKey:!t,onApiKey:t=>_i(e,t)});return}let n=process.env.DASHSCOPE_API_KEY;if(n&&!t.apiKey){let t=O(n);E({nonInteractive:e.nonInteractive})?await Yr({message:`Detected DASHSCOPE_API_KEY in environment (${t}).\nYou are already authenticated via env.\nDo you still want to configure local persistent credentials?`,initialValue:!1})||(process.stdout.write(`Login skipped. Using environment variables.
110
110
  `),process.exit(0)):process.stderr.write(`Warning: DASHSCOPE_API_KEY is already set in environment.
111
- `)}let r=t.apiKey||e.apiKey;r||(Mt(process.stderr),process.exit(0)),e.dryRun?P(`Would validate and save API key.`):(await di(e,r),Et())}})}));function hi(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:D(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:D(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:D(t)}:{configured:!1}}function gi(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:D(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:D(e.fileAccessToken)}:{configured:!1}}async function _i(e){try{return await k(e)}catch{return}}async function vi(e){try{return await pe(e)}catch{return}}async function yi(e){let t={api_key:hi(e),access_token:gi(e)},n=await _i(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:D(n.token)});let r=await vi(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:D(r.token)}),t}function bi(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function xi(e){P(`Authentication Status:`),P(` Stored credentials (can coexist):`),e.api_key.configured?P(` API key: ${e.api_key.source} ${e.api_key.masked}`):P(` API key: not configured`),e.access_token.configured?P(` Console token: ${e.access_token.source} ${e.access_token.masked}`):P(` Console token: not configured`),P(` Effective credential per command family:`),e.dashscope_commands?P(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):P(` DashScope API: unavailable`),e.console_gateway_commands?P(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):P(` Console gateway: unavailable (run bl auth login --console)`)}var Si,Ci=j((()=>{F(),Ct(),Si=m({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=h(e.output),r=await yi(e);if(!bi(r)){N({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${St}`].join(`
112
- `),...r},n);return}if(n!==`text`){N({authenticated:!0,...r},n);return}xi(r)}})}));async function wi(){let e=le();return e.access_token?(delete e.access_token,await Ee(e),!0):!1}var Ti,Ei=j((()=>{F(),Ti=m({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=le();if(t.console){let t=!!n.access_token;if(e.dryRun){P(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),P(`No changes made.`);return}t?(await wi(),process.stderr.write(`Cleared access_token from ${x()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
111
+ `)}let r=t.apiKey||e.apiKey;r||(Ft(process.stderr),process.exit(0)),e.dryRun?F(`Would validate and save API key.`):(await _i(e,r),kt())}})}));function xi(e){if(e.apiKey)return{configured:!0,source:`flag`,masked:O(e.apiKey)};if(e.fileApiKey)return{configured:!0,source:`config.json`,masked:O(e.fileApiKey)};let t=process.env.DASHSCOPE_API_KEY?.trim();return t?{configured:!0,source:`DASHSCOPE_API_KEY`,masked:O(t)}:{configured:!1}}function Si(e){return e.accessTokenEnv?{configured:!0,source:`DASHSCOPE_ACCESS_TOKEN`,masked:O(e.accessTokenEnv)}:e.fileAccessToken?{configured:!0,source:`config.json`,masked:O(e.fileAccessToken)}:{configured:!1}}async function Ci(e){try{return await A(e)}catch{return}}async function wi(e){try{return await me(e)}catch{return}}async function Ti(e){let t={api_key:xi(e),access_token:Si(e)},n=await Ci(e);n&&(t.dashscope_commands={method:n.method,source:n.source,masked:O(n.token)});let r=await wi(e);return r&&(t.console_gateway_commands={method:r.method,source:r.source,masked:O(r.token)}),t}function Ei(e){return e.api_key.configured||e.access_token.configured||!!e.dashscope_commands||!!e.console_gateway_commands}function Di(e){F(`Authentication Status:`),F(` Stored credentials (can coexist):`),e.api_key.configured?F(` API key: ${e.api_key.source} ${e.api_key.masked}`):F(` API key: not configured`),e.access_token.configured?F(` Console token: ${e.access_token.source} ${e.access_token.masked}`):F(` Console token: not configured`),F(` Effective credential per command family:`),e.dashscope_commands?F(` DashScope API: ${e.dashscope_commands.method} (${e.dashscope_commands.source}) ${e.dashscope_commands.masked}`):F(` DashScope API: unavailable`),e.console_gateway_commands?F(` Console gateway: ${e.console_gateway_commands.method} (${e.console_gateway_commands.source}) ${e.console_gateway_commands.masked}`):F(` Console gateway: unavailable (run bl auth login --console)`)}var Oi,ki=M((()=>{I(),Et(),Oi=m({name:`auth status`,description:`Show current authentication state`,usage:`bl auth status`,examples:[`bl auth status`,`bl auth status --output json`],async run(e,t){let n=h(e.output),r=await Ti(e);if(!Ei(r)){P({authenticated:!1,message:`Not authenticated.`,hint:[`DashScope API: bl auth login --api-key <key> or DASHSCOPE_API_KEY`,`Console gateway: bl auth login --console or DASHSCOPE_ACCESS_TOKEN`,`Get API Key: ${Tt}`].join(`
112
+ `),...r},n);return}if(n!==`text`){P({authenticated:!0,...r},n);return}Di(r)}})}));async function Ai(){let e=ue();return e.access_token?(delete e.access_token,await De(e),!0):!1}var ji,Mi=M((()=>{I(),ji=m({name:`auth logout`,description:`Clear stored credentials`,usage:`bl auth logout [--console] [--yes] [--dry-run]`,options:[{flag:`--console`,description:`Only clear the console access_token, keep api_key intact`,type:`boolean`},{flag:`--yes`,description:`Skip confirmation prompt`}],examples:[`bl auth logout`,`bl auth logout --console`,`bl auth logout --dry-run`,`bl auth logout --yes`],async run(e,t){let n=ue();if(t.console){let t=!!n.access_token;if(e.dryRun){F(t?`Would clear access_token from ~/.bailian/config.json`:`No console access_token to clear.`),F(`No changes made.`);return}t?(await Ai(),process.stderr.write(`Cleared access_token from ${S()}\n`),n.api_key&&process.stderr.write(`api_key is still configured and will be used for authentication.
113
113
  `)):process.stderr.write(`No console access_token to clear.
114
- `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){P(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),P(`No changes made.`);return}r?(await p(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
114
+ `);return}let r=!!(n.api_key||n.access_token);if(e.dryRun){F(r?`Would clear api_key / access_token from ~/.bailian/config.json`:`No credentials to clear.`),F(`No changes made.`);return}r?(await p(),process.stderr.write(`Cleared api_key / access_token from ~/.bailian/config.json
115
115
  `)):process.stderr.write(`No credentials to clear.
116
- `)}})}));function Di(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=ze(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var Oi,ki=j((()=>{W(),F(),Oi=m({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,apiDocs:`/compatibility-of-openai-with-dashscope`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.7-max)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=Di(t),i=r;if(i.length===0)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
117
- `),process.exit(1)),i=[{role:`user`,content:e}]}else U(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.7-max`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=h(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let l={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(l.temperature=t.temperature),t.topP!==void 0&&(l.top_p=t.topP),t.enableThinking&&(l.enable_thinking=!0,t.thinkingBudget!==void 0&&(l.thinking_budget=t.thinkingBudget)),t.tool&&(l.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=ze(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){N({request:l},s);return}let u=f(e.baseUrl);if(o){let t=await de(e,{url:u,method:`POST`,body:l,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,d=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of oe(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,d.write(`${a}Thinking:\n`)),i&&d.write(t.reasoning_content)),t.content&&(i&&r&&(d.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&d.write(o),s===`json`?N({content:n},s):f.write(`
118
- `)}else{let t=await O(e,{url:u,method:`POST`,body:l}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?P(n):N(t,s)}}})}));function Ai(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var ji,Mi,Ni=j((()=>{W(),F(),ji=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],Mi=m({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,apiDocs:`/model-studio/qwen-omni`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${ji.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "你好,你是谁?"`,`bl omni --message "描述这张图片" --image ./photo.jpg`,`bl omni --message "这段音频在说什么?" --audio https://example.com/audio.wav`,`bl omni --message "总结这个视频" --video https://example.com/video.mp4`,`bl omni --message "这个视频讲了什么" --video ./local-video.mp4 --text-only`,`bl omni --message "用四川话回答:今天天气怎么样" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "朗读这段话" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
119
- `),process.exit(1)),n=[e]}else U(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=h(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let l=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(l.has(n)){let r=e.slice(t+1);n===`system`?c.push({role:`system`,content:r}):c.push({role:n,content:r})}else c.push({role:`user`,content:e})}let u=t.image||[],d=t.audio||[],p=t.video||[],m=[],g=[],_=[];if(u.length>0||d.length>0||p.length>0){let t=await k(e);for(let e of u){let n=await A(e,t.token,r);m.push(n)}for(let e of d){let n=await A(e,t.token,r);g.push(n)}for(let e of p)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await A(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await A(e,t.token,r);_.push(n)}}if(m.length>0||g.length>0||_.length>0){for(let e=c.length-1;e>=0;e--)if(c[e].role===`user`){let t=c[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of m)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});c[e]={role:`user`,content:n};break}}let v={model:r,messages:c,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){N({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await de(e,{url:f(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,x=``,S=process.stdout.isTTY,C=process.stdout;for await(let e of oe(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(b+=t.content,S&&C.write(t.content)),t.audio?.data&&(x+=t.audio.data)}}catch{}}S&&b&&C.write(`
120
- `);let w;if(x&&!o){let n=Buffer.from(x,`base64`),r=Ai(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(me(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}Ve(a,i),w=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!S||s===`json`){let e={content:b};w&&(e.audio_saved=w,e.voice=i),N(e,s)}}})}));function Pi(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Ii[n%Ii.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 Fi(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(`
121
- `)}}}var Ii,Li=j((()=>{Ii=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function Ri(e,n){let r=Date.now()+n.timeoutSec*1e3,a=Pi(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await O(e,{url:n.url});if(n.getStatus&&!e.quiet&&a.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return a.stop(`Done.`),r;if(n.isFailed(r)){a.stop(`Failed.`),e.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let o=n.getErrorMessage?.(r);throw new t(o?`Task failed: ${o}`:`Task failed.`,i.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var zi=j((()=>{Li()}));async function Bi(e,n,r){let a=await fetch(e,{headers:Se()});if(!a.ok)throw new t(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new t(`No response body`,i.GENERAL);Re(He(n),{recursive:!0});let c=Ie(n),l=o>0&&!r?.quiet?Fi(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{Be(n)}catch{}}return{size:u}}function Vi(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`}var Hi=j((()=>{Li()}));function Ui(e){let t=e.concurrent;return Math.max(1,t??1)}async function Wi(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 Gi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var Ki=j((()=>{}));function qi(e,t){if(e)return(t?Ji:Yi)[e]??e}var Ji,Yi,Xi=j((()=>{Ji={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},Yi={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}})),Zi,Qi,$i,ea,ta=j((()=>{Zi=`Enable watermark (true/false). Omit flag to use CLI default (true).`,Qi=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,$i=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,ea=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`}));function na(e){return oa.some(t=>e.startsWith(t))}async function ra(e,n,r,a,o,s){let c=w(e.baseUrl),l=(await Wi(s,e,()=>O(e,{url:c,method:`POST`,body:r}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new t(`Generation completed but no images returned.`,i.GENERAL);await aa(l,a,e,o)}async function ia(e,n,r,a,o,s){let c=C(e.baseUrl),l=(await Wi(s,e,()=>O(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){N({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>Ri(e,{url:be(e.baseUrl,t),intervalSec:u,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new t(`All tasks completed but no images returned.`,i.GENERAL);await aa(p,a,e,o,l.length===1?l[0]:void 0,l)}async function aa(e,t,n,r,i,a){let o=me(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||v(`image`,s),l=await Gi(e.length>1?e.map((e,t)=>({url:e,destPath:We(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:We(o,`${c}.png`)}],Bi,{quiet:n.quiet});if(n.quiet)P(l.join(`
122
- `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),N(t,r)}}var oa,sa,ca=j((()=>{zi(),Hi(),Ki(),W(),F(),Xi(),ta(),oa=[`qwen-image-2.0`,`qwen-image-max`],sa=m({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,apiDocs:`/best-practice/wanx/text-to-image`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:$i},{flag:`--watermark <bool>`,description:Zi},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "一只穿太空服的猫在火星上"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --prompt-extend false`,`bl image generate --prompt "Logo" --watermark false`,`bl image generate --prompt "An alien in the space" --watermark false`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
123
- `),process.exit(1)),n=e}else U(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=na(r),a=qi(t.size||`1:1`,i),o=t.n??1,s=Ui(t),c=fe(t.promptExtend,i?!0:void 0,`prompt-extend`),l=he(t.watermark),u={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:l,negative_prompt:t.negativePrompt||void 0}},d=h(e.output);if(e.dryRun){N({request:u,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await ra(e,r,u,t,d,s):await ia(e,r,u,t,d,s)}})})),la,ua=j((()=>{Hi(),Ki(),W(),F(),Xi(),ta(),la=m({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,apiDocs:`/developer-reference/qwen-image-edit-api`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:Qi},{flag:`--watermark <bool>`,description:Zi},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "把背景换成海滩"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "把两张图合并成一张拼图"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`,`bl image edit --image ./photo.png --prompt "把背景换成海滩" --watermark false`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&U(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
124
- `),process.exit(1)),a=e}else U(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await k(e),c=await Promise.all(r.map(e=>A(e,s.token,o))),l=n.n??1,u=fe(n.promptExtend,!0,`prompt-extend`),d=c.map(e=>({image:e}));d.push({text:a});let f=he(n.watermark),p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:qi(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:f,negative_prompt:n.negativePrompt||void 0}};ye(p.parameters);let m=h(e.output);if(e.dryRun){N({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=w(e.baseUrl),_=(await Wi(Ui(n),e,()=>O(e,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new t(`Edit completed but no images returned.`,i.GENERAL);let y=me(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),b=n.outPrefix||v(`edited`,n?.prompt),x=await Gi(_.length>1?_.map((e,t)=>({url:e,destPath:We(y,`${b}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:We(y,`${b}.png`)}],Bi,{quiet:e.quiet});e.quiet?P(x.join(`
125
- `)):N({urls:_,saved:x,total:_.length},m)}})}));function da(e){if(e)return fa[e.toLowerCase()]||e}var fa,pa,ma=j((()=>{zi(),Hi(),Ki(),W(),F(),ta(),fa={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},pa=m({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,apiDocs:`/best-practice/wanx/text-to-video`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:ea},{flag:`--watermark <bool>`,description:Zi},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 5)`,type:`number`}],examples:[`bl video generate --prompt "一个人在读书,静态镜头"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "让画面中的猫动起来"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`,`bl video generate --prompt "A cat playing with a ball" --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
126
- `),process.exit(1)),r=e}else U(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=h(e.output),s=n.image,c;s&&(c=await A(s,(await k(e)).token,a));let l=he(n.watermark),u=fe(n.promptExtend,void 0,`prompt-extend`),d={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:da(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:u,watermark:l,seed:n.seed}};if(e.dryRun){N({request:d},o);return}let f=Ui(n),p=Te(e.baseUrl),m=(await Wi(f,e,()=>O(e,{url:p,method:`POST`,body:d,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){N(m.length===1?{task_id:m[0]}:{task_ids:m},o);return}let g=n.pollInterval??5,_=m.map(t=>Ri(e,{url:be(e.baseUrl,t),intervalSec:g,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),v=await Promise.all(_),y=[];for(let e=0;e<v.length;e++){let t=v[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&y.push({taskId:m[e],videoUrl:n})}if(y.length===0)throw new t(`All tasks completed but no video URLs returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Bi(y[0].videoUrl,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:y[0].taskId,video_url:y[0].videoUrl,status:`SUCCEEDED`,saved:t,size:Vi(r)},o);return}let b=me(e,{subDir:`videos`}),{join:x}=await import(`path`),S=[];await Promise.all(y.map(async({taskId:t,videoUrl:n})=>{let r=x(b,`${t}.mp4`);await Bi(n,r,{quiet:e.quiet}),S.push({task_id:t,video_url:n,saved:r})})),S.length===1?N(S[0],o):N({videos:S,total:S.length},o)}})})),ha,ga=j((()=>{zi(),Hi(),W(),F(),ta(),ha=m({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,apiDocs:`/best-practice/wanx/video-edit`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "将画面转换为黏土风格")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend <bool>`,description:ea},{flag:`--watermark <bool>`,description:Zi},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video edit --video https://example.com/input.mp4 --prompt "将整个画面转换为黏土风格"`,`bl video edit --video https://example.com/input.mp4 --prompt "替换衣服为图片中的款式" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`,`bl video edit --video https://example.com/input.mp4 --prompt "给视频里的小猫穿上衣服" --watermark false`],async run(e,n){let r=n.video;if(!r)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
127
- `),process.exit(1)),r=e}else U(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
128
- `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=h(e.output),c=await k(e),l=[{type:`video`,url:await A(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await A(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=fe(n.promptExtend,void 0,`prompt-extend`),f=he(n.watermark),p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:f,seed:n.seed}};if(e.dryRun){N({request:p},s);return}let m=(await O(e,{url:Te(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
129
- `)),n.noWait||e.async){N({task_id:m},s);return}let g=n.pollInterval??15,_=await Ri(e,{url:be(e.baseUrl,m),intervalSec:g,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),v=_.output.video_url||_.output.results&&_.output.results[0]?.url;if(!v)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Bi(v,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:m,video_url:v,status:`SUCCEEDED`,saved:t,size:Vi(r)},s);return}let y=await import(`path`),b=me(e,{subDir:`videos`}),x=y.join(b,`${m}.mp4`);await Bi(v,x,{quiet:e.quiet}),N({task_id:m,video_url:v,saved:x},s)}})})),_a,va=j((()=>{zi(),Hi(),W(),F(),ta(),_a=m({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,apiDocs:`/best-practice/wanx/video-reference`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (图1, 视频1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 720P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (2-10, default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:ea},{flag:`--watermark <bool>`,description:Zi},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "图1在草地上奔跑" --image person.jpg`,`bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`,`bl video ref --prompt "图1在喝水" --image person.jpg --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your video prompt (use 图1, 视频1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
130
- `),process.exit(1)),r=e}else U(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "描述" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=h(e.output),d=await k(e),f=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await A(a[e],d.token,l)};s[e]&&(t.reference_voice=await A(s[e],d.token,l)),f.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await A(o[e],d.token,l)};c[e]&&(t.reference_voice=await A(c[e],d.token,l)),f.push(t)}let p=fe(n.promptExtend,void 0,`prompt-extend`),m=he(n.watermark),g={model:l,input:{prompt:r,media:f},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:p,watermark:m,seed:n.seed}};if(e.dryRun){N({request:g},u);return}let _=(await O(e,{url:Te(e.baseUrl),method:`POST`,body:g,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
131
- `)),n.noWait||e.async){N({task_id:_},u);return}let v=n.pollInterval??15,y=await Ri(e,{url:be(e.baseUrl,_),intervalSec:v,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Bi(b,t,{quiet:e.quiet});e.quiet?P(t):N({task_id:_,video_url:b,status:`SUCCEEDED`,saved:t,size:Vi(r)},u);return}let{join:x}=await import(`path`),S=x(me(e,{subDir:`videos`}),`${_}.mp4`);await Bi(b,S,{quiet:e.quiet}),N({task_id:_,video_url:b,saved:S},u)}})})),ya,ba=j((()=>{W(),F(),ya=m({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||U(`task-id`,`bl video task get --task-id <id>`);let r=h(e.output);if(e.dryRun){N({task_id:n},r);return}let i=await O(e,{url:be(e.baseUrl,n)});if(e.quiet){P(i.output.task_status);return}N({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),xa,Sa=j((()=>{Hi(),W(),F(),xa=m({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||U(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||U(`out`,`bl video download --task-id <id> --out video.mp4`);let o=h(e.output);if(e.dryRun){N({task_id:r,action:`download`,out:a},o);return}let s=await O(e,{url:be(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Bi(c,a,{quiet:e.quiet});if(e.quiet){P(a);return}N({saved:a,size:Vi(l)},o)}})}));function Ca(e){let t=Ue(e).toLowerCase().split(`?`)[0];return!!(Ea.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function wa(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Le(e))throw new t(`File not found: ${e}`,i.USAGE);let n=Ue(e).toLowerCase(),r=Ta[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${ze(e).toString(`base64`)}`}var Ta,Ea,Da,Oa=j((()=>{W(),F(),Ta={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Ea=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Da=m({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen3-vl-plus)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen3-vl-plus`;r&&Ca(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,l=n.prompt||c;if(!r&&!s)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
132
- `),process.exit(1)),Ca(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
133
- bl vision describe --video <url-or-path>`);let u=h(e.output);if(e.dryRun){N({request:{prompt:l,image:r,video:a.length?a:void 0,model:o}},u);return}let d=[];if(a.length>0)for(let n of a){let r=n;if(E(n)){if(!Le(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await A(n,(await k(e)).token,o)}d.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await wa(r),n=t;if(E(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await k(e);n=await A(r,t.token,o)}}d.push({type:`image_url`,image_url:{url:n}})}d.push({type:`text`,text:l});let p={model:o,messages:[{role:`user`,content:d}]},m=await O(e,{url:f(e.baseUrl),method:`POST`,body:p}),g=m.choices?.[0]?.message?.content;if(u!==`text`){N(m,u);return}P(g||``)}})})),ka,Aa=j((()=>{F(),ka=m({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=le(),r=h(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:x()};n.api_key&&(i.api_key=D(n.api_key)),n.access_token&&(i.access_token=D(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),N(i,r)}})})),ja,Ma,Na,Pa,Fa=j((()=>{F(),ja=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],Ma=new Set([`api_key`,`access_token`,`access_key_id`,`access_key_secret`]),Na={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},Pa=m({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=Na[r]||r;if(!ja.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${ja.join(`, `)}`,i.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new t(`Invalid region "${a}". Valid values: cn, us, intl`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=h(e.output);if(e.dryRun){N({would_set:{[o]:a}},s);return}let c=le();if(c[o]=o===`timeout`?Number(a):a,await Ee(c),!e.quiet){let e=Ma.has(o)?D(String(c[o])):c[o];N({[o]:e},s)}}})})),Ia,La,Ra=j((()=>{Ia=[`auth `,`config `,`update`],La=m({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(Af(),Of)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=y(e);process.stdout.write(JSON.stringify(n,null,2)+`
134
- `);return}let o=Object.values(r).filter(e=>!Ia.some(t=>e.name.startsWith(t))).map(e=>y(e));process.stdout.write(JSON.stringify(o,null,2)+`
135
- `)}})}));mi(),Ci(),Ei(),ki(),Ni(),ca(),ua(),ma(),ga(),va(),ba(),Sa(),Oa(),Aa(),Fa(),Ra();var za=`1.2.1`,Ba,Va=j((()=>{Ba=za}));function Ha(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function Ua(){try{let e=ze(Xa(),`utf-8`);return JSON.parse(e)}catch{return null}}function Wa(e){try{Ve(Xa(),JSON.stringify(e))}catch{}}async function Ga(e=Qa){try{let t=Ya.replace(`/`,`%2f`),n=await fetch(`${Ja}/${t}/latest`,{headers:{Accept:`application/json`,...Se()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Ka(){return $a}async function qa(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Ua(),n=Date.now();if(t&&n-t.lastChecked<Za){t.latestVersion&&Ha(t.latestVersion,e)&&($a=t.latestVersion);return}let r=await Ga();r&&(Wa({lastChecked:n,latestVersion:r}),r&&Ha(r,e)&&($a=r))}var Ja,Ya,Xa,Za,Qa,$a,eo=j((()=>{Ja=`https://registry.npmjs.org`,Ya=`bailian-cli`,Xa=()=>We(b(),`update-state.json`),Za=14400*1e3,Qa=3e3,$a=null}));function to(){return{cmd:`npm install -g ${Ya}@latest`,label:`npm`}}function no(e){let{green:t,yellow:n,reset:r}=e;process.stderr.write(`
116
+ `)}})}));function Ni(e){let t=[],n;if(e.system&&(n=e.system),e.messagesFile){let r=e.messagesFile,i=Be(r===`-`?`/dev/stdin`:r,`utf-8`),a=JSON.parse(i);for(let e of a)e.role===`system`?n=typeof e.content==`string`?e.content:``:t.push(e)}if(e.message){let r=new Set([`system`,`user`,`assistant`]),i=e.message;for(let e of i){let i=e.indexOf(`:`),a=i===-1?``:e.slice(0,i);if(r.has(a)){let r=e.slice(i+1);a===`system`?n=r:t.push({role:a,content:r})}else t.push({role:`user`,content:e})}}return{system:n,messages:t}}var Pi,Fi=M((()=>{H(),I(),Pi=m({name:`text chat`,description:`Send a chat completion (OpenAI compatible, DashScope)`,usage:`bl text chat --message <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: qwen3.7-max)`},{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--messages-file <path>`,description:`JSON file with messages array (use - for stdin)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate (default: 4096)`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`},{flag:`--top-p <n>`,description:`Nucleus sampling threshold`,type:`number`},{flag:`--stream`,description:`Stream response tokens (default: on in TTY)`},{flag:`--tool <json-or-path>`,description:`Tool definition as JSON or file path (repeatable)`,type:`array`},{flag:`--enable-thinking`,description:`Enable thinking/reasoning mode (for qwen3/qwq models)`},{flag:`--thinking-budget <n>`,description:`Max tokens for thinking (default: 4096)`,type:`number`}],examples:[`bl text chat --message "What is Qwen?"`,`bl text chat --model qwen-max --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,`bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"`,`cat conversation.json | bl text chat --messages-file - --stream`,`bl text chat --message "Hello" --output json`,`bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking`],async run(e,t){let{system:n,messages:r}=Ni(t),i=r;if(i.length===0)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your message:`});e||(process.stderr.write(`Chat cancelled.
117
+ `),process.exit(1)),i=[{role:`user`,content:e}]}else V(`message`,`bl text chat --message <text>`);let a=t.model||e.defaultTextModel||`qwen3.7-max`,o=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,s=h(e.output),c=[];n&&c.push({role:`system`,content:n}),c.push(...i);let l={model:a,messages:c,max_tokens:t.maxTokens??4096,stream:o};if(t.temperature!==void 0&&(l.temperature=t.temperature),t.topP!==void 0&&(l.top_p=t.topP),t.enableThinking&&(l.enable_thinking=!0,t.thinkingBudget!==void 0&&(l.thinking_budget=t.thinkingBudget)),t.tool&&(l.tools=t.tool.map(e=>{try{return JSON.parse(e)}catch{let t=Be(e,`utf-8`);return JSON.parse(t)}})),e.dryRun){P({request:l},s);return}let u=f(e.baseUrl);if(o){let t=await fe(e,{url:u,method:`POST`,body:l,stream:!0}),n=``,r=!1,i=s===`text`,a=e.noColor?``:`\x1B[2m`,o=e.noColor?``:`\x1B[0m`,c=process.stdout.isTTY,d=s===`json`?process.stderr:c?process.stdout:process.stderr,f=process.stdout;for await(let e of se(t)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.reasoning_content&&(i&&!r&&(r=!0,d.write(`${a}Thinking:\n`)),i&&d.write(t.reasoning_content)),t.content&&(i&&r&&(d.write(`${o}\n\nResponse:\n`),r=!1),n+=t.content,i&&f.write(t.content))}}catch{}}r&&d.write(o),s===`json`?P({content:n},s):f.write(`
118
+ `)}else{let t=await k(e,{url:u,method:`POST`,body:l}),n=t.choices?.[0]?.message?.content??``;e.quiet||s===`text`?F(n):P(t,s)}}})}));function Ii(e){let t=Buffer.alloc(44);return t.write(`RIFF`,0),t.writeUInt32LE(36+e,4),t.write(`WAVE`,8),t.write(`fmt `,12),t.writeUInt32LE(16,16),t.writeUInt16LE(1,20),t.writeUInt16LE(1,22),t.writeUInt32LE(24e3,24),t.writeUInt32LE(48e3,28),t.writeUInt16LE(2,32),t.writeUInt16LE(16,34),t.write(`data`,36),t.writeUInt32LE(e,40),t}var Li,Ri,zi=M((()=>{H(),I(),Li=[`Chelsie`,`Cherry`,`Ethan`,`Serena`,`Tina`],Ri=m({name:`omni`,description:`Multimodal chat with text + audio output (Qwen-Omni)`,usage:`bl omni --message <text> [flags]`,options:[{flag:`--message <text>`,description:`Message text (repeatable, prefix role: to set role)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: qwen3.5-omni-plus)`},{flag:`--system <text>`,description:`System prompt`},{flag:`--image <url>`,description:`Image URL or local file (repeatable)`,type:`array`},{flag:`--audio <url>`,description:`Audio URL or local file (repeatable)`,type:`array`},{flag:`--video <url>`,description:`Video file URL / local path, or comma-separated frame URLs`,type:`array`},{flag:`--voice <voice>`,description:`Output voice (default: Cherry). Options: ${Li.join(`, `)}`},{flag:`--audio-format <fmt>`,description:`Audio output format (default: wav)`},{flag:`--audio-out <path>`,description:`Save audio to file (default: auto-generate)`},{flag:`--text-only`,description:`Output text only, no audio generation`},{flag:`--max-tokens <n>`,description:`Maximum tokens to generate`,type:`number`},{flag:`--temperature <n>`,description:`Sampling temperature (0.0, 2.0]`,type:`number`}],examples:[`bl omni --message "你好,你是谁?"`,`bl omni --message "描述这张图片" --image ./photo.jpg`,`bl omni --message "这段音频在说什么?" --audio https://example.com/audio.wav`,`bl omni --message "总结这个视频" --video https://example.com/video.mp4`,`bl omni --message "这个视频讲了什么" --video ./local-video.mp4 --text-only`,`bl omni --message "用四川话回答:今天天气怎么样" --voice Serena`,`bl omni --message "Hello" --text-only --output json`,`bl omni --message "朗读这段话" --audio-out greeting.wav`],async run(e,t){let n=[];if(t.message&&(n=t.message),n.length===0)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your message:`});e||(process.stderr.write(`Omni chat cancelled.
119
+ `),process.exit(1)),n=[e]}else V(`message`,`bl text omni --message <text>`);let r=t.model||e.defaultOmniModel||`qwen3.5-omni-plus`,i=t.voice||`Cherry`,a=t.audioFormat||`wav`,o=t.textOnly===!0,s=h(e.output),c=[];t.system&&c.push({role:`system`,content:t.system});let l=new Set([`system`,`user`,`assistant`]);for(let e of n){let t=e.indexOf(`:`),n=t===-1?``:e.slice(0,t);if(l.has(n)){let r=e.slice(t+1);n===`system`?c.push({role:`system`,content:r}):c.push({role:n,content:r})}else c.push({role:`user`,content:e})}let u=t.image||[],d=t.audio||[],p=t.video||[],m=[],g=[],_=[];if(u.length>0||d.length>0||p.length>0){let t=await A(e);for(let e of u){let n=await j(e,t.token,r);m.push(n)}for(let e of d){let n=await j(e,t.token,r);g.push(n)}for(let e of p)if(e.includes(`,`)){let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=await j(e,t.token,r);_.push(`frame:${n}`)}}else{let n=await j(e,t.token,r);_.push(n)}}if(m.length>0||g.length>0||_.length>0){for(let e=c.length-1;e>=0;e--)if(c[e].role===`user`){let t=c[e].content,n=[];typeof t==`string`?n.push({type:`text`,text:t}):Array.isArray(t)&&n.push(...t);for(let e of m)n.push({type:`image_url`,image_url:{url:e}});for(let e of g)n.push({type:`audio_url`,audio_url:{url:e}});let r=_.filter(e=>e.startsWith(`frame:`)).map(e=>e.slice(6)),i=_.filter(e=>!e.startsWith(`frame:`));r.length>0&&n.push({type:`video`,video:r});for(let e of i)n.push({type:`video_url`,video_url:{url:e}});c[e]={role:`user`,content:n};break}}let v={model:r,messages:c,stream:!0,stream_options:{include_usage:!0}};if(o||(v.modalities=[`text`,`audio`],v.audio={voice:i,format:a}),t.maxTokens!==void 0&&(v.max_tokens=t.maxTokens),t.temperature!==void 0&&(v.temperature=t.temperature),e.dryRun){P({request:v},s);return}if(!e.quiet){let e=o?`text-only`:`text+audio, voice: ${i}`;process.stderr.write(`[Model: ${r}] [${e}]\n`)}let y=await fe(e,{url:f(e.baseUrl),method:`POST`,body:v,stream:!0}),b=``,x=``,S=process.stdout.isTTY,C=process.stdout;for await(let e of se(y)){if(e.data===`[DONE]`)break;try{let t=JSON.parse(e.data);for(let e of t.choices){let t=e.delta;t.content&&(b+=t.content,S&&C.write(t.content)),t.audio?.data&&(x+=t.audio.data)}}catch{}}S&&b&&C.write(`
120
+ `);let w;if(x&&!o){let n=Buffer.from(x,`base64`),r=Ii(n.length),i=Buffer.concat([r,n]),a=t.audioOut;if(!a){let{join:t}=await import(`path`);a=t(he(e,{subDir:`omni`}),`omni_${Date.now()}.wav`)}He(a,i),w=a,e.quiet||process.stderr.write(`Audio saved: ${a}\n`)}if(!S||s===`json`){let e={content:b};w&&(e.audio_saved=w,e.voice=i),P(e,s)}}})}));function Bi(e){let t=process.stderr.isTTY,n=0,r=null,i=e;return{start(){t&&(r=setInterval(()=>{process.stderr.write(`\r${Hi[n%Hi.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 Vi(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(`
121
+ `)}}}var Hi,Ui=M((()=>{Hi=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`]}));async function Wi(e,n){let r=Date.now()+n.timeoutSec*1e3,a=Bi(`Polling...`);e.quiet||a.start();try{for(;Date.now()<r;){let r=await k(e,{url:n.url});if(n.getStatus&&!e.quiet&&a.update(`Status: ${n.getStatus(r)}`),n.isComplete(r))return a.stop(`Done.`),r;if(n.isFailed(r)){a.stop(`Failed.`),e.verbose&&process.stderr.write(`[verbose] Task response: ${JSON.stringify(r,null,2)}\n`);let o=n.getErrorMessage?.(r);throw new t(o?`Task failed: ${o}`:`Task failed.`,i.GENERAL,o?void 0:`Use --verbose to see full API response details.`)}await new Promise(e=>setTimeout(e,n.intervalSec*1e3))}}finally{a.stop()}throw new t(`Polling timed out.`,i.TIMEOUT,`Try increasing --timeout or check task status manually.`)}var Gi=M((()=>{Ui()}));async function Ki(e,n,r){let a=await fetch(e,{headers:Ce()});if(!a.ok)throw new t(`Download failed: HTTP ${a.status}`,i.GENERAL);let o=Number(a.headers.get(`content-length`)||0),s=a.body?.getReader();if(!s)throw new t(`No response body`,i.GENERAL);ze(Ue(n),{recursive:!0});let c=Le(n),l=o>0&&!r?.quiet?Vi(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{Ve(n)}catch{}}return{size:u}}function qi(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`}var Ji=M((()=>{Ui()}));function Yi(e){let t=e.concurrent;return Math.max(1,t??1)}async function Xi(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 Zi(e,t,n){return Promise.all(e.map(({url:e,destPath:r})=>t(e,r,n).then(()=>r)))}var Qi=M((()=>{}));function $i(e,t){if(e)return(t?ea:ta)[e]??e}var ea,ta,na=M((()=>{ea={"16:9":`2688*1536`,"9:16":`1536*2688`,"1:1":`2048*2048`,"4:3":`2368*1728`,"3:4":`1728*2368`},ta={"16:9":`1664*928`,"4:3":`1472*1104`,"1:1":`1328*1328`,"3:4":`1104*1472`,"9:16":`928*1664`}})),ra,ia,aa,oa,sa=M((()=>{ra=`Enable watermark (true/false). Omit flag to use CLI default (true).`,ia=`Enable prompt extend (true/false). Omit flag to use CLI default (true).`,aa=`Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).`,oa=`Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).`}));function ca(e){return fa.some(t=>e.startsWith(t))}async function la(e,n,r,a,o,s){let c=T(e.baseUrl),l=(await Xi(s,e,()=>k(e,{url:c,method:`POST`,body:r}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(l.length===0)throw new t(`Generation completed but no images returned.`,i.GENERAL);await da(l,a,e,o)}async function ua(e,n,r,a,o,s){let c=w(e.baseUrl),l=(await Xi(s,e,()=>k(e,{url:c,method:`POST`,body:r,async:!0}),`tasks`)).map(e=>e.output.task_id);if(a.noWait||e.async){P({task_ids:l},o);return}let u=a.pollInterval??3,d=l.map(t=>Wi(e,{url:xe(e.baseUrl,t),intervalSec:u,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),f=await Promise.all(d),p=[];for(let e of f){if(e.output.choices){let t=e.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);p.push(...t)}if(e.output.results){let t=e.output.results.map(e=>e.url).filter(Boolean);t.length>0&&p.length===0&&p.push(...t)}}if(p.length===0)throw new t(`All tasks completed but no images returned.`,i.GENERAL);await da(p,a,e,o,l.length===1?l[0]:void 0,l)}async function da(e,t,n,r,i,a){let o=he(n,{flagDir:t.outDir,subDir:t.outDir?void 0:`images`}),s=t.prompt||t._positional?.[0]||``,c=t.outPrefix||y(`image`,s),l=await Zi(e.length>1?e.map((e,t)=>({url:e,destPath:Ge(o,`${c}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:e[0],destPath:Ge(o,`${c}.png`)}],Ki,{quiet:n.quiet});if(n.quiet)F(l.join(`
122
+ `));else{let t={urls:e,saved:l,total:e.length};i&&(t.task_id=i),a&&a.length>1&&(t.task_ids=a),P(t,r)}}var fa,pa,ma=M((()=>{Gi(),Ji(),Qi(),H(),I(),na(),sa(),fa=[`qwen-image-2.0`,`qwen-image-max`],pa=m({name:`image generate`,description:`Generate images (Qwen-Image / wan2.x)`,usage:`bl image generate --prompt <text> [flags]`,options:[{flag:`--prompt <text>`,description:`Image description`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Image size: ratio (3:4, 16:9, 1:1) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images per request (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:aa},{flag:`--watermark <bool>`,description:ra},{flag:`--no-wait`,description:`Return task ID immediately without waiting (async models only)`},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: image)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 3)`,type:`number`}],examples:[`bl image generate --prompt "一只穿太空服的猫在火星上"`,`bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/`,`bl image generate --prompt "Mountain landscape" --size 2688*1536`,`bl image generate --prompt "A castle" --seed 42 --prompt-extend false`,`bl image generate --prompt "Logo" --watermark false`,`bl image generate --prompt "An alien in the space" --watermark false`,`bl image generate --prompt "sunset" --model wan2.6-t2i --no-wait --quiet`,`bl image generate --prompt "Pro quality" --model qwen-image-2.0-pro`,`bl image generate --prompt "Product shots" --n 2 --concurrent 3 # 6 images in parallel`],async run(e,t){let n=t.prompt??t._positional?.[0];if(!n)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your image prompt:`});e||(process.stderr.write(`Image generation cancelled.
123
+ `),process.exit(1)),n=e}else V(`prompt`,`bl image generate --prompt <text>`);let r=t.model||e.defaultImageModel||`qwen-image-2.0`,i=ca(r),a=$i(t.size||`1:1`,i),o=t.n??1,s=Yi(t),c=pe(t.promptExtend,i?!0:void 0,`prompt-extend`),l=ge(t.watermark),u={model:r,input:{messages:[{role:`user`,content:[{text:n}]}]},parameters:{size:a,n:o,seed:t.seed,prompt_extend:c,watermark:l,negative_prompt:t.negativePrompt||void 0}},d=h(e.output);if(e.dryRun){P({request:u,mode:i?`sync`:`async`},d);return}e.quiet||process.stderr.write(`[Model: ${r}] [Mode: ${i?`sync`:`async`}]\n`),i?await la(e,r,u,t,d,s):await ua(e,r,u,t,d,s)}})})),ha,ga=M((()=>{Ji(),Qi(),H(),I(),na(),sa(),ha=m({name:`image edit`,description:`Edit an existing image with text instructions (Qwen-Image)`,usage:`bl image edit --image <url> --prompt <text> [flags]`,options:[{flag:`--image <url>`,description:`Source image URL or local file path (repeatable for multi-image merge)`,required:!0,type:`array`},{flag:`--prompt <text>`,description:`Edit instruction text`,required:!0},{flag:`--model <model>`,description:`Model ID (default: qwen-image-2.0)`},{flag:`--size <W*H>`,description:`Output image size: ratio (3:4, 16:9) or pixels (2048*2048)`},{flag:`--n <count>`,description:`Number of images (default: 1, max: 6)`,type:`number`},{flag:`--seed <n>`,description:`Random seed for reproducible results`,type:`number`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--prompt-extend <bool>`,description:ia},{flag:`--watermark <bool>`,description:ra},{flag:`--out-dir <dir>`,description:`Download images to directory`},{flag:`--out-prefix <prefix>`,description:`Filename prefix (default: edited)`}],examples:[`bl image edit --image ./photo.png --prompt "把背景换成海滩"`,`bl image edit --image https://example.com/logo.png --prompt "Change color to blue" --n 3`,`bl image edit --image ./a.png --image ./b.png --prompt "把两张图合并成一张拼图"`,`bl image edit --image https://example.com/photo.png --prompt "Remove the person" --model qwen-image-2.0-pro`,`bl image edit --image ./photo.png --prompt "把背景换成海滩" --watermark false`],async run(e,n){let r=[];Array.isArray(n.image)?r=n.image:typeof n.image==`string`&&(r=[n.image]),r.length===0&&V(`image`,`bl image edit --image <url> --prompt <text>`);let a=n.prompt;if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Image editing cancelled.
124
+ `),process.exit(1)),a=e}else V(`prompt`,`bl image edit --image <url> --prompt <text>`);let o=n.model||e.defaultImageModel||`qwen-image-2.0`,s=await A(e),c=await Promise.all(r.map(e=>j(e,s.token,o))),l=n.n??1,u=pe(n.promptExtend,!0,`prompt-extend`),d=c.map(e=>({image:e}));d.push({text:a});let f=ge(n.watermark),p={model:o,input:{messages:[{role:`user`,content:d}]},parameters:{size:$i(n.size,!0),n:l,seed:n.seed,prompt_extend:u,watermark:f,negative_prompt:n.negativePrompt||void 0}};be(p.parameters);let m=h(e.output);if(e.dryRun){P({request:p},m);return}e.quiet||process.stderr.write(`[Model: ${o}] [Mode: sync] [Images: ${c.length}]\n`);let g=T(e.baseUrl),_=(await Xi(Yi(n),e,()=>k(e,{url:g,method:`POST`,body:p}))).flatMap(e=>e.output.choices||[]).flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean);if(_.length===0)throw new t(`Edit completed but no images returned.`,i.GENERAL);let v=he(e,{flagDir:n.outDir,subDir:n.outDir?void 0:`images`}),b=n.outPrefix||y(`edited`,n?.prompt),x=await Zi(_.length>1?_.map((e,t)=>({url:e,destPath:Ge(v,`${b}_${String(t+1).padStart(3,`0`)}.png`)})):[{url:_[0],destPath:Ge(v,`${b}.png`)}],Ki,{quiet:e.quiet});e.quiet?F(x.join(`
125
+ `)):P({urls:_,saved:x,total:_.length},m)}})}));function _a(e){if(e)return va[e.toLowerCase()]||e}var va,ya,ba=M((()=>{Gi(),Ji(),Qi(),H(),I(),sa(),va={"720p":`1280*720`,"1080p":`1920*1080`,"480p":`832*480`},ya=m({name:`video generate`,description:`Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v)`,usage:`bl video generate --prompt <text> [--image <url>] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image)`},{flag:`--prompt <text>`,description:`Video description`,required:!0},{flag:`--image <url>`,description:`Input image URL for image-to-video generation`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution (e.g. 1280*720, 960*960)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (e.g. 16:9, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 5)`,type:`number`}],examples:[`bl video generate --prompt "一个人在读书,静态镜头"`,`bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4`,`bl video generate --image https://example.com/cat.png --prompt "让画面中的猫动起来"`,`bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5`,`bl video generate --prompt "A cat playing with a ball" --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your video prompt:`});e||(process.stderr.write(`Video generation cancelled.
126
+ `),process.exit(1)),r=e}else V(`prompt`,`bl video generate --prompt <text>`);let a=n.model||e.defaultVideoModel||(n.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),o=h(e.output),s=n.image,c;s&&(c=await j(s,(await A(e)).token,a));let l=ge(n.watermark),u=pe(n.promptExtend,void 0,`prompt-extend`),d={model:a,input:{prompt:r,negative_prompt:n.negativePrompt||void 0,...c?{media:[{type:`first_frame`,url:c}]}:{}},parameters:{resolution:_a(n.resolution)||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:u,watermark:l,seed:n.seed}};if(e.dryRun){P({request:d},o);return}let f=Yi(n),p=Ee(e.baseUrl),m=(await Xi(f,e,()=>k(e,{url:p,method:`POST`,body:d,async:!0}),`tasks`)).map(e=>e.output.task_id);if(e.quiet||process.stderr.write(`[Model: ${a}]\n`),n.noWait||e.async){P(m.length===1?{task_id:m[0]}:{task_ids:m},o);return}let g=n.pollInterval??5,_=m.map(t=>Wi(e,{url:xe(e.baseUrl,t),intervalSec:g,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}})),v=await Promise.all(_),y=[];for(let e=0;e<v.length;e++){let t=v[e],n=t.output.video_url||t.output.results&&t.output.results[0]?.url;n&&y.push({taskId:m[e],videoUrl:n})}if(y.length===0)throw new t(`All tasks completed but no video URLs returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ki(y[0].videoUrl,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:y[0].taskId,video_url:y[0].videoUrl,status:`SUCCEEDED`,saved:t,size:qi(r)},o);return}let b=he(e,{subDir:`videos`}),{join:x}=await import(`path`),S=[];await Promise.all(y.map(async({taskId:t,videoUrl:n})=>{let r=x(b,`${t}.mp4`);await Ki(n,r,{quiet:e.quiet}),S.push({task_id:t,video_url:n,saved:r})})),S.length===1?P(S[0],o):P({videos:S,total:S.length},o)}})})),xa,Sa=M((()=>{Gi(),Ji(),H(),I(),sa(),xa=m({name:`video edit`,description:`Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.)`,usage:`bl video edit --video <url> --prompt <text> [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-video-edit)`},{flag:`--video <url>`,description:`Input video URL or local file (mp4/mov, 2-10s)`,required:!0},{flag:`--prompt <text>`,description:`Edit instruction (e.g. "将画面转换为黏土风格")`},{flag:`--ref-image <url>`,description:`Reference image URL (up to 4, comma-separated)`},{flag:`--negative-prompt <text>`,description:`Negative prompt to exclude unwanted content`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 1080P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4)`},{flag:`--duration <seconds>`,description:`Output video duration in seconds (2-10)`,type:`number`},{flag:`--audio-setting <mode>`,description:`Audio: auto (default) or origin (keep original)`},{flag:`--prompt-extend <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video edit --video https://example.com/input.mp4 --prompt "将整个画面转换为黏土风格"`,`bl video edit --video https://example.com/input.mp4 --prompt "替换衣服为图片中的款式" --ref-image https://example.com/clothes.png`,`bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4`,`bl video edit --video https://example.com/input.mp4 --prompt "给视频里的小猫穿上衣服" --watermark false`],async run(e,n){let r=n.video;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter the video URL to edit:`});e||(process.stderr.write(`Video editing cancelled.
127
+ `),process.exit(1)),r=e}else V(`video`,`bl video edit --video <url> --prompt <text>`);let a=n.prompt;if(!a&&E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your edit instruction:`});e||(process.stderr.write(`Video editing cancelled.
128
+ `),process.exit(1)),a=e}let o=n.model||`happyhorse-1.0-video-edit`,s=h(e.output),c=await A(e),l=[{type:`video`,url:await j(r,c.token,o)}],u=n.refImage;if(u){let e=u.split(`,`).map(e=>e.trim()).filter(Boolean);for(let t of e){let e=await j(t,c.token,o);l.push({type:`reference_image`,url:e})}}let d=pe(n.promptExtend,void 0,`prompt-extend`),f=ge(n.watermark),p={model:o,input:{prompt:a||void 0,negative_prompt:n.negativePrompt||void 0,media:l},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,audio_setting:n.audioSetting||void 0,prompt_extend:d,watermark:f,seed:n.seed}};if(e.dryRun){P({request:p},s);return}let m=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:p,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${o}]\n`),process.stderr.write(`Note: Video editing typically takes 5-8 minutes. Please be patient.
129
+ `)),n.noWait||e.async){P({task_id:m},s);return}let g=n.pollInterval??15,_=await Wi(e,{url:xe(e.baseUrl,m),intervalSec:g,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),v=_.output.video_url||_.output.results&&_.output.results[0]?.url;if(!v)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ki(v,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:m,video_url:v,status:`SUCCEEDED`,saved:t,size:qi(r)},s);return}let y=await import(`path`),b=he(e,{subDir:`videos`}),x=y.join(b,`${m}.mp4`);await Ki(v,x,{quiet:e.quiet}),P({task_id:m,video_url:v,saved:x},s)}})})),Ca,wa=M((()=>{Gi(),Ji(),H(),I(),sa(),Ca=m({name:`video ref`,description:`Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice`,usage:`bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]`,options:[{flag:`--model <model>`,description:`Model ID (default: happyhorse-1.0-r2v)`},{flag:`--prompt <text>`,description:`Video description with reference markers (图1, 视频1, etc.)`,required:!0},{flag:`--image <url>`,description:`Reference image URL or local file (repeatable for multiple subjects)`,type:`array`},{flag:`--ref-video <url>`,description:`Reference video URL or local file (repeatable)`,type:`array`},{flag:`--image-voice <url>`,description:`Voice URL for corresponding image (pairs by position)`,type:`array`},{flag:`--video-voice <url>`,description:`Voice URL for corresponding ref-video (pairs by position)`,type:`array`},{flag:`--resolution <res>`,description:`Resolution: 720P or 1080P (default: 720P)`},{flag:`--ratio <ratio>`,description:`Aspect ratio (16:9, 9:16, 1:1)`},{flag:`--duration <seconds>`,description:`Video duration in seconds (2-10, default: 5)`,type:`number`},{flag:`--prompt-extend <bool>`,description:oa},{flag:`--watermark <bool>`,description:ra},{flag:`--seed <n>`,description:`Random seed for reproducible generation`,type:`number`},{flag:`--download <path>`,description:`Save video to file on completion`},{flag:`--no-wait`,description:`Return task ID immediately without waiting`},{flag:`--async`,description:`Return task ID immediately (agent/CI mode, same as --no-wait)`},{flag:`--poll-interval <seconds>`,description:`Polling interval when waiting (default: 15)`,type:`number`}],examples:[`bl video ref --prompt "图1在草地上奔跑" --image person.jpg`,`bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg`,`bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P`,`bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3`,`bl video ref --prompt "图1在喝水" --image person.jpg --watermark false`],async run(e,n){let r=n.prompt;if(!r)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your video prompt (use 图1, 视频1 to reference inputs):`});e||(process.stderr.write(`Video generation cancelled.
130
+ `),process.exit(1)),r=e}else V(`prompt`,`bl video ref --prompt <text> --image <url>`);let a=n.image||[],o=n.refVideo||[];if(a.length===0&&o.length===0)throw new t(`At least one --image or --ref-video is required.`,i.USAGE,`bl video ref --prompt "描述" --image person.jpg`);let s=n.imageVoice||[],c=n.videoVoice||[],l=n.model||`happyhorse-1.0-r2v`,u=h(e.output),d=await A(e),f=[];for(let e=0;e<a.length;e++){let t={type:`reference_image`,url:await j(a[e],d.token,l)};s[e]&&(t.reference_voice=await j(s[e],d.token,l)),f.push(t)}for(let e=0;e<o.length;e++){let t={type:`reference_video`,url:await j(o[e],d.token,l)};c[e]&&(t.reference_voice=await j(c[e],d.token,l)),f.push(t)}let p=pe(n.promptExtend,void 0,`prompt-extend`),m=ge(n.watermark),g={model:l,input:{prompt:r,media:f},parameters:{resolution:n.resolution||void 0,ratio:n.ratio||void 0,duration:n.duration||void 0,prompt_extend:p,watermark:m,seed:n.seed}};if(e.dryRun){P({request:g},u);return}let _=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:g,async:!0})).output.task_id;if(e.quiet||(process.stderr.write(`[Model: ${l}]\n`),process.stderr.write(`Note: Reference-to-video typically takes 5-10 minutes. Please be patient.
131
+ `)),n.noWait||e.async){P({task_id:_},u);return}let v=n.pollInterval??15,y=await Wi(e,{url:xe(e.baseUrl,_),intervalSec:v,timeoutSec:Math.max(e.timeout,600),isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>{let t=e.output;return t.message||t.code||void 0}}),b=y.output.video_url||y.output.results&&y.output.results[0]?.url;if(!b)throw new t(`Task completed but no video URL returned.`,i.GENERAL);if(n.download){let t=n.download,{size:r}=await Ki(b,t,{quiet:e.quiet});e.quiet?F(t):P({task_id:_,video_url:b,status:`SUCCEEDED`,saved:t,size:qi(r)},u);return}let{join:x}=await import(`path`),S=x(he(e,{subDir:`videos`}),`${_}.mp4`);await Ki(b,S,{quiet:e.quiet}),P({task_id:_,video_url:b,saved:S},u)}})})),Ta,Ea=M((()=>{H(),I(),Ta=m({name:`video task get`,description:`Query async task status`,usage:`bl video task get --task-id <id>`,options:[{flag:`--task-id <id>`,description:`Async task ID`}],examples:[`bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx`,`bl video task get --task-id 3b256896-3e70-xxxx --output json`],async run(e,t){let n=t.taskId;n||V(`task-id`,`bl video task get --task-id <id>`);let r=h(e.output);if(e.dryRun){P({task_id:n},r);return}let i=await k(e,{url:xe(e.baseUrl,n)});if(e.quiet){F(i.output.task_status);return}P({task_id:i.output.task_id,task_status:i.output.task_status,video_url:i.output.video_url,results:i.output.results,submit_time:i.output.submit_time,end_time:i.output.end_time},r)}})})),Da,Oa=M((()=>{Ji(),H(),I(),Da=m({name:`video download`,description:`Download a completed video by task ID`,usage:`bl video download --task-id <id> --out <path>`,options:[{flag:`--task-id <id>`,description:`Task ID to download from`},{flag:`--out <path>`,description:`Output file path`}],examples:[`bl video download --task-id 3b256896-xxxx --out video.mp4`,`bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet`],async run(e,n){let r=n.taskId;r||V(`task-id`,`bl video download --task-id <id> --out <path>`);let a=n.out;a||V(`out`,`bl video download --task-id <id> --out video.mp4`);let o=h(e.output);if(e.dryRun){P({task_id:r,action:`download`,out:a},o);return}let s=await k(e,{url:xe(e.baseUrl,r)});if(s.output.task_status!==`SUCCEEDED`)throw new t(`Task is not complete (status: ${s.output.task_status}).`,i.GENERAL,`Wait for the task to complete before downloading.`);let c=s.output.video_url||s.output.results&&s.output.results[0]?.url;if(!c)throw new t(`No download URL available for this task.`,i.GENERAL);let{size:l}=await Ki(c,a,{quiet:e.quiet});if(e.quiet){F(a);return}P({saved:a,size:qi(l)},o)}})}));function ka(e){let t=We(e).toLowerCase().split(`?`)[0];return!!(Ma.has(t)||/\.(mp4|mov|avi|mkv|webm|flv|wmv)(\?|$)/i.test(e))}async function Aa(e){if(e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`))return e;if(!Re(e))throw new t(`File not found: ${e}`,i.USAGE);let n=We(e).toLowerCase(),r=ja[n];if(!r)throw new t(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,i.USAGE);return`data:${r};base64,${Be(e).toString(`base64`)}`}var ja,Ma,Na,Pa=M((()=>{H(),I(),ja={".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`},Ma=new Set([`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`,`.flv`,`.wmv`]),Na=m({name:`vision describe`,description:`Describe an image or video using Qwen-VL`,usage:`bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]`,options:[{flag:`--image <path-or-url>`,description:`Local image path or URL`},{flag:`--video <url>`,description:`Video file URL or local path (mp4/mov/avi/mkv/webm)`,type:`array`},{flag:`--prompt <text>`,description:`Question about the content (default: auto-detected)`},{flag:`--model <model>`,description:`Vision model (default: qwen3-vl-plus)`}],examples:[`bl vision describe --image photo.jpg`,`bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"`,`bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"`,`bl vision describe --video ./local-video.mp4`,`bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus`],async run(e,n){let r=n.image??n._positional?.[0],a=n.video??[],o=n.model||`qwen3-vl-plus`;r&&ka(r)&&(a.push(r),r=void 0);let s=a.length>0,c=s?`Describe the video.`:`Describe the image.`,l=n.prompt||c;if(!r&&!s)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter image/video path or URL:`});e||(process.stderr.write(`Vision describe cancelled.
132
+ `),process.exit(1)),ka(e)?a.push(e):r=e}else throw new t(`Missing required argument --image or --video.`,i.USAGE,`bl vision describe --image <path-or-url>
133
+ bl vision describe --video <url-or-path>`);let u=h(e.output);if(e.dryRun){P({request:{prompt:l,image:r,video:a.length?a:void 0,model:o}},u);return}let d=[];if(a.length>0)for(let n of a){let r=n;if(D(n)){if(!Re(n))throw new t(`Video file not found: ${n}`,i.USAGE);r=await j(n,(await A(e)).token,o)}d.push({type:`video_url`,video_url:{url:r}})}if(r){let t=await Aa(r),n=t;if(D(r)&&t.startsWith(`data:`)){let{statSync:t}=await import(`fs`);if(t(r).size>5*1024*1024){let t=await A(e);n=await j(r,t.token,o)}}d.push({type:`image_url`,image_url:{url:n}})}d.push({type:`text`,text:l});let p={model:o,messages:[{role:`user`,content:d}]},m=await k(e,{url:f(e.baseUrl),method:`POST`,body:p}),g=m.choices?.[0]?.message?.content;if(u!==`text`){P(m,u);return}F(g||``)}})})),Fa,Ia=M((()=>{I(),Fa=m({name:`config show`,description:`Display current configuration`,usage:`bl config show`,examples:[`bl config show`,`bl config show --output json`],async run(e,t){let n=ue(),r=h(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:S()};n.api_key&&(i.api_key=O(n.api_key)),n.access_token&&(i.access_token=O(n.access_token)),n.default_text_model&&(i.default_text_model=n.default_text_model),n.default_video_model&&(i.default_video_model=n.default_video_model),n.default_image_model&&(i.default_image_model=n.default_image_model),P(i,r)}})})),La,Ra,za,Ba,Va=M((()=>{I(),La=[`region`,`base_url`,`output`,`output_dir`,`timeout`,`api_key`,`access_token`,`default_text_model`,`default_video_model`,`default_image_model`,`default_speech_model`,`default_omni_model`,`access_key_id`,`access_key_secret`,`workspace_id`],Ra=new Set([`api_key`,`access_token`,`access_key_id`,`access_key_secret`]),za={"base-url":`base_url`,"output-dir":`output_dir`,"api-key":`api_key`,"access-token":`access_token`,"default-text-model":`default_text_model`,"default-video-model":`default_video_model`,"default-image-model":`default_image_model`,"default-speech-model":`default_speech_model`,"default-omni-model":`default_omni_model`,"access-key-id":`access_key_id`,"access-key-secret":`access_key_secret`,"workspace-id":`workspace_id`},Ba=m({name:`config set`,description:`Set a config value`,usage:`bl config set --key <key> --value <value>`,options:[{flag:`--key <key>`,description:`Config key (region, base_url, output, output_dir, timeout, api_key, access_token, default_*_model, access_key_id, access_key_secret, workspace_id)`},{flag:`--value <value>`,description:`Value to set`}],examples:[`bl config set --key output --value json`,`bl config set --key timeout --value 600`,`bl config set --key base_url --value https://dashscope.aliyuncs.com`],async run(e,n){let r=n.key,a=n.value;if(!r||a===void 0)throw new t(`--key and --value are required.`,i.USAGE,`bl config set --key <key> --value <value>`);let o=za[r]||r;if(!La.includes(o))throw new t(`Invalid config key "${r}". Valid keys: ${La.join(`, `)}`,i.USAGE);if(o===`region`&&![`cn`,`us`,`intl`].includes(a))throw new t(`Invalid region "${a}". Valid values: cn, us, intl`,i.USAGE);if(o===`output`&&![`text`,`json`].includes(a))throw new t(`Invalid output format "${a}". Valid values: text, json`,i.USAGE);if(o===`timeout`){let e=Number(a);if(isNaN(e)||e<=0)throw new t(`Invalid timeout "${a}". Must be a positive number.`,i.USAGE)}let s=h(e.output);if(e.dryRun){P({would_set:{[o]:a}},s);return}let c=ue();if(c[o]=o===`timeout`?Number(a):a,await De(c),!e.quiet){let e=Ra.has(o)?O(String(c[o])):c[o];P({[o]:e},s)}}})})),Ha,Ua,Wa=M((()=>{Ha=[`auth `,`config `,`update`],Ua=m({name:`config export-schema`,description:`Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas`,usage:`bl config export-schema [--command "<name>"]`,options:[{flag:`--command <name>`,description:`Export schema for a specific command only (e.g. "image generate")`}],examples:[`bl config export-schema`,`bl config export-schema --command "video generate"`],async run(e,n){let{commands:r}=await Promise.resolve().then(()=>(bm(),vm)),a=n.command;if(a){let e=r[a];if(!e)throw new t(`Command "${a}" not found.`,i.USAGE);let n=b(e);process.stdout.write(JSON.stringify(n,null,2)+`
134
+ `);return}let o=Object.values(r).filter(e=>!Ha.some(t=>e.name.startsWith(t))).map(e=>b(e));process.stdout.write(JSON.stringify(o,null,2)+`
135
+ `)}})}));bi(),ki(),Mi(),Fi(),zi(),ma(),ga(),ba(),Sa(),wa(),Ea(),Oa(),Pa(),Ia(),Va(),Wa();var Ga=`1.3.1`,Ka,qa=M((()=>{Ka=Ga}));function Ja(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]??0)>(r[e]??0))return!0;if((n[e]??0)<(r[e]??0))return!1}return!1}function Ya(){try{let e=Be(no(),`utf-8`);return JSON.parse(e)}catch{return null}}function Xa(e){try{He(no(),JSON.stringify(e))}catch{}}async function Za(e=io){try{let t=to.replace(`/`,`%2f`),n=await fetch(`${eo}/${t}/latest`,{headers:{Accept:`application/json`,...Ce()},signal:AbortSignal.timeout(e)});return n.ok?(await n.json()).version??null:null}catch{return null}}function Qa(){return ao}async function $a(e){if(process.env.CI||!process.stderr.isTTY)return;let t=Ya(),n=Date.now();if(t&&n-t.lastChecked<ro){t.latestVersion&&Ja(t.latestVersion,e)&&(ao=t.latestVersion);return}let r=await Za();r&&(Xa({lastChecked:n,latestVersion:r}),r&&Ja(r,e)&&(ao=r))}var eo,to,no,ro,io,ao,oo=M((()=>{eo=`https://registry.npmjs.org`,to=`bailian-cli`,no=()=>Ge(x(),`update-state.json`),ro=14400*1e3,io=3e3,ao=null}));function so(){return{cmd:`npm install -g ${to}@latest`,label:`npm`}}function co(e){let{green:t,yellow:n,reset:r}=e;process.stderr.write(`
136
136
  Updating agent skill...
137
- `);try{Ge(`npx skills update ${ro} -g -y`,{stdio:`inherit`}),process.stderr.write(`${t}\u2713 Agent skill updated.${r}\n`)}catch{process.stderr.write(`${n}Agent skill update skipped. Run manually: npx skills update ${ro} -g -y${r}\n`)}}var ro,io,ao=j((()=>{Va(),eo(),ro=`bailian-cli`,io=m({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${Ba}${r}\n`),process.stderr.write(`Checking for updates...
138
- `);let i=await Ga(5e3);if(i&&i===Ba){process.stderr.write(`${t}\u2713 Already up to date (${Ba}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=to();process.stderr.write(`Updating ${Ya} via ${o}...\n\n`);try{Ge(a,{stdio:`inherit`});try{let e=Ge(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Ba} \u2192 ${e}${r}\n`);try{Ve(We(b(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}no({green:t,yellow:n,reset:r})}catch{process.stderr.write(`
137
+ `);try{Ke(`npx skills update ${lo} -g -y`,{stdio:`inherit`}),process.stderr.write(`${t}\u2713 Agent skill updated.${r}\n`)}catch{process.stderr.write(`${n}Agent skill update skipped. Run manually: npx skills update ${lo} -g -y${r}\n`)}}var lo,uo,fo=M((()=>{qa(),oo(),lo=`bailian-cli`,uo=m({name:`update`,description:`Update bl to the latest version`,usage:`bl update`,examples:[`bl update`],async run(){let e=process.stderr.isTTY,t=e?`\x1B[32m`:``,n=e?`\x1B[33m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`Current version: ${n}${Ka}${r}\n`),process.stderr.write(`Checking for updates...
138
+ `);let i=await Za(5e3);if(i&&i===Ka){process.stderr.write(`${t}\u2713 Already up to date (${Ka}).${r}\n`);return}i&&process.stderr.write(`Latest version: ${t}${i}${r}\n\n`);let{cmd:a,label:o}=so();process.stderr.write(`Updating ${to} via ${o}...\n\n`);try{Ke(a,{stdio:`inherit`});try{let e=Ke(`bl --version 2>/dev/null`,{encoding:`utf-8`}).trim().replace(/^bl\s+/,``);process.stderr.write(`\n${t}\u2713 Update complete: ${Ka} \u2192 ${e}${r}\n`);try{He(Ge(x(),`update-state.json`),JSON.stringify({lastChecked:Date.now(),latestVersion:e}))}catch{}}catch{process.stderr.write(`\n${t}\u2713 Update complete.${r}\n`)}co({green:t,yellow:n,reset:r})}catch{process.stderr.write(`
139
139
  Automatic update failed. Please run manually:
140
- `),process.stderr.write(` ${a}\n\n`)}}})})),oo,so=j((()=>{W(),F(),oo=m({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||U(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||U(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=h(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let s=t.image;s&&s.length>0&&(o.input.image_list=s);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
141
- `),process.exit(1)}if(e.dryRun){N({endpoint:c(e.baseUrl,n),request:o},a);return}let u=c(e.baseUrl,n);if(i){let n=await de(e,{url:u,method:`POST`,body:o,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,s=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of oe(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(s&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?N({text:r,session_id:i},a):process.stdout.write(`
142
- `)}else{let t=await O(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?P(n):N(t,a)}}})})),co,lo,uo=j((()=>{F(),co=`zeldaEasy.broadscope-bailian.app-control.list`,lo=m({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name 客服`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,o=h(e.output),s=await pe(e),c={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){N({api:co,data:c,region:a,token:s.token.slice(0,8)+`...`},o);return}let l=await d(e,s.token,{api:co,data:c,region:a}),u=l?.data?.DataV2?.data?.data?.list??[];N({total:l?.data?.DataV2?.data?.data?.total??0,apps:u.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),fo,po=j((()=>{W(),F(),fo=m({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "用户喜欢Python编程"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"我喜欢旅行"}]'`,`bl memory add --user-id user1 --content "住在北京" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
140
+ `),process.stderr.write(` ${a}\n\n`)}}})})),po,mo=M((()=>{H(),I(),po=m({name:`app call`,description:`Call a Bailian application (agent or workflow)`,usage:`bl app call --app-id <id> --prompt <text> [flags]`,options:[{flag:`--app-id <id>`,description:`Application ID (required)`,required:!0},{flag:`--prompt <text>`,description:`Input prompt text`,required:!0},{flag:`--image <url>`,description:`Image URL(s) to pass to the app (repeatable)`,type:`array`},{flag:`--file-id <id>`,description:`Pre-uploaded file ID(s) (repeatable)`,type:`array`},{flag:`--session-id <id>`,description:`Session ID for multi-turn conversation`},{flag:`--stream`,description:`Stream response (default: on in TTY)`},{flag:`--pipeline-ids <ids>`,description:`Knowledge base pipeline IDs (comma-separated)`},{flag:`--memory-id <id>`,description:`Memory ID for long-term memory`},{flag:`--biz-params <json>`,description:`Business parameters JSON (workflow variables)`},{flag:`--has-thoughts`,description:`Show agent thinking process`}],examples:[`bl app call --app-id abc123 --prompt "你好"`,`bl app call --app-id abc123 --prompt "描述这张图片" --image https://example.com/photo.jpg`,`bl app call --app-id abc123 --prompt "分析图片" --image img1.jpg --image img2.jpg`,`bl app call --app-id abc123 --prompt "继续" --session-id sess_xxx --stream`,`bl app call --app-id abc123 --prompt "搜索资料" --pipeline-ids pipe1,pipe2`,`bl app call --app-id abc123 --prompt "开始" --biz-params '{"key":"value"}'`],async run(e,t){let n=t.appId;n||V(`app-id`,`bl app call --app-id <id> --prompt <text>`);let r=t.prompt;r||V(`prompt`,`bl app call --app-id <id> --prompt <text>`);let i=t.stream===!0||t.stream===void 0&&process.stdout.isTTY,a=h(e.output),o={input:{prompt:r},parameters:{incremental_output:i}};t.sessionId&&(o.input.session_id=t.sessionId);let s=t.image;s&&s.length>0&&(o.input.image_list=s);let l=t.fileId;if(l&&l.length>0&&(o.input.file_ids=l),t.hasThoughts&&(o.parameters.has_thoughts=!0),t.pipelineIds){let e=t.pipelineIds.split(`,`).map(e=>e.trim()).filter(Boolean);o.parameters.rag_options={pipeline_ids:e}}if(t.memoryId&&(o.parameters.memory_id=t.memoryId),t.bizParams)try{o.input.biz_params=JSON.parse(t.bizParams)}catch{process.stderr.write(`Error: --biz-params must be valid JSON
141
+ `),process.exit(1)}if(e.dryRun){P({endpoint:c(e.baseUrl,n),request:o},a);return}let u=c(e.baseUrl,n);if(i){let n=await fe(e,{url:u,method:`POST`,body:o,headers:{"X-DashScope-SSE":`enable`},stream:!0}),r=``,i=``,s=a===`text`,c=e.noColor?``:`\x1B[2m`,l=e.noColor?``:`\x1B[0m`;for await(let e of se(n)){if(e.data===`[DONE]`)break;try{let n=JSON.parse(e.data),a=n.output?.text;if(a&&(s&&process.stdout.write(a),r+=a),n.output?.session_id&&(i=n.output.session_id),n.output?.thoughts&&t.hasThoughts)for(let e of n.output.thoughts)e.thought&&process.stderr.write(`${c}[Thinking] ${e.thought}${l}\n`),e.action_name&&process.stderr.write(`${c}[Action] ${e.action_name}: ${e.action_input||``}${l}\n`),e.observation&&process.stderr.write(`${c}[Observation] ${e.observation}${l}\n`)}catch{}}i&&!e.quiet&&process.stderr.write(`${c}Session ID: ${i}${l}\n`),a===`json`?P({text:r,session_id:i},a):process.stdout.write(`
142
+ `)}else{let t=await k(e,{url:u,method:`POST`,body:o}),n=t.output?.text??``;e.quiet||a===`text`?F(n):P(t,a)}}})})),ho,go,_o=M((()=>{I(),ho=`zeldaEasy.broadscope-bailian.app-control.list`,go=m({name:`app list`,description:`List Bailian applications`,usage:`bl app list [flags]`,options:[{flag:`--name <name>`,description:`Filter by app name (keyword search)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl app list`,`bl app list --name 客服`,`bl app list --page 2 --page-size 10`,`bl app list --output json`],async run(e,t){let n=t.name||``,r=t.page||1,i=t.pageSize||30,a=t.region||`cn-beijing`,o=h(e.output),s=await me(e),c={reqDTO:{name:n,notInTypes:[10],type:5,statuses:[1,4],page_no:r,page_size:i}};if(e.dryRun){P({api:ho,data:c,region:a,token:s.token.slice(0,8)+`...`},o);return}let l=await d(e,s.token,{api:ho,data:c,region:a}),u=l?.data?.DataV2?.data?.data?.list??[];P({total:l?.data?.DataV2?.data?.data?.total??0,apps:u.map(e=>({code:e.code,name:e.name,user_prompt_params:e.config?.user_prompt_params??[]}))},o)}})})),vo,yo=M((()=>{H(),I(),vo=m({name:`memory add`,description:`Add memory from messages or custom content`,usage:`bl memory add --user-id <id> [--messages <json>] [--content <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--messages <json>`,description:`Messages JSON array: [{"role":"user","content":"..."},...]`},{flag:`--content <text>`,description:`Custom content text to memorize`},{flag:`--profile-schema <id>`,description:`Profile schema ID for user profiling`},{flag:`--memory-library-id <id>`,description:`Memory library ID (isolate memory space)`}],examples:[`bl memory add --user-id user1 --content "用户喜欢Python编程"`,`bl memory add --user-id user1 --messages '[{"role":"user","content":"我喜欢旅行"}]'`,`bl memory add --user-id user1 --content "住在北京" --profile-schema schema_xxx`],async run(e,t){let n=t.userId;n||V(`user-id`,`bl memory add --user-id <id>`);let r={user_id:n};if(t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
143
143
  `),process.exit(1)}t.content&&(r.custom_content=t.content),!r.messages&&!r.custom_content&&(process.stderr.write(`Error: at least one of --messages or --content is required
144
- `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){N({endpoint:ne(e.baseUrl),request:r},i);return}let a=await O(e,{url:ne(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?P(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):N(a,i)}})})),mo,ho=j((()=>{W(),F(),mo=m({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "编程偏好"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"推荐一本书"}]' --top-k 5`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
144
+ `),process.exit(1)),t.profileSchema&&(r.profile_schema=t.profileSchema),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:re(e.baseUrl),request:r},i);return}let a=await k(e,{url:re(e.baseUrl),method:`POST`,body:r});e.quiet||i===`text`?F(`Memory added. IDs: ${a.memory_ids?.join(`, `)||`none`}`):P(a,i)}})})),bo,xo=M((()=>{H(),I(),bo=m({name:`memory search`,description:`Search memory nodes by query or messages`,usage:`bl memory search --user-id <id> [--query <text>] [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query text`},{flag:`--messages <json>`,description:`Messages JSON array for context-based search`},{flag:`--top-k <n>`,description:`Number of results to return (default: 10)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory search --user-id user1 --query "编程偏好"`,`bl memory search --user-id user1 --messages '[{"role":"user","content":"推荐一本书"}]' --top-k 5`],async run(e,t){let n=t.userId;n||V(`user-id`,`bl memory search --user-id <id>`);let r={user_id:n};if(t.query&&(r.query=t.query),t.messages)try{r.messages=JSON.parse(t.messages)}catch{process.stderr.write(`Error: --messages must be valid JSON array
145
145
  `),process.exit(1)}!r.messages&&r.query&&(r.messages=[{role:`user`,content:r.query}]),!r.query&&!r.messages&&(process.stderr.write(`Error: at least one of --query or --messages is required
146
- `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){N({endpoint:ae(e.baseUrl),request:r},i);return}let a=await O(e,{url:ae(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)P(`No memory nodes found.`);else for(let e of a.memory_nodes)P(`[${e.memory_node_id}] ${e.content}`);else N(a,i)}})})),go,_o=j((()=>{W(),F(),go=m({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||U(`user-id`,`bl memory list --user-id <id>`);let r=h(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${re(e.baseUrl)}?${i.toString()}`;if(e.dryRun){N({endpoint:a,method:`GET`},r);return}let o=await O(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)P(`No memory nodes found.`);else{for(let e of o.memory_nodes)P(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&P(`\nTotal: ${o.total}`)}else N(o,r)}})})),vo,yo=j((()=>{W(),F(),vo=m({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "更新后的记忆内容"`],async run(e,t){let n=t.nodeId;n||U(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||U(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||U(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=h(e.output);if(e.dryRun){N({endpoint:ie(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await O(e,{url:ie(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?P(`Memory node ${n} updated.`):N(s,o)}})})),bo,xo=j((()=>{W(),F(),bo=m({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||U(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||U(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${ie(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){N({endpoint:o,method:`DELETE`},i);return}let s=await O(e,{url:o,method:`DELETE`});e.quiet||i===`text`?P(`Memory node ${n} deleted.`):N(s,i)}})})),So,Co=j((()=>{W(),F(),So=m({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"年龄"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"年龄"},{"name":"hobby","description":"爱好"}]'`],async run(e,t){let n=t.name;n||U(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||U(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
147
- `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=h(e.output);if(e.dryRun){N({endpoint:se(e.baseUrl),request:a},o);return}let s=await O(e,{url:se(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?P(`Profile schema created: ${s.profile_schema_id}`):N(s,o)}})})),wo,To=j((()=>{W(),F(),wo=m({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||U(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||U(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r}),o=`${we(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){N({endpoint:o,method:`GET`},i);return}let s=await O(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)P(`${e.name}: ${e.value??`(empty)`}`);else P(`No profile data found.`);else N(s,i)}})})),Eo,Do,Oo=j((()=>{W(),F(),Eo=`bailian.cn-beijing.aliyuncs.com`,Do=m({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base (requires AK/SK)`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (or env BAILIAN_WORKSPACE_ID)`},{flag:`--top-k <n>`,description:`Number of results (default: 10)`,type:`number`},{flag:`--rerank`,description:`Enable rerank`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (or env)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (or env)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼" --workspace-id ws_xxx`,`bl knowledge retrieve --index-id idx_xxx --query "API限流" --top-k 5 --rerank`],async run(e,n){let r=n.indexId;r||U(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let a=n.query;a||U(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let o=n.accessKeyId||e.accessKeyId,s=n.accessKeySecret||e.accessKeySecret,c=n.workspaceId||e.workspaceId;if(!o||!s)throw new t(`Knowledge retrieve requires Alibaba Cloud AK/SK.
148
- Set via: --access-key-id / --access-key-secret flags,
149
- or env: ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET,
150
- or config: bl config set access_key_id <key>`,i.AUTH);if(!c)throw new t(`Knowledge retrieve requires a workspace ID.
151
- Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);let l={IndexId:r,Query:a};n.topK!==void 0&&(l.TopK=n.topK),n.rerank&&(l.Rerank=!0),n.rerankTopN!==void 0&&(l.RerankTopN=n.rerankTopN);let u=h(e.output),d=`/${c}/index/retrieve`;if(e.dryRun){N({endpoint:`https://${Eo}${d}`,workspaceId:c,request:l},u);return}let f=JSON.stringify(l),p=ge({accessKeyId:o,accessKeySecret:s,action:`Retrieve`,version:`2023-12-29`,body:f,host:Eo,pathname:d}),m=`https://${Eo}${d}`;e.verbose&&(process.stderr.write(`> POST ${m}\n`),process.stderr.write(`> AK: ${D(o)}\n`));let g=e.timeout*1e3,_=await fetch(m,{method:`POST`,headers:{...p,...Se()},body:f,signal:AbortSignal.timeout(g)});e.verbose&&process.stderr.write(`< ${_.status} ${_.statusText}\n`);let v=await _.json();if(!_.ok||v.Code&&v.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${v.Code||_.status} - ${v.Message||_.statusText}`,i.GENERAL);if(e.quiet||u===`text`){let e=v.Data?.Nodes||[];if(e.length===0)P(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];P(`[${t+1}] (score: ${n.Score.toFixed(4)})`),P(n.Text),P(``)}}else N(v,u)}})}));async function ko(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(T({nonInteractive:e.nonInteractive})?await Ur({message:`Found DASHSCOPE_API_KEY in environment (${D(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!T({nonInteractive:e.nonInteractive}))throw new t(`No API key found.`,i.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await H({message:`Enter your DashScope API key:`});if(!n)throw new t(`API key is required.`,i.AUTH);r=n}await Ee({...le(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}var Ao=j((()=>{W()}));function jo(e){let t={};for(let n of e){let e=n.indexOf(`=`);e<=0&&(process.stderr.write(`Error: --arg must be in K=V form, got: ${n}\n`),process.exit(1));let r=n.slice(0,e).trim(),i=n.slice(e+1);try{t[r]=JSON.parse(i)}catch{t[r]=i}}return t}var Mo,No=j((()=>{W(),F(),Ao(),Mo=m({name:`mcp call`,description:`Call a tool on an MCP server (tools/call)`,usage:`bl mcp call <server-code>.<tool> [--arg k=v ...] [--json '{...}'] [--url <url>]`,options:[{flag:`<server-code>.<tool>`,description:`Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection`,required:!0},{flag:`--arg <kv>`,description:`Tool argument (repeatable). Values parsed as JSON if possible, else string.`,type:`array`},{flag:`--json <obj>`,description:`Full arguments object as JSON; merged with --arg (arg wins).`},{flag:`--query <text>`,description:`Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).`},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp call market-cmapi00073529.SmartStockSelection --query "筛选ROE>15%的消费股"`,`bl mcp call market-cmapi00073529.FinQuery --json '{"q":"贵州茅台","limit":5}'`,`bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10`],async run(e,t){let n=(t._positional??[])[0];n||U(`<server-code>.<tool>`,`bl mcp call <server-code>.<tool>`);let r=n.indexOf(`.`);(r<=0||r===n.length-1)&&(process.stderr.write(`Error: target must be <server-code>.<tool>, got "${n}".\n`),process.exit(1));let i=n.slice(0,r),a=n.slice(r+1),s={};if(t.json)try{let e=JSON.parse(t.json);(!e||typeof e!=`object`||Array.isArray(e))&&(process.stderr.write(`Error: --json must decode to an object.
152
- `),process.exit(1)),s=e}catch(e){process.stderr.write(`Error: --json is not valid JSON — ${e.message}\n`),process.exit(1)}Object.assign(s,jo(t.arg??[])),t.query!==void 0&&(s.query=t.query);let c=t.url||l(e.baseUrl,i),u=h(e.output);if(e.dryRun){N({server:i,url:c,tool:a,arguments:s},u);return}await ko(e);let d=new o(e,c);await d.initialize();let f=await d.callTool(a,s);if(f.isError){let e=f.content.map(e=>e.text||``).join(`
153
- `);process.stderr.write(`Tool error: ${e}\n`),process.exit(1)}N(f,u)}})})),Po,Fo,Io=j((()=>{F(),Po=`zeldaEasy.broadscope-bailian.mcp-server.PageList`,Fo=m({name:`mcp list`,description:`List MCP servers activated under your Bailian account`,usage:`bl mcp list [flags]`,options:[{flag:`--name <text>`,description:`Filter by server name (substring match)`},{flag:`--type <type>`,description:`Server type: OFFICIAL | PRIVATE (default: OFFICIAL)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl mcp list`,`bl mcp list --name 金融`,`bl mcp list --output json`],async run(e,n){let r=n.name||``,a=n.type||`OFFICIAL`,o=n.page||1,s=n.pageSize||30,c=n.region||`cn-beijing`,l=h(e.output),u={reqDTO:{type:a,displayTools:!1,activated:1,pageNo:o,pageSize:s,serverName:r}};if(e.dryRun){N({api:Po,data:u,region:c},l);return}let f=(await d(e,(await pe(e)).token,{api:Po,data:u,region:c}))?.data??{};if(f.success===!1){let e=f.errorCode??`UnknownError`,n=f.errorMsg??e,r=e===`BailianGateway.Login.NotLogined`?"Run `bl auth login --console` to refresh your console session.":void 0;throw new t(`Console gateway: ${n}`,i.AUTH,r)}let p=(f.DataV2??{}).data?.data??{},m=p.mcpServerDetailList??[];N({total:p.total??0,servers:m.map(e=>({code:e.serverCode??``,name:e.serverName??``,description:e.description,type:e.type??``,source:e.source,bizType:e.bizType,installType:e.installType,streamable:e.streamable===!0}))},l)}})})),Lo,Ro=j((()=>{W(),F(),Ao(),Lo=m({name:`mcp tools`,description:`List tools exposed by an MCP server (tools/list)`,usage:`bl mcp tools <server-code> [--url <url>]`,options:[{flag:`<server-code>`,description:"Server code from `bl mcp list` (e.g. market-cmapi00073529)",required:!0},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp tools market-cmapi00073529`,`bl mcp tools market-cmapi00073529 --output json`,`bl mcp tools my-server --url https://example.com/mcp`],async run(e,t){let n=(t._positional??[])[0];n||U(`server-code`,`bl mcp tools <server-code>`);let r=t.url||l(e.baseUrl,n),i=h(e.output);if(e.dryRun){N({server:n,url:r,action:`tools/list`},i);return}await ko(e);let a=new o(e,r);await a.initialize(),N({server:n,url:r,tools:await a.listTools()},i)}})})),zo,Bo=j((()=>{Li(),W(),F(),zo=m({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "阿里云百炼最新功能"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "今日新闻"`,`bl search web --list-tools`],async run(e,t){let n=te(e.baseUrl),r=h(e.output);if(t.listTools){if(e.dryRun){N({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),N({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
154
- `),process.exit(1)),i=e}else U(`query`,`bl search web --query <text>`);if(e.dryRun){N({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let a=new o(e,n),s=Pi(`Initializing search...`);e.quiet||s.start();try{await a.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let o=await a.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),o.isError){let e=o.content.map(e=>e.text||``).join(`
155
- `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)N(o,r);else for(let e of o.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?N({pages:t.pages,total:t.pages.length},r):N(t,r)}catch{N({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function Vo(e){let t=Ko[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
156
- `),process.stdout.write(`See: ${Wo}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function Ho(e,n,r,a,o){let s=await Wi(Ui(a),e,()=>O(e,{url:n,method:`POST`,body:r})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new t(`API returned no audio URL.`,i.GENERAL);let l=await import(`path`),u=me(e,{subDir:`speech`}),d=await Gi(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),i=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=r.input.format??`mp3`;n=l.join(u,`tts_${e}${i}.${a}`)}return{url:e,destPath:n}}),Bi,{quiet:e.quiet});if(e.quiet)P(d.join(`
157
- `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;N({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else N({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function Uo(e,t,n,r,i){let a=await de(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Ie(o):null,c;try{for await(let t of oe(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&N({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var Wo,Go,Ko,qo,Jo=j((()=>{Hi(),Ki(),W(),F(),Wo=`${r.cn}/cosyvoice-clone-design-api`,Go=[{voice:`longanyang`,name:`龙安洋`,desc:`阳光大男孩`,lang:`中文/英文`},{voice:`longanhuan`,name:`龙安欢`,desc:`欢脱元气女`,lang:`中文/英文`},{voice:`longantai_v3`,name:`龙安台`,desc:`嗲甜台湾女`,lang:`中文/英文`},{voice:`longhua_v3`,name:`龙华`,desc:`元气甜美女`,lang:`中文/英文`},{voice:`longcheng_v3`,name:`龙橙`,desc:`智慧青年男`,lang:`中文/英文`},{voice:`longze_v3`,name:`龙泽`,desc:`温暖元气男`,lang:`中文/英文`},{voice:`longzhe_v3`,name:`龙哲`,desc:`呆板大暖男`,lang:`中文/英文`},{voice:`longyan_v3`,name:`龙颜`,desc:`温暖春风女`,lang:`中文/英文`},{voice:`longxing_v3`,name:`龙星`,desc:`温婉邻家女`,lang:`中文/英文`},{voice:`longtian_v3`,name:`龙天`,desc:`磁性理智男`,lang:`中文/英文`},{voice:`longwan_v3`,name:`龙婉`,desc:`细腻柔声女`,lang:`中文/英文`},{voice:`longqiang_v3`,name:`龙嫱`,desc:`浪漫风情女`,lang:`中文/英文`},{voice:`longfeifei_v3`,name:`龙菲菲`,desc:`甜美娇气女`,lang:`中文/英文`},{voice:`longhao_v3`,name:`龙浩`,desc:`多情忧郁男`,lang:`中文/英文`},{voice:`longanrou_v3`,name:`龙安柔`,desc:`温柔娴静女`,lang:`中文/英文`},{voice:`longxiaochun_v3`,name:`龙小淳`,desc:`知性积极女`,lang:`中文/英文`},{voice:`longxiaoxia_v3`,name:`龙小夏`,desc:`沉稳权威女`,lang:`中文/英文`},{voice:`longyumi_v3`,name:`YUMI`,desc:`正经青年女`,lang:`中文/英文`},{voice:`longanyun_v3`,name:`龙安昀`,desc:`居家暖男`,lang:`中文/英文`},{voice:`longanwen_v3`,name:`龙安温`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longanli_v3`,name:`龙安莉`,desc:`利落从容女`,lang:`中文/英文`},{voice:`longanlang_v3`,name:`龙安朗`,desc:`清爽利落男`,lang:`中文/英文`},{voice:`longyingmu_v3`,name:`龙应沐`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longyingxun_v3`,name:`龙应询`,desc:`年轻青涩男`,lang:`中文/英文`},{voice:`longyingjing_v3`,name:`龙应静`,desc:`低调冷静女`,lang:`中文/英文`},{voice:`longyingling_v3`,name:`龙应聆`,desc:`温和共情女`,lang:`中文/英文`},{voice:`longyingtao_v3`,name:`龙应桃`,desc:`温柔淡定女`,lang:`中文/英文`},{voice:`longyingxiao_v3`,name:`龙应笑`,desc:`清甜推销女`,lang:`中文/英文`},{voice:`longfei_v3`,name:`龙飞`,desc:`热血磁性男`,lang:`中文/英文`},{voice:`longhuhu_v3`,name:`龙呼呼`,desc:`天真烂漫女童`,lang:`中文/英文`},{voice:`longpaopao_v3`,name:`龙泡泡`,desc:`飞天泡泡音`,lang:`中文/英文`},{voice:`longjielidou_v3`,name:`龙杰力豆`,desc:`阳光顽皮男`,lang:`中文/英文`},{voice:`longxian_v3`,name:`龙仙`,desc:`豪放可爱女`,lang:`中文/英文`},{voice:`longling_v3`,name:`龙铃`,desc:`稚气呆板女`,lang:`中文/英文`},{voice:`longshanshan_v3`,name:`龙闪闪`,desc:`戏剧化童声`,lang:`中文/英文`},{voice:`longniuniu_v3`,name:`龙牛牛`,desc:`阳光男童声`,lang:`中文/英文`},{voice:`longjiaxin_v3`,name:`龙嘉欣`,desc:`优雅粤语女`,lang:`粤语/英文`},{voice:`longjiayi_v3`,name:`龙嘉怡`,desc:`知性粤语女`,lang:`粤语/英文`},{voice:`longanyue_v3`,name:`龙安粤`,desc:`欢脱粤语男`,lang:`粤语/英文`},{voice:`longlaotie_v3`,name:`龙老铁`,desc:`东北直率男`,lang:`东北话/英文`},{voice:`longshange_v3`,name:`龙陕哥`,desc:`原味陕北男`,lang:`陕西话/英文`},{voice:`longanmin_v3`,name:`龙安闽`,desc:`清纯萝莉女`,lang:`闽南话/英文`},{voice:`loongabby_v3`,name:`loongabby`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongandy_v3`,name:`loongandy`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongannie_v3`,name:`loongannie`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongava_v3`,name:`loongava`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcally_v3`,name:`loongcally`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongemily_v3`,name:`loongemily`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongeric_v3`,name:`loongeric`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongluna_v3`,name:`loongluna`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongluca_v3`,name:`loongluca`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongriko_v3`,name:`Riko`,desc:`二次元霓虹女`,lang:`日语`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`日语女`,lang:`日语`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`日语男`,lang:`日语`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`日语女`,lang:`日语`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`日语男`,lang:`日语`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`韩语女`,lang:`韩语`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`韩语男`,lang:`韩语`},{voice:`loongindah_v3`,name:`loongindah`,desc:`印尼女`,lang:`印尼语`}],Ko={"cosyvoice-v3-flash":Go,"cosyvoice-v3-plus":Go,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},qo=m({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,apiDocs:`/developer-reference/cosyvoice`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "请用温柔的语调")`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "你好,我是千问" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "今天天气真好" --voice <voice_id> --instruction "请用温柔的语调说话"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "你好" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(e,n){let r=n.model||e.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){Vo(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=ze(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
158
- `),process.exit(1)),a=e}else U(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(T({nonInteractive:e.nonInteractive})){let e=Ko[r];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} · ${e.lang}`})),r=await Wr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
159
- `),process.exit(1)),o=r}else{let e=await H({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
160
- `),process.exit(1)),o=e}}else{let e=Ko[r];throw e&&e.length>0?new t(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${r}`,i.USAGE):new t(`--voice is required. Model ${r} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${Wo}`,i.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),d=n.volume===void 0?void 0:Number(n.volume),f=n.rate===void 0?void 0:Number(n.rate),p=n.pitch===void 0?void 0:Number(n.pitch),m=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=h(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:f,pitch:p,seed:m,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(ye(y.input),e.dryRun){N({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=ve(e.baseUrl);_?await Uo(e,b,y,n,v):await Ho(e,b,y,n,v)}})}));async function Yo(e,n,r,a,o,s){let c=(await O(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){N({task_id:c},o);return}let l=a.pollInterval??2,u=await Ri(e,{url:be(e.baseUrl,c),intervalSec:l,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){N({task_id:c,status:u.output.task_status},o);return}let f=[];for(let e=0;e<d.length;e++){let n=d[e],r=s>1;if(r&&process.stdout.write(`=== [${e+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} ${e}\n`),r&&process.stdout.write(`
146
+ `),process.exit(1)),t.topK!==void 0&&(r.top_k=t.topK),t.memoryLibraryId&&(r.memory_library_id=t.memoryLibraryId);let i=h(e.output);if(e.dryRun){P({endpoint:oe(e.baseUrl),request:r},i);return}let a=await k(e,{url:oe(e.baseUrl),method:`POST`,body:r});if(e.quiet||i===`text`)if(!a.memory_nodes||a.memory_nodes.length===0)F(`No memory nodes found.`);else for(let e of a.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);else P(a,i)}})})),So,Co=M((()=>{H(),I(),So=m({name:`memory list`,description:`List memory nodes for a user`,usage:`bl memory list --user-id <id> [flags]`,options:[{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--page-size <n>`,description:`Results per page (default: 10)`,type:`number`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--memory-library-id <id>`,description:`Memory library ID`}],examples:[`bl memory list --user-id user1`,`bl memory list --user-id user1 --page-size 20 --page 2`],async run(e,t){let n=t.userId;n||V(`user-id`,`bl memory list --user-id <id>`);let r=h(e.output),i=new URLSearchParams;i.set(`user_id`,n),t.pageSize!==void 0&&i.set(`page_size`,String(t.pageSize)),t.page!==void 0&&i.set(`page_num`,String(t.page)),t.memoryLibraryId&&i.set(`memory_library_id`,t.memoryLibraryId);let a=`${ie(e.baseUrl)}?${i.toString()}`;if(e.dryRun){P({endpoint:a,method:`GET`},r);return}let o=await k(e,{url:a,method:`GET`});if(e.quiet||r===`text`)if(!o.memory_nodes||o.memory_nodes.length===0)F(`No memory nodes found.`);else{for(let e of o.memory_nodes)F(`[${e.memory_node_id}] ${e.content}`);o.total!==void 0&&F(`\nTotal: ${o.total}`)}else P(o,r)}})})),wo,To=M((()=>{H(),I(),wo=m({name:`memory update`,description:`Update a memory node content`,usage:`bl memory update --node-id <id> --user-id <id> --content <text>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--content <text>`,description:`New content for the memory node (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory update --node-id node_xxx --user-id user1 --content "更新后的记忆内容"`],async run(e,t){let n=t.nodeId;n||V(`node-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let r=t.userId;r||V(`user-id`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let i=t.content;i||V(`content`,`bl memory update --node-id <id> --user-id <id> --content <text>`);let a={user_id:r,custom_content:i};t.memoryLibraryId&&(a.memory_library_id=t.memoryLibraryId);let o=h(e.output);if(e.dryRun){P({endpoint:ae(e.baseUrl,n),method:`PATCH`,request:a},o);return}let s=await k(e,{url:ae(e.baseUrl,n),method:`PATCH`,body:a});e.quiet||o===`text`?F(`Memory node ${n} updated.`):P(s,o)}})})),Eo,Do=M((()=>{H(),I(),Eo=m({name:`memory delete`,description:`Delete a memory node`,usage:`bl memory delete --node-id <id> --user-id <id>`,options:[{flag:`--node-id <id>`,description:`Memory node ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0},{flag:`--memory-library-id <id>`,description:`Memory library ID (non-default library)`}],examples:[`bl memory delete --node-id node_xxx --user-id user1`],async run(e,t){let n=t.nodeId;n||V(`node-id`,`bl memory delete --node-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory delete --node-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r});t.memoryLibraryId&&a.set(`memory_library_id`,t.memoryLibraryId);let o=`${ae(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`DELETE`},i);return}let s=await k(e,{url:o,method:`DELETE`});e.quiet||i===`text`?F(`Memory node ${n} deleted.`):P(s,i)}})})),Oo,ko=M((()=>{H(),I(),Oo=m({name:`memory profile create`,description:`Create a user profile schema for memory profiling`,usage:`bl memory profile create --name <name> --attributes <json> [flags]`,options:[{flag:`--name <name>`,description:`Schema name (required)`,required:!0},{flag:`--description <text>`,description:`Schema description`},{flag:`--attributes <json>`,description:`Attributes JSON array: [{"name":"age","description":"年龄"}]`,required:!0}],examples:[`bl memory profile create --name "user_basic" --attributes '[{"name":"age","description":"年龄"},{"name":"hobby","description":"爱好"}]'`],async run(e,t){let n=t.name;n||V(`name`,`bl memory profile create --name <name> --attributes <json>`);let r=t.attributes;r||V(`attributes`,`bl memory profile create --name <name> --attributes <json>`);let i;try{i=JSON.parse(r)}catch{process.stderr.write(`Error: --attributes must be valid JSON array
147
+ `),process.exit(1)}let a={name:n,attributes:i};t.description&&(a.description=t.description);let o=h(e.output);if(e.dryRun){P({endpoint:ce(e.baseUrl),request:a},o);return}let s=await k(e,{url:ce(e.baseUrl),method:`POST`,body:a});e.quiet||o===`text`?F(`Profile schema created: ${s.profile_schema_id}`):P(s,o)}})})),Ao,jo=M((()=>{H(),I(),Ao=m({name:`memory profile get`,description:`Get user profile by schema ID and user ID`,usage:`bl memory profile get --schema-id <id> --user-id <id>`,options:[{flag:`--schema-id <id>`,description:`Profile schema ID (required)`,required:!0},{flag:`--user-id <id>`,description:`User ID (required)`,required:!0}],examples:[`bl memory profile get --schema-id schema_xxx --user-id user1`],async run(e,t){let n=t.schemaId;n||V(`schema-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let r=t.userId;r||V(`user-id`,`bl memory profile get --schema-id <id> --user-id <id>`);let i=h(e.output),a=new URLSearchParams({user_id:r}),o=`${Te(e.baseUrl,n)}?${a.toString()}`;if(e.dryRun){P({endpoint:o,method:`GET`},i);return}let s=await k(e,{url:o,method:`GET`});if(e.quiet||i===`text`)if(s.profile?.attributes)for(let e of s.profile.attributes)F(`${e.name}: ${e.value??`(empty)`}`);else F(`No profile data found.`);else P(s,i)}})}));async function Mo(e,t,n,r,i){t.topK!==void 0&&t.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
148
+ `),t.rerankTopN=t.topK);let a={index_id:n,query:r,search_filters:[]};if(t.denseSimilarityTopK!==void 0&&(a.dense_similarity_top_k=t.denseSimilarityTopK),t.sparseSimilarityTopK!==void 0&&(a.sparse_similarity_top_k=t.sparseSimilarityTopK),t.rerank&&(a.enable_reranking=!0),t.rerankTopN!==void 0&&(a.rerank_top_n=t.rerankTopN),t.rerankModel){let e={model_name:t.rerankModel};t.rerankMode&&(e.rerank_mode=t.rerankMode),t.rerankInstruct&&(e.rerank_instruct=t.rerankInstruct),a.rerank=[e]}let o=ee(e.baseUrl);if(e.dryRun){P({endpoint:o,request:a},i);return}let s=await k(e,{url:o,method:`POST`,body:a}),c=s.data?.nodes||[];e.quiet||i===`text`?Po(c.map(e=>({text:e.text,score:e.score}))):P(s,i)}async function No(e,n,r,a,o){let s=n.accessKeyId||e.accessKeyId,c=n.accessKeySecret||e.accessKeySecret,l=n.workspaceId||e.workspaceId;if(!s||!c)throw new t(`No credentials found.
149
+ Preferred: set DASHSCOPE_API_KEY or pass --api-key.
150
+ Legacy (deprecated): set ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET.`,i.AUTH);if(!l)throw new t(`Knowledge retrieve requires a workspace ID.
151
+ Set via: --workspace-id flag, or env: BAILIAN_WORKSPACE_ID, or config: bl config set workspace_id <id>`,i.USAGE);process.stderr.write(`Warning: AK/SK auth for knowledge retrieve is deprecated. Prefer --api-key or DASHSCOPE_API_KEY.
152
+ `);let u={IndexId:r,Query:a};if(n.topK!==void 0&&n.rerankTopN===void 0&&(process.stderr.write(`Warning: --top-k is deprecated. Use --rerank-top-n instead.
153
+ `),n.rerankTopN=n.topK),n.rerank&&(u.EnableReranking=!0),n.rerankTopN!==void 0&&(u.RerankTopN=n.rerankTopN),n.denseSimilarityTopK!==void 0&&(u.DenseSimilarityTopK=n.denseSimilarityTopK),n.sparseSimilarityTopK!==void 0&&(u.SparseSimilarityTopK=n.sparseSimilarityTopK),n.rerankModel){let e={ModelName:n.rerankModel};n.rerankMode&&(e.RerankMode=n.rerankMode),n.rerankInstruct&&(e.RerankInstruct=n.rerankInstruct),u.Rerank=[e]}let d=`/${l}/index/retrieve`;if(e.dryRun){P({endpoint:`https://${Fo}${d}`,workspaceId:l,request:u},o);return}let f=JSON.stringify(u),p=_e({accessKeyId:s,accessKeySecret:c,action:`Retrieve`,version:`2023-12-29`,body:f,host:Fo,pathname:d}),m=`https://${Fo}${d}`;e.verbose&&(process.stderr.write(`> POST ${m}\n`),process.stderr.write(`> AK: ${O(s)}\n`));let h=e.timeout*1e3,g=await fetch(m,{method:`POST`,headers:{...p,...Ce()},body:f,signal:AbortSignal.timeout(h)});e.verbose&&process.stderr.write(`< ${g.status} ${g.statusText}\n`);let _=await g.json();if(!g.ok||_.Code&&_.Code!==`Success`)throw new t(`Knowledge retrieve failed: ${_.Code||g.status} - ${_.Message||g.statusText}`,i.GENERAL);let v=_.Data?.Nodes||[];e.quiet||o===`text`?Po(v.map(e=>({text:e.Text,score:e.Score}))):P(_,o)}function Po(e){if(e.length===0)F(`No results found.`);else for(let t=0;t<e.length;t++){let n=e[t];F(`[${t+1}] (score: ${n.score.toFixed(4)})`),F(n.text),F(``)}}var Fo,Io,Lo=M((()=>{H(),I(),Fo=`bailian.cn-beijing.aliyuncs.com`,Io=m({name:`knowledge retrieve`,description:`Retrieve from a Bailian knowledge base`,usage:`bl knowledge retrieve --index-id <id> --query <text> [flags]`,options:[{flag:`--index-id <id>`,description:`Knowledge base index ID (required)`,required:!0},{flag:`--query <text>`,description:`Search query (required)`,required:!0},{flag:`--dense-similarity-top-k <n>`,description:`Dense retrieval top K`,type:`number`},{flag:`--sparse-similarity-top-k <n>`,description:`Sparse retrieval top K`,type:`number`},{flag:`--rerank`,description:`Enable reranking`},{flag:`--rerank-top-n <n>`,description:`Rerank top N results`,type:`number`},{flag:`--rerank-model <name>`,description:`Rerank model, e.g. qwen3-rerank-hybrid`},{flag:`--rerank-mode <mode>`,description:`Rerank mode: qa, similar, or custom`},{flag:`--rerank-instruct <text>`,description:`Custom rerank instruction, when mode=custom`},{flag:`--top-k <n>`,description:`Number of results (deprecated, use --rerank-top-n)`,type:`number`},{flag:`--workspace-id <id>`,description:`Bailian workspace ID (required for AK/SK auth)`},{flag:`--access-key-id <key>`,description:`Alibaba Cloud Access Key ID (deprecated)`},{flag:`--access-key-secret <key>`,description:`Alibaba Cloud Access Key Secret (deprecated)`}],examples:[`bl knowledge retrieve --index-id idx_xxx --query "如何使用阿里云百炼"`,`bl knowledge retrieve --index-id idx_xxx --query "API限流" --rerank --rerank-model qwen3-rerank-hybrid`],async run(e,t){let n=t.indexId;n||V(`index-id`,`bl knowledge retrieve --index-id <id> --query <text>`);let r=t.query;r||V(`query`,`bl knowledge retrieve --index-id <id> --query <text>`);let i=h(e.output),a=!!e.apiKey,o=!!(t.accessKeyId&&t.accessKeySecret);if(a)await Mo(e,t,n,r,i);else if(o)await No(e,t,n,r,i);else{let a=!1;try{await A(e),a=!0}catch{}a?await Mo(e,t,n,r,i):await No(e,t,n,r,i)}}})}));async function Ro(e){if(e.apiKey||e.fileApiKey||e.accessTokenEnv||e.fileAccessToken)return;let n=process.env.DASHSCOPE_API_KEY,r;if(n&&(E({nonInteractive:e.nonInteractive})?await Yr({message:`Found DASHSCOPE_API_KEY in environment (${O(n)}). Save it to config file?`})&&(r=n):r=n),!r){if(!E({nonInteractive:e.nonInteractive}))throw new t(`No API key found.`,i.AUTH,`Set DASHSCOPE_API_KEY environment variable, pass --api-key, or run interactively to be prompted.`);let n=await Jr({message:`Enter your DashScope API key:`});if(!n)throw new t(`API key is required.`,i.AUTH);r=n}await De({...ue(),api_key:r}),e.fileApiKey=r;let a=e.configPath??`~/.bailian/config.json`;process.stderr.write(`API key saved to ${a}\n`)}var zo=M((()=>{H()}));function Bo(e){let t={};for(let n of e){let e=n.indexOf(`=`);e<=0&&(process.stderr.write(`Error: --arg must be in K=V form, got: ${n}\n`),process.exit(1));let r=n.slice(0,e).trim(),i=n.slice(e+1);try{t[r]=JSON.parse(i)}catch{t[r]=i}}return t}var Vo,Ho=M((()=>{H(),I(),zo(),Vo=m({name:`mcp call`,description:`Call a tool on an MCP server (tools/call)`,usage:`bl mcp call <server-code>.<tool> [--arg k=v ...] [--json '{...}'] [--url <url>]`,options:[{flag:`<server-code>.<tool>`,description:`Server code and tool name joined by a dot, e.g. market-cmapi00073529.SmartStockSelection`,required:!0},{flag:`--arg <kv>`,description:`Tool argument (repeatable). Values parsed as JSON if possible, else string.`,type:`array`},{flag:`--json <obj>`,description:`Full arguments object as JSON; merged with --arg (arg wins).`},{flag:`--query <text>`,description:`Shortcut for --arg query=<text> (mirrors many DashScope MCP tools).`},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp call market-cmapi00073529.SmartStockSelection --query "筛选ROE>15%的消费股"`,`bl mcp call market-cmapi00073529.FinQuery --json '{"q":"贵州茅台","limit":5}'`,`bl mcp call market-cmapi00073529.SmartFundSelection --arg riskLevel=R3 --arg minScale=10`],async run(e,t){let n=(t._positional??[])[0];n||V(`<server-code>.<tool>`,`bl mcp call <server-code>.<tool>`);let r=n.indexOf(`.`);(r<=0||r===n.length-1)&&(process.stderr.write(`Error: target must be <server-code>.<tool>, got "${n}".\n`),process.exit(1));let i=n.slice(0,r),a=n.slice(r+1),s={};if(t.json)try{let e=JSON.parse(t.json);(!e||typeof e!=`object`||Array.isArray(e))&&(process.stderr.write(`Error: --json must decode to an object.
154
+ `),process.exit(1)),s=e}catch(e){process.stderr.write(`Error: --json is not valid JSON — ${e.message}\n`),process.exit(1)}Object.assign(s,Bo(t.arg??[])),t.query!==void 0&&(s.query=t.query);let c=t.url||l(e.baseUrl,i),u=h(e.output);if(e.dryRun){P({server:i,url:c,tool:a,arguments:s},u);return}await Ro(e);let d=new o(e,c);await d.initialize();let f=await d.callTool(a,s);if(f.isError){let e=f.content.map(e=>e.text||``).join(`
155
+ `);process.stderr.write(`Tool error: ${e}\n`),process.exit(1)}P(f,u)}})})),Uo,Wo,Go=M((()=>{I(),Uo=`zeldaEasy.broadscope-bailian.mcp-server.PageList`,Wo=m({name:`mcp list`,description:`List MCP servers activated under your Bailian account`,usage:`bl mcp list [flags]`,options:[{flag:`--name <text>`,description:`Filter by server name (substring match)`},{flag:`--type <type>`,description:`Server type: OFFICIAL | PRIVATE (default: OFFICIAL)`},{flag:`--page <n>`,description:`Page number (default: 1)`,type:`number`},{flag:`--page-size <n>`,description:`Results per page (default: 30)`,type:`number`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl mcp list`,`bl mcp list --name 金融`,`bl mcp list --output json`],async run(e,n){let r=n.name||``,a=n.type||`OFFICIAL`,o=n.page||1,s=n.pageSize||30,c=n.region||`cn-beijing`,l=h(e.output),u={reqDTO:{type:a,displayTools:!1,activated:1,pageNo:o,pageSize:s,serverName:r}};if(e.dryRun){P({api:Uo,data:u,region:c},l);return}let f=(await d(e,(await me(e)).token,{api:Uo,data:u,region:c}))?.data??{};if(f.success===!1){let e=f.errorCode??`UnknownError`,n=f.errorMsg??e,r=e===`BailianGateway.Login.NotLogined`?"Run `bl auth login --console` to refresh your console session.":void 0;throw new t(`Console gateway: ${n}`,i.AUTH,r)}let p=(f.DataV2??{}).data?.data??{},m=p.mcpServerDetailList??[];P({total:p.total??0,servers:m.map(e=>({code:e.serverCode??``,name:e.serverName??``,description:e.description,type:e.type??``,source:e.source,bizType:e.bizType,installType:e.installType,streamable:e.streamable===!0}))},l)}})})),Ko,qo=M((()=>{H(),I(),zo(),Ko=m({name:`mcp tools`,description:`List tools exposed by an MCP server (tools/list)`,usage:`bl mcp tools <server-code> [--url <url>]`,options:[{flag:`<server-code>`,description:"Server code from `bl mcp list` (e.g. market-cmapi00073529)",required:!0},{flag:`--url <url>`,description:`Override the MCP endpoint URL (for non-Bailian servers)`}],examples:[`bl mcp tools market-cmapi00073529`,`bl mcp tools market-cmapi00073529 --output json`,`bl mcp tools my-server --url https://example.com/mcp`],async run(e,t){let n=(t._positional??[])[0];n||V(`server-code`,`bl mcp tools <server-code>`);let r=t.url||l(e.baseUrl,n),i=h(e.output);if(e.dryRun){P({server:n,url:r,action:`tools/list`},i);return}await Ro(e);let a=new o(e,r);await a.initialize(),P({server:n,url:r,tools:await a.listTools()},i)}})})),Jo,Yo=M((()=>{Ui(),H(),I(),Jo=m({name:`search web`,description:`Search the web using DashScope MCP WebSearch service`,usage:`bl search web --query <text> [flags]`,options:[{flag:`--query <text>`,description:`Search query text`,required:!0},{flag:`--count <n>`,description:`Number of search results (default: 10)`,type:`number`},{flag:`--list-tools`,description:`List available MCP tools and exit`}],examples:[`bl search web --query "阿里云百炼最新功能"`,`bl search web --query "TypeScript 5.9 new features" --count 5`,`bl search web --query "今日新闻"`,`bl search web --list-tools`],async run(e,t){let n=ne(e.baseUrl),r=h(e.output);if(t.listTools){if(e.dryRun){P({endpoint:n,action:`tools/list`},r);return}let t=new o(e,n);await t.initialize(),P({tools:await t.listTools()},r);return}let i=t.query;if(!i)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter your search query:`});e||(process.stderr.write(`Search cancelled.
156
+ `),process.exit(1)),i=e}else V(`query`,`bl search web --query <text>`);if(e.dryRun){P({endpoint:n,action:`tools/call`,tool:`bailian_web_search`,arguments:{query:i,count:t.count||void 0}},r);return}let a=new o(e,n),s=Bi(`Initializing search...`);e.quiet||s.start();try{await a.initialize(),e.quiet||s.update(`Searching...`);let n={query:i};t.count&&(n.count=t.count);let o=await a.callTool(`bailian_web_search`,n);if(e.quiet||s.stop(`Done.`),o.isError){let e=o.content.map(e=>e.text||``).join(`
157
+ `);process.stderr.write(`Search error: ${e}\n`),process.exit(1)}if(r===`json`)P(o,r);else for(let e of o.content)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);t.pages&&Array.isArray(t.pages)?P({pages:t.pages,total:t.pages.length},r):P(t,r)}catch{P({text:e.text},r)}}catch(e){throw s.stop(`Failed.`),e}}})}));function Xo(e){let t=ts[e];if(!t){process.stdout.write(`No built-in voice list available for model: ${e}\n`);return}if(t.length===0){process.stdout.write(`Model ${e} has no system voices.\n`),process.stdout.write(`Use clone or design voices created via the CosyVoice API.
158
+ `),process.stdout.write(`See: ${$o}\n`);return}let n=(e,t)=>e.padEnd(t);process.stdout.write(`\nSystem voices for ${e}:\n`),process.stdout.write(`${n(`VOICE ID`,26)} ${n(`NAME`,10)} ${n(`DESCRIPTION`,16)} LANGUAGE\n`),process.stdout.write(`${`-`.repeat(26)} ${`-`.repeat(10)} ${`-`.repeat(16)} ${`-`.repeat(12)}\n`);for(let e of t)process.stdout.write(`${n(e.voice,26)} ${n(e.name,10)} ${n(e.desc,16)} ${e.lang}\n`);process.stdout.write(`\nTotal: ${t.length} voices\n`)}async function Zo(e,n,r,a,o){let s=await Xi(Yi(a),e,()=>k(e,{url:n,method:`POST`,body:r})),c=s.map(e=>e.output?.audio?.url).filter(Boolean);if(c.length===0)throw new t(`API returned no audio URL.`,i.GENERAL);let l=await import(`path`),u=he(e,{subDir:`speech`}),d=await Zi(c.map((e,t)=>{let n=a.out;if(!(n&&c.length===1)){let e=Date.now(),i=c.length>1?`_${String(t+1).padStart(3,`0`)}`:``,a=r.input.format??`mp3`;n=l.join(u,`tts_${e}${i}.${a}`)}return{url:e,destPath:n}}),Ki,{quiet:e.quiet});if(e.quiet)F(d.join(`
159
+ `));else if(d.length===1){let e=s[0].output?.audio?.expires_at;P({saved:d[0],audio_url:c[0],model:r.model,voice:r.input.voice,...e?{url_expires_at:e}:{}},o)}else P({saved:d,audio_urls:c,total:d.length,model:r.model,voice:r.input.voice},o)}async function Qo(e,t,n,r,i){let a=await fe(e,{url:t,method:`POST`,body:n,stream:!0,headers:{Accept:`text/event-stream`,"X-DashScope-SSE":`enable`}}),o=r.out,s=o?Le(o):null,c;try{for await(let t of se(a)){if(!t.data||t.data===`[DONE]`)continue;let n;try{n=JSON.parse(t.data)}catch{continue}let r=n.output?.audio?.data;if(r){let e=Buffer.from(r,`base64`);s?s.write(e)||await new Promise(e=>s.once(`drain`,()=>e())):process.stdout.write(e)}if(n.output?.finish_reason===`stop`){c=n.output?.audio?.url,c&&!e.quiet&&process.stderr.write(`\nFull audio URL: ${c}\n`);break}}}finally{s&&(await new Promise((e,t)=>{s.on(`finish`,e),s.on(`error`,t),s.end()}),!e.quiet&&o&&process.stderr.write(`Saved: ${o}\n`))}o&&P({saved:o,...c?{audio_url:c}:{},model:n.model,voice:n.input.voice},i)}var $o,es,ts,ns,rs=M((()=>{Ji(),Qi(),H(),I(),$o=`${r.cn}/cosyvoice-clone-design-api`,es=[{voice:`longanyang`,name:`龙安洋`,desc:`阳光大男孩`,lang:`中文/英文`},{voice:`longanhuan`,name:`龙安欢`,desc:`欢脱元气女`,lang:`中文/英文`},{voice:`longantai_v3`,name:`龙安台`,desc:`嗲甜台湾女`,lang:`中文/英文`},{voice:`longhua_v3`,name:`龙华`,desc:`元气甜美女`,lang:`中文/英文`},{voice:`longcheng_v3`,name:`龙橙`,desc:`智慧青年男`,lang:`中文/英文`},{voice:`longze_v3`,name:`龙泽`,desc:`温暖元气男`,lang:`中文/英文`},{voice:`longzhe_v3`,name:`龙哲`,desc:`呆板大暖男`,lang:`中文/英文`},{voice:`longyan_v3`,name:`龙颜`,desc:`温暖春风女`,lang:`中文/英文`},{voice:`longxing_v3`,name:`龙星`,desc:`温婉邻家女`,lang:`中文/英文`},{voice:`longtian_v3`,name:`龙天`,desc:`磁性理智男`,lang:`中文/英文`},{voice:`longwan_v3`,name:`龙婉`,desc:`细腻柔声女`,lang:`中文/英文`},{voice:`longqiang_v3`,name:`龙嫱`,desc:`浪漫风情女`,lang:`中文/英文`},{voice:`longfeifei_v3`,name:`龙菲菲`,desc:`甜美娇气女`,lang:`中文/英文`},{voice:`longhao_v3`,name:`龙浩`,desc:`多情忧郁男`,lang:`中文/英文`},{voice:`longanrou_v3`,name:`龙安柔`,desc:`温柔娴静女`,lang:`中文/英文`},{voice:`longxiaochun_v3`,name:`龙小淳`,desc:`知性积极女`,lang:`中文/英文`},{voice:`longxiaoxia_v3`,name:`龙小夏`,desc:`沉稳权威女`,lang:`中文/英文`},{voice:`longyumi_v3`,name:`YUMI`,desc:`正经青年女`,lang:`中文/英文`},{voice:`longanyun_v3`,name:`龙安昀`,desc:`居家暖男`,lang:`中文/英文`},{voice:`longanwen_v3`,name:`龙安温`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longanli_v3`,name:`龙安莉`,desc:`利落从容女`,lang:`中文/英文`},{voice:`longanlang_v3`,name:`龙安朗`,desc:`清爽利落男`,lang:`中文/英文`},{voice:`longyingmu_v3`,name:`龙应沐`,desc:`优雅知性女`,lang:`中文/英文`},{voice:`longyingxun_v3`,name:`龙应询`,desc:`年轻青涩男`,lang:`中文/英文`},{voice:`longyingjing_v3`,name:`龙应静`,desc:`低调冷静女`,lang:`中文/英文`},{voice:`longyingling_v3`,name:`龙应聆`,desc:`温和共情女`,lang:`中文/英文`},{voice:`longyingtao_v3`,name:`龙应桃`,desc:`温柔淡定女`,lang:`中文/英文`},{voice:`longyingxiao_v3`,name:`龙应笑`,desc:`清甜推销女`,lang:`中文/英文`},{voice:`longfei_v3`,name:`龙飞`,desc:`热血磁性男`,lang:`中文/英文`},{voice:`longhuhu_v3`,name:`龙呼呼`,desc:`天真烂漫女童`,lang:`中文/英文`},{voice:`longpaopao_v3`,name:`龙泡泡`,desc:`飞天泡泡音`,lang:`中文/英文`},{voice:`longjielidou_v3`,name:`龙杰力豆`,desc:`阳光顽皮男`,lang:`中文/英文`},{voice:`longxian_v3`,name:`龙仙`,desc:`豪放可爱女`,lang:`中文/英文`},{voice:`longling_v3`,name:`龙铃`,desc:`稚气呆板女`,lang:`中文/英文`},{voice:`longshanshan_v3`,name:`龙闪闪`,desc:`戏剧化童声`,lang:`中文/英文`},{voice:`longniuniu_v3`,name:`龙牛牛`,desc:`阳光男童声`,lang:`中文/英文`},{voice:`longjiaxin_v3`,name:`龙嘉欣`,desc:`优雅粤语女`,lang:`粤语/英文`},{voice:`longjiayi_v3`,name:`龙嘉怡`,desc:`知性粤语女`,lang:`粤语/英文`},{voice:`longanyue_v3`,name:`龙安粤`,desc:`欢脱粤语男`,lang:`粤语/英文`},{voice:`longlaotie_v3`,name:`龙老铁`,desc:`东北直率男`,lang:`东北话/英文`},{voice:`longshange_v3`,name:`龙陕哥`,desc:`原味陕北男`,lang:`陕西话/英文`},{voice:`longanmin_v3`,name:`龙安闽`,desc:`清纯萝莉女`,lang:`闽南话/英文`},{voice:`loongabby_v3`,name:`loongabby`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongandy_v3`,name:`loongandy`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongannie_v3`,name:`loongannie`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongava_v3`,name:`loongava`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbeth_v3`,name:`loongbeth`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongbetty_v3`,name:`loongbetty`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcally_v3`,name:`loongcally`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongcindy_v3`,name:`loongcindy`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongdavid_v3`,name:`loongdavid`,desc:`美式英文男`,lang:`美式英语`},{voice:`loongdonna_v3`,name:`loongdonna`,desc:`美式英文女`,lang:`美式英语`},{voice:`loongemily_v3`,name:`loongemily`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongeric_v3`,name:`loongeric`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongluna_v3`,name:`loongluna`,desc:`英式英文女`,lang:`英式英语`},{voice:`loongluca_v3`,name:`loongluca`,desc:`英式英文男`,lang:`英式英语`},{voice:`loongriko_v3`,name:`Riko`,desc:`二次元霓虹女`,lang:`日语`},{voice:`loongtomoka_v3`,name:`loongtomoka`,desc:`日语女`,lang:`日语`},{voice:`loongtomoya_v3`,name:`loongtomoya`,desc:`日语男`,lang:`日语`},{voice:`loongyuuna_v3`,name:`Yuuna`,desc:`日语女`,lang:`日语`},{voice:`loongyuuma_v3`,name:`Yuuma`,desc:`日语男`,lang:`日语`},{voice:`loongkyong_v3`,name:`loongkyong`,desc:`韩语女`,lang:`韩语`},{voice:`loongjihun_v3`,name:`Jihun`,desc:`韩语男`,lang:`韩语`},{voice:`loongindah_v3`,name:`loongindah`,desc:`印尼女`,lang:`印尼语`}],ts={"cosyvoice-v3-flash":es,"cosyvoice-v3-plus":es,"cosyvoice-v3.5-flash":[],"cosyvoice-v3.5-plus":[],"cosyvoice-v2":[]},ns=m({name:`speech synthesize`,description:`Synthesize speech from text (CosyVoice TTS)`,usage:`bl speech synthesize --text <text> [flags]`,options:[{flag:`--text <text>`,description:`Text to synthesize into speech`,required:!0},{flag:`--text-file <path>`,description:`Read text from a file instead of --text`},{flag:`--model <model>`,description:`Model ID (default: cosyvoice-v3-flash). System voices available for cosyvoice-v3-flash`},{flag:`--voice <voice>`,description:`Voice ID. Use --list-voices to see system voices for cosyvoice-v3-flash; for v3.5-flash provide a clone/design voice ID`},{flag:`--list-voices`,description:`List available system voices for the selected model and exit`},{flag:`--format <format>`,description:`Audio format: mp3, pcm, wav, opus (default: mp3)`},{flag:`--sample-rate <rate>`,description:`Audio sample rate in Hz (e.g. 24000)`},{flag:`--volume <volume>`,description:`Volume 0-100 (default: 50)`},{flag:`--rate <rate>`,description:`Speech rate 0.5-2.0 (default: 1.0)`},{flag:`--pitch <pitch>`,description:`Pitch multiplier 0.5-2.0 (default: 1.0)`},{flag:`--seed <seed>`,description:`Random seed 0-65535 for reproducible synthesis`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja, ko, fr, de)`},{flag:`--instruction <text>`,description:`Natural language instruction to control speech style (e.g. "请用温柔的语调")`},{flag:`--enable-ssml`,description:`Enable SSML markup parsing in input text`},{flag:`--out <path>`,description:`Save audio to file (default: auto-generate in temp dir)`},{flag:`--stream`,description:`Stream raw PCM audio to stdout (pipe to player)`}],examples:[`bl speech synthesize --list-voices --model cosyvoice-v3-flash`,`bl speech synthesize --text "你好,我是千问" --voice <voice_id>`,`bl speech synthesize --text "Hello world" --voice <voice_id> --language en`,`bl speech synthesize --text-file script.txt --out speech.wav --voice <voice_id>`,`bl speech synthesize --text "今天天气真好" --voice <voice_id> --instruction "请用温柔的语调说话"`,`bl speech synthesize --text "Hello" --voice <voice_id> --format wav --sample-rate 24000`,`# Stream to audio player (macOS)`,`bl speech synthesize --text "你好" --voice <voice_id> --stream | afplay -`,`# Pipe to ffplay`,`bl speech synthesize --text "Hello" --voice <voice_id> --stream | ffplay -nodisp -autoexit -f s16le -ar 24000 -ac 1 -`],async run(e,n){let r=n.model||e.defaultSpeechModel||`cosyvoice-v3-flash`;if(n.listVoices){Xo(r);return}let a=n.text;if(!a&&n.textFile){let e=n.textFile;try{a=Be(e,`utf-8`).trim()}catch{throw new t(`Cannot read text file: ${e}`,i.USAGE)}}if(!a)if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`Enter text to synthesize:`});e||(process.stderr.write(`Speech synthesis cancelled.
160
+ `),process.exit(1)),a=e}else V(`text`,`bl speech synthesize --text <text>`);let o=n.voice||void 0;if(!o)if(E({nonInteractive:e.nonInteractive})){let e=ts[r];if(e&&e.length>0){let t=e[0].voice,n=e.map(e=>({value:e.voice,label:`${e.name} (${e.voice})`,hint:`${e.desc} · ${e.lang}`})),r=await Xr({message:`Select a voice (default: ${t}):`,choices:n,defaultValue:t});r||(process.stderr.write(`Speech synthesis cancelled.
161
+ `),process.exit(1)),o=r}else{let e=await Jr({message:`Enter voice ID (clone/design voice):`});e||(process.stderr.write(`Speech synthesis cancelled.
162
+ `),process.exit(1)),o=e}}else{let e=ts[r];throw e&&e.length>0?new t(`--voice is required.\nRun the following to see available voices:\n bl speech synthesize --list-voices --model ${r}`,i.USAGE):new t(`--voice is required. Model ${r} has no built-in system voices.\nCreate a clone or design voice first, then pass its ID via --voice <voice_id>.\nSee: ${$o}`,i.USAGE)}let s=n.language||void 0,c=n.instruction||void 0,l=n.format||void 0,u=n.sampleRate===void 0?void 0:Number(n.sampleRate),d=n.volume===void 0?void 0:Number(n.volume),f=n.rate===void 0?void 0:Number(n.rate),p=n.pitch===void 0?void 0:Number(n.pitch),m=n.seed===void 0?void 0:Number(n.seed),g=n.enableSsml===!0?!0:void 0,_=n.stream===!0,v=h(e.output),y={model:r,input:{text:a,voice:o,format:l,sample_rate:u,volume:d,rate:f,pitch:p,seed:m,language_hints:s?[s]:void 0,instruction:c,enable_ssml:g}};if(be(y.input),e.dryRun){P({request:y},v);return}e.quiet||process.stderr.write(`[Model: ${r}] [Voice: ${o}]\n`);let b=ye(e.baseUrl);_?await Qo(e,b,y,n,v):await Zo(e,b,y,n,v)}})}));async function is(e,n,r,a,o,s){let c=(await k(e,{url:n,method:`POST`,body:r,async:!0})).output.task_id;if(a.noWait||e.async){P({task_id:c},o);return}let l=a.pollInterval??2,u=await Wi(e,{url:xe(e.baseUrl,c),intervalSec:l,timeoutSec:e.timeout,isComplete:e=>e.output.task_status===`SUCCEEDED`,isFailed:e=>e.output.task_status===`FAILED`,getStatus:e=>e.output.task_status,getErrorMessage:e=>e.output.message}),d=u.output.results??[];if(d.length===0){P({task_id:c,status:u.output.task_status},o);return}let f=[];for(let e=0;e<d.length;e++){let n=d[e],r=s>1;if(r&&process.stdout.write(`=== [${e+1}/${d.length}] ${n.file_url??``} ===\n`),n.subtask_status===`FAILED`){let e=n.message??n.code??`unknown error`;process.stdout.write(`[FAILED] ${n.file_url??``} — ${e}\n`),r&&process.stdout.write(`
161
163
  `);continue}if(!n.transcription_url){r&&process.stdout.write(`
162
- `);continue}let a=await fetch(n.transcription_url,{headers:Se()});if(!a.ok)throw new t(`Failed to download transcription: HTTP ${a.status}`,i.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
163
- `);else P(JSON.stringify(o));r&&process.stdout.write(`
164
- `)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;Ve(t,JSON.stringify(n,null,2)+`
165
- `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var Xo,Zo=j((()=>{zi(),W(),F(),Xo=m({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,apiDocs:`/developer-reference/recording-file-recognition`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&U(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
166
- Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=h(e.output),l=await k(e),u=await Promise.all(r.map(e=>A(e,l.token,s))),d=n.channelId,f=n.language,p=n.vocabularyId,m={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:f?[f]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:p}};if(ye(m.parameters),e.dryRun){N({request:m,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await Yo(e,_e(e.baseUrl),m,n,c,u.length)}})})),Qo,$o=j((()=>{W(),F(),Qo=m({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,apiDocs:`/developer-reference/get-temporary-file-url`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen3-vl-plus`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||U(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||U(`model`,`bl file upload --file <path> --model <model>`);let i=h(e.output);if(e.dryRun){N({action:`upload`,file:n,model:r},i);return}let a=await Ce({apiKey:(await k(e)).token,model:r,filePath:n});e.quiet?P(a):N({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),es,ts=j((()=>{W(),F(),es=m({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`],async run(e,r){let i=r.api;i||U(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||U(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
167
- `),process.exit(1)}let s=r.region||`cn-beijing`,c=h(e.output),l;try{l=(await pe(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){N({api:i,data:o,region:s,token:l?l.slice(0,8)+`...`:null},c);return}N(await d(e,l,{api:i,data:o,region:s}),c)}})})),ns,rs,is=j((()=>{W(),F(),ns=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,rs=m({name:`usage free`,description:`Query free-tier quota for a model`,usage:`bl usage free --model <model> [flags]`,options:[{flag:`--model <model>`,description:`Model name to query (e.g. qwen3-max, qwen-turbo)`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free --model qwen3-max`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model;n||U(`model`,`bl usage free --model <model>`);let r=t.region||`cn-beijing`,i=h(e.output),a=await pe(e),o={queryFreeTierQuotaRequest:{models:[n]}};if(e.dryRun){N({api:ns,data:o,region:r,token:a.token.slice(0,8)+`...`},i);return}N(await d(e,a.token,{api:ns,data:o,region:r}),i)}})}));function as(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,os=j((()=>{G=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 ss(){return us}function cs(e,t,n,r){let i,a;n instanceof ls?(i=n,a=r):(i=us,a=n??r),i.registerStep(e,t,a)}var ls,us,ds=j((()=>{os(),ls=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 G(`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)}},us=new ls}));function fs(){let e=ee(ps);return e.clientName=`bailian-cli`,e}var ps,ms=j((()=>{ps={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function hs(e){return e.startsWith(`./`)||e.startsWith(`../`)}function gs(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&hs(a)?(n[i]=Qe(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function _s(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await Ke(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function vs(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 K(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ys(e,t){if(Array.isArray(e)){e.forEach(e=>ys(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))ys(n,t)}}async function bs(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(xs.includes(e)||typeof i!=`string`||!hs(i))continue;let a=Qe(t,i);await Ke(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var xs,Ss=j((()=>{xs=[`download`,`out-dir`,`output`]}));async function Cs(e,t,n){if(!t.message)throw new G(`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};return 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`])),await O(e,{url:f(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function ws(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;if(E(i)){let t=await k(e);i=await A(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;E(t)&&(i=await A(t,(await k(e)).token,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}]};return await O(e,{url:f(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Ts(e){return Is.some(t=>e.startsWith(t))}async function Es(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Ts(r),a=t.n??1,o=fe(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:qi(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:he(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await O(e,{url:w(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Os(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await O(e,{url:C(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await Ns(e,r,n),a=await Os(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ds(e,t,n){if(!t.prompt)throw new G(`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=Ts(i),o=t.n??1,s=fe(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;E(t)&&(r=await A(t,(await k(e)).token,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:qi(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:he(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await O(e,{url:w(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Os(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await O(e,{url:C(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await Ns(e,r,n),a=await Os(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Os(e,t,n){if(!t||e.length===0)return;await qe(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:Ze(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:Ze(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Bi(e,t,{quiet:!0}),a.push(t);return a}async function ks(e,t,n){if(!t.prompt)throw new G(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(E(t.image)){let a=await k(e);i=await A(t.image,a.token,r,{signal:n.signal})}else i=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:fe(t[`prompt-extend`],void 0,`prompt-extend`),watermark:he(t.watermark),seed:t.seed}};ye(a.parameters);let o=(await O(e,{url:Te(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Ps(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function As(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 G(`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`]}};ye(a.input);let o=await O(e,{url:ve(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function js(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new G(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(E(a)){let r=await k(e);i.push(await A(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else 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`]}};ye(a.parameters);let o=(await O(e,{url:_e(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Ps(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Ms(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 Ns(e,t,n){return await Ps(e,t,3e3,e.timeout*1e3,n)}async function Ps(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new G(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Fs(n,i?.signal),o++;let s=await O(e,{url:be(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Ms(s);if(c===`FAILED`)throw new G(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new G(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Fs(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new G(`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))}var Is,Ls=j((()=>{os(),Xi(),Hi(),Is=[`qwen-image-2.0`,`qwen-image-max`]}));function Rs(e){for(let t of Object.keys(qs))cs(t,async(e,n)=>await zs(t,e,n),e,Ys[t])}async function zs(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=qs[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??fs(),t,n),a=Js[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Bs(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of Ws(e.urls))t.push({url:r,taskId:n,kind:Gs(r)});for(let r of Ws(e.saved))t.push({path:r,taskId:n,kind:Ks(r)});let r=q(e.video_url)??q(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=q(e.saved);if(i&&t.push({path:i,taskId:n,kind:Ks(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!K(n))continue;let e=q(n.task_id)??q(n.taskId),r=q(n.video_url)??q(n.videoUrl),i=q(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(q).filter(Us):[];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 Vs(e,t){if(!K(e))return;let n=[],r=q(e.task_id)??q(e.taskId),i=[q(e.url),q(e.audio_url),q(e.audioUrl),q(e.output_url),q(e.outputUrl)].filter(Us);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[q(e.saved),q(e.path),q(e.output_path),q(e.outputPath)].filter(Us);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?Hs(n):void 0}function Hs(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 Us(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function Ws(e){return Array.isArray(e)?e.map(q).filter(Us):[]}function Gs(e){try{return Ks(new URL(e).pathname)}catch{return`artifact`}}function Ks(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 qs,Js,Ys,Xs=j((()=>{ds(),ms(),Ss(),Ls(),qs={"text/chat":(e,t,n)=>Cs(e,t,n),"vision/describe":(e,t,n)=>ws(e,t,n),"image/generate":(e,t,n)=>Es(e,t,n),"image/edit":(e,t,n)=>Ds(e,t,n),"video/generate":(e,t,n)=>ks(e,t,n),"speech/synthesize":(e,t,n)=>As(e,t,n),"speech/recognize":(e,t,n)=>js(e,t,n)},Js={"image/generate":e=>({data:e,artifacts:Bs(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Bs(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Bs(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:Vs(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:Vs(e,`transcript`),warnings:[],metadata:{}})},Ys={"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`}]}}})),Zs=M((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})),Qs=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Zs();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}}})),J=M((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=Zs(),n=Qs();var r=Zs();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=Qs();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&&=te(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=te(this.rhs,e,n),this}get names(){return D(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=te(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)||(ne(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ee(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(re(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=te(this.condition,e,t),this}get names(){let e=super.names;return D(e,this.condition),this.else&&ee(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=te(this.iteration,e,t),this}get names(){return ee(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 D(D(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=te(this.iterable,e,t),this}get names(){return ee(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&&ee(e,this.catch.names),this.finally&&ee(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?`
168
- `:``},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 ee(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function D(e,n){return n instanceof t._CodeOrName?ee(e,n.names):e}function te(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 ne(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function re(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${le(e)}`}e.not=re;let ie=ce(e.operators.AND);function ae(...e){return e.reduce(ie)}e.and=ae;let oe=ce(e.operators.OR);function se(...e){return e.reduce(oe)}e.or=se;function ce(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${le(n)} ${e} ${le(r)}`}function le(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=M((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=J(),n=Zs();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})),$s=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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`)}})),ec=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=J(),n=Y(),r=$s();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])}})),tc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ec(),n=J(),r=$s(),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)}})),nc=M((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})),rc=M((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})),ic=M((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=nc(),n=rc(),r=ec(),i=J(),a=Y();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
164
+ `);continue}let a=await fetch(n.transcription_url,{headers:Ce()});if(!a.ok)throw new t(`Failed to download transcription: HTTP ${a.status}`,i.GENERAL);let o=await a.json();f.push(o);let c=o.transcripts;if(c&&c.length>0)for(let e of c)if(e.sentences&&e.sentences.length>0)for(let t of e.sentences){let e=t.speaker_id===void 0?``:` [Speaker ${t.speaker_id}]`;process.stdout.write(`${t.text}${e}\n`)}else e.text&&process.stdout.write(e.text+`
165
+ `);else F(JSON.stringify(o));r&&process.stdout.write(`
166
+ `)}if(a.out){let t=a.out,n=f.length===1?f[0]:f;He(t,JSON.stringify(n,null,2)+`
167
+ `),e.quiet||process.stderr.write(`Full result saved to: ${t}\n`)}}var as,os=M((()=>{Gi(),H(),I(),as=m({name:`speech recognize`,description:`Recognize speech from audio files (FunAudio-ASR)`,usage:`bl speech recognize --url <audio-url> [flags]`,options:[{flag:`--url <url>`,description:`Audio file URL or local file path (repeatable, max 100)`,required:!0,type:`array`},{flag:`--model <model>`,description:`Model ID (default: fun-asr)`},{flag:`--language <lang>`,description:`Language hint (e.g. zh, en, ja)`},{flag:`--diarization`,description:`Enable automatic speaker diarization`},{flag:`--speaker-count <n>`,description:`Expected number of speakers (requires --diarization)`,type:`number`},{flag:`--vocabulary-id <id>`,description:`Hot-word vocabulary ID for improved accuracy`},{flag:`--channel-id <n>`,description:`Audio channel ID (default: 0)`,type:`number`},{flag:`--out <path>`,description:`Save full transcription result to JSON file`},{flag:`--no-wait`,description:`Return task ID immediately without polling`},{flag:`--poll-interval <seconds>`,description:`Polling interval in seconds (default: 2)`,type:`number`}],examples:[`bl speech recognize --url https://example.com/audio.mp3`,`bl speech recognize --url https://example.com/a.mp3 --url https://example.com/b.mp3`,`bl speech recognize --url https://example.com/meeting.wav --diarization --speaker-count 3`,`bl speech recognize --url https://example.com/audio.mp3 --language zh`,`bl speech recognize --url https://example.com/audio.mp3 --vocabulary-id vocab-abc123`,`bl speech recognize --url https://example.com/audio.mp3 --out result.json`,`bl speech recognize --url https://example.com/audio.mp3 --no-wait --quiet`],async run(e,n){let r=[];Array.isArray(n.url)?r=n.url:typeof n.url==`string`&&(r=[n.url]),r.length===0&&V(`url`,`bl speech recognize --url <audio-url>`);let a=n.speakerCount,o=n.diarization===!0;if(a!==void 0&&!o)throw new t(`--speaker-count requires --diarization to be enabled.
168
+ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.model||`fun-asr`,c=h(e.output),l=await A(e),u=await Promise.all(r.map(e=>j(e,l.token,s))),d=n.channelId,f=n.language,p=n.vocabularyId,m={model:s,input:{file_urls:u},parameters:{channel_id:d===void 0?[0]:[d],language_hints:f?[f]:void 0,diarization_enabled:o?!0:void 0,speaker_count:a,vocabulary_id:p}};if(be(m.parameters),e.dryRun){P({request:m,mode:`async`},c);return}e.quiet||process.stderr.write(`[Model: ${s}] [Mode: async] [Files: ${u.length}]\n`),await is(e,ve(e.baseUrl),m,n,c,u.length)}})})),ss,cs=M((()=>{H(),I(),ss=m({name:`file upload`,description:`Upload a local file to DashScope temporary storage (48h)`,usage:`bl file upload --file <path> --model <model>`,options:[{flag:`--file <path>`,description:`Local file to upload (image, video, audio)`,required:!0},{flag:`--model <model>`,description:`Target model name (file is bound to this model)`,required:!0}],examples:[`bl file upload --file photo.jpg --model qwen3-vl-plus`,`bl file upload --file video.mp4 --model wan2.1-t2v-plus`,`bl file upload --file audio.wav --model qwen3-asr-flash`,`bl file upload --file cat.png --model qwen-image-2.0`],async run(e,t){let n=t.file;n||V(`file`,`bl file upload --file <path> --model <model>`);let r=t.model;r||V(`model`,`bl file upload --file <path> --model <model>`);let i=h(e.output);if(e.dryRun){P({action:`upload`,file:n,model:r},i);return}let a=await we({apiKey:(await A(e)).token,model:r,filePath:n});e.quiet?F(a):P({url:a,model:r,expires_in:`48 hours`,note:`When using this URL in API calls, add header: X-DashScope-OssResourceResolve: enable`},i)}})})),ls,us=M((()=>{H(),I(),ls=m({name:`console call`,description:`Call a Bailian console API via the CLI gateway`,usage:`bl console call --api <api> --data <json> [flags]`,options:[{flag:`--api <api>`,description:`API name (e.g. zeldaEasy.broadscope-bailian.memory-library.getLibraries)`,required:!0},{flag:`--data <json>`,description:`Request data as JSON string`,required:!0},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl console call --api zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota --data '{"queryFreeTierQuotaRequest":{"models":["qwen3-max"]}}'`,`bl console call --api some.api.name --data '{"key":"value"}' --region cn-beijing`],async run(e,r){let i=r.api;i||V(`api`,`bl console call --api <api> --data <json>`);let a=r.data;a||V(`data`,`bl console call --api <api> --data <json>`);let o;try{o=JSON.parse(a)}catch{process.stderr.write(`Error: --data must be valid JSON
169
+ `),process.exit(1)}let s=r.region||`cn-beijing`,c=h(e.output),l;try{l=(await me(e)).token}catch(e){if(!(e instanceof t&&e.message===n))throw e}if(e.dryRun){P({api:i,data:o,region:s,token:l?l.slice(0,8)+`...`:null},c);return}P(await d(e,l,{api:i,data:o,region:s}),c)}})}));function ds(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 U(e){let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=ds(e)?2:1}return t}function W(e,t){let n=t-U(e);return n>0?e+` `.repeat(n):e}var fs=M((()=>{}));function ps(e){return e.toLocaleString(`en-US`)}function ms(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function hs(e){return e.quotaInitTotal?`${((e.quotaInitTotal-e.quotaTotal)/e.quotaInitTotal*100).toFixed(1)}%`:`-`}function gs(e){for(let t of e){let e=Cs[t];if(e)return e}return`-`}function _s(e,t,n,r){let i=[`模型`,`类型`,`剩余/总量`,`使用率`,`过期时间`,`用完即停`],a=[`Model`,`Type`,`Remaining/Total`,`Usage`,`Expires`,`Auto-Stop`],o=e.map(e=>{let r=e.quotaInitTotal!=null&&e.quotaTotal!=null,i=r?ps(e.quotaTotal):`-`,a=r?ps(e.quotaInitTotal):`-`,o=t.get(e.model);return[e.model,n.get(e.model)||`-`,r?`${i} / ${a}`:`-`,hs(e),e.quotaValidityPeriod?ms(e.quotaValidityPeriod):`-`,e.quotaStatus===`UNKNOWN`?`Unsupported`:o===!0?`ON`:o===!1?`OFF`:`-`]}),s=i.map((e,t)=>Math.max(U(e),U(a[t]),...o.map(e=>U(e[t])))),c=r?e=>e:e=>`\x1b[2m${e}\x1b[0m`,l=r?e=>e:e=>`\x1b[1m${e}\x1b[0m`,u=r?e=>e:e=>`\x1b[32m${e}\x1b[0m`,d=r?e=>e:e=>`\x1b[33m${e}\x1b[0m`,f=i.length-1,p=i.map((e,t)=>l(W(e,s[t]))).join(` `),m=a.map((e,t)=>c(W(e,s[t]))).join(` `),h=s.map(e=>c(`─`.repeat(e))).join(`──`);process.stdout.write(p+`
170
+ `),process.stdout.write(m+`
171
+ `),process.stdout.write(h+`
172
+ `);for(let e of o){let t=e.map((e,t)=>{if(t===f){if(e===`ON`)return u(W(e,s[t]));if(e===`OFF`)return d(W(e,s[t]))}return W(e,s[t])});process.stdout.write(t.join(` `)+`
173
+ `)}}function vs(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierQuotas||[]:t.data?.freeTierQuotas||[]}function ys(e){let t=e.data;if(!t)return[];let n=t.DataV2;return n?n.data?.data?.freeTierOnlyStatuses||[]:t.data?.freeTierOnlyStatuses||[]}async function bs(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.filter(e=>typeof e.model==`string`&&e.model).map(e=>({name:e.model,type:gs(e.capabilities||[])}))}var xs,Ss,Cs,ws,Ts=M((()=>{I(),fs(),xs=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Ss=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Cs={Reasoning:`Text`,TG:`Text`,VU:`Text`,IG:`Vision`,VG:`Vision`,"Realtime-Omni":`Multimodal`,"Multimodal-Omni":`Multimodal`,ASR:`Audio`,TTS:`Audio`,"Voice-Replication":`Audio`,"Realtime-Text-to-Speech":`Audio`,"Realtime-Voice-Replication":`Audio`,"Realtime-ASR":`Audio`,"Realtime-Audio-Translate":`Audio`,ME:`Embedding`,TR:`Embedding`},ws=m({name:`usage free`,description:`Query free-tier quota for models (all models if --model is omitted)`,usage:`bl usage free [--model <model>[,model2,...]] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s) to query, comma-separated for multiple; omit for all models`},{flag:`--expiring <days>`,description:`Only show quotas expiring within N days`},{flag:`--sort <field>`,description:`Sort by: remaining (ascending), expires (ascending)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage free`,`bl usage free --model qwen3-max`,`bl usage free --model qwen3-max,qwen-turbo`,`bl usage free --expiring 30`,`bl usage free --sort remaining`,`bl usage free --model qwen-turbo --output json`,`bl usage free --model qwen3-max --region cn-beijing`],async run(e,t){let n=t.model||void 0,r=Number(t.expiring)||0,i=[`remaining`,`expires`],a=t.sort||void 0;a&&!i.includes(a)&&(process.stderr.write(`Error: invalid --sort value "${a}". Must be one of: ${i.join(`, `)}\n`),process.exit(1));let o=t.region||`cn-beijing`,s=h(e.output),c=await me(e),l,u=new Map;if(n){l=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))];let t=await Promise.all(l.map(t=>g(e,c.token,{name:t,pageSize:50})));for(let e=0;e<l.length;e++){let n=t[e].models.find(t=>t.model===l[e]);n&&u.set(l[e],gs(n.capabilities||[]))}}else{let t=await bs(e,c.token);l=t.map(e=>e.name);for(let e of t)u.set(e.name,e.type)}let f={queryFreeTierQuotaRequest:{models:l}};if(e.dryRun){P({api:xs,data:f,region:o,token:c.token.slice(0,8)+`...`},s);return}let[p,m]=await Promise.all([d(e,c.token,{api:xs,data:f,region:o}),d(e,c.token,{api:Ss,data:{queryFreeTierOnlyStatusRequest:{models:l}},region:o})]);if(s===`json`){P(p,s);return}let _=vs(p),v=n?_:_.filter(e=>e.quotaStatus===`VALID`&&e.quotaInitTotal>0);if(r>0){let e=Date.now()+r*24*60*60*1e3;v=v.filter(t=>t.quotaValidityPeriod>0&&t.quotaValidityPeriod<=e)}if(a===`remaining`?v.sort((e,t)=>(e.quotaInitTotal?e.quotaTotal/e.quotaInitTotal:0)-(t.quotaInitTotal?t.quotaTotal/t.quotaInitTotal:0)):a===`expires`&&v.sort((e,t)=>(e.quotaValidityPeriod??0)-(t.quotaValidityPeriod??0)),v.length===0){process.stdout.write(`No free-tier quota found.
174
+ `);return}let y=ys(m),b=new Map(y.map(e=>[e.model,e.freeTierOnly]));_s(v,b,u,e.noColor)}})}));function Es(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ds(e){let t=Es(e,`data`);if(!t)return e;let n=Es(t,`DataV2`);if(n){let e=Es(n,`data`);return(e?Es(e,`data`):void 0)??e??n}return Es(t,`data`)??t}async function Os(e,t,n,r,i,a){let o;for(let s=0;s<Fs;s++){let s=await d(e,t,{api:n,data:{[r]:o?{taskId:o}:{models:i}},region:a}),c=Ds(s);if(c.taskId&&Object.keys(c).length===1){o=c.taskId,await new Promise(e=>setTimeout(e,Ps));continue}return s}return null}async function ks(e,t){let n=[],r=1;for(;;){let i=await g(e,t,{pageNo:r,pageSize:50});if(n.push(...i.models),n.length>=i.total)break;r++}return n.map(e=>e.model).filter(Boolean)}var As,js,Ms,Ns,Ps,Fs,Is,Ls=M((()=>{I(),As=`zeldaEasy.broadscope-bailian.freeTrial.batchActivateFreeTierOnly`,js=`zeldaEasy.broadscope-bailian.freeTrial.batchDeactivateFreeTierOnly`,Ms=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota`,Ns=`zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierOnlyStatus`,Ps=500,Fs=20,Is=m({name:`usage freetier`,description:`Enable or disable auto-stop for free-tier models. Enables by default; use --off to disable`,usage:`bl usage freetier <--model <model>[,model2,...] | --all> [--off] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated for multiple`},{flag:`--all`,description:`Apply to all free-tier models`},{flag:`--on`,description:`Enable auto-stop (default behavior)`},{flag:`--off`,description:`Disable auto-stop`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage freetier --model qwen3-max`,`bl usage freetier --model qwen3-max,qwen-turbo`,`bl usage freetier --all`,`bl usage freetier --on --model qwen3-max`,`bl usage freetier --off --model qwen3-max`,`bl usage freetier --off --all`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=!!t.off,a=t.region||`cn-beijing`,o=h(e.output);!n&&!r&&(process.stderr.write(`Error: missing required flag. Specify --model <model>[,model2,...] or --all
175
+ `),process.exit(1));let s=await me(e),c;c=n?[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))]:await ks(e,s.token);let l=i?js:As,u=i?`BatchDeactivateFreeTierOnlyRequest`:`BatchActivateFreeTierOnlyRequest`;if(e.dryRun){P({api:l,data:{[u]:{models:c}},region:a,token:s.token.slice(0,8)+`...`},o);return}if(i){let[t,n]=await Promise.all([d(e,s.token,{api:Ms,data:{queryFreeTierQuotaRequest:{models:c}},region:a}),d(e,s.token,{api:Ns,data:{queryFreeTierOnlyStatusRequest:{models:c}},region:a})]),r=Ds(t).freeTierQuotas??[],i=new Map(r.map(e=>[e.model,e])),o=Ds(n).freeTierOnlyStatuses??[],f=new Map(o.map(e=>[e.model,e.freeTierOnly]));for(let t of c){if(f.get(t)===!1){process.stderr.write(`Auto-stop is already disabled for "${t}".\n`);continue}let n=i.get(t);if(n&&n.quotaTotal>0&&f.get(t)===!0){process.stderr.write(`Cannot disable auto-stop for "${t}": free-tier quota has not been fully consumed. Please disable auto-stop after the quota is exhausted.\n`);continue}await Os(e,s.token,l,u,[t],a),process.stdout.write(`Disabled auto-stop for "${t}".\n`)}return}let f=[];for(let t of c){let n=await Os(e,s.token,l,u,[t],a);if(o===`json`){f.push(n);continue}if(n){let e=Ds(n).failureModels??[];e.length>0?process.stderr.write(`Failed to enable auto-stop for "${t}" (${e[0].errorCode}).\n`):process.stdout.write(`Enabled auto-stop for "${t}".\n`)}else process.stderr.write(`Warning: operation timed out for "${t}".\n`)}o===`json`&&P(f,o)}})}));function Rs(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function zs(e){let t=Rs(e,`data`);if(!t)return e;let n=Rs(t,`DataV2`);if(n){let e=Rs(n,`data`);return(e?Rs(e,`data`):void 0)??e??n}return Rs(t,`data`)??t}async function Bs(e,t,n,r,i){let a;for(let o=0;o<$s;o++){let o=await d(e,t,{api:n,data:a?{reqDTO:{...r,asyncTaskId:a}}:{reqDTO:r},region:i}),s=zs(o);if(s.taskId&&Object.keys(s).length===1){a=s.taskId,await new Promise(e=>setTimeout(e,Qs));continue}return o}return null}function Vs(e,t){if(t)return t;if(e.workspaceId)return e.workspaceId;process.stderr.write("Error: workspace-id is required. Set via --workspace-id, BAILIAN_WORKSPACE_ID, or `bl config set workspace_id <id>`.\n"),process.stderr.write("Hint: run `bl workspace list` to view available workspaces.\n"),process.exit(1)}function Hs(e){return e.toLocaleString(`en-US`)}function Us(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Ws(e){let t=zs(e);if(t.callSuccessCount!==void 0||t.usages!==void 0)return t}function Gs(e){let t=zs(e);return{list:t.list??[],totalCount:t.totalCount??0,maxResults:t.maxResults??0}}function Ks(e){let t={};if(e.usages&&Array.isArray(e.usages))for(let n of e.usages)n.key&&n.value!=null&&(t[n.key]=n.value);if(e.usage&&typeof e.usage==`object`)for(let[n,r]of Object.entries(e.usage))r!=null&&(t[n]=r);return t}function qs(e){let t=e.unit?` [${e.unit}]`:``;return`${e.cn} (${e.en})${t}`}function Js(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;process.stdout.write(`${o(`时间范围 Period:`)} ${Us(t)} ~ ${Us(n)} ${o(`(${r} 天)`)}\n\n`);let s=[[`调用模型数 (Models Called)`,Hs(e.modelCount??0)],[`调用成功次数 (Successful Calls)`,Hs(e.callSuccessCount??0)]];for(let t of e.usages??[]){let e=ec[t.key],n=e?qs(e):t.key;s.push([n,Hs(t.value)])}let c=Math.max(...s.map(([e])=>U(e)));for(let[e,t]of s)process.stdout.write(`${a(W(e,c+2))}${t}\n`)}function Ys(e,t,n,r,i){let a=i?e=>e:e=>`\x1b[1m${e}\x1b[0m`,o=i?e=>e:e=>`\x1b[2m${e}\x1b[0m`;if(process.stdout.write(`${o(`时间范围 Period:`)} ${Us(t)} ~ ${Us(n)} ${o(`(${r} 天)`)}\n\n`),e.length===0){process.stdout.write(`No usage data found.
176
+ `);return}let s=new Set,c=e.map(e=>{let t=Ks(e);for(let e of Object.keys(t))s.add(e);return t}),l=[...s].sort((e,t)=>{let n=[`total_token`,`input_token`,`output_token`,`input_token_cache`,`image_number`,`video_duration`,`content_duration`,`tts_text_number`],r=n.indexOf(e),i=n.indexOf(t);return(r===-1?999:r)-(i===-1?999:i)}),u=[`模型`,`调用次数`,...l.map(e=>{let t=ec[e];return t?t.unit?`${t.cn} [${t.unit}]`:t.cn:e})],d=[`Model`,`Calls`,...l.map(e=>ec[e]?.en??e)],f=e.map((e,t)=>[e.model,Hs(e.callSuccessCount??0),...l.map(e=>{let n=c[t][e];return n==null?`-`:Hs(n)})]),p=u.map((e,t)=>Math.max(U(e),U(d[t]),...f.map(e=>U(e[t])))),m=u.map((e,t)=>a(W(e,p[t]))).join(` `),h=d.map((e,t)=>o(W(e,p[t]))).join(` `),g=p.map(e=>o(`─`.repeat(e))).join(`──`);process.stdout.write(m+`
177
+ `),process.stdout.write(h+`
178
+ `),process.stdout.write(g+`
179
+ `);for(let e of f){let t=e.map((e,t)=>W(e,p[t]));process.stdout.write(t.join(` `)+`
180
+ `)}process.stdout.write(o(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
181
+ `)}var Xs,Zs,Qs,$s,ec,tc,nc=M((()=>{I(),fs(),Xs=`zeldaEasy.bailian-telemetry.model.getModelUsageStatistic`,Zs=`zeldaEasy.bailian-telemetry.model.listModelUsageStatisticData`,Qs=500,$s=30,ec={total_token:{cn:`总 Token`,en:`Total Tokens`,unit:`tokens`},input_token:{cn:`输入 Token`,en:`Input Tokens`,unit:`tokens`},output_token:{cn:`输出 Token`,en:`Output Tokens`,unit:`tokens`},input_token_cache:{cn:`缓存 Token`,en:`Cached Tokens`,unit:`tokens`},input_token_cache_read:{cn:`缓存读取`,en:`Cache Read`,unit:`tokens`},input_token_cache_creation:{cn:`缓存创建`,en:`Cache Creation`,unit:`tokens`},thinking_input_token:{cn:`思考输入`,en:`Thinking Input`,unit:`tokens`},thinking_output_token:{cn:`思考输出`,en:`Thinking Output`,unit:`tokens`},text_input_token:{cn:`文本输入`,en:`Text Input`,unit:`tokens`},purein_text_output_token:{cn:`文本输出`,en:`Text Output`,unit:`tokens`},embedding_token:{cn:`向量`,en:`Embedding`,unit:`tokens`},image_number:{cn:`图片数`,en:`Images`,unit:`张`},video_duration:{cn:`视频时长`,en:`Video Duration`,unit:`秒`},content_duration:{cn:`音频时长`,en:`Audio Duration`,unit:`秒`},tts_text_number:{cn:`语音合成`,en:`TTS Chars`,unit:`字符`},total_token_avg:{cn:`平均 Token/次`,en:`Avg Tokens/Req`}},tc=m({name:`usage stats`,description:`Query model usage statistics`,usage:`bl usage stats [--model <model>] [--days <days>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated; omit for overview`},{flag:`--days <days>`,description:`Number of days (default: 7)`},{flag:`--type <type>`,description:`Model type: Text, Vision, Multimodal, Audio, Embedding`},{flag:`--workspace-id <id>`,description:`Workspace ID (env: BAILIAN_WORKSPACE_ID)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl usage stats`,`bl usage stats --days 30`,`bl usage stats --model qwen-turbo`,`bl usage stats --model qwen-turbo --days 7`,`bl usage stats --model qwen3.6-plus,deepseek-v4-pro`,`bl usage stats --type Text --days 14`,`bl usage stats --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.days)||7,i=t.type||void 0,a=t.region||`cn-beijing`,o=h(e.output),s=Vs(e,t.workspaceId||void 0),c=await me(e),l=Date.now(),u=l-r*24*60*60*1e3;if(n){let t=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))],d={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s,maxResults:50,skip:0,sortField:`success_count`,sortOrder:`DESC`};if(i&&(d.obsModelType=i),e.dryRun){P({api:Zs,data:{reqDTO:{...d,model:t.join(`,`)}},region:a},o);return}let f=await Promise.all(t.map(t=>Bs(e,c.token,Zs,{...d,model:t},a))),p=[],m=[];for(let e of f){if(!e)continue;m.push(e);let t=Gs(e);p.push(...t.list)}if(o===`json`){P(m.length===1?m[0]:m,o);return}Ys(p,u,l,r,e.noColor)}else{let t={startTime:u,endTime:l,modelCallSource:`Online`,filterWorkspaceId:s};if(i&&(t.obsModelType=i),e.dryRun){P({api:Xs,data:{reqDTO:t},region:a},o);return}let n=await Bs(e,c.token,Xs,t,a);if(n||(process.stderr.write(`Error: request timed out.
182
+ `),process.exit(1)),o===`json`){P(n,o);return}let d=Ws(n);if(!d){process.stdout.write(`No usage data found.
183
+ `);return}Js(d,u,l,r,e.noColor)}}})}));function rc(e,t){return e instanceof G?e:new G(`step_execution_error`,e instanceof Error?e.message:String(e),{step:t})}var G,ic=M((()=>{G=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 ac(){return cc}function oc(e,t,n,r){let i,a;n instanceof sc?(i=n,a=r):(i=cc,a=n??r),i.registerStep(e,t,a)}var sc,cc,lc=M((()=>{ic(),sc=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 G(`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)}},cc=new sc}));function uc(){let e=te(dc);return e.clientName=`bailian-cli`,e}var dc,fc=M((()=>{dc={output:`json`,nonInteractive:!0,noColor:!0,quiet:!0,verbose:!1,yes:!1,dryRun:!1,help:!1,async:!1}}));function pc(e){return e.startsWith(`./`)||e.startsWith(`../`)}function mc(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))typeof a==`string`&&pc(a)?(n[i]=$e(t,a),r.push(i)):n[i]=a;return{input:n,resolvedKeys:r}}async function hc(e,t,n){let r=[];for(let i of t){let t=e[i];typeof t==`string`&&(await qe(t).then(()=>!0,()=>!1)||r.push(`Step "${n}" input "${i}" references file that does not exist: ${t}`))}return r}function gc(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 K(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function _c(e,t){if(Array.isArray(e)){e.forEach(e=>_c(e,t));return}if(K(e)){`$from`in e&&typeof e.$from==`string`&&t.add(e.$from);for(let n of Object.values(e))_c(n,t)}}async function vc(e,t){let n=[];for(let r of e)for(let[e,i]of Object.entries(r.input)){if(yc.includes(e)||typeof i!=`string`||!pc(i))continue;let a=$e(t,i);await qe(a).then(()=>!0,()=>!1)||n.push(`Step "${r.id}" input "${e}" references file that does not exist: ${a}`)}return n}var yc,bc=M((()=>{yc=[`download`,`out-dir`,`output`]}));async function xc(e,t,n){if(!t.message)throw new G(`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};return 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`])),await k(e,{url:f(e.baseUrl),method:`POST`,body:a,timeout:n.blRequestTimeoutSeconds,signal:n.signal})}async function Sc(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;if(D(i)){let t=await A(e);i=await j(i,t.token,r,{signal:n.signal})}s.push({type:`video_url`,video_url:{url:i}})}for(let t of i){let i=t;D(t)&&(i=await j(t,(await A(e)).token,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}]};return await k(e,{url:f(e.baseUrl),method:`POST`,body:c,signal:n.signal})}function Cc(e){return Pc.some(t=>e.startsWith(t))}async function wc(e,t,n){if(!t.prompt)throw new G(`missing_input`,`image/generate requires 'prompt' input`,{step:`image/generate`});let r=t.model||`qwen-image-2.0`,i=Cc(r),a=t.n??1,o=pe(t[`prompt-extend`],i?!0:void 0,`prompt-extend`),s={model:r,input:{messages:[{role:`user`,content:[{text:t.prompt}]}]},parameters:{size:$i(t.size,i),n:a,seed:t.seed,prompt_extend:o,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(i){let r=await k(e,{url:T(e.baseUrl),method:`POST`,body:s,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Ec(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:s,async:!0,signal:n.signal})).output.task_id,i=await jc(e,r,n),a=await Ec(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Tc(e,t,n){if(!t.prompt)throw new G(`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=Cc(i),o=t.n??1,s=pe(t[`prompt-extend`],a?!0:void 0,`prompt-extend`),c=[];for(let t of r){let r=t;D(t)&&(r=await j(t,(await A(e)).token,i,{signal:n.signal})),c.push({image:r})}c.push({text:t.prompt});let l={model:i,input:{messages:[{role:`user`,content:c}]},parameters:{size:$i(t.size,a),n:o,seed:t.seed,prompt_extend:s,watermark:ge(t.watermark),negative_prompt:t[`negative-prompt`]||void 0}};if(a){let r=await k(e,{url:T(e.baseUrl),method:`POST`,body:l,signal:n.signal}),i=r.output.choices.flatMap(e=>e.message?.content||[]).map(e=>e.image).filter(Boolean),a=await Ec(i,t[`out-dir`],t[`out-prefix`]);return{urls:i,request_id:r.request_id,...a?{saved:a}:{}}}else{let r=(await k(e,{url:w(e.baseUrl),method:`POST`,body:l,async:!0,signal:n.signal})).output.task_id,i=await jc(e,r,n),a=await Ec(Array.isArray(i.urls)?i.urls:[],t[`out-dir`],t[`out-prefix`]);return a&&(i.saved=a),i}}async function Ec(e,t,n){if(!t||e.length===0)return;await Je(t,{recursive:!0});let r=n&&n.length>0?n:`image`,i=e.length===1?[{url:e[0],destPath:Qe(t,`${r}.png`)}]:e.map((e,n)=>({url:e,destPath:Qe(t,`${r}_${String(n+1).padStart(3,`0`)}.png`)})),a=[];for(let{url:e,destPath:t}of i)await Ki(e,t,{quiet:!0}),a.push(t);return a}async function Dc(e,t,n){if(!t.prompt)throw new G(`missing_input`,`video/generate requires 'prompt' input`,{step:`video/generate`});let r=t.model||(t.image?`happyhorse-1.0-i2v`:`happyhorse-1.0-t2v`),i;if(t.image)if(D(t.image)){let a=await A(e);i=await j(t.image,a.token,r,{signal:n.signal})}else i=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:pe(t[`prompt-extend`],void 0,`prompt-extend`),watermark:ge(t.watermark),seed:t.seed}};be(a.parameters);let o=(await k(e,{url:Ee(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Mc(e,o,(t[`poll-interval`]??10)*1e3,(n.timeoutSeconds??900)*1e3,n)}async function Oc(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 G(`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`]}};be(a.input);let o=await k(e,{url:ye(e.baseUrl),method:`POST`,body:a,signal:n.signal});return{audio_url:o.output.audio.url,url_expires_at:o.output.audio.expires_at,model:i,voice:t.voice,request_id:o.request_id}}async function kc(e,t,n){let r=Array.isArray(t.url)?t.url:t.url?[t.url]:[];if(r.length===0)throw new G(`missing_input`,`speech/recognize requires 'url' input`,{step:`speech/recognize`});let i=[];for(let a of r)if(D(a)){let r=await A(e);i.push(await j(a,r.token,t.model||`fun-asr`,{signal:n.signal}))}else 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`]}};be(a.parameters);let o=(await k(e,{url:ve(e.baseUrl),method:`POST`,body:a,async:!0,signal:n.signal})).output.task_id;return await Mc(e,o,(t[`poll-interval`]??2)*1e3,(n.timeoutSeconds??300)*1e3,n)}function Ac(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 jc(e,t,n){return await Mc(e,t,3e3,e.timeout*1e3,n)}async function Mc(e,t,n,r,i){let a=Date.now(),o=0;for(;;){if(i?.signal?.aborted)throw new G(`aborted`,`Task polling was aborted`,{details:{taskId:t}});await Nc(n,i?.signal),o++;let s=await k(e,{url:xe(e.baseUrl,t),method:`GET`,signal:i?.signal}),c=s.output.task_status;if(c===`SUCCEEDED`)return Ac(s);if(c===`FAILED`)throw new G(`async_task_failed`,s.output.message||s.output.code||`Task failed`,{details:{taskId:t,data:s}});let l=Date.now()-a;if(await i?.emitEvent?.({type:`step.polling`,timestamp:new Date().toISOString(),status:`running`,taskId:t,taskStatus:c,elapsedMs:l,pollAttempt:o}),l>r)throw new G(`async_poll_timeout`,`Task ${t} timed out after ${Math.round(r/1e3)}s`,{details:{taskId:t,timeoutMs:r,pollAttempts:o}})}}function Nc(e,t){return t?new Promise((n,r)=>{let i=setTimeout(()=>{o(),n()},e),a=()=>{o(),r(new G(`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))}var Pc,Fc=M((()=>{ic(),na(),Ji(),Pc=[`qwen-image-2.0`,`qwen-image-max`]}));function Ic(e){for(let t of Object.keys(Gc))oc(t,async(e,n)=>await Lc(t,e,n),e,qc[t])}async function Lc(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=Gc[e];if(!r)throw Error(`No direct API handler registered for step: ${e}`);let i=await r(n.blConfig??uc(),t,n),a=Kc[e];return a?a(i):{data:i,warnings:[],metadata:{}}}function Rc(e){if(!K(e))return;let t=[],n=q(e.task_id)??q(e.taskId);for(let r of Hc(e.urls))t.push({url:r,taskId:n,kind:Uc(r)});for(let r of Hc(e.saved))t.push({path:r,taskId:n,kind:Wc(r)});let r=q(e.video_url)??q(e.videoUrl);r&&t.push({url:r,taskId:n,kind:`video`});let i=q(e.saved);if(i&&t.push({path:i,taskId:n,kind:Wc(i)}),Array.isArray(e.videos))for(let n of e.videos){if(!K(n))continue;let e=q(n.task_id)??q(n.taskId),r=q(n.video_url)??q(n.videoUrl),i=q(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(q).filter(Vc):[];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 zc(e,t){if(!K(e))return;let n=[],r=q(e.task_id)??q(e.taskId),i=[q(e.url),q(e.audio_url),q(e.audioUrl),q(e.output_url),q(e.outputUrl)].filter(Vc);for(let e of i)n.push({url:e,taskId:r,kind:t});let a=[q(e.saved),q(e.path),q(e.output_path),q(e.outputPath)].filter(Vc);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?Bc(n):void 0}function Bc(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 Vc(e){return typeof e==`string`}function q(e){return typeof e==`string`&&e.length>0?e:void 0}function Hc(e){return Array.isArray(e)?e.map(q).filter(Vc):[]}function Uc(e){try{return Wc(new URL(e).pathname)}catch{return`artifact`}}function Wc(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 Gc,Kc,qc,Jc=M((()=>{lc(),fc(),bc(),Fc(),Gc={"text/chat":(e,t,n)=>xc(e,t,n),"vision/describe":(e,t,n)=>Sc(e,t,n),"image/generate":(e,t,n)=>wc(e,t,n),"image/edit":(e,t,n)=>Tc(e,t,n),"video/generate":(e,t,n)=>Dc(e,t,n),"speech/synthesize":(e,t,n)=>Oc(e,t,n),"speech/recognize":(e,t,n)=>kc(e,t,n)},Kc={"image/generate":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"image/edit":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"video/generate":e=>({data:e,artifacts:Rc(e),warnings:[],metadata:{}}),"speech/synthesize":e=>({data:e,artifacts:zc(e,`audio`),warnings:[],metadata:{}}),"speech/recognize":e=>({data:e,artifacts:zc(e,`transcript`),warnings:[],metadata:{}})},qc={"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`}]}}})),Yc=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})),Xc=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Yc();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}}})),J=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=Yc(),n=Xc();var r=Yc();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=Xc();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&&=te(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=te(this.rhs,e,n),this}get names(){return ee(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=te(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)||(O(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(ne(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=te(this.condition,e,t),this}get names(){let e=super.names;return ee(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=te(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 ee(ee(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=te(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?`
184
+ `:``},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 ee(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function te(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 O(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ne(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${ce(e)}`}e.not=ne;let re=se(e.operators.AND);function ie(...e){return e.reduce(re)}e.and=ie;let ae=se(e.operators.OR);function oe(...e){return e.reduce(ae)}e.or=oe;function se(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${ce(n)} ${e} ${ce(r)}`}function ce(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Y=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=J(),n=Yc();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})),Zc=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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`)}})),Qc=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=J(),n=Y(),r=Zc();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])}})),$c=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Qc(),n=J(),r=Zc(),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)}})),el=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})),tl=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})),nl=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=el(),n=tl(),r=Qc(),i=J(),a=Y();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
169
185
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
170
186
  || (${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"
171
- || ${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}}})),ac=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=J(),n=Y();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)}`)}})),oc=M((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=J(),n=Y(),r=$s(),i=Y();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})),sc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=$s(),r=oc(),i=ec();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})),cc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=J(),n=Y();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})),lc=M(((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}})),uc=M(((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`)}})),dc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Y(),n=lc(),r=uc(),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})),fc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=tc(),n=ic(),r=rc(),i=ic(),a=ac(),o=sc(),s=cc(),c=J(),l=$s(),u=dc(),d=Y(),f=ec();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&&ne(e),ee(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),re(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function 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&&ne(e),D(e),te(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 ae(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ae(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 ee(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 D(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function te(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function ne({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function re(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&ie(e),t.return((0,c._)`${l.default.errors} === 0`))}function ie({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function ae(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>A(e,`$ref`,h.all.$ref.definition));return}p.jtd||se(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),oe(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):oe(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function oe(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&A(e,n.keyword,n.definition,t.type)})}function se(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(ce(e,t),e.opts.allowUnionTypes||le(e,t),ue(e,e.dataTypes))}function ce(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{O(e.dataTypes,t)||pe(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),fe(e,t)}}function le(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&pe(e,`use allowUnionTypes to allow union type keyword`)}function ue(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=>de(t,e))&&pe(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function de(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function O(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function fe(e,t){let n=[];for(let r of e.dataTypes)O(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function pe(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var k=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`,ge(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=k;function A(e,t,n,r){let i=new k(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 me=/^\/(?:[^~]|~0|~1)*$/,he=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ge(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!me.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=he.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=ge})),pc=M((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}}})),mc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=dc();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))}}})),hc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=pc(),r=$s(),i=dc(),a=Y(),o=fc();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}})),gc=M(((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}})),_c=M(((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}})),vc=M(((e,t)=>{let{isUUID:n}=_c(),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}})),yc=M(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=_c(),{SCHEMES:d,getSchemeHandler:f}=vc();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})),bc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=yc();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),xc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=fc();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=J();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=pc(),i=mc(),a=nc(),o=hc(),s=J(),c=dc(),l=ic(),u=Y(),d=gc(),f=bc(),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=ee(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(te.call(this,n,t),!t)return(0,u.eachItem)(n,e=>ne.call(this,e)),this;ie.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>ne.call(this,e,r):e=>r.type.forEach(t=>ne.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=oe(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function 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 ee(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 D=/^[a-z_$][a-z0-9_$:-]*$/i;function te(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!D.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 ne(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?re.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function re(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ie(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=oe(t)),e.validateSchema=this.compile(t,!0))}let ae={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function oe(e){return{anyOf:[e,ae]}}})),Sc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Cc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=mc(),n=oc(),r=J(),i=$s(),a=hc(),o=Y(),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})),wc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Sc(),n=Cc();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Tc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),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})`)}}})),Ec=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}))`)}}})),Dc=M((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`})),Oc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Dc();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}`)}}})),kc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=oc(),n=Y(),r=J();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})`)}}}})),Ac=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}`)}}})),jc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=oc(),n=J(),r=Y();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)}}}})),Mc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}`)}}})),Nc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=lc();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Pc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ic(),n=J(),r=Y(),i=Nc();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)})))}}}})),Fc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Nc();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}`)}}})),Ic=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Nc();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}`}}}})),Lc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Tc(),n=Ec(),r=Oc(),i=kc(),a=Ac(),o=jc(),s=Mc(),c=Pc(),l=Fc(),u=Ic();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]})),Rc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=J(),n=Y(),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})),zc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=oc(),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})),Bc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=zc();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Vc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=oc(),i=Rc();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)))}}})),Hc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)))}}}})),Uc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=oc();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},
187
+ || ${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}}})),rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=J(),n=Y();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)}`)}})),il=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=J(),n=Y(),r=Zc(),i=Y();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})),al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=J(),n=Zc(),r=il(),i=Qc();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})),ol=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=J(),n=Y();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})),sl=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}})),cl=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`)}})),ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=Y(),n=sl(),r=cl(),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})),ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=$c(),n=nl(),r=tl(),i=nl(),a=rl(),o=al(),s=ol(),c=J(),l=Zc(),u=ll(),d=Y(),f=Qc();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&&O(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),ne(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&&O(e),ee(e),te(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 ie(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);ie(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 ee(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function te(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function O({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 ne(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&&re(e),t.return((0,c._)`${l.default.errors} === 0`))}function re({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 ie(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>me(e,`$ref`,h.all.$ref.definition));return}p.jtd||oe(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)),ae(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):ae(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function ae(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&me(e,n.keyword,n.definition,t.type)})}function oe(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(se(e,t),e.opts.allowUnionTypes||ce(e,t),le(e,e.dataTypes))}function se(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{de(e.dataTypes,t)||k(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),fe(e,t)}}function ce(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&k(e,`use allowUnionTypes to allow union type keyword`)}function le(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>ue(t,e))&&k(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ue(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function de(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function fe(e,t){let n=[];for(let r of e.dataTypes)de(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function k(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var pe=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,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=pe;function me(e,t,n,r){let i=new pe(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let A=/^\/(?:[^~]|~0|~1)*$/,j=/^([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(!A.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=j.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})),dl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ll();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))}}})),pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=J(),n=dl(),r=Zc(),i=ll(),a=Y(),o=ul();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}})),ml=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}})),hl=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}})),gl=N(((e,t)=>{let{isUUID:n}=hl(),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}})),_l=N(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=hl(),{SCHEMES:d,getSchemeHandler:f}=gl();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})),vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=_l();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),yl=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=ul();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=J();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=dl(),i=fl(),a=el(),o=pl(),s=J(),c=ll(),l=nl(),u=Y(),d=ml(),f=vl(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=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(te.call(this,n,t),!t)return(0,u.eachItem)(n,e=>O.call(this,e)),this;re.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=>O.call(this,e,r):e=>r.type.forEach(t=>O.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]=ae(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 ee=/^[a-z_$][a-z0-9_$:-]*$/i;function te(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!ee.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 O(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?ne.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 ne(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 re(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ae(t)),e.validateSchema=this.compile(t,!0))}let ie={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function ae(e){return{anyOf:[e,ie]}}})),bl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=fl(),n=il(),r=J(),i=Zc(),a=pl(),o=Y(),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})),Sl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=bl(),n=xl();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Cl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),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})`)}}})),wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}))`)}}})),Tl=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`})),El=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=Tl();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}`)}}})),Dl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),n=Y(),r=J();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})`)}}}})),Ol=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}`)}}})),kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),n=J(),r=Y();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)}}}})),Al=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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}`)}}})),jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=sl();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Ml=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=nl(),n=J(),r=Y(),i=jl();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)})))}}}})),Nl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=jl();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}`)}}})),Pl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=jl();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}`}}}})),Fl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Cl(),n=wl(),r=El(),i=Dl(),a=Ol(),o=kl(),s=Al(),c=Ml(),l=Nl(),u=Pl();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]})),Il=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=J(),n=Y(),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})),Ll=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=J(),n=Y(),r=il(),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})),Rl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ll();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),zl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),r=il(),i=Il();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)))}}})),Bl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)))}}}})),Vl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=J(),n=Y(),r=il();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},
172
188
  missingProperty: ${i},
173
189
  depsCount: ${n},
174
- 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})),Wc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)}}})),Gc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=oc(),n=J(),r=$s(),i=Y();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)}}}})),Kc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=fc(),n=oc(),r=Y(),i=Gc();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)}}}})),qc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=oc(),n=J(),r=Y(),i=Y();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())})})}}}})),Jc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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`}}})),Yc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:oc().validateUnion,error:{message:`must match a schema in anyOf`}}})),Xc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)})})}}}})),Zc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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)})}}})),Qc=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),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})),$c=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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`)}}})),el=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Rc(),n=Bc(),r=zc(),i=Vc(),a=Hc(),o=Uc(),s=Wc(),c=Gc(),l=Kc(),u=qc(),d=Jc(),f=Yc(),p=Xc(),m=Zc(),h=Qc(),g=$c();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=_})),tl=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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})`}}}}})),nl=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[tl().default]})),rl=M((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`]})),il=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=wc(),n=Lc(),r=el(),i=nl(),a=rl();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),al=M((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={}))})),ol=M((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=al(),r=hc(),i=mc(),a=Y();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}}}}})),sl=M(((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}})),cl=M(((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=xc(),r=il(),i=ol(),a=sl(),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=fc();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=J();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=pc();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=mc();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function ll(e,t=`schema`){let n=[];return pl(e,t,n),n.length===0&&!Cl.validateSchema(e)&&n.push(...ml(Cl.errors,t)),n}function ul(e,t){let n=gl(t,e,`input`);return n.ok?K(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function dl(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 fl(e,t){let n=dl(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(K(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function pl(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))xl.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&hl(e.type,`${t}.type`,n),`properties`in e)if(!K(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))pl(i,`${t}.properties.${r}`,n);if(`items`in e&&pl(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&&!K(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):K(r)&&pl(r,`${t}.additionalProperties`,n)}}function ml(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 hl(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)Sl.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function gl(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(vl);if(!r.includes(vl(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=_l(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=gl(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(!(K(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!K(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!K(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=gl(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=gl(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 _l(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function vl(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var yl,bl,xl,Sl,Cl,wl=j((()=>{yl=dt(cl(),1),Ss(),bl=yl.default,xl=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),Sl=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),Cl=new bl({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Tl(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function El(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Ml(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 Dl(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=Nl(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Ol(e,t,n,r){return Il(e,e=>Ml(e,t,n,r))}function kl(e){return Il(e,e=>X(e,e,!1,e!==void 0))}function Al(e){return{...e.data===void 0?{}:{data:Ul},...e.artifacts?{artifacts:e.artifacts.map(Vl)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function jl(e){return{code:e.code,message:Ul,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Ml(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Ml(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Hl(e)){if(!K(e))return X(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=Ml(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return X(i,a,o)}if(`$input`in e){let t=fl(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new G(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=fl(n,i);if(a===void 0)throw new G(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return X(a,a,!1,!0)}if(`$env`in e){let n=Pl(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Pl(t.secrets,e.$secret,!0);return X(n,Ul,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Ml(e,t,n,r)),a=i.map(e=>Tl(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?Ul:Tl(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Ml(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 X(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=Ml(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return X(e,c?Ul:e,c)}catch(e){throw new G(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return X(e,e,!1)}function Nl(e,t,n){if(Array.isArray(e)){let r=e.map(e=>Nl(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Hl(e)){if(!K(e))return X(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=Nl(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=fl(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e)return X({...e},{...e},!1);if(`$env`in e){let n=Pl(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return Pl(t.secrets,e.$secret,!0),X(Ul,Ul,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>Nl(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return K(r)&&`$from`in r}))return X({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>Tl(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?Ul:Tl(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>K(e)&&`$from`in e))return X({...e},{...e},!1);for(let e of r){let r=Nl(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}return`$js`in e?X({...e},{...e},!1):X(e,e,!1)}function Pl(e,t,n){if(!Fl(e,t))throw new G(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 G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function Fl(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function X(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Il(e,t){if(typeof e==`boolean`)return e;if(K(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof G&&e.code===`pipeline_reference_error`)return!1;throw e}if(K(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Bl(`$and must be a non-empty array`);return e.$and.every(e=>Il(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Bl(`$or must be a non-empty array`);return e.$or.some(e=>Il(e,t))}if(K(e)&&`$not`in e)return!Il(e.$not,t);let n=Ll(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Rl(i,a);case`$ne`:return!Rl(i,a);case`$gt`:return zl(i,a,n.operator)>0;case`$gte`:return zl(i,a,n.operator)>=0;case`$lt`:return zl(i,a,n.operator)<0;case`$lte`:return zl(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Bl(`$in right operand must be an array`);return a.some(e=>Rl(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Rl(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Bl(`$contains left operand must be an array or string`)}}return!!t(e).value}function Ll(e){if(K(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 Bl(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Rl(e,t){return JSON.stringify(e)===JSON.stringify(t)}function zl(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 Bl(`${n} operands must both be finite numbers or both be strings`)}function Bl(e){return new G(`pipeline_condition_error`,e)}function Vl(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Hl(e){return K(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}var Ul,Wl=j((()=>{os(),wl(),Ss(),Ul=`[redacted]`}));function Gl(e){cs(`logic/switch`,e=>{let t=Kl(e.cases);for(let e of t)if(kl(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 G(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,Yl),cs(`logic/select`,e=>{let t=ql(e.candidates);for(let e of t)if(!(e.available!==void 0&&!kl(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 G(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Xl),cs(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!kl(Jl(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new G(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,Zl)}function Kl(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function ql(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Jl(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var Yl,Xl,Zl,Ql=j((()=>{os(),ds(),Ss(),Wl(),Yl={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)`}]},Xl={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)`}]},Zl={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function $l(e){cs(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new G(`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 G(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,eu)}var eu,tu=j((()=>{os(),ds(),eu={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 nu(e=ss()){return ru.has(e)?e:(ru.add(e),Rs(e),Gl(e),$l(e),e)}var ru,iu=j((()=>{ds(),Xs(),Ql(),tu(),ru=new WeakSet}));function au(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??[]);ys(r.step.input,t),r.step.when!==void 0&&ys(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 ou(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 su(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 cu(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 lu(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new G(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,uu)}var uu,du=j((()=>{os(),Ss(),uu=64})),fu,pu=j((()=>{fu=`workflow/v1`}));function mu(e,t=ss()){let n=_u(e);return n.length>0?n:vu(e,t)}function hu(e,t=ss()){if(_u(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)xu(i.input,i.id,r,t,n);return n}function gu(e,t){if(!e.inputs)return t;let n=ul(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function _u(e){let t=[];if(!K(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${fu}"`),!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(!K(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`),K(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function vu(e,t){let n=[];e.inputs&&n.push(...ll(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&&bu(a.retry,r,n),a.timeout!==void 0&&vs(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(K(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`);yu(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);ys(e.input,t),e.when!==void 0&&ys(e.when,t),a.set(e.id,t)}for(let e of Su(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function yu(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>yu(e,t,n,r));return}if(K(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))yu(i,t,n,r)}}function bu(e,t,n){if(!K(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 xu(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>xu(e,t,n,r,i));return}if(K(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))xu(a,t,n,r,i)}}function Su(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}var Cu=j((()=>{os(),ds(),wl(),pu(),Ss()}));async function wu(e,t={},n={}){return await Eu(e,t,n)}async function*Tu(e,t={},n={}){let r=new Ru(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;Eu(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 Eu(e,t,n){let r=n.stepDispatcher??ss(),i=mu(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=gu(e,t);if(n.basePath){let t=await bs(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=fs(),s=au(e),c=lu(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Z(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of ou(s)){let n=Dl(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:Z(),status:`planned`,step:Au(t),input:ju(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:Au(t),input:ju(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Z(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:fu,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 su(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`;ku(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Au(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`;ku(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Au(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Ol(i.step.when,e,a,d))){let e=`condition evaluated to false`;ku(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:Z(),status:`running`,step:Au(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Du(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),ku(l,u,e),t=!0}if(!t)throw new G(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=cu(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:Z(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?Au(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:fu,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:fu,steps:g,artifacts:f}}async function Du(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:Z(),status:`running`,step:Au(e),timing:{startedAt:p},attempt:h});try{let l=El(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=gs(u,o.basePath);u=t.input,g=gs(l.redacted,o.basePath).input;let n=await _s(u,t.resolvedKeys.filter(e=>!xs.includes(e)),e.step.id);if(n.length>0)throw new G(`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:Z(),status:`running`,step:Au(e),input:ju(g,l.sensitiveKeys)});let _=await Ou(e.step,u,o,Au(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Al(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Z(),status:`running`,step:Au(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:Au(e),timing:Pu(p,m),output:Mu(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=as(t,e.step.type);if(u=f?jl(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:Au(e),attempt:h,nextAttempt:h+1,error:u});let t=Fu(e.step.retry?.backoff,h,o.retryDelayBaseMs??Lu);t>0&&await(o.sleep??Iu)(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:Z(),status:`failed`,step:Au(e),timing:Pu(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 Ou(e,t,n,r,i,a,o){let s=vs(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??Z(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blConfig: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 G(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function ku(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function Au(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function ju(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Mu(e){return{...e.data===void 0?{}:{dataType:Nu(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function Nu(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Pu(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Fu(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Iu(e){return new Promise(t=>setTimeout(t,e))}var Lu,Ru,zu=j((()=>{os(),ms(),ds(),Wl(),du(),Ss(),Cu(),pu(),Lu=100,Ru=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()?.()}}})),Q=M((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),Bu=M((e=>{var t=Q();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),Vu=M((e=>{var t=Q(),n=Bu();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
175
- `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Hu=M((e=>{var t=Q(),n=Bu();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),Uu=M((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),Wu=M((e=>{var t=Q();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),Gu=M((e=>{var t=Uu(),n=Q(),r=Wu();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),Ku=M((e=>{var t=Hu(),n=Bu(),r=Q(),i=Gu(),a=Wu(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),$=M((e=>{var t=Q(),n=Gu(),r=Wu();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),qu=M((e=>{var t=Ku(),n=Q(),r=$();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),Ju=M((e=>{var t=qu(),n=Q(),r=Gu();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),Yu=M((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
190
+ 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})),Hl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)}}})),Ul=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),n=J(),r=Zc(),i=Y();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)}}}})),Wl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ul(),n=il(),r=Y(),i=Ul();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)}}}})),Gl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=il(),n=J(),r=Y(),i=Y();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())})})}}}})),Kl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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`}}})),ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:il().validateUnion,error:{message:`must match a schema in anyOf`}}})),Jl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y();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)})})}}}})),Yl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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)})}}})),Xl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=Y(),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})),Zl=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Y();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`)}}})),Ql=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Il(),n=Rl(),r=Ll(),i=zl(),a=Bl(),o=Vl(),s=Hl(),c=Ul(),l=Wl(),u=Gl(),d=Kl(),f=ql(),p=Jl(),m=Yl(),h=Xl(),g=Zl();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=_})),$l=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J();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})`}}}}})),eu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[$l().default]})),tu=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`]})),nu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Sl(),n=Fl(),r=Ql(),i=eu(),a=tu();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),ru=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={}))})),iu=N((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=J(),n=ru(),r=pl(),i=fl(),a=Y();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}}}}})),au=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}})),ou=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=yl(),r=nu(),i=iu(),a=au(),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=ul();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return l.KeywordCxt}});var u=J();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=dl();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return d.default}});var f=fl();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return f.default}})}));function su(e,t=`schema`){let n=[];return du(e,t,n),n.length===0&&!xu.validateSchema(e)&&n.push(...fu(xu.errors,t)),n}function cu(e,t){let n=mu(t,e,`input`);return n.ok?K(n.value)?{ok:!0,value:n.value}:{ok:!1,issues:[`input must be an object`]}:{ok:!1,issues:n.issues}}function lu(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 uu(e,t){let n=lu(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(K(r)){if(e===`__proto__`||e===`constructor`||e===`prototype`||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e];continue}return}return r}function du(e,t,n){if(!K(e)){n.push(`${t} must be an object`);return}for(let r of Object.keys(e))yu.has(r)||n.push(`${t} has unsupported keyword "${r}"`);if(`type`in e&&pu(e.type,`${t}.type`,n),`properties`in e)if(!K(e.properties))n.push(`${t}.properties must be an object`);else for(let[r,i]of Object.entries(e.properties))du(i,`${t}.properties.${r}`,n);if(`items`in e&&du(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&&!K(r)?n.push(`${t}.additionalProperties must be a boolean or schema object`):K(r)&&du(r,`${t}.additionalProperties`,n)}}function fu(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 pu(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)bu.has(e)||n.push(`${t} has unsupported type "${String(e)}"`)}function mu(e,t,n){if((e==null||e===``)&&t.default!==void 0&&(e=t.default),t.enum&&e!==void 0){let r=t.enum.map(gu);if(!r.includes(gu(e)))return{ok:!1,issues:[`${n} must be one of: ${r.join(`, `)}`]}}let r=hu(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=mu(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(!(K(e)&&r.has(`object`))&&r.has(`string`)&&!Array.isArray(e)&&!K(e))return{ok:!0,value:String(e)}}if(r.has(`object`)){if(!K(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=mu(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=mu(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 hu(e){let t=e.type===void 0?[]:Array.isArray(e.type)?e.type:[e.type];return new Set(t)}function gu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}var _u,vu,yu,bu,xu,Su=M((()=>{_u=mt(ou(),1),bc(),vu=_u.default,yu=new Set([`type`,`properties`,`items`,`required`,`enum`,`default`,`description`,`format`,`additionalProperties`]),bu=new Set([`string`,`number`,`integer`,`boolean`,`array`,`object`,`null`]),xu=new vu({allErrors:!0,coerceTypes:!1,strict:!1,useDefaults:!1})}));function Cu(e){return e==null?``:typeof e==`object`?JSON.stringify(e)??``:String(e)}function wu(e,t,n,r){let i={},a={},o=[],s=!1;for(let[c,l]of Object.entries(e.input)){let e=Au(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 Tu(e,t,n){let r={},i=[];for(let[a,o]of Object.entries(e.input)){let e=ju(o,t,n);r[a]=e.redacted,e.sensitive&&i.push(a)}return{redacted:r,sensitiveKeys:i}}function Eu(e,t,n,r){return Pu(e,e=>Au(e,t,n,r))}function Du(e){return Pu(e,e=>X(e,e,!1,e!==void 0))}function Ou(e){return{...e.data===void 0?{}:{data:Vu},...e.artifacts?{artifacts:e.artifacts.map(zu)}:{},...e.warnings?{warnings:e.warnings.map(e=>({code:e.code,message:e.message}))}:{},metadata:{...e.metadata?.step?{step:e.metadata.step}:{},redacted:!0}}}function ku(e){return{code:e.code,message:Vu,...e.step?{step:e.step}:{},details:{redacted:!0}}}function Au(e,t,n,r){if(Array.isArray(e)){let i=e.map(e=>Au(e,t,n,r));return X(i.map(e=>e.value),i.map(e=>e.redacted),i.some(e=>e.sensitive))}if(!Bu(e)){if(!K(e))return X(e,e,!1,e!==void 0);let i={},a={},o=!1;for(let[s,c]of Object.entries(e)){let e=Au(c,t,n,r);i[s]=e.value,a[s]=e.redacted,o||=e.sensitive}return X(i,a,o)}if(`$input`in e){let t=uu(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e){let t=e.$from,n=r.get(t);if(!n)throw new G(`pipeline_reference_error`,`Step output not found: ${t}`);let i=typeof e.path==`string`?e.path:``,a=uu(n,i);if(a===void 0)throw new G(`pipeline_reference_error`,`Step output path not found: ${t}${i}`);return X(a,a,!1,!0)}if(`$env`in e){let n=Mu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e){let n=Mu(t.secrets,e.$secret,!0);return X(n,Vu,!0,n!==void 0)}if(`$concat`in e){let i=e.$concat.map(e=>Au(e,t,n,r)),a=i.map(e=>Cu(e.value)).join(``),o=i.some(e=>e.sensitive);return X(a,i.map(e=>e.sensitive?Vu:Cu(e.value)).join(``),o)}if(`$coalesce`in e){let i=e.$coalesce,a;for(let e of i)try{let i=Au(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 X(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=Au(i,t,n,r);o[e]=a.value,s[e]=a.redacted,c||=a.sensitive}try{let e=Function(`args`,`return (${i})`)(o);return X(e,c?Vu:e,c)}catch(e){throw new G(`pipeline_js_error`,`$js expression failed: ${e instanceof Error?e.message:String(e)}`)}}return X(e,e,!1)}function ju(e,t,n){if(Array.isArray(e)){let r=e.map(e=>ju(e,t,n));return X(r.map(e=>e.value),r.map(e=>e.redacted),r.some(e=>e.sensitive))}if(!Bu(e)){if(!K(e))return X(e,e,!1,e!==void 0);let r={},i=!1;for(let[a,o]of Object.entries(e)){let e=ju(o,t,n);r[a]=e.redacted,i||=e.sensitive}return X(r,r,i)}if(`$input`in e){let t=uu(n,e.$input);return X(t,t,!1,t!==void 0)}if(`$from`in e)return X({...e},{...e},!1);if(`$env`in e){let n=Mu(t.env,e.$env,!1);return X(n,n,!1,n!==void 0)}if(`$secret`in e)return Mu(t.secrets,e.$secret,!0),X(Vu,Vu,!0,!0);if(`$concat`in e){let r=e.$concat.map(e=>ju(e,t,n));if(r.some((t,n)=>{let r=e.$concat[n];return K(r)&&`$from`in r}))return X({...e},{...e},r.some(e=>e.sensitive));let i=r.map(e=>Cu(e.value)).join(``),a=r.some(e=>e.sensitive);return X(i,r.map(e=>e.sensitive?Vu:Cu(e.value)).join(``),a)}if(`$coalesce`in e){let r=e.$coalesce;if(r.some(e=>K(e)&&`$from`in e))return X({...e},{...e},!1);for(let e of r){let r=ju(e,t,n);if(r.exists&&r.value!==void 0&&r.value!==null)return r}return X(void 0,void 0,!1,!1)}return`$js`in e?X({...e},{...e},!1):X(e,e,!1)}function Mu(e,t,n){if(!Nu(e,t))throw new G(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 G(n?`pipeline_secret_error`:`pipeline_env_error`,`${n?`Secret`:`Environment`} binding not found: ${t}`)}function Nu(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function X(e,t,n,r=!0){return{value:e,redacted:t,sensitive:n,exists:r}}function Pu(e,t){if(typeof e==`boolean`)return e;if(K(e)&&`$exists`in e)try{return t(e.$exists).exists}catch(e){if(e instanceof G&&e.code===`pipeline_reference_error`)return!1;throw e}if(K(e)&&`$and`in e){if(!Array.isArray(e.$and)||e.$and.length===0)throw Ru(`$and must be a non-empty array`);return e.$and.every(e=>Pu(e,t))}if(K(e)&&`$or`in e){if(!Array.isArray(e.$or)||e.$or.length===0)throw Ru(`$or must be a non-empty array`);return e.$or.some(e=>Pu(e,t))}if(K(e)&&`$not`in e)return!Pu(e.$not,t);let n=Fu(e);if(n){let[e,r]=n.operands,i=t(e).value,a=t(r).value;switch(n.operator){case`$eq`:return Iu(i,a);case`$ne`:return!Iu(i,a);case`$gt`:return Lu(i,a,n.operator)>0;case`$gte`:return Lu(i,a,n.operator)>=0;case`$lt`:return Lu(i,a,n.operator)<0;case`$lte`:return Lu(i,a,n.operator)<=0;case`$in`:if(!Array.isArray(a))throw Ru(`$in right operand must be an array`);return a.some(e=>Iu(e,i));case`$contains`:if(Array.isArray(i))return i.some(e=>Iu(e,a));if(typeof i==`string`&&typeof a==`string`)return i.includes(a);throw Ru(`$contains left operand must be an array or string`)}}return!!t(e).value}function Fu(e){if(K(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 Ru(`${t} must be a two-item array`);return{operator:t,operands:e[t]}}}}function Iu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Lu(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 Ru(`${n} operands must both be finite numbers or both be strings`)}function Ru(e){return new G(`pipeline_condition_error`,e)}function zu(e){return{id:e.id,kind:e.kind,mediaType:e.mediaType,metadata:e.metadata?{redacted:!0}:void 0}}function Bu(e){return K(e)&&(`$input`in e||`$from`in e||`$env`in e||`$secret`in e||`$concat`in e||`$coalesce`in e||`$js`in e)}var Vu,Hu=M((()=>{ic(),Su(),bc(),Vu=`[redacted]`}));function Uu(e){oc(`logic/switch`,e=>{let t=Wu(e.cases);for(let e of t)if(Du(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 G(`logic_no_match`,`logic/switch did not match any case`,{step:`logic/switch`,details:{caseCount:t.length}})},e,qu),oc(`logic/select`,e=>{let t=Gu(e.candidates);for(let e of t)if(!(e.available!==void 0&&!Du(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 G(`logic_no_candidate`,`logic/select did not receive an available candidate`,{step:`logic/select`,details:{candidateCount:t.length}})},e,Ju),oc(`logic/assert`,e=>{let t=typeof e.message==`string`?e.message:`Logic assertion failed`,n=K(e.metadata)?e.metadata:void 0;if(!Du(Ku(e.condition))){if(e.soft===!0)return{data:{ok:!1,message:t,...n?{metadata:n}:{}}};throw new G(`logic_assertion_failed`,t,{step:`logic/assert`,details:n??{}})}return{data:{ok:!0,...e.message===void 0?{}:{message:t},...n?{metadata:n}:{}}}},e,Yu)}function Wu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`cases must be an array`,{step:`logic/switch`});return e}function Gu(e){if(!Array.isArray(e))throw new G(`logic_input_error`,`candidates must be an array`,{step:`logic/select`});return e}function Ku(e){if(e===void 0)throw new G(`logic_input_error`,`condition is required`,{step:`logic/assert`});return e}var qu,Ju,Yu,Xu=M((()=>{ic(),lc(),bc(),Hu(),qu={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)`}]},Ju={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)`}]},Yu={description:`Assert a condition is true`,paths:[{path:`/data/ok`,description:`Whether the assertion passed (boolean)`},{path:`/data/message`,description:`Assertion message`}]}}));function Zu(e){oc(`script/js`,e=>{let t=e.code;if(!t||typeof t!=`string`)throw new G(`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 G(`script_js_error`,`script/js execution failed: ${e instanceof Error?e.message:String(e)}`,{step:`script/js`})}},e,Qu)}var Qu,$u=M((()=>{ic(),lc(),Qu={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 ed(e=ac()){return td.has(e)?e:(td.add(e),Ic(e),Uu(e),Zu(e),e)}var td,nd=M((()=>{lc(),Jc(),Xu(),$u(),td=new WeakSet}));function rd(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??[]);_c(r.step.input,t),r.step.when!==void 0&&_c(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 id(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 ad(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 od(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 sd(e){if(e===void 0)return 1;if(!Number.isInteger(e)||e<1)throw new G(`pipeline_validation_error`,`Invalid pipeline execution options`,{details:{issues:[`concurrency must be a positive integer`]}});return Math.min(e,cd)}var cd,ld=M((()=>{ic(),bc(),cd=64})),ud,dd=M((()=>{ud=`workflow/v1`}));function fd(e,t=ac()){let n=hd(e);return n.length>0?n:gd(e,t)}function pd(e,t=ac()){if(hd(e).length>0)return[];let n=[],r=new Map(e.steps.map(e=>[e.id,e.type]));for(let i of e.steps)yd(i.input,i.id,r,t,n);return n}function md(e,t){if(!e.inputs)return t;let n=cu(e.inputs,t);if(n.ok)return n.value;throw new G(`pipeline_validation_error`,`Invalid pipeline runtime input`,{details:{issues:n.issues}})}function hd(e){let t=[];if(!K(e))return t.push(`structural: pipeline must be an object`),t;if(e.version!==`workflow/v1`&&t.push(`structural: pipeline.version must be "${ud}"`),!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(!K(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`),K(r.input)||t.push(`structural: step at index ${n} must have an input object`)}return t}function gd(e,t){let n=[];e.inputs&&n.push(...su(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&&vd(a.retry,r,n),a.timeout!==void 0&&gc(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(K(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`);_d(e.input,e.id,i,n)}let a=new Map;for(let e of r){let t=new Set(e.dependsOn??[]);_c(e.input,t),e.when!==void 0&&_c(e.when,t),a.set(e.id,t)}for(let e of bd(a))n.push(`semantic: pipeline graph contains cycle: ${e.join(` -> `)}`);return n}function _d(e,t,n,r){if(Array.isArray(e)){e.forEach(e=>_d(e,t,n,r));return}if(K(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))_d(i,t,n,r)}}function vd(e,t,n){if(!K(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 yd(e,t,n,r,i){if(Array.isArray(e)){e.forEach(e=>yd(e,t,n,r,i));return}if(K(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))yd(a,t,n,r,i)}}function bd(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}var xd=M((()=>{ic(),lc(),Su(),dd(),bc()}));async function Sd(e,t={},n={}){return await wd(e,t,n)}async function*Cd(e,t={},n={}){let r=new Id(1024),i=new AbortController,a=()=>i.abort();n.signal?.aborted?a():n.signal?.addEventListener(`abort`,a,{once:!0});let o=!1,s;wd(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 wd(e,t,n){let r=n.stepDispatcher??ac(),i=fd(e,r);if(i.length>0)throw new G(`pipeline_validation_error`,`Invalid pipeline definition`,{details:{issues:i}});let a=md(e,t);if(n.basePath){let t=await vc(e.steps,n.basePath);if(t.length>0)throw new G(`pipeline_file_not_found`,t.join(`; `),{details:{issues:t}})}let o=uc(),s=rd(e),c=sd(n.concurrency),l=[],u=new Map,d=new Map,f=[],p=async e=>{await n.onEvent?.(e)};if(await p({type:`pipeline.started`,timestamp:Z(),status:n.dryRun?`planned`:`running`,stepCount:e.steps.length,dryRun:!!n.dryRun}),n.dryRun){for(let t of id(s)){let n=Tu(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:Z(),status:`planned`,step:Od(t),input:kd(n.redacted,n.sensitiveKeys)}),await p({type:`step.planned`,timestamp:Z(),status:`planned`,step:Od(t),input:kd(n.redacted,n.sensitiveKeys),...t.step.when===void 0?{}:{condition:`pending`}})}return await p({type:`pipeline.planned`,timestamp:Z(),status:`planned`,stepCount:l.length,artifactCount:f.length}),{status:`planned`,version:ud,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 ad(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`;Dd(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Od(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`;Dd(l,u,{id:i.step.id,type:i.step.type,status:`skipped`,dependencies:i.dependencies,skipReason:e}),await p({type:`step.skipped`,timestamp:Z(),status:`running`,step:Od(i),reason:e}),m.delete(i.step.id),t=!0;continue}if(!(i.step.when===void 0||Eu(i.step.when,e,a,d))){let e=`condition evaluated to false`;Dd(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:Z(),status:`running`,step:Od(i),reason:e}),m.delete(i.step.id),t=!0;continue}let _=Td(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),Dd(l,u,e),t=!0}if(!t)throw new G(`pipeline_graph_error`,`Workflow graph did not make progress`,{details:{remaining:Array.from(m)}})}let g=od(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:Z(),status:`failed`,stepCount:g.length,artifactCount:f.length,failedStep:e?Od(e):{id:_.id,type:_.type,dependencies:_.dependencies,index:g.findIndex(e=>e.id===_.id)+1,total:g.length},error:_.error}),{status:`failed`,version:ud,steps:g,artifacts:f}}return await p({type:`pipeline.succeeded`,timestamp:Z(),status:`succeeded`,stepCount:g.length,artifactCount:f.length}),{status:`succeeded`,version:ud,steps:g,artifacts:f}}async function Td(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:Z(),status:`running`,step:Od(e),timing:{startedAt:p},attempt:h});try{let l=wu(e.step,t,n,r),u=l.value,g=l.redacted;if(o.basePath){let t=mc(u,o.basePath);u=t.input,g=mc(l.redacted,o.basePath).input;let n=await hc(u,t.resolvedKeys.filter(e=>!yc.includes(e)),e.step.id);if(n.length>0)throw new G(`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:Z(),status:`running`,step:Od(e),input:kd(g,l.sensitiveKeys)});let _=await Ed(e.step,u,o,Od(e),a,s,c);r.set(e.step.id,_);let v=l.sensitive?Ou(_):_;v.artifacts&&i.push(...v.artifacts),m=new Date().toISOString();for(let t of v.artifacts??[])await a({type:`artifact.created`,timestamp:Z(),status:`running`,step:Od(e),artifact:t});return await a({type:`step.succeeded`,timestamp:Z(),status:`running`,step:Od(e),timing:Md(p,m),output:Ad(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=rc(t,e.step.type);if(u=f?ku(n.toJSON()):n.toJSON(),m=new Date().toISOString(),h<l){await a({type:`step.retrying`,timestamp:Z(),status:`running`,step:Od(e),attempt:h,nextAttempt:h+1,error:u});let t=Nd(e.step.retry?.backoff,h,o.retryDelayBaseMs??Fd);t>0&&await(o.sleep??Pd)(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:Z(),status:`failed`,step:Od(e),timing:Md(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 Ed(e,t,n,r,i,a,o){let s=gc(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??Z(),status:`running`,step:r,taskId:e.taskId,taskStatus:e.taskStatus,elapsedMs:e.elapsedMs,pollAttempt:e.pollAttempt})},blConfig: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 G(`step_timeout`,`Step ${e.id} exceeded timeout ${s}s`,{step:e.type}))},{once:!0})})])}finally{clearTimeout(f),n.signal?.removeEventListener(`abort`,u)}}function Dd(e,t,n){e.push(n),t.set(n.id,n)}function Z(){return new Date().toISOString()}function Od(e){return{id:e.step.id,type:e.step.type,dependencies:e.dependencies,index:e.index,total:e.total}}function kd(e,t=[]){return{keys:Object.keys(e).sort(),...t.length>0?{redactedKeys:t.sort()}:{}}}function Ad(e){return{...e.data===void 0?{}:{dataType:jd(e.data)},artifactCount:e.artifacts?.length??0,warningCount:e.warnings?.length??0,...e.metadata?{metadata:e.metadata}:{}}}function jd(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Md(e,t){return{startedAt:e,finishedAt:t,durationMs:Math.max(0,Date.parse(t)-Date.parse(e))}}function Nd(e=`none`,t,n){return e===`none`?0:e===`linear`?n*t:n*2**(t-1)}function Pd(e){return new Promise(t=>setTimeout(t,e))}var Fd,Id,Ld=M((()=>{ic(),fc(),lc(),Hu(),ld(),bc(),xd(),dd(),Fd=100,Id=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()?.()}}})),Q=N((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),Rd=N((e=>{var t=Q();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),zd=N((e=>{var t=Q(),n=Rd();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
191
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Bd=N((e=>{var t=Q(),n=Rd();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),Vd=N((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),Hd=N((e=>{var t=Q();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),Ud=N((e=>{var t=Vd(),n=Q(),r=Hd();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),Wd=N((e=>{var t=Bd(),n=Rd(),r=Q(),i=Ud(),a=Hd(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let c=n.get(o);if(c||=(a.toJS(o,null,t),n.get(o)),c?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=s(r,o,n)),c.count*c.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return c.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),$=N((e=>{var t=Q(),n=Ud(),r=Hd();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),Gd=N((e=>{var t=Wd(),n=Q(),r=$();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),Kd=N((e=>{var t=Gd(),n=Q(),r=Ud();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),qd=N((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
176
192
  `)?n(r,t):r.includes(`
177
193
  `)?`
178
- `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Xu=M((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
194
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Jd=N((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
179
195
  `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
180
196
  `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
181
197
  `&&t!==` `&&(h=v)}if(v>=m)if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
182
- `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),Zu=M((e=>{var t=$(),n=Xu();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
198
+ `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),Yd=N((e=>{var t=$(),n=Jd();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
183
199
  `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
184
200
 
185
201
  `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
@@ -197,29 +213,29 @@ Hint: Add --diarization flag to enable speaker separation.`,i.USAGE);let s=n.mod
197
213
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
198
214
  `)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
199
215
  `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
200
- `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),Qu=M((e=>{var t=Hu(),n=Q(),r=Yu(),i=Zu();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),$u=M((e=>{var t=Q(),n=$(),r=Qu(),i=Yu();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
216
+ `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),Xd=N((e=>{var t=Bd(),n=Q(),r=qd(),i=Yd();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),Zd=N((e=>{var t=Q(),n=$(),r=Xd(),i=qd();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
201
217
  `:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
202
218
  `&&C&&(E=`
203
219
 
204
220
  `):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
205
221
  `),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else (T===``||T[0]===`
206
- `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),ed=M((e=>{var t=ft(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),td=M((e=>{var t=Q(),n=$();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){if(r=e&&t.isAlias(r)?r.resolve(e.doc):r,t.isSeq(r))for(let t of r.items)o(e,n,t);else if(Array.isArray(r))for(let t of r)o(e,n,t);else o(e,n,r)}function o(e,n,r){let i=e&&t.isAlias(r)?r.resolve(e.doc):r;if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),nd=M((e=>{var t=ed(),n=td(),r=Qu(),i=Q(),a=Wu();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),rd=M((e=>{var t=qu(),n=$u(),r=nd(),i=Q();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),id=M((e=>{var t=Q(),n=Qu(),r=Yu();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
222
+ `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),Qd=N((e=>{var t=ht(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),$d=N((e=>{var t=Q(),n=$();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){if(r=e&&t.isAlias(r)?r.resolve(e.doc):r,t.isSeq(r))for(let t of r.items)o(e,n,t);else if(Array.isArray(r))for(let t of r)o(e,n,t);else o(e,n,r)}function o(e,n,r){let i=e&&t.isAlias(r)?r.resolve(e.doc):r;if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),ef=N((e=>{var t=Qd(),n=$d(),r=Xd(),i=Q(),a=Hd();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),tf=N((e=>{var t=Gd(),n=Zd(),r=ef(),i=Q();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),nf=N((e=>{var t=Q(),n=Xd(),r=qd();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
207
223
  `}}return e?(_+=`
208
224
  `+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
209
225
  `),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
210
- `;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),ad=M((e=>{var t=id(),n=nd(),r=Ju(),i=Q(),a=rd(),o=$();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),od=M((e=>{var t=Q(),n=ad();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),sd=M((e=>{var t=qu(),n=id(),r=Ju(),i=Q(),a=$(),o=Wu(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),cd=M((e=>{var t=Q(),n=sd();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),ld=M((e=>{var t=Zu();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),ud=M((e=>{var t=$();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),dd=M((e=>{var t=$();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),fd=M((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),pd=M((e=>{var t=$(),n=fd();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),md=M((e=>{var t=fd();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),hd=M((e=>{var t=od(),n=ud(),r=cd(),i=ld(),a=dd(),o=pd(),s=md();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),gd=M((e=>{var t=$(),n=od(),r=cd();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),_d=M((e=>{var t=ft(`buffer`),n=$(),r=Zu();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
211
- `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),vd=M((e=>{var t=Q(),n=rd(),r=$(),i=sd();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),yd=M((e=>{var t=Q(),n=Wu(),r=ad(),i=sd(),a=vd(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),bd=M((e=>{var t=$();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),xd=M((e=>{var t=$(),n=fd();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Sd=M((e=>{var t=fd();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Cd=M((e=>{var t=Q(),n=rd(),r=ad(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),wd=M((e=>{var t=fd();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Td=M((e=>{var t=od(),n=ud(),r=cd(),i=ld(),a=_d(),o=bd(),s=xd(),c=Sd(),l=td(),u=yd(),d=vd(),f=Cd(),p=wd();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Ed=M((e=>{var t=od(),n=ud(),r=cd(),i=ld(),a=dd(),o=pd(),s=md(),c=hd(),l=gd(),u=_d(),d=td(),f=yd(),p=vd(),m=Td(),h=Cd(),g=wd();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),Dd=M((e=>{var t=Q(),n=od(),r=cd(),i=ld(),a=Ed();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Od=M((e=>{var t=Q(),n=Qu(),r=Yu();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
226
+ `;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),rf=N((e=>{var t=nf(),n=ef(),r=Kd(),i=Q(),a=tf(),o=$();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),af=N((e=>{var t=Q(),n=rf();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),of=N((e=>{var t=Gd(),n=nf(),r=Kd(),i=Q(),a=$(),o=Hd(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),sf=N((e=>{var t=Q(),n=of();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),cf=N((e=>{var t=Yd();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),lf=N((e=>{var t=$();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),uf=N((e=>{var t=$();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),df=N((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),ff=N((e=>{var t=$(),n=df();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),pf=N((e=>{var t=df();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),mf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=uf(),o=ff(),s=pf();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),hf=N((e=>{var t=$(),n=af(),r=sf();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),gf=N((e=>{var t=ht(`buffer`),n=$(),r=Yd();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
227
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),_f=N((e=>{var t=Q(),n=tf(),r=$(),i=of();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),vf=N((e=>{var t=Q(),n=Hd(),r=rf(),i=of(),a=_f(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),yf=N((e=>{var t=$();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),bf=N((e=>{var t=$(),n=df();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),xf=N((e=>{var t=df();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Sf=N((e=>{var t=Q(),n=tf(),r=rf(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),Cf=N((e=>{var t=df();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),wf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=gf(),o=yf(),s=bf(),c=xf(),l=$d(),u=vf(),d=_f(),f=Sf(),p=Cf();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Tf=N((e=>{var t=af(),n=lf(),r=sf(),i=cf(),a=uf(),o=ff(),s=pf(),c=mf(),l=hf(),u=gf(),d=$d(),f=vf(),p=_f(),m=wf(),h=Sf(),g=Cf();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),Ef=N((e=>{var t=Q(),n=af(),r=sf(),i=cf(),a=Tf();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Df=N((e=>{var t=Q(),n=Xd(),r=qd();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
212
228
  `)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`);else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
213
229
  `)+`
214
- `}e.stringifyDocument=i})),kd=M((e=>{var t=Ku(),n=Ju(),r=Q(),i=rd(),a=Wu(),o=Dd(),s=Od(),c=Hu(),l=Uu(),u=qu(),d=Vu(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),Ad=M((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
215
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),jd=M((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),Md=M((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
216
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),Nd=M((e=>{var t=Md();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),Pd=M((e=>{var t=Q();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),Fd=M((e=>{var t=rd(),n=ad(),r=jd(),i=Md(),a=Nd(),o=Pd();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
230
+ `}e.stringifyDocument=i})),Of=N((e=>{var t=Wd(),n=Kd(),r=Q(),i=tf(),a=Hd(),o=Ef(),s=Df(),c=Bd(),l=Vd(),u=Gd(),d=zd(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),kf=N((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
231
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),Af=N((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),jf=N((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
232
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),Mf=N((e=>{var t=jf();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),Nf=N((e=>{var t=Q();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),Pf=N((e=>{var t=tf(),n=rf(),r=Af(),i=jf(),a=Mf(),o=Nf();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
217
233
  `+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
218
- `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),Id=M((e=>{var t=sd(),n=jd(),r=Nd();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),Ld=M((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),Rd=M((e=>{var t=Q(),n=rd(),r=ad(),i=sd(),a=Ld(),o=jd(),s=Md(),c=Pd();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
234
+ `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),Ff=N((e=>{var t=of(),n=Af(),r=Mf();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),If=N((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),Lf=N((e=>{var t=Q(),n=tf(),r=rf(),i=of(),a=If(),o=Af(),s=jf(),c=Nf();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
219
235
  `+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
220
236
  `+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
221
237
  `+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
222
- `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),zd=M((e=>{var t=Q(),n=$(),r=ad(),i=sd(),a=Fd(),o=Id(),s=Rd();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),Bd=M((e=>{var t=$();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
238
+ `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),Rf=N((e=>{var t=Q(),n=$(),r=rf(),i=of(),a=Pf(),o=Ff(),s=Lf();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),zf=N((e=>{var t=$();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
223
239
  `.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
224
240
  `;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be less indented than their ${s.indent?`explicit indentation indicator`:`first line`}`;a(f-r.length-(i?2:1),`BAD_INDENT`,e),n=``}c===t.Scalar.BLOCK_LITERAL?(m+=h+n.slice(d)+r,h=`
225
241
  `):n.length>d||r[0]===` `?(h===` `?h=`
@@ -234,7 +250,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
234
250
  `+l[e][0].slice(d);m[m.length-1]!==`
235
251
  `&&(m+=`
236
252
  `);break;default:m+=`
237
- `}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),Vd=M((e=>{var t=$(),n=Ld();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
253
+ `}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),Bf=N((e=>{var t=$(),n=If();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
238
254
  `,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
239
255
  `,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
240
256
  `?i+=a:a=`
@@ -249,10 +265,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
249
265
  `);)r===`
250
266
  `&&(n+=`
251
267
  `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
252
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}e.resolveFlowScalar=r})),Hd=M((e=>{var t=Q(),n=$(),r=Bd(),i=Vd();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),Ud=M((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),Wd=M((e=>{var t=Ku(),n=Q(),r=zd(),i=Hd(),a=Ld(),o=Ud();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),Gd=M((e=>{var t=kd(),n=Wd(),r=Ld(),i=jd();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),Kd=M((e=>{var t=ft(`process`),n=Vu(),r=kd(),i=Ad(),a=Q(),o=Gd(),s=Ld();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
268
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}e.resolveFlowScalar=r})),Vf=N((e=>{var t=Q(),n=$(),r=zf(),i=Bf();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),Hf=N((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),Uf=N((e=>{var t=Wd(),n=Q(),r=Rf(),i=Vf(),a=If(),o=Hf();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),Wf=N((e=>{var t=Of(),n=Uf(),r=If(),i=Af();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),Gf=N((e=>{var t=ht(`process`),n=zd(),r=Of(),i=kf(),a=Q(),o=Wf(),s=If();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
253
269
 
254
270
  `:`
255
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),qd=M((e=>{var t=Bd(),n=Vd(),r=Ad(),i=Zu();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
271
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),Kf=N((e=>{var t=zf(),n=Bf(),r=kf(),i=Yd();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
256
272
  `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
257
273
  `),t=c.substring(0,e),n=c.substring(e+1)+`
258
274
  `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
@@ -260,9 +276,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
260
276
  `),r=t.substring(0,n),i=t.substring(n+1)+`
261
277
  `;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
262
278
  `});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
263
- `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),Jd=M((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),Yd=M((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),Xd=M((e=>{var t=qd(),n=Jd(),r=Yd();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
279
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),qf=N((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),Jf=N((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),Yf=N((e=>{var t=Kf(),n=qf(),r=Jf();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
264
280
  `:case`\r
265
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),Zd=M((e=>{var t=Xd();function n(e){switch(e){case void 0:case` `:case`
281
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),Xf=N((e=>{var t=Yf();function n(e){switch(e){case void 0:case` `:case`
266
282
  `:case`\r`:case` `:return!0;default:return!1}}let r=new Set(`0123456789ABCDEFabcdef`),i=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=new Set(`,[]{}`),o=new Set(` ,[]{}
267
283
  \r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
268
284
  `?!0:t===`\r`?this.buffer[e+1]===`
@@ -281,34 +297,64 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
281
297
  `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
282
298
  `){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(s))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(n(t)||e&&a.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
283
299
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
284
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),Qd=M((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),$d=M((e=>{var t=ft(`process`),n=Xd(),r=Zd();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&l(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
300
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),Zf=N((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),Qf=N((e=>{var t=ht(`process`),n=Yf(),r=Xf();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&l(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
285
301
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
286
302
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
287
303
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
288
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),ef=M((e=>{var t=Kd(),n=kd(),r=Ad(),i=ed(),a=Q(),o=Qd(),s=$d();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),tf=M((e=>{var t=Kd(),n=kd(),r=Dd(),i=Ad(),a=Ku(),o=Q(),s=rd(),c=$(),l=ad(),u=sd(),d=Xd(),f=Zd(),p=Qd(),m=$d(),h=ef(),g=Bu();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.CST=d,e.Lexer=f.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}));async function nf(e){let t=await Je(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Xe(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>dt(tf(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>dt(tf(),1));r=e(t)}return r}var rf=j((()=>{}));async function af(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
289
- `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Je(Qe(n),`utf-8`);return JSON.parse(e)}return{}}function of(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${sf(e.step)}\n`):process.stderr.write(`${t}\n`)}function sf(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function cf(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) — ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
304
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),$f=N((e=>{var t=Gf(),n=Of(),r=kf(),i=Qd(),a=Q(),o=Zf(),s=Qf();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),ep=N((e=>{var t=Gf(),n=Of(),r=Ef(),i=kf(),a=Wd(),o=Q(),s=tf(),c=$(),l=rf(),u=of(),d=Yf(),f=Xf(),p=Zf(),m=Qf(),h=$f(),g=Rd();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.CST=d,e.Lexer=f.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}));async function tp(e){let t=await Ye(e,`utf-8`).catch(e=>{process.stderr.write(`Error: cannot read pipeline file: ${e.message}\n`),process.exit(2)}),n=Ze(e).toLowerCase(),r;if(n===`.yaml`||n===`.yml`){let{parse:e}=await Promise.resolve().then(()=>mt(ep(),1));r=e(t)}else try{r=JSON.parse(t)}catch{let{parse:e}=await Promise.resolve().then(()=>mt(ep(),1));r=e(t)}return r}var np=M((()=>{}));async function rp(e){let t=e.input,n=e.inputFile;if(t&&n&&(process.stderr.write(`Error: use --input or --input-file, not both
305
+ `),process.exit(2)),t)return JSON.parse(t);if(n){let e=await Ye($e(n),`utf-8`);return JSON.parse(e)}return{}}function ip(e){let t=`[${e.type}]`;if(`stepCount`in e){process.stderr.write(`${t} ${e.stepCount} step${e.stepCount===1?``:`s`}\n`);return}`step`in e&&e.step?process.stderr.write(`${t} ${ap(e.step)}\n`):process.stderr.write(`${t}\n`)}function ap(e){return`${e.index!==void 0&&e.total!==void 0?`${e.index}/${e.total} `:``}${e.id} (${e.type})`}function op(e){let t=e.status===`succeeded`?`+`:e.status===`failed`?`x`:`~`;process.stdout.write(`\nPipeline ${e.status} [${t}]\n\n`);for(let t of e.steps){let e=` [${t.status===`succeeded`?`+`:t.status===`failed`?`x`:t.status===`skipped`?`-`:`~`}] ${t.id} (${t.type}) — ${t.status}`;t.skipReason&&(e+=` (${t.skipReason})`),t.error&&(e+=`: ${t.error.message}`),process.stdout.write(e+`
290
306
  `)}process.stdout.write(`
291
- `)}var lf,uf=j((()=>{F(),iu(),zu(),rf(),lf=m({name:`pipeline run`,description:`Run a pipeline workflow definition`,usage:`bl pipeline run <file> [flags]`,options:[{flag:`--input <json>`,description:`Runtime input as inline JSON`},{flag:`--input-file <path>`,description:`Runtime input from a JSON file`},{flag:`--concurrency <n>`,description:`Max parallel steps (default: 1)`,type:`number`},{flag:`--events <format>`,description:`Emit lifecycle events: jsonl`},{flag:`--timeout <seconds>`,description:`Default step timeout in seconds`,type:`number`}],examples:[`bl pipeline run workflow.yaml --input '{"brief":"hello"}'`,`bl pipeline run workflow.json --input-file inputs.json --concurrency 3`,`bl pipeline run workflow.yaml --dry-run`,`bl pipeline run workflow.json --events jsonl`,`bl pipeline run workflow.yaml --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
307
+ `)}var sp,cp=M((()=>{I(),nd(),Ld(),np(),sp=m({name:`pipeline run`,description:`Run a pipeline workflow definition`,usage:`bl pipeline run <file> [flags]`,options:[{flag:`--input <json>`,description:`Runtime input as inline JSON`},{flag:`--input-file <path>`,description:`Runtime input from a JSON file`},{flag:`--concurrency <n>`,description:`Max parallel steps (default: 1)`,type:`number`},{flag:`--events <format>`,description:`Emit lifecycle events: jsonl`},{flag:`--timeout <seconds>`,description:`Default step timeout in seconds`,type:`number`}],examples:[`bl pipeline run workflow.yaml --input '{"brief":"hello"}'`,`bl pipeline run workflow.json --input-file inputs.json --concurrency 3`,`bl pipeline run workflow.yaml --dry-run`,`bl pipeline run workflow.json --events jsonl`,`bl pipeline run workflow.yaml --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
292
308
  Usage: bl pipeline run <file>
293
- `),process.exit(2)),nu();let r=t.events;r!==void 0&&r!==`jsonl`&&(process.stderr.write(`Error: unsupported --events format: ${r}. Supported: jsonl\n`),process.exit(2));let i=Qe(n),a=await nf(i),o=await af(t),s=Ye(i);if(r===`jsonl`){for await(let e of Tu(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
294
- `);return}let c=await wu(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?of:void 0});e.output===`json`?N(c,`json`):cf(c),c.status===`failed`&&(process.exitCode=1)}})})),df,ff=j((()=>{F(),iu(),Cu(),rf(),df=m({name:`pipeline validate`,description:`Validate a pipeline definition without executing`,usage:`bl pipeline validate <file>`,options:[],examples:[`bl pipeline validate workflow.yaml`,`bl pipeline validate workflow.json --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
309
+ `),process.exit(2)),ed();let r=t.events;r!==void 0&&r!==`jsonl`&&(process.stderr.write(`Error: unsupported --events format: ${r}. Supported: jsonl\n`),process.exit(2));let i=$e(n),a=await tp(i),o=await rp(t),s=Xe(i);if(r===`jsonl`){for await(let e of Cd(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout}))process.stdout.write(JSON.stringify(e)+`
310
+ `);return}let c=await Sd(a,o,{concurrency:t.concurrency,basePath:s,dryRun:t.dryRun,timeoutSeconds:t.timeout,onEvent:t.verbose?ip:void 0});e.output===`json`?P(c,`json`):op(c),c.status===`failed`&&(process.exitCode=1)}})})),lp,up=M((()=>{I(),nd(),xd(),np(),lp=m({name:`pipeline validate`,description:`Validate a pipeline definition without executing`,usage:`bl pipeline validate <file>`,options:[],examples:[`bl pipeline validate workflow.yaml`,`bl pipeline validate workflow.json --output json`],async run(e,t){let n=(t._positional??[])[0];n||(process.stderr.write(`Error: pipeline file is required
295
311
  Usage: bl pipeline validate <file>
296
- `),process.exit(2)),nu();let r=await nf(Qe(n)),i=mu(r),a=i.length===0?hu(r):[];if(e.output===`json`)N({valid:i.length===0,issues:i,...a.length>0?{hints:a}:{}},`json`),i.length>0&&(process.exitCode=1);else if(i.length===0){process.stdout.write(`Pipeline definition is valid.
312
+ `),process.exit(2)),ed();let r=await tp($e(n)),i=fd(r),a=i.length===0?pd(r):[];if(e.output===`json`)P({valid:i.length===0,issues:i,...a.length>0?{hints:a}:{}},`json`),i.length>0&&(process.exitCode=1);else if(i.length===0){process.stdout.write(`Pipeline definition is valid.
297
313
  `);for(let e of a)process.stderr.write(` hint: ${e}\n`)}else{process.stderr.write(`Pipeline validation failed:
298
- `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})}));function pf(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}function mf(e,t){let n=t?new tt({level:0}):et,r=[];r.push(n.cyan.bold(`需求理解`)),e.taskSummary&&(r.push(``),r.push(e.taskSummary)),e.scenarioHints.length&&(r.push(``),r.push(`${n.dim(`场景特征`)} ${e.scenarioHints.join(` · `)}`));let i=e.inputModality.map(e=>bf[e]??e),a=e.outputModality.map(e=>bf[e]??e);if(i.length||a.length){r.push(``);let e=[];i.length&&e.push(`${n.dim(`输入`)} ${i.join(`, `)}`),a.length&&e.push(`${n.dim(`输出`)} ${a.join(`, `)}`),r.push(e.join(` `))}let o=e.requiredCapabilities.map(e=>xf[e]??e);o.length&&r.push(`${n.dim(`所需能力`)} ${o.join(`, `)}`);let s=Sf[e.budget]??e.budget,c=Cf[e.qualityPreference]??e.qualityPreference;r.push(``),r.push(`${n.dim(`预算倾向`)} ${s} ${n.dim(`质量偏好`)} ${c}`);let l=e.modelPreference;if(l&&l.mode!==`unconstrained`){r.push(``);let e=wf[l.mode]??l.mode,t=[n.dim(`推荐模式`)+` ${n.yellow(e)}`];l.targets?.length&&t.push(n.dim(`目标`)+` ${l.targets.join(`, `)}`),l.excludes?.length&&t.push(n.dim(`排除`)+` ${l.excludes.join(`, `)}`),r.push(t.join(` `))}if(e.segments?.length){r.push(``),r.push(n.dim(`任务拆解`));for(let[t,i]of e.segments.entries()){let e=i.outputModality.map(e=>bf[e]??e).join(`, `);r.push(` ${n.dim(`${t+1}.`)} ${i.step}${e?n.dim(` → ${e}`):``}`)}}return $e(r.join(`
299
- `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`cyan`,borderStyle:`round`,dimBorder:!0})}function hf(e,t,n){let r=[n.green.bold,n.blue.bold,n.magenta.bold][t]??n.white.bold,i=Tf[t]??`推荐 #${t+1}`,a=[];a.push(r(`⬢ 推荐 #${t+1} — ${i}`)),a.push(``),a.push(`${n.bold(e.name)} ${n.dim(`(${e.model})`)}`),a.push(``),a.push(`${n.cyan(`推荐理由`)} ${e.reason}`),e.highlights.length&&(a.push(``),a.push(e.highlights.map(e=>n.bgGray.white(` ${e} `)).join(` `)));let o=[];e.contextWindow&&o.push(`上下文 ${pf(e.contextWindow)}`),e.maxOutputTokens&&o.push(`最大输出 ${pf(e.maxOutputTokens)}`),o.length&&(a.push(``),a.push(n.dim(o.join(` · `))));let s=u(e.docUrl);return s&&(a.push(``),a.push(n.dim(`文档 ${s}`))),$e(a.join(`
300
- `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`gray`,borderStyle:`round`,dimBorder:!0})}function gf(e,t){let n=t?new tt({level:0}):et;return e.map((e,t)=>hf(e,t,n)).join(`
301
- `)}function _f(e,t,n){let r=n?new tt({level:0}):et,i=[];i.push(` ${r.yellow.bold(`⚡ 组合方案`)} ${e}`);for(let[e,{step:n,recommendations:a,warnings:o}]of t.entries()){if(i.push(``),i.push(r.bold(` ━━━ Step ${e+1}: ${n} ━━━`)),o?.length)for(let e of o)i.push(` ${r.yellow(`⚠`)} ${r.yellow(e)}`);i.push(``),i.push(a.map((e,t)=>hf(e,t,r)).join(`
314
+ `);for(let e of i)process.stderr.write(` - ${e}\n`);process.exitCode=1}}})}));function dp(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e)}function fp(e,t){let n=t?new nt({level:0}):tt,r=[];r.push(n.cyan.bold(`需求理解`)),e.taskSummary&&(r.push(``),r.push(e.taskSummary)),e.scenarioHints.length&&(r.push(``),r.push(`${n.dim(`场景特征`)} ${e.scenarioHints.join(` · `)}`));let i=e.inputModality.map(e=>vp[e]??e),a=e.outputModality.map(e=>vp[e]??e);if(i.length||a.length){r.push(``);let e=[];i.length&&e.push(`${n.dim(`输入`)} ${i.join(`, `)}`),a.length&&e.push(`${n.dim(`输出`)} ${a.join(`, `)}`),r.push(e.join(` `))}let o=e.requiredCapabilities.map(e=>yp[e]??e);o.length&&r.push(`${n.dim(`所需能力`)} ${o.join(`, `)}`);let s=bp[e.budget]??e.budget,c=xp[e.qualityPreference]??e.qualityPreference;r.push(``),r.push(`${n.dim(`预算倾向`)} ${s} ${n.dim(`质量偏好`)} ${c}`);let l=e.modelPreference;if(l&&l.mode!==`unconstrained`){r.push(``);let e=Sp[l.mode]??l.mode,t=[n.dim(`推荐模式`)+` ${n.yellow(e)}`];l.targets?.length&&t.push(n.dim(`目标`)+` ${l.targets.join(`, `)}`),l.excludes?.length&&t.push(n.dim(`排除`)+` ${l.excludes.join(`, `)}`),r.push(t.join(` `))}if(e.segments?.length){r.push(``),r.push(n.dim(`任务拆解`));for(let[t,i]of e.segments.entries()){let e=i.outputModality.map(e=>vp[e]??e).join(`, `);r.push(` ${n.dim(`${t+1}.`)} ${i.step}${e?n.dim(` → ${e}`):``}`)}}return et(r.join(`
315
+ `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`cyan`,borderStyle:`round`,dimBorder:!0})}function pp(e,t,n){let r=[n.green.bold,n.blue.bold,n.magenta.bold][t]??n.white.bold,i=Cp[t]??`推荐 #${t+1}`,a=[];a.push(r(`⬢ 推荐 #${t+1} — ${i}`)),a.push(``),a.push(`${n.bold(e.name)} ${n.dim(`(${e.model})`)}`),a.push(``),a.push(`${n.cyan(`推荐理由`)} ${e.reason}`),e.highlights.length&&(a.push(``),a.push(e.highlights.map(e=>n.bgGray.white(` ${e} `)).join(` `)));let o=[];e.contextWindow&&o.push(`上下文 ${dp(e.contextWindow)}`),e.maxOutputTokens&&o.push(`最大输出 ${dp(e.maxOutputTokens)}`),o.length&&(a.push(``),a.push(n.dim(o.join(` · `))));let s=u(e.docUrl);return s&&(a.push(``),a.push(n.dim(`文档 ${s}`))),et(a.join(`
316
+ `),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:0,bottom:0,left:1,right:0},borderColor:`gray`,borderStyle:`round`,dimBorder:!0})}function mp(e,t){let n=t?new nt({level:0}):tt;return e.map((e,t)=>pp(e,t,n)).join(`
317
+ `)}function hp(e,t,n){let r=n?new nt({level:0}):tt,i=[];i.push(` ${r.yellow.bold(`⚡ 组合方案`)} ${e}`);for(let[e,{step:n,recommendations:a,warnings:o}]of t.entries()){if(i.push(``),i.push(r.bold(` ━━━ Step ${e+1}: ${n} ━━━`)),o?.length)for(let e of o)i.push(` ${r.yellow(`⚠`)} ${r.yellow(e)}`);i.push(``),i.push(a.map((e,t)=>pp(e,t,r)).join(`
302
318
  `))}return i.join(`
303
- `)}function vf(e,t){return e.type===`pipeline`?_f(e.summary,e.steps,t):gf(e.recommendations,t)}function yf(e){return e.type===`pipeline`?e.steps.length===0:e.recommendations.length===0}var bf,xf,Sf,Cf,wf,Tf,Ef,Df=j((()=>{F(),Li(),W(),bf={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`},xf={TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,Reasoning:`推理`},Sf={low:`低成本优先`,medium:`适中`,high:`高投入`},Cf={flagship:`旗舰优先`,balanced:`均衡`,"cost-optimized":`性价比优先`},wf={scoped:`限定范围`,comparison:`对比评估`,alternative:`替代推荐`},Tf=[`最佳推荐`,`次优选择`,`备选参考`],Ef=m({name:`advisor recommend`,description:`Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)`,usage:`bl advisor recommend <prompt> [flags]`,options:[{flag:`--message <text>`,description:`Describe your requirements (alternative to positional prompt)`},{flag:`--dry-run`,description:`Show intent analysis and candidate list without LLM ranking`},{flag:`--output <format>`,description:`Output format: text (default in TTY), json, yaml`}],examples:[`bl advisor recommend --message "我要做一个能理解图片的客服机器人"`,`bl advisor recommend --message "做一个Agent自动根据用户意图生成动画片"`,`bl advisor recommend --message "法律合同审查,要求高精准度"`,`bl advisor recommend --message "做一个低成本高并发的在线客服" --output json`,`bl advisor recommend --message "长文本摘要" --dry-run`,`bl advisor recommend # 交互式输入需求`],async run(e,t){let n=t._positional??[],r=t.message||n.join(` `);if(!r.trim())if(T({nonInteractive:e.nonInteractive})){let e=await H({message:`描述你的需求:`});e||(process.stderr.write(`已取消。
304
- `),process.exit(1)),r=e}else U(`message`,`bl advisor recommend "你的需求"`);let i=h(e.output),a={onPrepareStart:()=>process.stderr.write(`初始化中...
319
+ `)}function gp(e,t){return e.type===`pipeline`?hp(e.summary,e.steps,t):mp(e.recommendations,t)}function _p(e){return e.type===`pipeline`?e.steps.length===0:e.recommendations.length===0}var vp,yp,bp,xp,Sp,Cp,wp,Tp=M((()=>{I(),Ui(),H(),vp={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`},yp={TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,Reasoning:`推理`},bp={low:`低成本优先`,medium:`适中`,high:`高投入`},xp={flagship:`旗舰优先`,balanced:`均衡`,"cost-optimized":`性价比优先`},Sp={scoped:`限定范围`,comparison:`对比评估`,alternative:`替代推荐`},Cp=[`最佳推荐`,`次优选择`,`备选参考`],wp=m({name:`advisor recommend`,description:`Recommend the best models for your use case (intent analysis → candidate recall → LLM ranking)`,usage:`bl advisor recommend <prompt> [flags]`,options:[{flag:`--message <text>`,description:`Describe your requirements (alternative to positional prompt)`},{flag:`--dry-run`,description:`Show intent analysis and candidate list without LLM ranking`},{flag:`--output <format>`,description:`Output format: text (default in TTY), json, yaml`}],examples:[`bl advisor recommend --message "I need a visual-understanding chatbot"`,`bl advisor recommend --message "Build an Agent that auto-generates animations"`,`bl advisor recommend --message "Legal contract review, high precision required"`,`bl advisor recommend --message "Low-cost high-concurrency online customer service" --output json`,`bl advisor recommend --message "Long document summarization" --dry-run`,`bl advisor recommend # Interactive input`],async run(e,t){let n=t._positional??[],r=t.message||n.join(` `);if(!r.trim())if(E({nonInteractive:e.nonInteractive})){let e=await Jr({message:`描述你的需求:`});e||(process.stderr.write(`已取消。
320
+ `),process.exit(1)),r=e}else V(`message`,`bl advisor recommend "你的需求"`);let i=h(e.output),a={onPrepareStart:()=>process.stderr.write(`初始化中...
305
321
  `)};process.stderr.write(`正在分析需求...
306
- `);let[o,c]=await Promise.all([S(e,a),s(e,r)]);c.confidence===0?process.stderr.write(`需求分析超时,使用默认参数继续...
322
+ `);let[o,c]=await Promise.all([C(e,a),s(e,r)]);c.confidence===0?process.stderr.write(`需求分析超时,使用默认参数继续...
307
323
  `):process.stderr.write(`
308
- `);let l=await ue(e,o,r,50,c);if(e.dryRun){N({userInput:r,intent:c,candidateCount:l.length,candidates:l.map(({model:e,score:t})=>({model:e.model,score:t})),top:3},i);return}let u=Pi(`正在推荐最佳模型...`);u.start();let d=await ce(e,l,c,r,3);if(u.stop(),yf(d)){P(`暂无满足该需求的模型。`);return}if(i!==`text`){N(d,i);return}P(mf(c,e.noColor)),P(``),P(vf(d,e.noColor))}})})),Of=lt({commands:()=>kf}),kf,Af=j((()=>{ao(),so(),uo(),po(),ho(),_o(),yo(),xo(),Co(),To(),Oo(),No(),Io(),Ro(),Bo(),Jo(),Zo(),$o(),ts(),is(),uf(),ff(),Df(),kf={"auth login":pi,"auth status":Si,"auth logout":Ti,"text chat":Oi,omni:Mi,"image generate":sa,"image edit":la,"video generate":pa,"video edit":ha,"video ref":_a,"video task get":ya,"video download":xa,"vision describe":Da,"app call":oo,"app list":lo,"memory add":fo,"memory search":mo,"memory list":go,"memory update":vo,"memory delete":bo,"memory profile create":So,"memory profile get":wo,"knowledge retrieve":Do,"mcp list":Fo,"mcp tools":Lo,"mcp call":Mo,"search web":zo,"speech synthesize":qo,"speech recognize":Xo,"file upload":Qo,"console call":es,"usage free":rs,"pipeline run":lf,"pipeline validate":df,"config show":ka,"config set":Pa,"config export-schema":La,"advisor recommend":Ef,update:io}}));Af();const jf=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}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}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(e){let n=this.root,r=[];for(let t of e){let e=n.children.get(t);if(!e)break;n=e,r.push(t)}if(n.command)return{command:n.command,extra:e.slice(r.length)};if(r.length>0&&n.children.size===1){let[,t]=n.children.entries().next().value;if(t.command)return{command:t.command,extra:e.slice(r.length)}}if(r.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${r.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${r.join(` `)} ${e} [${n}]`}).join(`
324
+ `);let l=await de(e,o,r,50,c);if(e.dryRun){P({userInput:r,intent:c,candidateCount:l.length,candidates:l.map(({model:e,score:t})=>({model:e.model,score:t})),top:3},i);return}let u=Bi(`正在推荐最佳模型...`);u.start();let d=await le(e,l,c,r,3);if(u.stop(),_p(d)){F(`暂无满足该需求的模型。`);return}if(i!==`text`){P(d,i);return}F(fp(c,e.noColor)),F(``),F(gp(d,e.noColor))}})}));function Ep(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Dp(e){let t=Ep(e,`data`);if(!t)return e;let n=Ep(t,`DataV2`);if(n){let e=Ep(n,`data`);return(e?Ep(e,`data`):void 0)??e??n}return Ep(t,`data`)??t}function Op(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=[`空间名称`,`Workspace ID`,`默认空间`],o=[`Name`,``,`Default`],s=e.map(e=>[e.agentName,e.workspaceId,e.defaultAgent?`Yes`:`-`]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>n(W(e,c[t]))).join(` `),u=o.map((e,t)=>r(W(e,c[t]))).join(` `),d=c.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
325
+ `),process.stdout.write(u+`
326
+ `),process.stdout.write(d+`
327
+ `);for(let e of s){let t=e.map((e,t)=>t===2&&e===`Yes`?i(W(e,c[t])):W(e,c[t]));process.stdout.write(t.join(` `)+`
328
+ `)}process.stdout.write(r(`\n共 ${e.length} 个空间 (Total: ${e.length})`)+`
329
+ `)}var kp,Ap,jp=M((()=>{I(),fs(),kp=`zeldaEasy.bailian-dash-workspace.space.listWorkspaces`,Ap=m({name:`workspace list`,description:`List all workspaces`,usage:`bl workspace list [flags]`,options:[{flag:`--list <n>`,description:`Limit number of results`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl workspace list`,`bl workspace list --list 5`,`bl workspace list --output json`],async run(e,t){let n=t.region||`cn-beijing`,r=Number(t.list)||0,i=h(e.output),a=await me(e);if(e.dryRun){P({api:kp,data:{},region:n},i);return}let o=await d(e,a.token,{api:kp,data:{},region:n});if(i===`json`){P(o,i);return}let s=Dp(o).data;if(!Array.isArray(s)||s.length===0){process.stdout.write(`No workspace found.
330
+ `);return}let c=s;r>0&&(c=c.slice(0,r)),Op(c,e.noColor)}})}));function Mp(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function Np(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Pp(e){return e.toLocaleString(`en-US`)}function Fp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Ip(e){let t=Fp(e,`data`);if(!t)return e;let n=Fp(t,`DataV2`);if(n){let e=Fp(n,`data`);return(e?Fp(e,`data`):void 0)??e??n}return Fp(t,`data`)??t}async function Lp(e,t,n,r){let i=[],a=1;for(;;){let o={pageNo:a,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r&&(o.supports={selfServiceLimitIncrease:!0});let s=Ip(await d(e,t,{api:zp,data:{input:o},region:n})),c=s.list??[],l=s.total??0;if(i.push(...c),i.length>=l||c.length===0)break;a++}return i}function Rp(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=[`模型`,`RPM`,`TPM`,`可设上限 TPM`],a=[`Model`,`Req/min`,`Token/min`,`Max TPM`],o=e.map(e=>{let t=e.qpmInfo,n=t?.[`model-default`],r=t?.[`user-spec`],i=Mp(n),a=Np(n),o=Mp(r,n?.count_limit_period)||i,s=Np(r,n?.usage_limit_period)||a,c=a*2;return[e.model,o>0?Pp(o):`-`,s>0?Pp(s):`-`,c>0?Pp(c):`-`]});if(o.length===0){process.stdout.write(`No models found.
331
+ `);return}let s=i.map((e,t)=>Math.max(U(e),U(a[t]),...o.map(e=>U(e[t])))),c=i.map((e,t)=>n(W(e,s[t]))).join(` `),l=a.map((e,t)=>r(W(e,s[t]))).join(` `),u=s.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(c+`
332
+ `),process.stdout.write(l+`
333
+ `),process.stdout.write(u+`
334
+ `);for(let e of o)process.stdout.write(e.map((e,t)=>W(e,s[t])).join(` `)+`
335
+ `);process.stdout.write(r(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
336
+ `)}var zp,Bp,Vp=M((()=>{I(),fs(),zp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,Bp=m({name:`quota list`,description:`View model RPM/TPM rate limits`,usage:`bl quota list [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--all`,description:`Show all models, not just self-service ones`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota list`,`bl quota list --model qwen3.6-plus`,`bl quota list --model qwen3.6-plus,qwen-turbo`,`bl quota list --all`,`bl quota list --output json`],async run(e,t){let n=t.model||void 0,r=!!t.all,i=t.region||`cn-beijing`,a=h(e.output),o=await me(e);if(e.dryRun){let e={pageNo:1,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0};r||(e.supports={selfServiceLimitIncrease:!0}),P({api:zp,data:{input:e},region:i},a);return}let s=await Lp(e,o.token,i,!r);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));s=s.filter(t=>e.has(t.model)),s.length===0&&(process.stderr.write(`Error: no matching models found for "${n}".\n`),process.exit(1))}if(a===`json`){P(s,a);return}Rp(s,e.noColor)}})}));function Hp(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function Up(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Wp(e){let t=Up(e,`data`);if(!t)return e;let n=Up(t,`DataV2`);if(n){let e=Up(n,`data`);return(e?Up(e,`data`):void 0)??e??n}return Up(t,`data`)??t}async function Gp(e,t,n,r){return(Wp(await d(e,t,{api:Kp,data:{input:{pageNo:1,pageSize:50,name:r,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})).list??[]).find(e=>e.model===r&&e.qpmInfo)}var Kp,qp,Jp,Yp=M((()=>{I(),Kp=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,qp=`zeldaEasy.broadscope-platform.modelInstance.updateFoundationModelLimits`,Jp=m({name:`quota request`,description:`Request a temporary quota increase`,usage:`bl quota request --model <model> --tpm <value> [flags]`,options:[{flag:`--model <model>`,description:`Model name (required)`,required:!0},{flag:`--tpm <value>`,description:`Target TPM value (required)`,required:!0},{flag:`--yes`,description:`Skip downgrade confirmation`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota request --model qwen-turbo --tpm 100000`,`bl quota request --model qwen3.6-plus --tpm 8000000 --yes`,`bl quota request --model qwen-turbo --tpm 100000 --output json`],async run(e,n){let r=n.model;r||(process.stderr.write(`Error: --model is required.
337
+ `),process.exit(1));let i=Number(n.tpm);(!i||i<=0)&&(process.stderr.write(`Error: --tpm must be a positive number.
338
+ `),process.exit(1));let a=!!n.yes||e.yes,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l=await Gp(e,c.token,o,r);l||(process.stderr.write(`Error: model "${r}" not found or does not support self-service quota increase.\n`),process.stderr.write("Hint: run `bl quota list` to view available models.\n"),process.exit(1));let u=l.qpmInfo[`model-default`],f=l.qpmInfo[`user-spec`],p=Hp(u),m=Hp(f,u?.usage_limit_period)||p,g=p*2;(i<p||i>g)&&(process.stderr.write(`Error: TPM value ${i.toLocaleString()} is out of range.\n Current: ${m.toLocaleString()}\n Range: ${p.toLocaleString()} ~ ${g.toLocaleString()}\n`),process.exit(1));let _={input:{model:r,limit:{usage_limit:i},originalQpmInfo:l.qpmInfo}};if(e.dryRun){P({api:qp,data:_,region:o},s);return}let v=async n=>{n&&(_.input.confirmedDowngrade=!0);try{return await d(e,c.token,{api:qp,data:_,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}},y=await v(),b=Wp(y);if(b.needConfirm){let e=b.confirmCode;e===`Refresh_Required`&&(process.stderr.write(`Error: rate limit has been updated externally. Please retry.
339
+ `),process.exit(1)),e===`Downgrade`&&(a||(process.stderr.write(`Warning: target TPM (${i.toLocaleString()}) is lower than current (${m.toLocaleString()}).\nUse --yes to confirm downgrade.
340
+ `),process.exit(1)),y=await v(!0))}if(s===`json`){P(y,s);return}process.stdout.write(`Quota updated for "${r}": TPM ${m.toLocaleString()} → ${i.toLocaleString()}\n`)}})}));function Xp(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function Zp(e){let t=Xp(e,`data`);if(!t)return e;let n=Xp(t,`DataV2`);if(n){let e=Xp(n,`data`);return(e?Xp(e,`data`):void 0)??e??n}return Xp(t,`data`)??t}function Qp(e){if(!e)return`-`;try{let t=new Date(e);return isNaN(t.getTime())?e:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return e}}function $p(e){return e.toLocaleString(`en-US`)}function em(e,t,n){let r=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,a=[`模型`,`Token 账号限流`,`申请时间`],o=[`Model`,`Token Limit`,`Applied At`],s=e.map(e=>[e.deployedModel,$p(e.usageLimit),Qp(e.gmtCreate)]),c=a.map((e,t)=>Math.max(U(e),U(o[t]),...s.map(e=>U(e[t])))),l=a.map((e,t)=>r(W(e,c[t]))).join(` `),u=o.map((e,t)=>i(W(e,c[t]))).join(` `),d=c.map(e=>i(`─`.repeat(e))).join(`──`);process.stdout.write(l+`
341
+ `),process.stdout.write(u+`
342
+ `),process.stdout.write(d+`
343
+ `);for(let e of s)process.stdout.write(e.map((e,t)=>W(e,c[t])).join(` `)+`
344
+ `);process.stdout.write(i(`\n共 ${n} 条记录 (Total: ${n})`)+`
345
+ `)}var tm,nm,rm=M((()=>{I(),fs(),tm=`zeldaEasy.broadscope-platform.modelInstance.listModelLimitApplications`,nm=m({name:`quota history`,description:`View quota change history`,usage:`bl quota history [flags]`,options:[{flag:`--page <n>`,description:`Page number (default: 1)`},{flag:`--page-size <n>`,description:`Page size (default: 10)`},{flag:`--model <model>`,description:`Filter by model name`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota history`,`bl quota history --page 2`,`bl quota history --page-size 20`,`bl quota history --model qwen-turbo`,`bl quota history --output json`],async run(e,n){let r=Number(n.page)||1,i=Number(n.pageSize)||10,a=n.model||void 0,o=n.region||`cn-beijing`,s=h(e.output),c=await me(e),l={input:{pageNo:r,pageSize:i}};if(e.dryRun){P({api:tm,data:l,region:o},s);return}let u;try{u=await d(e,c.token,{api:tm,data:l,region:o})}catch(e){throw e instanceof t&&e.message.includes(`NotLogined`)&&(process.stderr.write("Error: session expired. Run `bl auth login --console` to re-authenticate.\n"),process.exit(1)),e}if(s===`json`){P(u,s);return}let f=Zp(u),p=f.records??[],m=f.items??p.length;if(a&&(p=p.filter(e=>e.deployedModel===a)),p.length===0){process.stdout.write(`No quota change history found.
346
+ `);return}em(p,e.noColor,a?p.length:m)}})}));function im(e,t){if(!e)return 0;let n=e.count_limit_period||t;return n?Math.floor(e.count_limit*60/n):0}function am(e,t){if(!e)return 0;let n=e.usage_limit_period||t;return n?Math.floor(e.usage_limit*60/n):0}function om(e){return e.toLocaleString(`en-US`)}function sm(e,t){if(t<=0)return`-`;let n=Math.round(e/t*100);return`${om(e)}/${om(t)} (${n}%)`}function cm(e,t){if(t<=0)return`-`;let n=e/t*100;return n>=100?`已限流`:n>=80?`接近限流`:`正常`}function lm(e,t){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))return n}function um(e){let t=lm(e,`data`);if(!t)return e;let n=lm(t,`DataV2`);if(n){let e=lm(n,`data`);return(e?lm(e,`data`):void 0)??e??n}return lm(t,`data`)??t}async function dm(e,t,n){let r=[],i=1;for(;;){let a=um(await d(e,t,{api:mm,data:{input:{pageNo:i,pageSize:50,group:!1,queryQpmInfo:!0,ignoreWorkspaceServiceSite:!0,supports:{selfServiceLimitIncrease:!0}}},region:n})),o=a.list??[],s=a.total??0;if(r.push(...o),r.length>=s||o.length===0)break;i++}return r}async function fm(e,t,n,r,i){let a=Date.now(),o=a-i*60*1e3;try{let i=um(await d(e,t,{api:hm,data:{reqDTO:{monitorType:`Advanced`,metricFilters:[{aggMethod:`sum_pm`,metricName:`model_total_amount`},{aggMethod:`sum_pm`,metricName:`model_call_count`}],labelFilters:{resourceId:r,resourceType:`model`},startTime:o,endTime:a}},region:n})),s=i.data??i;if(!Array.isArray(s))return{rpm:0,tpm:0};let c=0,l=0;for(let e of s){if(e.aggMethod!==`sum_pm`||!e.points?.length)continue;let t=e.points[e.points.length-1].value??0;e.metricName===`model_call_count`&&(c=Math.round(t)),e.metricName===`model_total_amount`&&(l=Math.round(t))}return{rpm:c,tpm:l}}catch{return{rpm:-1,tpm:-1}}}function pm(e,t){let n=t?e=>e:e=>`\x1b[1m${e}\x1b[0m`,r=t?e=>e:e=>`\x1b[2m${e}\x1b[0m`,i=t?e=>e:e=>`\x1b[32m${e}\x1b[0m`,a=t?e=>e:e=>`\x1b[33m${e}\x1b[0m`,o=t?e=>e:e=>`\x1b[31m${e}\x1b[0m`,s=[`模型`,`RPM 用量/限额`,`TPM 用量/限额`,`状态`],c=[`Model`,`RPM Usage/Limit`,`TPM Usage/Limit`,`Status`],l=e.map(e=>{let t=e.rpmUsage<0?`-`:sm(e.rpmUsage,e.rpmLimit),n=e.tpmUsage<0?`-`:sm(e.tpmUsage,e.tpmLimit),r=Math.max(e.rpmLimit>0?e.rpmUsage/e.rpmLimit*100:0,e.tpmLimit>0?e.tpmUsage/e.tpmLimit*100:0),i=e.rpmUsage<0?`-`:cm(Math.max(e.rpmUsage,e.tpmUsage),Math.max(e.rpmLimit,e.tpmLimit));return{cells:[e.model,t,n,i],maxPct:r}});if(l.length===0){process.stdout.write(`No models found.
347
+ `);return}let u=s.map((e,t)=>Math.max(U(e),U(c[t]),...l.map(e=>U(e.cells[t])))),d=s.map((e,t)=>n(W(e,u[t]))).join(` `),f=c.map((e,t)=>r(W(e,u[t]))).join(` `),p=u.map(e=>r(`─`.repeat(e))).join(`──`);process.stdout.write(d+`
348
+ `),process.stdout.write(f+`
349
+ `),process.stdout.write(p+`
350
+ `);for(let e of l){let t=e.cells.map((e,t)=>{if(t===3){if(e===`已限流`)return o(W(e,u[t]));if(e===`接近限流`)return a(W(e,u[t]));if(e===`正常`)return i(W(e,u[t]))}return W(e,u[t])});process.stdout.write(t.join(` `)+`
351
+ `)}process.stdout.write(r(`\n共 ${e.length} 个模型 (Total: ${e.length})`)+`
352
+ `)}var mm,hm,gm,_m=M((()=>{I(),fs(),mm=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,hm=`zeldaEasy.bailian-telemetry.monitor.getMonitorData`,gm=m({name:`quota check`,description:`Check current usage against rate limits`,usage:`bl quota check [--model <model>] [flags]`,options:[{flag:`--model <model>`,description:`Model name(s), comma-separated`},{flag:`--period <minutes>`,description:`Query usage for the last N minutes (default: 2)`},{flag:`--region <region>`,description:`API region (default: cn-beijing)`}],examples:[`bl quota check`,`bl quota check --model qwen3.6-plus`,`bl quota check --period 5`,`bl quota check --model qwen3.6-plus,qwen-turbo`,`bl quota check --output json`],async run(e,t){let n=t.model||void 0,r=Number(t.period)||2;r<1&&(process.stderr.write(`Error: --period must be at least 1 minute.
353
+ `),process.exit(1));let i=r,a=t.region||`cn-beijing`,o=h(e.output),s=await me(e);if(e.dryRun){P({apis:[mm,hm],region:a},o);return}let c=await dm(e,s.token,a);if(n){let e=new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean));c=c.filter(t=>e.has(t.model))}if(c=c.filter(e=>e.qpmInfo),c.length===0){process.stdout.write(`No models found.
354
+ `);return}let l=await Promise.all(c.map(t=>fm(e,s.token,a,t.model,i))),u=c.map((e,t)=>{let n=e.qpmInfo,r=n[`model-default`],i=n[`user-spec`],a=im(i,r?.count_limit_period)||im(r),o=am(i,r?.usage_limit_period)||am(r);return{model:e.model,rpmUsage:l[t].rpm,rpmLimit:a,tpmUsage:l[t].tpm,tpmLimit:o}});if(o===`json`){P(u,o);return}pm(u,e.noColor)}})})),vm=ft({commands:()=>ym}),ym,bm=M((()=>{fo(),mo(),_o(),yo(),xo(),Co(),To(),Do(),ko(),jo(),Lo(),Ho(),Go(),qo(),Yo(),rs(),os(),cs(),us(),Ts(),Ls(),nc(),cp(),up(),Tp(),jp(),Vp(),Yp(),rm(),_m(),ym={"auth login":yi,"auth status":Oi,"auth logout":ji,"text chat":Pi,omni:Ri,"image generate":pa,"image edit":ha,"video generate":ya,"video edit":xa,"video ref":Ca,"video task get":Ta,"video download":Da,"vision describe":Na,"app call":po,"app list":go,"memory add":vo,"memory search":bo,"memory list":So,"memory update":wo,"memory delete":Eo,"memory profile create":Oo,"memory profile get":Ao,"knowledge retrieve":Io,"mcp list":Wo,"mcp tools":Ko,"mcp call":Vo,"search web":Jo,"speech synthesize":ns,"speech recognize":as,"file upload":ss,"console call":ls,"usage free":ws,"usage freetier":Is,"usage stats":tc,"pipeline run":sp,"pipeline validate":lp,"config show":Fa,"config set":Ba,"config export-schema":Ua,"advisor recommend":wp,"workspace list":Ap,"quota list":Bp,"quota request":Jp,"quota history":nm,"quota check":gm,update:uo}}));bm();const xm=new class{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(` `),r=this.root;for(let e of n)r.children.has(e)||r.children.set(e,{children:new Map}),r=r.children.get(e);r.command=t}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}isGroupPath(e){let t=this.root;for(let n of e){let e=t.children.get(n);if(!e)return!1;t=e}return!t.command&&t.children.size>0}resolve(e){let n=this.root,r=[];for(let t of e){let e=n.children.get(t);if(!e)break;n=e,r.push(t)}if(n.command)return{command:n.command,extra:e.slice(r.length)};if(r.length>0&&n.children.size===1){let[,t]=n.children.entries().next().value;if(t.command)return{command:t.command,extra:e.slice(r.length)}}if(r.length>0&&n.children.size>0){let a=Array.from(n.children.entries()).map(([e,t])=>{if(t.command)return` ${r.join(` `)} ${e} ${t.command.description}`;let n=Array.from(t.children.keys()).join(`, `);return` ${r.join(` `)} ${e} [${n}]`}).join(`
309
355
  `);throw new t(`Unknown command: bl ${e.join(` `)}\n\nAvailable commands:\n${a}`,i.USAGE,`bl ${r.join(` `)} --help`)}throw new t(`Unknown command: bl ${e.join(` `)}`,i.USAGE,`bl --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(`
310
356
  `)}buildGlobalFlagLines(e,t){let n=Math.max(...a.map(e=>e.flag.length));return a.map(r=>` ${e(r.flag.padEnd(n+2))} ${t(r.description)}`).join(`
311
- `)}bold=(e,t)=>t.isTTY?`\x1b[1m${e}\x1b[0m`:e;accent=(e,t)=>t.isTTY?`\x1b[38;2;59;130;246m${e}\x1b[0m`:e;dim=(e,t)=>t.isTTY?`\x1b[2m${e}\x1b[0m`:e;printHelp(e,t=process.stdout,n=`cn`){if(e.length===0){this.printRootHelp(t);return}let r=this.root;for(let n of e){let e=r.children.get(n);if(!e){this.printRootHelp(t);return}r=e}if(r.command){this.printCommandHelp(r.command,t,n);return}let i=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${i} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(r,i,t),i===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
357
+ `)}bold=(e,t)=>t.isTTY?`\x1b[1m${e}\x1b[0m`:e;accent=(e,t)=>t.isTTY?`\x1b[38;2;59;130;246m${e}\x1b[0m`:e;dim=(e,t)=>t.isTTY?`\x1b[2m${e}\x1b[0m`: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,t);return}let r=e.join(` `);t.write(`\n${this.bold(`Usage:`,t)} bl ${r} <command> [flags]\n\n`),t.write(`${this.bold(`Commands:`,t)}\n`),this.printChildren(n,r,t),r===`pipeline`&&this.printPipelineQuickStart(t),t.write(`
312
358
  `)}printPipelineQuickStart(e){let t=t=>this.bold(t,e),n=t=>this.dim(t,e);e.write(`
313
359
  ${t(`Minimal workflow.yaml:`)}
314
360
  ${n(` version: workflow/v1`)}
@@ -336,13 +382,15 @@ ${o}
336
382
  ${n(`Getting Help:`)}
337
383
  ${i(`Add --help after any command to see its full list of options, defaults,`)}
338
384
  ${i(`and usage examples. For example:`)} bl text chat --help
339
- `)}printCommandHelp(e,t,n=`cn`){let i=e=>this.bold(e,t),a=e=>this.accent(e,t),o=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${i(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let n=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${i(`Options:`)}\n`);for(let r of e.options)t.write(` ${a(r.flag.padEnd(n+2))} ${o(r.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${i(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${o(n)}\n`)}e.apiDocs&&t.write(`\n${i(`API Reference:`)} ${o(r[n]+e.apiDocs)}\n`),t.write(`\n${o(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${o(`Run`)} bl --help ${o(`for the full list.`)}\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`)}}(kf);Ct();function Mf(e){return e.padEnd(13)}function Nf(e){return e.split(`
385
+ `)}printCommandHelp(e,t){let n=e=>this.bold(e,t),r=e=>this.accent(e,t),i=e=>this.dim(e,t);if(t.write(`\n${e.description}\n`),e.usage&&t.write(`${n(`Usage:`)} ${e.usage}\n`),e.options&&e.options.length>0){let a=Math.max(...e.options.map(e=>e.flag.length));t.write(`\n${n(`Options:`)}\n`);for(let n of e.options)t.write(` ${r(n.flag.padEnd(a+2))} ${i(n.description)}\n`)}if(e.examples&&e.examples.length>0){t.write(`\n${n(`Examples:`)}\n`);for(let n of e.examples)t.write(` ${i(n)}\n`)}t.write(`\n${i(`Global flags (--api-key, --output, --quiet, etc.) are always available.`)}\n`),t.write(`${i(`Run`)} bl --help ${i(`for the full list.`)}\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`)}}(ym);function Sm(e,...t){for(let n of t){let t=e[n]?.trim();if(t)return t}}function Cm(e=process.env){return{httpProxy:Sm(e,`http_proxy`,`HTTP_PROXY`),httpsProxy:Sm(e,`https_proxy`,`HTTPS_PROXY`),noProxy:Sm(e,`no_proxy`,`NO_PROXY`)}}function wm(){let{httpProxy:e,httpsProxy:n,noProxy:r}=Cm();if(!(!e&&!n))try{it(new rt({httpProxy:e,httpsProxy:n,noProxy:r}))}catch(e){throw new t(`Invalid proxy configuration: ${e instanceof Error?e.message:String(e)}`,i.USAGE,`Check HTTP_PROXY / HTTPS_PROXY values, e.g. export HTTPS_PROXY=http://127.0.0.1:7890`,{cause:e})}}Et();function Tm(e){return e.padEnd(13)}function Em(e){return e.split(`
340
386
  `).map((e,t)=>t===0?e:` `.repeat(13)+e).join(`
341
- `)}function Pf(e){return e.exitCode===i.AUTH?e.message===n?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${St}`].filter(e=>e!==void 0).join(`
342
- `):e.hint}function Ff(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 h(e[n+1]||t);if(r?.startsWith(`--output=`))return h(r.slice(9))}return h(t)}function If(e){let n=e.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new t(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Lf(r),{cause:e})}function Lf(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;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.`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;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 connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function Rf(e){let n=e.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 t(`File system error: ${e.message}`,i.GENERAL,r,{cause:e})}function zf(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Mf(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Bf(e){process.stderr.write(`\n${Mf(`Error:`)}${e.message}\n`);let t=Pf(e);t&&process.stderr.write(`${Mf(`Hint:`)}${Nf(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Mf(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Mf(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Mf(`Request ID:`)}${n.requestId}\n`)}zf(e),process.stderr.write(`${Mf(`Exit code:`)}${e.exitCode}\n`)}function Vf(e){if(e instanceof t&&(Ff()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
343
- `):Bf(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Vf(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
387
+ `)}function Dm(e){return e.exitCode===i.AUTH?e.message===n?e.hint:[e.hint,``,`bl auth login --api-key <your-key>`,`bl auth status`,`Get API Key: ${Tt}`].filter(e=>e!==void 0).join(`
388
+ `):e.hint}function Om(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 h(e[n+1]||t);if(r?.startsWith(`--output=`))return h(r.slice(9))}return h(t)}function km(e){let n=e.cause,r=n?.code,a=n?.message,o=[];return r&&o.push(r),a&&a!==r&&o.push(a),new t(`Network request failed: ${o.length>0?o.join(`: `):`unknown cause`}`,i.NETWORK,Am(r),{cause:e})}function Am(e){switch(e){case`ENOTFOUND`:case`EAI_AGAIN`:return`DNS resolution failed. Check DASHSCOPE_BASE_URL or your DNS / network.`;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.
389
+ If you are behind a VPN or corporate proxy, route bl through it:
390
+ export HTTPS_PROXY=http://127.0.0.1:<proxy-port>`;case`ETIMEDOUT`:return`Connection timed out. Check your network or try a different region.`;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 connection, proxy settings (HTTP_PROXY / HTTPS_PROXY), and DASHSCOPE_BASE_URL.`}}function jm(e){let n=e.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 t(`File system error: ${e.message}`,i.GENERAL,r,{cause:e})}function Mm(e){let t=e.cause,n=0;for(;t instanceof Error&&n<5;)process.stderr.write(`${Tm(`Caused by:`)}${t.message}\n`),t=t.cause,n++}function Nm(e){process.stderr.write(`\n${Tm(`Error:`)}${e.message}\n`);let t=Dm(e);t&&process.stderr.write(`${Tm(`Hint:`)}${Em(t)}\n`);let n=e.api;if(n){if(n.httpStatus!==void 0){let e=n.apiCode?` (${n.apiCode})`:``;process.stderr.write(`${Tm(`Status:`)}HTTP ${n.httpStatus}${e}\n`)}else n.apiCode&&process.stderr.write(`${Tm(`Code:`)}${n.apiCode}\n`);n.requestId&&process.stderr.write(`${Tm(`Request ID:`)}${n.requestId}\n`)}Mm(e),process.stderr.write(`${Tm(`Exit code:`)}${e.exitCode}\n`)}function Pm(e){if(e instanceof t&&(Om()===`json`?process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
391
+ `):Nm(e),process.exit(e.exitCode)),e instanceof Error){if(e.name===`AbortError`||e.name===`TimeoutError`||e.message.includes(`timed out`))return Pm(new t(`Request timed out.`,i.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
344
392
  If this happens on every request with a valid API key, you may be hitting the wrong region.
345
393
  Run: bl auth status — to check your credentials and region.
346
- Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Vf(If(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Vf(Rf(e));process.stderr.write(`\n${Mf(`Error:`)}${e.message}\n`),zf(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Mf(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Hf=`\x1B[0m`,Uf=`\x1B[2m`;function Wf(e){return e.startsWith(nt())?e.replace(nt(),`~`):e}function Gf(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Wf(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} · ${n.method}`:e.apiKey?`flag · api-key`:`config`,o=D(t);process.stderr.write(`BAILIAN${Hf} ${Uf}${r}${Hf} ${Uf}|${Hf} ${Uf}Region:${Hf} ${i}${Hf} ${Uf}|${Hf} ${Uf}Auth:${Hf} ${o}${Hf} ${Uf}${a}${Hf}\n`)}Ao(),eo(),Ot(),Va(),Ft(),jt((e,t)=>{let n=process.argv.slice(2),r=n.indexOf(`--region`),i=r>=0&&n[r+1]||process.env.DASHSCOPE_REGION||le().region||`cn`;jf.printHelp(e,t,i)}),process.on(`SIGINT`,()=>{process.stderr.write(`
394
+ Run: bl config set --key region --value cn — to override the region.`,{cause:e}));if(e instanceof TypeError&&e.message===`fetch failed`)return Pm(km(e));let n=e.code;if(typeof n==`string`&&n.startsWith(`E`))return Pm(jm(e));process.stderr.write(`\n${Tm(`Error:`)}${e.message}\n`),Mm(e),process.env.DASHSCOPE_VERBOSE===`1`&&process.stderr.write(`${e.stack}\n`)}else process.stderr.write(`\n${Tm(`Error:`)}${String(e)}\n`);process.exit(i.GENERAL)}const Fm=`\x1B[0m`,Im=`\x1B[2m`;function Lm(e){return e.startsWith(at())?e.replace(at(),`~`):e}function Rm(e,t,n){if(e.quiet||!process.stderr.isTTY)return;let r=e.configPath?Lm(e.configPath):`~/.bailian/config.json`,i=e.fileRegion?`${e.fileRegion} (file)`:`cn (default)`,a=n?`${n.source} · ${n.method}`:e.apiKey?`flag · api-key`:`config`,o=O(t);process.stderr.write(`BAILIAN${Fm} ${Im}${r}${Fm} ${Im}|${Fm} ${Im}Region:${Fm} ${i}${Fm} ${Im}|${Fm} ${Im}Auth:${Fm} ${o}${Fm} ${Im}${a}${Fm}\n`)}zo(),oo(),jt(),qa(),Rt();try{wm()}catch(e){Pm(e)}Pt((e,t)=>{xm.printHelp(e,t)}),process.on(`SIGINT`,()=>{process.stderr.write(`
347
395
  Interrupted. Exiting.
348
- `),g(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const Kf=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`pipeline`,`run`],[`pipeline`,`validate`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`],[`mcp`,`list`],[`mcp`,`tools`],[`mcp`,`call`]];async function qf(){let e=process.argv.slice(2);e[0]===`--`&&(e=e.slice(1)),(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Ba}\n`),process.exit(0));let t=vt(e,a);if(e.includes(`--help`)||e.includes(`-h`)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||le().region||`cn`;jf.printHelp(t,process.stderr,r),process.exit(0)}if(t.length===0){jf.printHelp([],process.stderr);let t=ee(yt(e,a));t.clientName=`bailian-cli`,t.clientVersion=Ba,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?Et():Tt(),process.exit(0)}if(jf.isGroupPath(t)){let n=e.indexOf(`--region`),r=n>=0&&e[n+1]||process.env.DASHSCOPE_REGION||le().region||`cn`;jf.printHelp(t,process.stderr,r),process.exit(0)}let{command:n,extra:r}=jf.resolve(t),i=yt(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=ee(i);if(o.clientName=`bailian-cli`,o.clientVersion=Ba,!Kf.some(e=>e.every((e,n)=>t[n]===e))){await ko(o);try{let e=await k(o);Gf(o,e.token,e)}catch{}}let s=qa(Ba).catch(()=>{});kt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(Mt(process.stderr),process.exit(0)),await xe(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=Ka();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Ba} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await g(1e3)}qf().catch(e=>{g(1e3).finally(()=>Vf(e))});export{};
396
+ `),_(500).finally(()=>process.exit(130))}),process.stdout.on(`error`,e=>{if(e.code===`EPIPE`)process.exit(0);else throw e});const zm=[[`auth`,`login`],[`auth`,`logout`],[`config`,`show`],[`config`,`set`],[`config`,`export-schema`],[`update`],[`knowledge`,`retrieve`],[`pipeline`,`run`],[`pipeline`,`validate`],[`model`,`list`],[`app`,`list`],[`console`,`call`],[`usage`,`free`],[`usage`,`freetier`],[`usage`,`stats`],[`mcp`,`list`],[`mcp`,`tools`],[`mcp`,`call`],[`workspace`,`list`],[`quota`,`list`],[`quota`,`request`],[`quota`,`history`],[`quota`,`check`]];async function Bm(){let e=process.argv.slice(2);e[0]===`--`&&(e=e.slice(1)),(e.includes(`--version`)||e.includes(`-v`))&&(process.stdout.write(`bl ${Ka}\n`),process.exit(0));let t=xt(e,a);if((e.includes(`--help`)||e.includes(`-h`))&&(xm.printHelp(t,process.stderr),process.exit(0)),t.length===0){xm.printHelp([],process.stderr);let t=te(St(e,a));t.clientName=`bailian-cli`,t.clientVersion=Ka,t.apiKey||t.fileApiKey||t.fileAccessToken||t.accessTokenEnv?kt():Ot(),process.exit(0)}xm.isGroupPath(t)&&(xm.printHelp(t,process.stderr),process.exit(0));let{command:n,extra:r}=xm.resolve(t),i=St(e,[...a,...n.options??[]]);r.length>0&&(i._positional=r);let o=te(i);if(o.clientName=`bailian-cli`,o.clientVersion=Ka,!zm.some(e=>e.every((e,n)=>t[n]===e))){await Ro(o);try{let e=await A(o);Rm(o,e.token,e)}catch{}}let s=$a(Ka).catch(()=>{});Mt(t),t[0]===`auth`&&t[1]===`login`&&!i.console&&!String(i.apiKey??``).trim()&&!String(o.apiKey??``).trim()&&!process.env.DASHSCOPE_API_KEY?.trim()&&(Ft(process.stderr),process.exit(0)),await Se(o,t,i,()=>n.execute(o,i)),await s;let c=t.length===1&&t[0]===`update`,l=Qa();if(l&&!o.quiet&&!c){let e=process.stderr.isTTY,t=e?`\x1B[33m`:``,n=e?`\x1B[36m`:``,r=e?`\x1B[0m`:``;process.stderr.write(`\n ${t}Update available: ${Ka} → ${l}${r}\n`),process.stderr.write(` Run ${n}bl update${r} to upgrade\n\n`)}await _(1e3)}Bm().catch(e=>{_(1e3).finally(()=>Pm(e))});export{};