@earlyai/cli 2.18.3 → 2.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
17
17
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
18
18
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let o=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function l(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=l(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=l(d,`${n}-${e._name}`))}u=t||u}o=s.includes(r.extname(u));let f;a.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.execPath,t,{stdio:`inherit`})):o?(t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{a.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new c(e,`commander.executeSubCommandAsync`,`(close)`)):a.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)a.exit(1);else{let e=new c(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
19
19
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in a.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,a.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new f(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=p(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=p(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>s(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=r.basename(e,r.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(a.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
20
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:te,createCommand:ne,createArgument:j,createOption:re,CommanderError:M,InvalidArgumentError:N,InvalidOptionArgumentError:P,Command:F,Argument:ie,Option:ae,Help:I}=u(s((e=>{let{Argument:t}=D(),{Command:n}=ee(),{CommanderError:r,InvalidArgumentError:i}=E(),{Help:a}=O(),{Option:o}=k();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var L=`2.18.3`,oe=s((e=>{let t=e=>e!=null,n=e=>typeof e==`object`&&!!e,r=e=>Array.isArray(e),i=e=>e instanceof Map,a=e=>e instanceof Set,o=e=>e instanceof Date,s=e=>typeof e==`number`,c=e=>typeof e==`string`,l=e=>typeof e==`boolean`,u=e=>e instanceof Error,d=e=>t(e)?c(e)||r(e)?e.length===0:i(e)||a(e)?e.size===0:o(e)?!1:n(e)?Object.keys(e).length===0:!1:!0,f=e=>u(e)?e.message:`error is not Instance of Error`,p=(e,t)=>{let n=new Set(e);for(let e of n)t.includes(e)||n.delete(e);return[...n]},m=async(e,t)=>{let n=await Promise.all(e.map(e=>t(e)));return e.filter((e,t)=>n[t])},h=(e,t)=>{let n=[];for(let r of e)n.some(e=>t(r,e))||n.push(r);return n},g=e=>[...new Set(e)],_=async e=>Promise.all(e.map(e=>new Promise((t,n)=>e().then(e=>e?t(e):n(e)).catch(e=>n(e))))).then(()=>!0).catch(e=>{if(!l(e))throw e;return e}),v=e=>e.trim().replaceAll(/([\da-z])([A-Z])/g,`$1-$2`).replaceAll(/([A-Z])([A-Z][\da-z])/g,`$1-$2`).replaceAll(/[\s_]+/g,`-`).toLowerCase(),y=e=>e.replaceAll(/[\s-]+/g,` `).split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),b=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n)??0;t=Math.trunc(t*31+r)}return t>>>0},x=(...e)=>{let n={};for(let r of e)for(let e in r)t(r[e])&&(n[e]=r[e]);return n},S=(e,t)=>r(e)?e.map(e=>S(e,t)):n(e)?Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)).map(([e,n])=>[e,S(n,t)])):e,C=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},w=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>{n=!1},t))}};var T=class{listeners=[];addListener(e){this.listeners.push(e)}notifyAll(e){for(let t of this.listeners)t(e)}clear(){this.listeners.length=0}},E=class{set=new Set;constructor(e=[]){for(let t of e)this.safeAdd(t)}safeAdd(e){return t(e)?(this.set.add(e),!0):!1}has(e){return t(e)?this.set.has(e):!1}delete(e){return t(e)?this.set.delete(e):!1}clear(){this.set.clear()}get size(){return this.set.size}values(){return this.set.values()}toSet(){return structuredClone(this.set)}[Symbol.iterator](){return this.set[Symbol.iterator]()}concatSet(e){for(let t of e)this.safeAdd(t)}};e.Observer=T,e.SafeSet=E,e.arePromiseFnsTruthy=_,e.debounce=C,e.fastHash=b,e.filterAsync=m,e.getErrorMessage=f,e.intersection=p,e.isArray=r,e.isBoolean=l,e.isDate=o,e.isDefined=t,e.isEmpty=d,e.isError=u,e.isMap=i,e.isNumber=s,e.isObject=n,e.isSet=a,e.isString=c,e.merge=x,e.removeNestedField=S,e.throttle=w,e.toCamelCase=y,e.toKebabCase=v,e.uniq=g,e.uniqWith=h})),R=oe();function z(e,t,n,{key:r=``,prefix:i=`EARLY`,parser:a,def:o,isRequired:s=!1,envName:c}={}){let l=new ae(t,n);a&&l.argParser(a),s&&l.makeOptionMandatory(!0);let u=c??(()=>{let n=[];for(let t=e;t&&(0,R.isDefined)(t.name());t=t.parent)t.parent&&n.unshift(t.name());return[i,...n,r||t.split(/[ ,|]/)[1].replace(/^--?/,``)].join(`_`).replaceAll(/[- ]/g,`_`).toUpperCase()})();return l.env(u),(0,R.isDefined)(o)&&l.default(o),e.addOption(l),l}function se(e){return(typeof e==`object`&&!!e||typeof e==`function`)&&typeof e.then==`function`}function ce(e){switch(typeof e){case`string`:case`symbol`:return e.toString();case`function`:return e.name;default:throw Error(`Unexpected ${typeof e} service id type`)}}const le=Symbol.for(`@inversifyjs/common/islazyServiceIdentifier`);var ue=class{[le];#e;constructor(e){this.#e=e,this[le]=!0}static is(e){return typeof e==`object`&&!!e&&!0===e[le]}unwrap(){return this.#e()}};function de(e,t,n){return Reflect.getOwnMetadata(t,e,n)}function fe(e,t,n,r){Reflect.defineMetadata(t,n,e,r)}function pe(e,t,n,r,i){let a=r(de(e,t,i)??n());Reflect.defineMetadata(t,a,e,i)}function me(e){return Object.getPrototypeOf(e.prototype)?.constructor}const he=`@inversifyjs/container/bindingId`;function ge(){let e=de(Object,he)??0;return e===2**53-1?fe(Object,he,-(2**53-1)):pe(Object,he,()=>e,e=>e+1),e}const _e={Request:`Request`,Singleton:`Singleton`,Transient:`Transient`},ve={ConstantValue:`ConstantValue`,DynamicValue:`DynamicValue`,Factory:`Factory`,Instance:`Instance`,Provider:`Provider`,ResolvedValue:`ResolvedValue`,ServiceRedirection:`ServiceRedirection`};function*ye(...e){for(let t of e)yield*t}var be=class e{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(let t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#a(e).push(t);for(let n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){let e=this.#r(),t=this.#i(),n=Reflect.ownKeys(this.#n),r=this._buildNewInstance(this.#n);this.#u(this.#e,r.#e,e,t);for(let t of n)this.#l(this.#t[t],r.#t[t],e);return r}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){let n=this.get(e,t);if(n===void 0)return;let r=new Set(n);for(let n of r){let r=this.#e.get(n);if(r===void 0)throw Error(`Expecting model relation, none found`);for(let i of r)i[e]===t&&this.#d(n,i);this.#e.delete(n)}}_buildNewInstance(t){return new e(t)}_cloneModel(e){return e}_cloneRelation(e){return e}#r(){let e=new Map;for(let t of this.#e.keys()){let n=this._cloneModel(t);e.set(t,n)}return e}#i(){let e=new Map;for(let t of this.#e.values())for(let n of t){let t=this._cloneRelation(n);e.set(n,t)}return e}#a(e){let t=this.#e.get(e);return t===void 0&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return n===void 0&&(n=[],this.#t[e].set(t,n)),n}#s(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting model to be cloned, none found`);return n}#c(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting relation to be cloned, none found`);return n}#l(e,t,n){for(let[r,i]of e){let e=[];for(let t of i)e.push(this.#s(t,n));t.set(r,e)}}#u(e,t,n,r){for(let[i,a]of e){let e=[];for(let t of a)e.push(this.#c(t,r));t.set(this.#s(i,n),e)}}#d(e,t){for(let n of Reflect.ownKeys(t))this.#f(e,n,t[n])}#f(e,t,n){let r=this.#t[t].get(n);if(r!==void 0){let i=r.indexOf(e);i!==-1&&r.splice(i,1),r.length===0&&this.#t[t].delete(n)}}},xe;(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(xe||={});var Se=class e{#e;#t;constructor(e,t){this.#e=t??new be({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(xe.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return ye(...t)}removeAllByModuleId(e){this.#e.removeByRelation(xe.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(xe.serviceId,e)}};const Ce=`@inversifyjs/core/classMetadataReflectKey`;function we(){return{constructorArguments:[],lifecycle:{postConstructMethodNames:new Set,preDestroyMethodNames:new Set},properties:new Map,scope:void 0}}const Te=`@inversifyjs/core/pendingClassMetadataCountReflectKey`,Ee=Symbol.for(`@inversifyjs/core/InversifyCoreError`);var De=class e extends Error{[Ee];kind;constructor(e,t,n){super(t,n),this[Ee]=!0,this.kind=e}static is(e){return typeof e==`object`&&!!e&&!0===e[Ee]}static isErrorOfKind(t,n){return e.is(t)&&t.kind===n}},Oe,ke,Ae,je,Me;function Ne(e){let t=de(e,Ce)??we();if(!function(e){let t=de(e,Te);return t!==void 0&&t!==0}(e))return function(e,t){let n=[];if(t.length<e.length)throw new De(Oe.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)t[e]===void 0&&n.push(e);if(n.length>0)throw new De(Oe.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join(`", "`)}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(e,t.constructorArguments),t;(function(e,t){let n=[];for(let r=0;r<t.constructorArguments.length;++r){let i=t.constructorArguments[r];i!==void 0&&i.kind!==ke.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${r.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(let[r,i]of t.properties)i.kind===ke.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${r.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);throw n.length===0?new De(Oe.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`):new De(Oe.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join(`
|
|
20
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g}));const{program:te,createCommand:ne,createArgument:j,createOption:re,CommanderError:M,InvalidArgumentError:N,InvalidOptionArgumentError:P,Command:F,Argument:ie,Option:ae,Help:I}=u(s((e=>{let{Argument:t}=D(),{Command:n}=ee(),{CommanderError:r,InvalidArgumentError:i}=E(),{Help:a}=O(),{Option:o}=k();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var L=`2.18.5`,oe=s((e=>{let t=e=>e!=null,n=e=>typeof e==`object`&&!!e,r=e=>Array.isArray(e),i=e=>e instanceof Map,a=e=>e instanceof Set,o=e=>e instanceof Date,s=e=>typeof e==`number`,c=e=>typeof e==`string`,l=e=>typeof e==`boolean`,u=e=>e instanceof Error,d=e=>t(e)?c(e)||r(e)?e.length===0:i(e)||a(e)?e.size===0:o(e)?!1:n(e)?Object.keys(e).length===0:!1:!0,f=e=>u(e)?e.message:`error is not Instance of Error`,p=(e,t)=>{let n=new Set(e);for(let e of n)t.includes(e)||n.delete(e);return[...n]},m=async(e,t)=>{let n=await Promise.all(e.map(e=>t(e)));return e.filter((e,t)=>n[t])},h=(e,t)=>{let n=[];for(let r of e)n.some(e=>t(r,e))||n.push(r);return n},g=e=>[...new Set(e)],_=async e=>Promise.all(e.map(e=>new Promise((t,n)=>e().then(e=>e?t(e):n(e)).catch(e=>n(e))))).then(()=>!0).catch(e=>{if(!l(e))throw e;return e}),v=e=>e.trim().replaceAll(/([\da-z])([A-Z])/g,`$1-$2`).replaceAll(/([A-Z])([A-Z][\da-z])/g,`$1-$2`).replaceAll(/[\s_]+/g,`-`).toLowerCase(),y=e=>e.replaceAll(/[\s-]+/g,` `).split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``),b=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n)??0;t=Math.trunc(t*31+r)}return t>>>0},x=(...e)=>{let n={};for(let r of e)for(let e in r)t(r[e])&&(n[e]=r[e]);return n},S=(e,t)=>r(e)?e.map(e=>S(e,t)):n(e)?Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)).map(([e,n])=>[e,S(n,t)])):e,C=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},w=(e,t)=>{let n=!1;return(...r)=>{n||(e(...r),n=!0,setTimeout(()=>{n=!1},t))}};var T=class{listeners=[];addListener(e){this.listeners.push(e)}notifyAll(e){for(let t of this.listeners)t(e)}clear(){this.listeners.length=0}},E=class{set=new Set;constructor(e=[]){for(let t of e)this.safeAdd(t)}safeAdd(e){return t(e)?(this.set.add(e),!0):!1}has(e){return t(e)?this.set.has(e):!1}delete(e){return t(e)?this.set.delete(e):!1}clear(){this.set.clear()}get size(){return this.set.size}values(){return this.set.values()}toSet(){return structuredClone(this.set)}[Symbol.iterator](){return this.set[Symbol.iterator]()}concatSet(e){for(let t of e)this.safeAdd(t)}};e.Observer=T,e.SafeSet=E,e.arePromiseFnsTruthy=_,e.debounce=C,e.fastHash=b,e.filterAsync=m,e.getErrorMessage=f,e.intersection=p,e.isArray=r,e.isBoolean=l,e.isDate=o,e.isDefined=t,e.isEmpty=d,e.isError=u,e.isMap=i,e.isNumber=s,e.isObject=n,e.isSet=a,e.isString=c,e.merge=x,e.removeNestedField=S,e.throttle=w,e.toCamelCase=y,e.toKebabCase=v,e.uniq=g,e.uniqWith=h})),R=oe();function z(e,t,n,{key:r=``,prefix:i=`EARLY`,parser:a,def:o,isRequired:s=!1,envName:c}={}){let l=new ae(t,n);a&&l.argParser(a),s&&l.makeOptionMandatory(!0);let u=c??(()=>{let n=[];for(let t=e;t&&(0,R.isDefined)(t.name());t=t.parent)t.parent&&n.unshift(t.name());return[i,...n,r||t.split(/[ ,|]/)[1].replace(/^--?/,``)].join(`_`).replaceAll(/[- ]/g,`_`).toUpperCase()})();return l.env(u),(0,R.isDefined)(o)&&l.default(o),e.addOption(l),l}function se(e){return(typeof e==`object`&&!!e||typeof e==`function`)&&typeof e.then==`function`}function ce(e){switch(typeof e){case`string`:case`symbol`:return e.toString();case`function`:return e.name;default:throw Error(`Unexpected ${typeof e} service id type`)}}const le=Symbol.for(`@inversifyjs/common/islazyServiceIdentifier`);var ue=class{[le];#e;constructor(e){this.#e=e,this[le]=!0}static is(e){return typeof e==`object`&&!!e&&!0===e[le]}unwrap(){return this.#e()}};function de(e,t,n){return Reflect.getOwnMetadata(t,e,n)}function fe(e,t,n,r){Reflect.defineMetadata(t,n,e,r)}function pe(e,t,n,r,i){let a=r(de(e,t,i)??n());Reflect.defineMetadata(t,a,e,i)}function me(e){return Object.getPrototypeOf(e.prototype)?.constructor}const he=`@inversifyjs/container/bindingId`;function ge(){let e=de(Object,he)??0;return e===2**53-1?fe(Object,he,-(2**53-1)):pe(Object,he,()=>e,e=>e+1),e}const _e={Request:`Request`,Singleton:`Singleton`,Transient:`Transient`},ve={ConstantValue:`ConstantValue`,DynamicValue:`DynamicValue`,Factory:`Factory`,Instance:`Instance`,Provider:`Provider`,ResolvedValue:`ResolvedValue`,ServiceRedirection:`ServiceRedirection`};function*ye(...e){for(let t of e)yield*t}var be=class e{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(let t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#a(e).push(t);for(let n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){let e=this.#r(),t=this.#i(),n=Reflect.ownKeys(this.#n),r=this._buildNewInstance(this.#n);this.#u(this.#e,r.#e,e,t);for(let t of n)this.#l(this.#t[t],r.#t[t],e);return r}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){let n=this.get(e,t);if(n===void 0)return;let r=new Set(n);for(let n of r){let r=this.#e.get(n);if(r===void 0)throw Error(`Expecting model relation, none found`);for(let i of r)i[e]===t&&this.#d(n,i);this.#e.delete(n)}}_buildNewInstance(t){return new e(t)}_cloneModel(e){return e}_cloneRelation(e){return e}#r(){let e=new Map;for(let t of this.#e.keys()){let n=this._cloneModel(t);e.set(t,n)}return e}#i(){let e=new Map;for(let t of this.#e.values())for(let n of t){let t=this._cloneRelation(n);e.set(n,t)}return e}#a(e){let t=this.#e.get(e);return t===void 0&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return n===void 0&&(n=[],this.#t[e].set(t,n)),n}#s(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting model to be cloned, none found`);return n}#c(e,t){let n=t.get(e);if(n===void 0)throw Error(`Expecting relation to be cloned, none found`);return n}#l(e,t,n){for(let[r,i]of e){let e=[];for(let t of i)e.push(this.#s(t,n));t.set(r,e)}}#u(e,t,n,r){for(let[i,a]of e){let e=[];for(let t of a)e.push(this.#c(t,r));t.set(this.#s(i,n),e)}}#d(e,t){for(let n of Reflect.ownKeys(t))this.#f(e,n,t[n])}#f(e,t,n){let r=this.#t[t].get(n);if(r!==void 0){let i=r.indexOf(e);i!==-1&&r.splice(i,1),r.length===0&&this.#t[t].delete(n)}}},xe;(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(xe||={});var Se=class e{#e;#t;constructor(e,t){this.#e=t??new be({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(xe.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return ye(...t)}removeAllByModuleId(e){this.#e.removeByRelation(xe.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(xe.serviceId,e)}};const Ce=`@inversifyjs/core/classMetadataReflectKey`;function we(){return{constructorArguments:[],lifecycle:{postConstructMethodNames:new Set,preDestroyMethodNames:new Set},properties:new Map,scope:void 0}}const Te=`@inversifyjs/core/pendingClassMetadataCountReflectKey`,Ee=Symbol.for(`@inversifyjs/core/InversifyCoreError`);var De=class e extends Error{[Ee];kind;constructor(e,t,n){super(t,n),this[Ee]=!0,this.kind=e}static is(e){return typeof e==`object`&&!!e&&!0===e[Ee]}static isErrorOfKind(t,n){return e.is(t)&&t.kind===n}},Oe,ke,Ae,je,Me;function Ne(e){let t=de(e,Ce)??we();if(!function(e){let t=de(e,Te);return t!==void 0&&t!==0}(e))return function(e,t){let n=[];if(t.length<e.length)throw new De(Oe.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)t[e]===void 0&&n.push(e);if(n.length>0)throw new De(Oe.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join(`", "`)}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(e,t.constructorArguments),t;(function(e,t){let n=[];for(let r=0;r<t.constructorArguments.length;++r){let i=t.constructorArguments[r];i!==void 0&&i.kind!==ke.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${r.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(let[r,i]of t.properties)i.kind===ke.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${r.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);throw n.length===0?new De(Oe.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`):new De(Oe.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join(`
|
|
21
21
|
|
|
22
22
|
`)}`)})(e,t)}function Pe(e,t){let n=Ne(t).scope??e.scope;return{cache:{isRight:!1,value:void 0},id:ge(),implementationType:t,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:n,serviceIdentifier:t,type:ve.Instance}}function Fe(e){return e.isRight?{isRight:!0,value:e.value}:e}function Ie(e){switch(e.type){case ve.ConstantValue:case ve.DynamicValue:return function(e){return{cache:Fe(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type,value:e.value}}(e);case ve.Factory:return function(e){return{cache:Fe(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case ve.Instance:return function(e){return{cache:Fe(e.cache),id:e.id,implementationType:e.implementationType,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case ve.Provider:return function(e){return{cache:Fe(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,provider:e.provider,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case ve.ResolvedValue:return function(e){return{cache:Fe(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,metadata:e.metadata,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case ve.ServiceRedirection:return function(e){return{id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,serviceIdentifier:e.serviceIdentifier,targetServiceIdentifier:e.targetServiceIdentifier,type:e.type}}(e)}}(function(e){e[e.injectionDecoratorConflict=0]=`injectionDecoratorConflict`,e[e.missingInjectionDecorator=1]=`missingInjectionDecorator`,e[e.planning=2]=`planning`,e[e.resolution=3]=`resolution`,e[e.unknown=4]=`unknown`})(Oe||={}),function(e){e[e.unknown=32]=`unknown`}(ke||={}),function(e){e.id=`id`,e.moduleId=`moduleId`,e.serviceId=`serviceId`}(Ae||={});var Le=class e extends be{_buildNewInstance(t){return new e(t)}_cloneModel(e){return Ie(e)}},Re=class e{#e;#t;#n;constructor(e,t,n){this.#t=n??new Le({id:{isOptional:!1},moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#n=e,this.#e=t}static build(t,n){return new e(t,n)}clone(){return new e(this.#n,this.#e,this.#t.clone())}get(e){let t=this.getNonParentBindings(e)??this.#n()?.get(e);if(t!==void 0)return t;let n=this.#r(e);return n===void 0?n:[n]}*getChained(e){let t=this.getNonParentBindings(e);t!==void 0&&(yield*t);let n=this.#n();if(n===void 0){if(t===void 0){let t=this.#r(e);t!==void 0&&(yield t)}}else yield*n.getChained(e)}getBoundServices(){let e=new Set(this.#t.getAllKeys(Ae.serviceId)),t=this.#n();if(t!==void 0)for(let n of t.getBoundServices())e.add(n);return e}getById(e){return this.#t.get(Ae.id,e)??this.#n()?.getById(e)}getByModuleId(e){return this.#t.get(Ae.moduleId,e)??this.#n()?.getByModuleId(e)}getNonParentBindings(e){return this.#t.get(Ae.serviceId,e)}getNonParentBoundServices(){return this.#t.getAllKeys(Ae.serviceId)}removeById(e){this.#t.removeByRelation(Ae.id,e)}removeAllByModuleId(e){this.#t.removeByRelation(Ae.moduleId,e)}removeAllByServiceId(e){this.#t.removeByRelation(Ae.serviceId,e)}set(e){let t={[Ae.id]:e.id,[Ae.serviceId]:e.serviceIdentifier};e.moduleId!==void 0&&(t[Ae.moduleId]=e.moduleId),this.#t.add(e,t)}#r(e){if(this.#e===void 0||typeof e!=`function`)return;let t=Pe(this.#e,e);return this.set(t),t}};(function(e){e.moduleId=`moduleId`,e.serviceId=`serviceId`})(je||={});var ze=class e{#e;#t;constructor(e,t){this.#e=t??new be({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(t){return new e(t)}add(e,t){this.#e.add(e,t)}clone(){return new e(this.#t,this.#e.clone())}get(e){let t=[],n=this.#e.get(je.serviceId,e);n!==void 0&&t.push(n);let r=this.#t()?.get(e);if(r!==void 0&&t.push(r),t.length!==0)return ye(...t)}removeAllByModuleId(e){this.#e.removeByRelation(je.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(je.serviceId,e)}};function Be(){return 0}function Ve(e){return t=>{t!==void 0&&t.kind===ke.unknown&&pe(e,Te,Be,e=>e-1)}}function He(e,t){return(...n)=>r=>{if(r===void 0)return e(...n);if(r.kind===Me.unmanaged)throw new De(Oe.injectionDecoratorConflict,`Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found`);return t(r,...n)}}function Ue(e){if(e.kind!==ke.unknown&&!0!==e.isFromTypescriptParamType)throw new De(Oe.injectionDecoratorConflict,`Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found`)}(function(e){e[e.multipleInjection=0]=`multipleInjection`,e[e.singleInjection=1]=`singleInjection`,e[e.unmanaged=2]=`unmanaged`})(Me||={});const B=He(function(e,t,n){return e===Me.multipleInjection?{chained:n?.chained??!1,kind:e,name:void 0,optional:!1,tags:new Map,value:t}:{kind:e,name:void 0,optional:!1,tags:new Map,value:t}},function(e,t,n,r){return Ue(e),t===Me.multipleInjection?{...e,chained:r?.chained??!1,kind:t,value:n}:{...e,kind:t,value:n}});function We(e,t){return n=>{let r=n.properties.get(t);return n.properties.set(t,e(r)),n}}var Ge;function Ke(e,t,n,r){if(De.isErrorOfKind(r,Oe.injectionDecoratorConflict)){let i=function(e,t,n){if(n===void 0){if(t===void 0)throw new De(Oe.unknown,`Unexpected undefined property and index values`);return{kind:Ge.property,property:t,targetClass:e.constructor}}return typeof n==`number`?{index:n,kind:Ge.parameter,targetClass:e}:{kind:Ge.method,method:t,targetClass:e}}(e,t,n);throw new De(Oe.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${r.message}\n\nDetails\n\n${function(e){switch(e.kind){case Ge.method:return`[class: "${e.targetClass.name}", method: "${e.method.toString()}"]`;case Ge.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case Ge.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:r})}throw r}function qe(e,t){return(n,r,i)=>{try{i===void 0?function(e,t){let n=Je(e,t);return(e,t)=>{pe(e.constructor,Ce,we,We(n(e),t))}}(e,t)(n,r):typeof i==`number`?function(e,t){let n=Je(e,t);return(e,t,r)=>{if(!function(e,t){return typeof e==`function`&&t===void 0}(e,t))throw new De(Oe.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${t?.toString()??``}" at class "${e.constructor.name}"`);pe(e,Ce,we,function(e,t){return n=>{let r=n.constructorArguments[t];return n.constructorArguments[t]=e(r),n}}(n(e),r))}}(e,t)(n,r,i):function(e,t){let n=Je(e,t);return(e,t,r)=>{if(!function(e){return e.set!==void 0}(r))throw new De(Oe.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${t.toString()}" at class "${e.constructor.name}"`);pe(e.constructor,Ce,we,We(n(e),t))}}(e,t)(n,r,i)}catch(e){Ke(n,r,i,e)}}}function Je(e,t){return n=>{let r=t(n);return t=>(r(t),e(t))}}function Ye(e){return qe(B(Me.singleInjection,e),Ve)}(function(e){e[e.method=0]=`method`,e[e.parameter=1]=`parameter`,e[e.property=2]=`property`})(Ge||={});const Xe=`@inversifyjs/core/classIsInjectableFlagReflectKey`,Ze=[Array,BigInt,Boolean,Function,Number,Object,String];function Qe(e){let t=de(e,`design:paramtypes`);t!==void 0&&pe(e,Ce,we,function(e){return t=>(e.forEach((e,n)=>{var r;t.constructorArguments[n]!==void 0||(r=e,Ze.includes(r))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:Me.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))}),t)}(t))}function $e(e){return t=>{(function(e){if(de(e,Xe)!==void 0)throw new De(Oe.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${e.name}"`);fe(e,Xe,!0)})(t),Qe(t),e!==void 0&&pe(t,Ce,we,t=>({...t,scope:e}))}}function et(e,t,n){let r;return e.extendConstructorArguments??!0?(r=[...t.constructorArguments],n.constructorArguments.map((e,t)=>{r[t]=e})):r=n.constructorArguments,r}function tt(e,t,n){return e?new Set([...t,...n]):n}function nt(e,t,n){let r=e.lifecycle?.extendPostConstructMethods??!0,i=tt(e.lifecycle?.extendPreDestroyMethods??!0,t.lifecycle.preDestroyMethodNames,n.lifecycle.preDestroyMethodNames);return{postConstructMethodNames:tt(r,t.lifecycle.postConstructMethodNames,n.lifecycle.postConstructMethodNames),preDestroyMethodNames:i}}function rt(e,t,n){let r;return r=e.extendProperties??!0?new Map(ye(t.properties,n.properties)):n.properties,r}function it(e){return t=>{pe(t,Ce,we,function(e,t){return n=>({constructorArguments:et(e,t,n),lifecycle:nt(e,t,n),properties:rt(e,t,n),scope:n.scope})}(e,Ne(e.type)))}}function at(e){return t=>{let n=me(t);if(n===void 0)throw new De(Oe.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);it({...e,type:n})(t)}}function ot(e){return t=>{let n=[],r=me(t);for(;r!==void 0&&r!==Object;){let e=r;n.push(e),r=me(e)}n.reverse();for(let r of n)it({...e,type:r})(t)}}function st(e){return t=>{t===void 0&&pe(e,Te,Be,e=>e+1)}}function ct(e){return t=>{let n=t??{kind:ke.unknown,name:void 0,optional:!1,tags:new Map};if(n.kind===Me.unmanaged)throw new De(Oe.injectionDecoratorConflict,`Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections`);return e(n)}}function lt(e){if(e.optional)throw new De(Oe.injectionDecoratorConflict,`Unexpected duplicated optional decorator`);return e.optional=!0,e}function V(){return qe(ct(lt),st)}var ut;function dt(e){return e instanceof Error?e instanceof RangeError&&/stack space|call stack|too much recursion/i.test(e.message)||e.name===`InternalError`&&/too much recursion/.test(e.message):!1}function ft(e,t){if(dt(t)){let n=function(e){let t=[...e];return t.length===0?`(No dependency trace)`:t.map(ce).join(` -> `)}(function(e){let t=new Set;for(let n of e.servicesBranch){if(t.has(n))return[...t,n];t.add(n)}return[...t]}(e));throw new De(Oe.planning,`Circular dependency found: ${n}`,{cause:t})}throw t}(function(e){e[e.multipleInjection=0]=`multipleInjection`,e[e.singleInjection=1]=`singleInjection`})(ut||={});const pt=Symbol.for(`@inversifyjs/core/LazyPlanServiceNode`);var mt=class{[pt];_serviceIdentifier;_serviceNode;constructor(e,t){this[pt]=!0,this._serviceNode=e,this._serviceIdentifier=t}get bindings(){return this._getNode().bindings}get isContextFree(){return this._getNode().isContextFree}get serviceIdentifier(){return this._serviceIdentifier}set bindings(e){this._getNode().bindings=e}set isContextFree(e){this._getNode().isContextFree=e}static is(e){return typeof e==`object`&&!!e&&!0===e[pt]}invalidate(){this._serviceNode=void 0}isExpanded(){return this._serviceNode!==void 0}_getNode(){return this._serviceNode===void 0&&(this._serviceNode=this._buildPlanServiceNode()),this._serviceNode}},ht=class e{#e;constructor(e){this.#e=e}get name(){return this.#e.elem.name}get serviceIdentifier(){return this.#e.elem.serviceIdentifier}get tags(){return this.#e.elem.tags}getAncestor(){if(this.#e.elem.getAncestorsCalled=!0,this.#e.previous!==void 0)return new e(this.#e.previous)}};function gt(e,t,n){let r=n?.customServiceIdentifier??t.serviceIdentifier,i=(!0===n?.chained?[...e.operations.getBindingsChained(r)]:[...e.operations.getBindings(r)??[]]).filter(e=>e.isSatisfiedBy(t));if(i.length===0&&e.autobindOptions!==void 0&&typeof r==`function`){let n=Pe(e.autobindOptions,r);e.operations.setBinding(n),n.isSatisfiedBy(t)&&i.push(n)}return i}var _t=class e{last;constructor(e){this.last=e}concat(t){return new e({elem:t,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(e===void 0)return{done:!0,value:void 0};let t=e.elem;return e=e.previous,{done:!1,value:t}}}}};function vt(e){let t=new Map;return e.rootConstraints.tag!==void 0&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value),new _t({elem:{getAncestorsCalled:!1,name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0})}function yt(e){return e.redirections!==void 0}function bt(e,t,n,r){let i=n.elem.serviceIdentifier,a=n.previous?.elem.serviceIdentifier;Array.isArray(e)?function(e,t,n,r,i,a){if(e.length!==0){let t=`Ambiguous bindings found for service: "${ce(a[a.length-1]??n)}".${wt(a)}\n\nRegistered bindings:\n\n${e.map(e=>function(e){switch(e.type){case ve.Instance:return`[ type: "${e.type}", serviceIdentifier: "${ce(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case ve.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${ce(e.serviceIdentifier)}", redirection: "${ce(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${ce(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding)).join(`
|
|
23
23
|
`)}\n\nTrying to resolve bindings for "${St(n,r)}".${Ct(i)}`;throw new De(Oe.planning,t)}t||xt(n,r,i,a)}(e,t,i,a,n.elem,r):function(e,t,n,r,i,a){e!==void 0||t||xt(n,r,i,a)}(e,t,i,a,n.elem,r)}function xt(e,t,n,r){let i=`No bindings found for service: "${ce(r[r.length-1]??e)}".\n\nTrying to resolve bindings for "${St(e,t)}".${wt(r)}${Ct(n)}`;throw new De(Oe.planning,i)}function St(e,t){return t===void 0?`${ce(e)} (Root service)`:ce(t)}function Ct(e){let t=e.tags.size===0?``:`\n- tags:\n - ${[...e.tags.keys()].map(e=>e.toString()).join(`
|
|
@@ -32365,11 +32365,11 @@ https://www.w3ctech.com/topic/2226`));let i=t(...r);return i.postcssPlugin=e,i.p
|
|
|
32365
32365
|
`);let t=new x(`!xml`),n=t,r=``,i=``,a=new S(this.options.processEntities);for(let o=0;o<e.length;o++)if(e[o]===`<`)if(e[o+1]===`/`){let t=I(e,`>`,o,`Closing Tag is not closed.`),a=e.substring(o+2,t).trim();if(this.options.removeNSPrefix){let e=a.indexOf(`:`);e!==-1&&(a=a.substr(e+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&(r=this.saveTextToParentTag(r,n,i));let s=i.substring(i.lastIndexOf(`.`)+1);if(a&&this.options.unpairedTags.indexOf(a)!==-1)throw Error(`Unpaired tag can not be used as closing tag: </${a}>`);let c=0;s&&this.options.unpairedTags.indexOf(s)!==-1?(c=i.lastIndexOf(`.`,i.lastIndexOf(`.`)-1),this.tagsNodeStack.pop()):c=i.lastIndexOf(`.`),i=i.substring(0,c),n=this.tagsNodeStack.pop(),r=``,o=t}else if(e[o+1]===`?`){let t=L(e,o,!1,`?>`);if(!t)throw Error(`Pi Tag is not closed.`);if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&t.tagName===`?xml`||this.options.ignorePiTags)){let e=new x(t.tagName);e.add(this.options.textNodeName,``),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[`:@`]=this.buildAttributesMap(t.tagExp,i,t.tagName)),this.addChild(n,e,i,o)}o=t.closeIndex+1}else if(e.substr(o+1,3)===`!--`){let t=I(e,`-->`,o+4,`Comment is not closed.`);if(this.options.commentPropName){let a=e.substring(o+4,t-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}o=t}else if(e.substr(o+1,2)===`!D`){let t=a.readDocType(e,o);this.docTypeEntities=t.entities,o=t.i}else if(e.substr(o+1,2)===`![`){let t=I(e,`]]>`,o,`CDATA is not closed.`)-2,a=e.substring(o+9,t);r=this.saveTextToParentTag(r,n,i);let s=this.parseTextData(a,n.tagname,i,!0,!1,!0,!0);s??=``,this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):n.add(this.options.textNodeName,s),o=t+2}else{let a=L(e,o,this.options.removeNSPrefix),s=a.tagName,c=a.rawTagName,l=a.tagExp,u=a.attrExpPresent,d=a.closeIndex;this.options.transformTagName&&(s=this.options.transformTagName(s)),n&&r&&n.tagname!==`!xml`&&(r=this.saveTextToParentTag(r,n,i,!1));let f=n;f&&this.options.unpairedTags.indexOf(f.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf(`.`))),s!==t.tagname&&(i+=i?`.`+s:s);let p=o;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,i,s)){let t=``;if(l.length>0&&l.lastIndexOf(`/`)===l.length-1)s[s.length-1]===`/`?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),l=s):l=l.substr(0,l.length-1),o=a.closeIndex;else if(this.options.unpairedTags.indexOf(s)!==-1)o=a.closeIndex;else{let n=this.readStopNodeData(e,c,d+1);if(!n)throw Error(`Unexpected end of ${c}`);o=n.i,t=n.tagContent}let r=new x(s);s!==l&&u&&(r[`:@`]=this.buildAttributesMap(l,i,s)),t&&=this.parseTextData(t,s,i,!0,u,!0,!0),i=i.substr(0,i.lastIndexOf(`.`)),r.add(this.options.textNodeName,t),this.addChild(n,r,i,p)}else{if(l.length>0&&l.lastIndexOf(`/`)===l.length-1){s[s.length-1]===`/`?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),l=s):l=l.substr(0,l.length-1),this.options.transformTagName&&(s=this.options.transformTagName(s));let e=new x(s);s!==l&&u&&(e[`:@`]=this.buildAttributesMap(l,i,s)),this.addChild(n,e,i,p),i=i.substr(0,i.lastIndexOf(`.`))}else{let e=new x(s);this.tagsNodeStack.push(n),s!==l&&u&&(e[`:@`]=this.buildAttributesMap(l,i,s)),this.addChild(n,e,i,p),n=e}r=``,o=d}}else r+=e[o];return t.child};function P(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.updateTag(t.tagname,n,t[`:@`]);!1===i||(typeof i==`string`&&(t.tagname=i),e.addChild(t,r))}let F=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){let n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function ie(e,t,n,r){return e&&=(r===void 0&&(r=t.child.length===0),(e=this.parseTextData(e,t.tagname,n,!1,!!t[`:@`]&&Object.keys(t[`:@`]).length!==0,r))!==void 0&&e!==``&&t.add(this.options.textNodeName,e),``),e}function ae(e,t,n,r){return!(!t||!t.has(r))||!(!e||!e.has(n))}function I(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}function L(e,t,n,r=`>`){let i=function(e,t,n=`>`){let r,i=``;for(let a=t;a<e.length;a++){let t=e[a];if(r)t===r&&(r=``);else if(t===`"`||t===`'`)r=t;else if(t===n[0]){if(!n[1]||e[a+1]===n[1])return{data:i,index:a}}else t===` `&&(t=` `);i+=t}}(e,t+1,r);if(!i)return;let a=i.data,o=i.index,s=a.search(/\s/),c=a,l=!0;s!==-1&&(c=a.substring(0,s),a=a.substring(s+1).trimStart());let u=c;if(n){let e=c.indexOf(`:`);e!==-1&&(c=c.substr(e+1),l=c!==i.data.substr(e+1))}return{tagName:c,tagExp:a,closeIndex:o,attrExpPresent:l,rawTagName:u}}function oe(e,t,n){let r=n,i=1;for(;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`/`){let a=I(e,`>`,n,`${t} is not closed`);if(e.substring(n+2,a).trim()===t&&(i--,i===0))return{tagContent:e.substring(r,n),i:a};n=a}else if(e[n+1]===`?`)n=I(e,`?>`,n+1,`StopNode is not closed.`);else if(e.substr(n+1,3)===`!--`)n=I(e,`-->`,n+3,`StopNode is not closed.`);else if(e.substr(n+1,2)===`![`)n=I(e,`]]>`,n,`StopNode is not closed.`)-2;else{let r=L(e,n,`>`);r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!==`/`&&i++,n=r.closeIndex)}}function R(e,t,n){if(t&&typeof e==`string`){let t=e.trim();return t===`true`||t!==`false`&&function(e,t={}){if(t=Object.assign({},O,t),!e||typeof e!=`string`)return e;let n=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(n))return e;if(e===`0`)return 0;if(t.hex&&E.test(n))return function(e){if(parseInt)return parseInt(e,16);if(Number.parseInt)return Number.parseInt(e,16);if(window&&window.parseInt)return window.parseInt(e,16);throw Error(`parseInt, Number.parseInt, window.parseInt are not supported`)}(n);if(n.search(/.+[eE].+/)!==-1)return function(e,t,n){if(!n.eNotation)return e;let r=t.match(k);if(r){let i=r[1]||``,a=r[3].indexOf(`e`)===-1?`E`:`e`,o=r[2],s=i?e[o.length+1]===a:e[o.length]===a;return o.length>1&&s?e:o.length!==1||!r[3].startsWith(`.${a}`)&&r[3][0]!==a?n.leadingZeros&&!s?(t=(r[1]||``)+r[3],Number(t)):e:Number(t)}return e}(e,n,t);{let i=D.exec(n);if(i){let a=i[1]||``,o=i[2],s=((r=i[3])&&r.indexOf(`.`)!==-1&&((r=r.replace(/0+$/,``))===`.`?r=`0`:r[0]===`.`?r=`0`+r:r[r.length-1]===`.`&&(r=r.substring(0,r.length-1))),r),c=a?e[o.length+1]===`.`:e[o.length]===`.`;if(!t.leadingZeros&&(o.length>1||o.length===1&&!c))return e;{let r=Number(n),i=String(r);if(r===0||r===-0)return r;if(i.search(/[eE]/)!==-1)return t.eNotation?r:e;if(n.indexOf(`.`)!==-1)return i===`0`||i===s||i===`${a}${s}`?r:e;let c=o?s:n;return o?c===i||a+c===i?r:e:c===i||c===a+i?r:e}}return e}var r}(e,n)}return e===void 0?``:e}let z=x.getMetaDataSymbol();function se(e,t){return ce(e,t)}function ce(e,t,n){let r,i={};for(let a=0;a<e.length;a++){let o=e[a],s=le(o),c=``;if(c=n===void 0?s:n+`.`+s,s===t.textNodeName)r===void 0?r=o[s]:r+=``+o[s];else{if(s===void 0)continue;if(o[s]){let e=ce(o[s],t,c),n=de(e,t);o[z]!==void 0&&(e[z]=o[z]),o[`:@`]?ue(e,o[`:@`],c,t):Object.keys(e).length!==1||e[t.textNodeName]===void 0||t.alwaysCreateTextNode?Object.keys(e).length===0&&(t.alwaysCreateTextNode?e[t.textNodeName]=``:e=``):e=e[t.textNodeName],i[s]!==void 0&&i.hasOwnProperty(s)?(Array.isArray(i[s])||(i[s]=[i[s]]),i[s].push(e)):t.isArray(s,c,n)?i[s]=[e]:i[s]=e}}}return typeof r==`string`?r.length>0&&(i[t.textNodeName]=r):r!==void 0&&(i[t.textNodeName]=r),i}function le(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(n!==`:@`)return n}}function ue(e,t,n,r){if(t){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let a=i[o];r.isArray(a,n+`.`+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function de(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return r===0||!(r!==1||!e[n]&&typeof e[n]!=`boolean`&&e[n]!==0)}class fe{constructor(e){this.externalEntities={},this.options=function(e){return Object.assign({},y,e)}(e)}parse(e,t){if(typeof e!=`string`&&e.toString)e=e.toString();else if(typeof e!=`string`)throw Error(`XML data is accepted in String or Bytes[] form.`);if(t){!0===t&&(t={});let n=s(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new ee(this.options);n.addExternalEntities(this.externalEntities);let r=n.parseXml(e);return this.options.preserveOrder||r===void 0?r:se(r,this.options)}addEntity(e,t){if(t.indexOf(`&`)!==-1)throw Error(`Entity value can't have '&'`);if(e.indexOf(`&`)!==-1||e.indexOf(`;`)!==-1)throw Error(`An entity must be set without '&' and ';'. Eg. use '#xD' for '
'`);if(t===`&`)throw Error(`An entity with value '&' is not permitted`);this.externalEntities[e]=t}static getMetaDataSymbol(){return x.getMetaDataSymbol()}}function pe(e,t){let n=``;return t.format&&t.indentBy.length>0&&(n=`
|
|
32366
32366
|
`),me(e,t,``,n)}function me(e,t,n,r){let i=``,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=he(s);if(c===void 0)continue;let l=``;if(l=n.length===0?c:`${n}.${c}`,c===t.textNodeName){let e=s[c];_e(l,t)||(e=t.tagValueProcessor(c,e),e=ve(e,t)),a&&(i+=r),i+=e,a=!1;continue}if(c===t.cdataPropName){a&&(i+=r),i+=`<![CDATA[${s[c][0][t.textNodeName]}]]>`,a=!1;continue}if(c===t.commentPropName){i+=r+`\x3c!--${s[c][0][t.textNodeName]}--\x3e`,a=!0;continue}if(c[0]===`?`){let e=ge(s[`:@`],t),n=c===`?xml`?``:r,o=s[c][0][t.textNodeName];o=o.length===0?``:` `+o,i+=n+`<${c}${o}${e}?>`,a=!0;continue}let u=r;u!==``&&(u+=t.indentBy);let d=r+`<${c}${ge(s[`:@`],t)}`,f=me(s[c],t,l,u);t.unpairedTags.indexOf(c)===-1?f&&f.length!==0||!t.suppressEmptyNode?f&&f.endsWith(`>`)?i+=d+`>${f}${r}</${c}>`:(i+=d+`>`,f&&r!==``&&(f.includes(`/>`)||f.includes(`</`))?i+=r+t.indentBy+f+r:i+=f,i+=`</${c}>`):i+=d+`/>`:t.suppressUnpairedNode?i+=d+`>`:i+=d+`/>`,a=!0}return i}function he(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(e.hasOwnProperty(r)&&r!==`:@`)return r}}function ge(e,t){let n=``;if(e&&!t.ignoreAttributes)for(let r in e){if(!e.hasOwnProperty(r))continue;let i=t.attributeValueProcessor(r,e[r]);i=ve(i,t),!0===i&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${i}"`}return n}function _e(e,t){let n=(e=e.substr(0,e.length-t.textNodeName.length-1)).substr(e.lastIndexOf(`.`)+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]===`*.`+n)return!0;return!1}function ve(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}let ye={attributeNamePrefix:`@_`,attributesGroupName:!1,textNodeName:`#text`,ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:` `,suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:RegExp(`&`,`g`),val:`&`},{regex:RegExp(`>`,`g`),val:`>`},{regex:RegExp(`<`,`g`),val:`<`},{regex:RegExp(`'`,`g`),val:`'`},{regex:RegExp(`"`,`g`),val:`"`}],processEntities:!0,stopNodes:[],oneListGroup:!1};function be(e){this.options=Object.assign({},ye,e),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=A(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Ce),this.processTextOrObjNode=xe,this.options.format?(this.indentate=Se,this.tagEndChar=`>
|
|
32367
32367
|
`,this.newLine=`
|
|
32368
|
-
`):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}function xe(e,t,n,r){let i=this.j2x(e,n+1,r.concat(t));return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,n):this.buildObjectNode(i.val,t,i.attrStr,n)}function Se(e){return this.options.indentBy.repeat(e)}function Ce(e){return!(!e.startsWith(this.options.attributeNamePrefix)||e===this.options.textNodeName)&&e.substr(this.attrPrefixLen)}be.prototype.build=function(e){return this.options.preserveOrder?pe(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)},be.prototype.j2x=function(e,t,n){let r=``,i=``,a=n.join(`.`);for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o))if(e[o]===void 0)this.isAttribute(o)&&(i+=``);else if(e[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?i+=``:o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(e[o]instanceof Date)i+=this.buildTextValNode(e[o],o,``,t);else if(typeof e[o]!=`object`){let n=this.isAttribute(o);if(n&&!this.ignoreAttributesFn(n,a))r+=this.buildAttrPairStr(n,``+e[o]);else if(!n)if(o===this.options.textNodeName){let t=this.options.tagValueProcessor(o,``+e[o]);i+=this.replaceEntitiesValue(t)}else i+=this.buildTextValNode(e[o],o,``,t)}else if(Array.isArray(e[o])){let r=e[o].length,a=``,s=``;for(let c=0;c<r;c++){let r=e[o][c];if(r!==void 0)if(r===null)o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(typeof r==`object`)if(this.options.oneListGroup){let e=this.j2x(r,t+1,n.concat(o));a+=e.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else a+=this.processTextOrObjNode(r,o,t,n);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(o,r);e=this.replaceEntitiesValue(e),a+=e}else a+=this.buildTextValNode(r,o,``,t)}this.options.oneListGroup&&(a=this.buildObjectNode(a,o,s,t)),i+=a}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let t=Object.keys(e[o]),n=t.length;for(let i=0;i<n;i++)r+=this.buildAttrPairStr(t[i],``+e[o][t[i]])}else i+=this.processTextOrObjNode(e[o],o,t,n);return{attrStr:r,val:i}},be.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+t+`"`},be.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),!n&&n!==``||e.indexOf(`<`)!==-1?!1!==this.options.commentPropName&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i:this.indentate(r)+`<`+t+n+a+`>`+e+i}},be.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},be.prototype.buildTextValNode=function(e,t,n,r){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},be.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};let we={validate:s};t.exports=n})()})),vU=s((e=>{let t=ur(),n=dr(),r=t.__toESM(require(`@anthropic-ai/claude-agent-sdk`));e.getMessageContentBlocks=n.getMessageContentBlocks,e.isErrorResult=n.isErrorResult,e.isResultMessage=n.isResultMessage,Object.defineProperty(e,`query`,{enumerable:!0,get:function(){return r.query}})})),yU=s((e=>{let t=fr();e.buildFileToFlowMappingPrompt=t.buildFileToFlowMappingPrompt,e.buildFileToFlowMappingSystemPrompt=t.buildFileToFlowMappingSystemPrompt})),bU=s((e=>{let t=ur(),n=dr(),r=fr(),i=t.__toESM(Oi()),a=t.__toESM(ki()),o=t.__toESM(require(`node:fs/promises`)),s=t.__toESM(require(`node:async_hooks`)),c=t.__toESM(oe()),l=t.__toESM(Bi()),u=t.__toESM(Rc()),f=t.__toESM(require(`node:process`)),p=t.__toESM(require(`node:os`)),m=t.__toESM(require(`node:tty`)),h=t.__toESM(require(`node:crypto`)),g=t.__toESM(cL()),_=t.__toESM(Cj()),v=t.__toESM(hR()),y=t.__toESM((LA(),d(IA))),b=t.__toESM(require(`node:fs`)),x=t.__toESM(qR()),S=t.__toESM(wee()),C=t.__toESM(require(`node:child_process`)),w=t.__toESM(require(`node:util`)),T=t.__toESM(require(`@prisma/internals`)),E=t.__toESM(fB()),D=t.__toESM(require(`node:zlib`)),O=t.__toESM(gV()),k=t.__toESM(vV()),A=t.__toESM(SV()),ee=t.__toESM(DV()),te=t.__toESM(require(`node:events`)),ne=t.__toESM(SH()),j=t.__toESM(cU()),re=t.__toESM(hU()),M=t.__toESM(gU()),N=t.__toESM(_U()),P=t.__toESM(CH());t.__toESM(require(`node:readline`));let F=t.__toESM(require(`node:path`)),ie=t.__toESM(require(`node:module`)),ae=t.__toESM(require(`@anthropic-ai/claude-agent-sdk`)),I={DELETE:`delete`,COMMENT_OUT:`comment out`,KEEP:`keep`,SKIP:`skip`},L={GREEN:`Green`,GREY:`Grey`,RED:`Red`,NA:`NA`},R={GREEN:`Green`,GREY:`Grey`,RUNTIME_ERROR:`RuntimeError`},z=function(e){return e.IDE=`IDE`,e.CLI=`CLI`,e}({}),se=function(e){return e.SIBLING_FOLDER=`siblingFolder`,e.ROOT_FOLDER=`rootFolder`,e}({}),ce=function(e){return e.JEST=`jest`,e.MOCHA=`mocha`,e.VITEST=`vitest`,e.PYTEST=`pytest`,e}({}),le=function(e){return e.SPEC=`spec`,e.TEST=`test`,e}({}),ue=function(e){return e.CAMEL_CASE=`camelCase`,e.KEBAB_CASE=`kebabCase`,e}({}),de=function(e){return e.NONE=`none`,e.CATEGORIES=`categories`,e}({}),fe=function(e){return e.NEW_CODE_FILE=`newCodeFile`,e.OVERRIDE_CODE_FILE=`overrideCodeFile`,e}({}),pe=function(e){return e.ON=`on`,e.OFF=`off`,e}({}),me={DEFAULT:0,MIN:0,MAX:100},he={DEFAULT:5,MIN:1,MAX:50};i.z.object({rootPath:i.z.string().default(process.cwd()),testStructure:i.z.enum(se).optional(),testFramework:i.z.enum(ce).optional(),testSuffix:i.z.enum(le).optional(),testFileName:i.z.enum(ue).optional(),calculateCoverage:i.z.enum(pe).optional(),coverageThreshold:i.z.number().min(me.MIN).max(me.MAX).default(me.DEFAULT),requestSource:i.z.enum(z).optional(),concurrency:i.z.number().min(he.MIN).max(he.MAX).default(he.DEFAULT),backendURL:i.z.string().optional(),secretToken:i.z.string().optional(),modelName:i.z.string().optional(),context:i.z.object({git:i.z.object({ref_name:i.z.string(),anchorBranch:i.z.string(),compareBranch:i.z.string(),repository:i.z.string(),owner:i.z.string(),sha:i.z.string(),workflowRunId:i.z.string(),remoteUrl:i.z.string(),topLevel:i.z.string()}).partial().optional()}).optional(),testCommand:i.z.string().optional(),coverageCommand:i.z.string().optional(),lintCommand:i.z.string().optional(),prettierCommand:i.z.string().optional(),disableLintRules:i.z.boolean().optional(),ignoreAsAnyLintErrors:i.z.boolean().optional(),includeEarlyTests:i.z.boolean().optional(),greyTestBehaviour:i.z.enum(I).optional(),redTestBehaviour:i.z.enum(I).optional(),keepErrorTests:i.z.boolean().optional(),keepFailedTests:i.z.boolean().optional(),conditionalKeep:i.z.boolean().optional(),continueOnTestErrors:i.z.boolean().optional(),perFunctionTimeout:i.z.number().positive().optional(),dynamicPromptIterations:i.z.number().min(0).max(10).optional(),removeComments:i.z.boolean().optional(),experimentalAgentSdk:i.z.boolean().optional(),compressOutput:i.z.boolean().optional(),agentSdkModel:i.z.string().optional(),agentSdkBudget:i.z.number().positive().optional(),pluginPath:i.z.string().optional(),claudeCodeExecutablePath:i.z.string().optional(),projectId:i.z.string().optional(),e2eCatalogIds:i.z.array(i.z.string()).optional(),jobId:i.z.string().optional(),label:i.z.string().optional(),debug:i.z.boolean().optional(),verbose:i.z.boolean().optional(),progressLogger:i.z.custom().optional(),onTokenRefresh:i.z.custom().optional()});var ge=`@earlyai/ts-agent`,_e=`0.106.2`;let ve={VSCODE:`vscode`,GITHUB_ACTION:`github-action`,UNKNOWN:`unknown`},ye=`$early_filename`,be=`$early_coverage_dir`,xe=`$early_test_files`,Se=`npx jest ${ye} --no-coverage --silent --json --forceExit --maxWorkers=1`,Ce=`npx --no eslint ${ye}`,we=`npx --no prettier ${ye} --write`,Te={rootPath:process.cwd(),isSiblingFolderStructured:!0,gitURL:`https://github.com/your-owner/your-repo`,testFramework:ce.JEST,greyTestBehaviour:I.DELETE,redTestBehaviour:I.DELETE,keepErrorTests:!1,keepFailedTests:!1,conditionalKeep:!1,continueOnTestErrors:!0,generatedTestStructure:de.CATEGORIES,isRootFolderStructured:!1,clientSource:ve.GITHUB_ACTION,backendURL:`https://api.startearly.ai`,requestSource:z.CLI,userPrompt:``,testLocation:`__tests__`,coverageThreshold:me.DEFAULT,concurrency:5,testFileFormat:`ts`,outputType:fe.NEW_CODE_FILE,shouldRefreshCoverage:!0,kebabCaseFileName:!1,earlyTestFilenameSuffix:`.early.${le.TEST}`,testSuffix:le.TEST,isAppendPrompt:!1,dynamicPromptIterations:3,wsServerEndpoint:`wss://api.startearly.ai`,secretToken:``,loggerConfig:{consoleEnabled:!1,azureEnabled:!0,azureConnectionString:`InstrumentationKey=8b9b0d6a-5400-44a3-ada6-3cd026de6cfe;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=d6e130b6-4aaa-4dcc-8d26-c1fa25d4656a`},context:void 0,includeEarlyTests:!1,lintCommand:Ce,prettierCommand:we,disableLintRules:!1,ignoreAsAnyLintErrors:!0,allowUndefinedLintErrors:!0,perFunctionTimeout:42e4,removeComments:!0,experimentalAgentSdk:!1,compressOutput:!1,agentSdkModel:void 0,agentSdkBudget:void 0,debug:!1,verbose:!1},Ee=e=>{let t=`testFramework.testSuffix.backendURL.requestSource.secretToken.concurrency.coverageThreshold.context.rootPath.testCommand.coverageCommand.lintCommand.prettierCommand.disableLintRules.greyTestBehaviour.redTestBehaviour.keepErrorTests.keepFailedTests.conditionalKeep.continueOnTestErrors.perFunctionTimeout.dynamicPromptIterations.removeComments.experimentalAgentSdk.compressOutput.agentSdkModel.agentSdkBudget.pluginPath.claudeCodeExecutablePath.jobId.label.projectId.e2eCatalogIds.debug.verbose.progressLogger.onTokenRefresh`.split(`.`).reduce((t,n)=>(0,c.isDefined)(e[n])?{...t,[n]:e[n]}:t,{}),n={...(0,c.isDefined)(e.testStructure)&&{isSiblingFolderStructured:e.testStructure===se.SIBLING_FOLDER,isRootFolderStructured:e.testStructure===se.ROOT_FOLDER},...(0,c.isDefined)(e.testFileName)&&{kebabCaseFileName:e.testFileName===ue.KEBAB_CASE},...(0,c.isDefined)(e.calculateCoverage)&&{shouldRefreshCoverage:e.calculateCoverage===pe.ON},...(0,c.isDefined)(e.modelName)&&{fixTestsLLMModelName:e.modelName,generateTestsLLMModelName:e.modelName},...(0,c.isDefined)(e.testSuffix)&&{earlyTestFilenameSuffix:`.early.${e.testSuffix}`},...(0,c.isDefined)(e.requestSource)&&{clientSource:e.requestSource===z.IDE?ve.VSCODE:ve.GITHUB_ACTION}};return{...t,...n}},De=(e=0)=>t=>`\u001B[${t+e}m`,Oe=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,ke=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,Ae={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(Ae.modifier);let je=Object.keys(Ae.color),Me=Object.keys(Ae.bgColor);[...je,...Me];function Ne(){let e=new Map;for(let[t,n]of Object.entries(Ae)){for(let[t,r]of Object.entries(n))Ae[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=Ae[t],e.set(r[0],r[1]);Object.defineProperty(Ae,t,{value:n,enumerable:!1})}return Object.defineProperty(Ae,`codes`,{value:e,enumerable:!1}),Ae.color.close=`\x1B[39m`,Ae.bgColor.close=`\x1B[49m`,Ae.color.ansi=De(),Ae.color.ansi256=Oe(),Ae.color.ansi16m=ke(),Ae.bgColor.ansi=De(10),Ae.bgColor.ansi256=Oe(10),Ae.bgColor.ansi16m=ke(10),Object.defineProperties(Ae,{rgbToAnsi256:{value(e,t,n){return 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=>Ae.rgbToAnsi256(...Ae.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)=>Ae.ansi256ToAnsi(Ae.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Ae.ansi256ToAnsi(Ae.hexToAnsi256(e)),enumerable:!1}}),Ae}var Pe=Ne();function Fe(e,t=globalThis.Deno?globalThis.Deno.args:f.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}let{env:Ie}=f.default,Le;Fe(`no-color`)||Fe(`no-colors`)||Fe(`color=false`)||Fe(`color=never`)?Le=0:(Fe(`color`)||Fe(`colors`)||Fe(`color=true`)||Fe(`color=always`))&&(Le=1);function Re(){if(`FORCE_COLOR`in Ie)return Ie.FORCE_COLOR===`true`?1:Ie.FORCE_COLOR===`false`?0:Ie.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Ie.FORCE_COLOR,10),3)}function ze(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Be(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Re();r!==void 0&&(Le=r);let i=n?Le:r;if(i===0)return 0;if(n){if(Fe(`color=16m`)||Fe(`color=full`)||Fe(`color=truecolor`))return 3;if(Fe(`color=256`))return 2}if(`TF_BUILD`in Ie&&`AGENT_NAME`in Ie)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(Ie.TERM===`dumb`)return a;if(f.default.platform===`win32`){let e=p.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in Ie)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in Ie)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in Ie)||Ie.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in Ie)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ie.TEAMCITY_VERSION)?1:0;if(Ie.COLORTERM===`truecolor`||Ie.TERM===`xterm-kitty`||Ie.TERM===`xterm-ghostty`||Ie.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in Ie){let e=Number.parseInt((Ie.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(Ie.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(Ie.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ie.TERM)||`COLORTERM`in Ie?1:a}function Ve(e,t={}){return ze(Be(e,{streamIsTTY:e&&e.isTTY,...t}))}var He={stdout:Ve({isTTY:m.default.isatty(1)}),stderr:Ve({isTTY:m.default.isatty(2)})};function Ue(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function B(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
32368
|
+
`):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``)}function xe(e,t,n,r){let i=this.j2x(e,n+1,r.concat(t));return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,n):this.buildObjectNode(i.val,t,i.attrStr,n)}function Se(e){return this.options.indentBy.repeat(e)}function Ce(e){return!(!e.startsWith(this.options.attributeNamePrefix)||e===this.options.textNodeName)&&e.substr(this.attrPrefixLen)}be.prototype.build=function(e){return this.options.preserveOrder?pe(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0,[]).val)},be.prototype.j2x=function(e,t,n){let r=``,i=``,a=n.join(`.`);for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o))if(e[o]===void 0)this.isAttribute(o)&&(i+=``);else if(e[o]===null)this.isAttribute(o)||o===this.options.cdataPropName?i+=``:o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(e[o]instanceof Date)i+=this.buildTextValNode(e[o],o,``,t);else if(typeof e[o]!=`object`){let n=this.isAttribute(o);if(n&&!this.ignoreAttributesFn(n,a))r+=this.buildAttrPairStr(n,``+e[o]);else if(!n)if(o===this.options.textNodeName){let t=this.options.tagValueProcessor(o,``+e[o]);i+=this.replaceEntitiesValue(t)}else i+=this.buildTextValNode(e[o],o,``,t)}else if(Array.isArray(e[o])){let r=e[o].length,a=``,s=``;for(let c=0;c<r;c++){let r=e[o][c];if(r!==void 0)if(r===null)o[0]===`?`?i+=this.indentate(t)+`<`+o+`?`+this.tagEndChar:i+=this.indentate(t)+`<`+o+`/`+this.tagEndChar;else if(typeof r==`object`)if(this.options.oneListGroup){let e=this.j2x(r,t+1,n.concat(o));a+=e.val,this.options.attributesGroupName&&r.hasOwnProperty(this.options.attributesGroupName)&&(s+=e.attrStr)}else a+=this.processTextOrObjNode(r,o,t,n);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(o,r);e=this.replaceEntitiesValue(e),a+=e}else a+=this.buildTextValNode(r,o,``,t)}this.options.oneListGroup&&(a=this.buildObjectNode(a,o,s,t)),i+=a}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){let t=Object.keys(e[o]),n=t.length;for(let i=0;i<n;i++)r+=this.buildAttrPairStr(t[i],``+e[o][t[i]])}else i+=this.processTextOrObjNode(e[o],o,t,n);return{attrStr:r,val:i}},be.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,``+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t===`true`?` `+e:` `+e+`="`+t+`"`},be.prototype.buildObjectNode=function(e,t,n,r){if(e===``)return t[0]===`?`?this.indentate(r)+`<`+t+n+`?`+this.tagEndChar:this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar;{let i=`</`+t+this.tagEndChar,a=``;return t[0]===`?`&&(a=`?`,i=``),!n&&n!==``||e.indexOf(`<`)!==-1?!1!==this.options.commentPropName&&t===this.options.commentPropName&&a.length===0?this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine:this.indentate(r)+`<`+t+n+a+this.tagEndChar+e+this.indentate(r)+i:this.indentate(r)+`<`+t+n+a+`>`+e+i}},be.prototype.closeTag=function(e){let t=``;return this.options.unpairedTags.indexOf(e)===-1?t=this.options.suppressEmptyNode?`/`:`></${e}`:this.options.suppressUnpairedNode||(t=`/`),t},be.prototype.buildTextValNode=function(e,t,n,r){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(r)+`\x3c!--${e}--\x3e`+this.newLine;if(t[0]===`?`)return this.indentate(r)+`<`+t+n+`?`+this.tagEndChar;{let i=this.options.tagValueProcessor(t,e);return i=this.replaceEntitiesValue(i),i===``?this.indentate(r)+`<`+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+`<`+t+n+`>`+i+`</`+t+this.tagEndChar}},be.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};let we={validate:s};t.exports=n})()})),vU=s((e=>{let t=ur(),n=dr(),r=t.__toESM(require(`@anthropic-ai/claude-agent-sdk`));e.getMessageContentBlocks=n.getMessageContentBlocks,e.isErrorResult=n.isErrorResult,e.isResultMessage=n.isResultMessage,Object.defineProperty(e,`query`,{enumerable:!0,get:function(){return r.query}})})),yU=s((e=>{let t=fr();e.buildFileToFlowMappingPrompt=t.buildFileToFlowMappingPrompt,e.buildFileToFlowMappingSystemPrompt=t.buildFileToFlowMappingSystemPrompt})),bU=s((e=>{let t=ur(),n=dr(),r=fr(),i=t.__toESM(Oi()),a=t.__toESM(ki()),o=t.__toESM(require(`node:fs/promises`)),s=t.__toESM(require(`node:async_hooks`)),c=t.__toESM(oe()),l=t.__toESM(Bi()),u=t.__toESM(Rc()),f=t.__toESM(require(`node:process`)),p=t.__toESM(require(`node:os`)),m=t.__toESM(require(`node:tty`)),h=t.__toESM(require(`node:crypto`)),g=t.__toESM(cL()),_=t.__toESM(Cj()),v=t.__toESM(hR()),y=t.__toESM((LA(),d(IA))),b=t.__toESM(require(`node:fs`)),x=t.__toESM(qR()),S=t.__toESM(wee()),C=t.__toESM(require(`node:child_process`)),w=t.__toESM(require(`node:util`)),T=t.__toESM(require(`@prisma/internals`)),E=t.__toESM(fB()),D=t.__toESM(require(`node:zlib`)),O=t.__toESM(gV()),k=t.__toESM(vV()),A=t.__toESM(SV()),ee=t.__toESM(DV()),te=t.__toESM(require(`node:events`)),ne=t.__toESM(SH()),j=t.__toESM(cU()),re=t.__toESM(hU()),M=t.__toESM(gU()),N=t.__toESM(_U()),P=t.__toESM(CH());t.__toESM(require(`node:readline`));let F=t.__toESM(require(`node:path`)),ie=t.__toESM(require(`node:module`)),ae=t.__toESM(require(`@anthropic-ai/claude-agent-sdk`)),I={DELETE:`delete`,COMMENT_OUT:`comment out`,KEEP:`keep`,SKIP:`skip`},L={GREEN:`Green`,GREY:`Grey`,RED:`Red`,NA:`NA`},R={GREEN:`Green`,GREY:`Grey`,RUNTIME_ERROR:`RuntimeError`},z=function(e){return e.IDE=`IDE`,e.CLI=`CLI`,e}({}),se=function(e){return e.SIBLING_FOLDER=`siblingFolder`,e.ROOT_FOLDER=`rootFolder`,e}({}),ce=function(e){return e.JEST=`jest`,e.MOCHA=`mocha`,e.VITEST=`vitest`,e.PYTEST=`pytest`,e}({}),le=function(e){return e.SPEC=`spec`,e.TEST=`test`,e}({}),ue=function(e){return e.CAMEL_CASE=`camelCase`,e.KEBAB_CASE=`kebabCase`,e}({}),de=function(e){return e.NONE=`none`,e.CATEGORIES=`categories`,e}({}),fe=function(e){return e.NEW_CODE_FILE=`newCodeFile`,e.OVERRIDE_CODE_FILE=`overrideCodeFile`,e}({}),pe=function(e){return e.ON=`on`,e.OFF=`off`,e}({}),me={DEFAULT:0,MIN:0,MAX:100},he={DEFAULT:5,MIN:1,MAX:50};i.z.object({rootPath:i.z.string().default(process.cwd()),testStructure:i.z.enum(se).optional(),testFramework:i.z.enum(ce).optional(),testSuffix:i.z.enum(le).optional(),testFileName:i.z.enum(ue).optional(),calculateCoverage:i.z.enum(pe).optional(),coverageThreshold:i.z.number().min(me.MIN).max(me.MAX).default(me.DEFAULT),requestSource:i.z.enum(z).optional(),concurrency:i.z.number().min(he.MIN).max(he.MAX).default(he.DEFAULT),backendURL:i.z.string().optional(),secretToken:i.z.string().optional(),modelName:i.z.string().optional(),context:i.z.object({git:i.z.object({ref_name:i.z.string(),anchorBranch:i.z.string(),compareBranch:i.z.string(),repository:i.z.string(),owner:i.z.string(),sha:i.z.string(),workflowRunId:i.z.string(),remoteUrl:i.z.string(),topLevel:i.z.string()}).partial().optional()}).optional(),testCommand:i.z.string().optional(),coverageCommand:i.z.string().optional(),lintCommand:i.z.string().optional(),prettierCommand:i.z.string().optional(),disableLintRules:i.z.boolean().optional(),ignoreAsAnyLintErrors:i.z.boolean().optional(),includeEarlyTests:i.z.boolean().optional(),greyTestBehaviour:i.z.enum(I).optional(),redTestBehaviour:i.z.enum(I).optional(),keepErrorTests:i.z.boolean().optional(),keepFailedTests:i.z.boolean().optional(),conditionalKeep:i.z.boolean().optional(),continueOnTestErrors:i.z.boolean().optional(),perFunctionTimeout:i.z.number().positive().optional(),dynamicPromptIterations:i.z.number().min(0).max(10).optional(),removeComments:i.z.boolean().optional(),experimentalAgentSdk:i.z.boolean().optional(),compressOutput:i.z.boolean().optional(),agentSdkModel:i.z.string().optional(),agentSdkBudget:i.z.number().positive().optional(),pluginPath:i.z.string().optional(),claudeCodeExecutablePath:i.z.string().optional(),projectId:i.z.string().optional(),e2eCatalogIds:i.z.array(i.z.string()).optional(),jobId:i.z.string().optional(),label:i.z.string().optional(),debug:i.z.boolean().optional(),verbose:i.z.boolean().optional(),progressLogger:i.z.custom().optional(),onTokenRefresh:i.z.custom().optional()});var ge=`@earlyai/ts-agent`,_e=`0.107.0`;let ve={VSCODE:`vscode`,GITHUB_ACTION:`github-action`,UNKNOWN:`unknown`},ye=`$early_filename`,be=`$early_coverage_dir`,xe=`$early_test_files`,Se=`npx jest ${ye} --no-coverage --silent --json --forceExit --maxWorkers=1`,Ce=`npx --no eslint ${ye}`,we=`npx --no prettier ${ye} --write`,Te={rootPath:process.cwd(),isSiblingFolderStructured:!0,gitURL:`https://github.com/your-owner/your-repo`,testFramework:ce.JEST,greyTestBehaviour:I.DELETE,redTestBehaviour:I.DELETE,keepErrorTests:!1,keepFailedTests:!1,conditionalKeep:!1,continueOnTestErrors:!0,generatedTestStructure:de.CATEGORIES,isRootFolderStructured:!1,clientSource:ve.GITHUB_ACTION,backendURL:`https://api.startearly.ai`,requestSource:z.CLI,userPrompt:``,testLocation:`__tests__`,coverageThreshold:me.DEFAULT,concurrency:5,testFileFormat:`ts`,outputType:fe.NEW_CODE_FILE,shouldRefreshCoverage:!0,kebabCaseFileName:!1,earlyTestFilenameSuffix:`.early.${le.TEST}`,testSuffix:le.TEST,isAppendPrompt:!1,dynamicPromptIterations:3,wsServerEndpoint:`wss://api.startearly.ai`,secretToken:``,loggerConfig:{consoleEnabled:!1,azureEnabled:!0,azureConnectionString:`InstrumentationKey=8b9b0d6a-5400-44a3-ada6-3cd026de6cfe;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=d6e130b6-4aaa-4dcc-8d26-c1fa25d4656a`},context:void 0,includeEarlyTests:!1,lintCommand:Ce,prettierCommand:we,disableLintRules:!1,ignoreAsAnyLintErrors:!0,allowUndefinedLintErrors:!0,perFunctionTimeout:42e4,removeComments:!0,experimentalAgentSdk:!1,compressOutput:!1,agentSdkModel:void 0,agentSdkBudget:void 0,debug:!1,verbose:!1},Ee=e=>{let t=`testFramework.testSuffix.backendURL.requestSource.secretToken.concurrency.coverageThreshold.context.rootPath.testCommand.coverageCommand.lintCommand.prettierCommand.disableLintRules.greyTestBehaviour.redTestBehaviour.keepErrorTests.keepFailedTests.conditionalKeep.continueOnTestErrors.perFunctionTimeout.dynamicPromptIterations.removeComments.experimentalAgentSdk.compressOutput.agentSdkModel.agentSdkBudget.pluginPath.claudeCodeExecutablePath.jobId.label.projectId.e2eCatalogIds.debug.verbose.progressLogger.onTokenRefresh`.split(`.`).reduce((t,n)=>(0,c.isDefined)(e[n])?{...t,[n]:e[n]}:t,{}),n={...(0,c.isDefined)(e.testStructure)&&{isSiblingFolderStructured:e.testStructure===se.SIBLING_FOLDER,isRootFolderStructured:e.testStructure===se.ROOT_FOLDER},...(0,c.isDefined)(e.testFileName)&&{kebabCaseFileName:e.testFileName===ue.KEBAB_CASE},...(0,c.isDefined)(e.calculateCoverage)&&{shouldRefreshCoverage:e.calculateCoverage===pe.ON},...(0,c.isDefined)(e.modelName)&&{fixTestsLLMModelName:e.modelName,generateTestsLLMModelName:e.modelName},...(0,c.isDefined)(e.testSuffix)&&{earlyTestFilenameSuffix:`.early.${e.testSuffix}`},...(0,c.isDefined)(e.requestSource)&&{clientSource:e.requestSource===z.IDE?ve.VSCODE:ve.GITHUB_ACTION}};return{...t,...n}},De=(e=0)=>t=>`\u001B[${t+e}m`,Oe=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,ke=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,Ae={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(Ae.modifier);let je=Object.keys(Ae.color),Me=Object.keys(Ae.bgColor);[...je,...Me];function Ne(){let e=new Map;for(let[t,n]of Object.entries(Ae)){for(let[t,r]of Object.entries(n))Ae[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=Ae[t],e.set(r[0],r[1]);Object.defineProperty(Ae,t,{value:n,enumerable:!1})}return Object.defineProperty(Ae,`codes`,{value:e,enumerable:!1}),Ae.color.close=`\x1B[39m`,Ae.bgColor.close=`\x1B[49m`,Ae.color.ansi=De(),Ae.color.ansi256=Oe(),Ae.color.ansi16m=ke(),Ae.bgColor.ansi=De(10),Ae.bgColor.ansi256=Oe(10),Ae.bgColor.ansi16m=ke(10),Object.defineProperties(Ae,{rgbToAnsi256:{value(e,t,n){return 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=>Ae.rgbToAnsi256(...Ae.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)=>Ae.ansi256ToAnsi(Ae.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Ae.ansi256ToAnsi(Ae.hexToAnsi256(e)),enumerable:!1}}),Ae}var Pe=Ne();function Fe(e,t=globalThis.Deno?globalThis.Deno.args:f.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}let{env:Ie}=f.default,Le;Fe(`no-color`)||Fe(`no-colors`)||Fe(`color=false`)||Fe(`color=never`)?Le=0:(Fe(`color`)||Fe(`colors`)||Fe(`color=true`)||Fe(`color=always`))&&(Le=1);function Re(){if(`FORCE_COLOR`in Ie)return Ie.FORCE_COLOR===`true`?1:Ie.FORCE_COLOR===`false`?0:Ie.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Ie.FORCE_COLOR,10),3)}function ze(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Be(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Re();r!==void 0&&(Le=r);let i=n?Le:r;if(i===0)return 0;if(n){if(Fe(`color=16m`)||Fe(`color=full`)||Fe(`color=truecolor`))return 3;if(Fe(`color=256`))return 2}if(`TF_BUILD`in Ie&&`AGENT_NAME`in Ie)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(Ie.TERM===`dumb`)return a;if(f.default.platform===`win32`){let e=p.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in Ie)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in Ie)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in Ie)||Ie.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in Ie)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ie.TEAMCITY_VERSION)?1:0;if(Ie.COLORTERM===`truecolor`||Ie.TERM===`xterm-kitty`||Ie.TERM===`xterm-ghostty`||Ie.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in Ie){let e=Number.parseInt((Ie.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(Ie.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(Ie.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ie.TERM)||`COLORTERM`in Ie?1:a}function Ve(e,t={}){return ze(Be(e,{streamIsTTY:e&&e.isTTY,...t}))}var He={stdout:Ve({isTTY:m.default.isatty(1)}),stderr:Ve({isTTY:m.default.isatty(2)})};function Ue(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function B(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
32369
32369
|
`:`
|
|
32370
32370
|
`)+n,i=r+1,r=e.indexOf(`
|
|
32371
32371
|
`,i)}while(r!==-1);return a+=e.slice(i),a}let{stdout:We,stderr:Ge}=He,Ke=Symbol(`GENERATOR`),qe=Symbol(`STYLER`),Je=Symbol(`IS_EMPTY`),Ye=[`ansi`,`ansi`,`ansi256`,`ansi16m`],Xe=Object.create(null),Ze=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=We?We.level:0;e.level=t.level===void 0?n:t.level},Qe=e=>{let t=(...e)=>e.join(` `);return Ze(t,e),Object.setPrototypeOf(t,$e.prototype),t};function $e(e){return Qe(e)}Object.setPrototypeOf($e.prototype,Function.prototype);for(let[e,t]of Object.entries(Pe))Xe[e]={get(){let n=rt(this,nt(t.open,t.close,this[qe]),this[Je]);return Object.defineProperty(this,e,{value:n}),n}};Xe.visible={get(){let e=rt(this,this[qe],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};let et=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?Pe[n].ansi16m(...r):t===`ansi256`?Pe[n].ansi256(Pe.rgbToAnsi256(...r)):Pe[n].ansi(Pe.rgbToAnsi(...r)):e===`hex`?et(`rgb`,t,n,...Pe.hexToRgb(...r)):Pe[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){Xe[e]={get(){let{level:t}=this;return function(...n){let r=nt(et(e,Ye[t],`color`,...n),Pe.color.close,this[qe]);return rt(this,r,this[Je])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);Xe[t]={get(){let{level:t}=this;return function(...n){let r=nt(et(e,Ye[t],`bgColor`,...n),Pe.bgColor.close,this[qe]);return rt(this,r,this[Je])}}}}let tt=Object.defineProperties(()=>{},{...Xe,level:{enumerable:!0,get(){return this[Ke].level},set(e){this[Ke].level=e}}}),nt=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},rt=(e,t,n)=>{let r=(...e)=>it(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,tt),r[Ke]=e,r[qe]=t,r[Je]=n,r},it=(e,t)=>{if(e.level<=0||!t)return e[Je]?``:t;let n=e[qe];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=Ue(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
32372
|
-
`);return a!==-1&&(t=B(t,i,r,a)),r+t+i};Object.defineProperties($e.prototype,Xe);let at=$e();$e({level:Ge?Ge.level:0});var ot=at;let st=()=>{},ct={info:st,verbose:st,debug:st},lt=[ot.cyan,ot.magenta,ot.green,ot.blue,ot.redBright,ot.cyanBright,ot.magentaBright,ot.greenBright];function V(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.codePointAt(n)??0,t=Math.imul(t,16777619);return lt[Math.abs(t)%lt.length]}function ut(e,t){let n=(0,c.isDefined)(t.parentName)?`${t.parentName}.${t.methodName}`:t.methodName,r=V(n)(`[${n}]`);return{info:(...t)=>e.info(r,...t),verbose:(...t)=>e.verbose(r,...t),debug:(...t)=>e.debug(r,...t)}}var dt=t.__commonJSMin(((e,t)=>{function n(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),ft=t.__commonJSMin(((e,t)=>{function n(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),pt=t.__toESM(dt()),mt=t.__toESM(ft()),ht,gt;let _t=class{config;constructor(e,t={}){if(!(0,c.isDefined)(e)){this.config=Te;return}let n=Ee(e);this.config=(0,c.merge)(Te,n,t)}getRootPath=()=>this.config.rootPath;isSiblingFolderStructured=()=>this.config.isSiblingFolderStructured;getGitURL=()=>this.config.context?.git?.remoteUrl??this.config.gitURL;getGitTopLevel=()=>this.config.context?.git?.topLevel??this.getRootPath();getTestFramework=()=>this.config.testFramework;getGreyTestBehaviour=()=>this.config.greyTestBehaviour;getRedTestBehaviour=()=>this.config.redTestBehaviour;shouldKeepErrorTests=()=>this.config.keepErrorTests;shouldKeepFailedTests=()=>this.config.keepFailedTests;shouldConditionalKeep=()=>this.config.conditionalKeep;getGeneratedTestStructure=()=>this.config.generatedTestStructure;getGenerateTestsLLMModelName=()=>this.config.generateTestsLLMModelName;isRootFolderStructured=()=>this.config.isRootFolderStructured;getLLMTemperature=()=>this.config.llmTemperature;getLLMTopP=()=>this.config.llmTopP;getClientSource=()=>this.config.clientSource;getBackendURL=()=>this.config.backendURL;getRequestSource=()=>this.config.requestSource;getUserPrompt=()=>this.config.userPrompt;getTestLocation=()=>this.config.testLocation;getCoverageThreshold=()=>this.config.coverageThreshold;getConcurrency=()=>this.config.concurrency;getTestFileFormat=()=>this.config.testFileFormat;getOutputType=()=>this.config.outputType;getShouldRefreshCoverage=()=>this.config.shouldRefreshCoverage;isKebabCaseFileName=()=>this.config.kebabCaseFileName;getEarlyTestFilenameSuffix=()=>this.config.earlyTestFilenameSuffix;getTestSuffix=()=>this.config.testSuffix;getIsAppendPrompt=()=>this.config.isAppendPrompt;getFixTestsLLMModelName=()=>this.config.fixTestsLLMModelName;getDynamicPromptIterations=()=>this.config.dynamicPromptIterations;getWSServerEndpoint=()=>this.config.backendURL.replace(`http://`,`ws://`).replace(`https://`,`wss://`);getAnthropicProxyUrl=()=>new URL(`/anthropic`,this.config.backendURL).href;getSecretToken=()=>this.config.secretToken;getLoggerConfig=()=>this.config.loggerConfig;getContext=()=>this.config.context;getTestCommand=()=>this.config.testCommand;getCoverageCommand=()=>this.config.coverageCommand;getLintCommand=()=>this.config.lintCommand;getPrettierCommand=()=>this.config.prettierCommand;shouldDisableLintRules=()=>this.config.disableLintRules;shouldIgnoreAsAnyLintErrors=()=>this.config.ignoreAsAnyLintErrors;allowUndefinedLintErrors=()=>this.config.allowUndefinedLintErrors;getIncludeEarlyTests=()=>this.config.includeEarlyTests??!1;shouldContinueOnTestErrors=()=>this.config.continueOnTestErrors;getPerFunctionTimeout=()=>this.config.perFunctionTimeout;shouldRemoveComments=()=>this.config.removeComments;getExperimentalAgentSdk=()=>this.config.experimentalAgentSdk;shouldCompressOutput=()=>this.config.compressOutput;getAgentSdkModel=()=>this.config.agentSdkModel;getAgentSdkBudget=()=>this.config.agentSdkBudget;getPluginPath=()=>this.config.pluginPath;getClaudeCodeExecutablePath=()=>this.config.claudeCodeExecutablePath;getJobId=()=>this.config.jobId;getLabel=()=>this.config.label;getProjectId=()=>this.config.projectId;getE2eCatalogIds=()=>this.config.e2eCatalogIds;updateContext=e=>{this.config.context=(0,c.merge)(this.config.context??{},e??{})};updateRootPath=e=>{this.config.rootPath=e};isDebug=()=>this.config.debug??!1;isVerbose=()=>this.config.verbose??!1;getOnTokenRefresh=()=>this.config.onTokenRefresh;getProgressLogger=e=>{let t=this.config.progressLogger??ct;return(0,c.isDefined)(e)?ut(t,e):t}};_t=(0,mt.default)([(0,u.injectable)(`Singleton`),(0,pt.default)(`design:paramtypes`,[typeof(ht=typeof Partial<`u`&&Partial)==`function`?ht:Object,typeof(gt=typeof Partial<`u`&&Partial)==`function`?gt:Object])],_t);var vt=new u.Container({autobind:!0,defaultScope:`Singleton`});let yt=()=>vt.get(_t);var bt=class{storage=new s.AsyncLocalStorage;isConsoleEnabled;constructor(e){this.isConsoleEnabled=e}orderedFlush={nextOrder:1,pending:new Map};resetOrder(){this.orderedFlush={nextOrder:1,pending:new Map}}async withBufferedPrinting(e,t){let n=[];try{return await this.storage.run(n,e)}finally{this.flushInOrder(t,n)}}printOrBuffer(e,t){let n=this.storage.getStore();if((0,c.isDefined)(n)){n.push({method:e,message:t});return}this.isConsoleEnabled&&console[e](t)}async flushInOrder(e,t){if(this.orderedFlush.nextOrder===e){this.flushBuffer(t),this.orderedFlush.nextOrder++,this.drainPendingFlushes();return}return new Promise(n=>{this.orderedFlush.pending.set(e,{buffer:t,resolve:n})})}drainPendingFlushes(){let e=this.orderedFlush.pending.get(this.orderedFlush.nextOrder);for(;(0,c.isDefined)(e);)this.orderedFlush.pending.delete(this.orderedFlush.nextOrder),this.flushBuffer(e.buffer),this.orderedFlush.nextOrder++,e.resolve(),e=this.orderedFlush.pending.get(this.orderedFlush.nextOrder)}flushBuffer(e){if(this.isConsoleEnabled)for(let t of e)console[t.method](t.message)}};let xt=function(e){return e.DEFAULT=`default`,e.VERBOSE=`verbose`,e.DEBUG=`debug`,e}({}),St=function(e){return e.INFO=`info`,e.WARN=`warn`,e}({});function Ct(){return(0,h.randomUUID)()}function wt(){let e=``;for(let t=0;t<8;t++)e+=`abcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*36));return e}var Tt=t.__toESM(dt()),Et=t.__toESM(ft()),Dt=class{export(e,t){for(let t of e){let e=t.body;if((0,c.isString)(e))console.info(e);else try{console.info(JSON.stringify(e))}catch{console.info(String(e))}}t({code:0})}shutdown(){return Promise.resolve()}};let Ot=class{loggerProvider;config;constructor(e){this.config=e,this.loggerProvider=new v.LoggerProvider({resource:(0,_.resourceFromAttributes)({[y.ATTR_SERVICE_NAME]:ge,[y.ATTR_SERVICE_VERSION]:_e})}),this.initializeExporters(),this.setGlobalLoggerProvider()}getLogger(e){return this.loggerProvider.getLogger(e)}initializeExporters(){let e=[];if(this.config.consoleEnabled){let t=new Dt;e.push(new v.SimpleLogRecordProcessor(t))}if(this.config.azureEnabled&&(0,c.isDefined)(this.config.azureConnectionString)){let t=new g.AzureMonitorLogExporter({connectionString:this.config.azureConnectionString});e.push(new v.BatchLogRecordProcessor(t))}this.loggerProvider=new v.LoggerProvider({processors:e})}setGlobalLoggerProvider(){l.logs.setGlobalLoggerProvider(this.loggerProvider)}};Ot=(0,Et.default)([(0,u.injectable)(),(0,Tt.default)(`design:paramtypes`,[Object])],Ot),t.__toESM(dt()),t.__toESM(ft());let H=new class{storage;otelService;otelLogger;isConsoleEnabled;printBuffer;default=this.createLogObject(xt.DEFAULT);verbose=this.createLogObject(xt.VERBOSE);constructor(e){this.storage=new s.AsyncLocalStorage,this.otelService=new Ot(e),this.otelLogger=this.otelService.getLogger(`ts-agent`),this.isConsoleEnabled=e.consoleEnabled,this.printBuffer=new bt(e.consoleEnabled)}resetPrintOrder(){this.printBuffer.resetOrder()}async withBufferedPrinting(e,t){return this.printBuffer.withBufferedPrinting(e,t)}info={startLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`Start ${e}`,...t),endLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`End ${e}`,...t),failedLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`Failed ${e}`,...t),defaultLog:(e,...t)=>this.log(l.SeverityNumber.INFO,e,...t)};debug={startLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`Start ${e}`,...t),endLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`End ${e}`,...t),failedLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`Failed ${e}`,...t),defaultLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,e,...t)};error(e,t,...n){let r=t instanceof Error?`${e} ${t.message} ${t.stack}`:`${e} ${JSON.stringify(t)}`;this.log(l.SeverityNumber.ERROR,r,...n)}getRequestId(){return this.storage.getStore()?.requestId??``}getTraceId(){return this.storage.getStore()?.traceId??``}log(e,t,...n){let r=this.formatMessage(t,...n);this.logToOpenTelemetry(e,r),!(!this.isConsoleEnabled||!this.isLevelEnabled(xt.DEBUG))&&console.info(r)}logToOpenTelemetry(e,t){let n=this.storage.getStore(),r={service:ge,version:_e};(0,c.isDefined)(n)&&((0,c.isDefined)(n.traceId)&&(r.traceId=n.traceId),(0,c.isDefined)(n.requestId)&&(r.requestId=n.requestId),(0,c.isDefined)(n.category)&&(r.category=n.category),(0,c.isDefined)(n.subCategory)&&(r.subCategory=n.subCategory),(0,c.isDefined)(n.testedMethodClass)&&(r.testedMethodClass=n.testedMethodClass),(0,c.isDefined)(n.testedFunction)&&(r.testedFunction=n.testedFunction),(0,c.isDefined)(n.userId)&&(r.userId=n.userId.toString())),this.otelLogger.emit({severityNumber:e,severityText:this.getSeverityText(e),body:t,attributes:r})}getSeverityText(e){switch(e){case l.SeverityNumber.TRACE:return`TRACE`;case l.SeverityNumber.DEBUG:return`DEBUG`;case l.SeverityNumber.INFO:return`INFO`;case l.SeverityNumber.WARN:return`WARN`;case l.SeverityNumber.ERROR:return`ERROR`;case l.SeverityNumber.FATAL:return`FATAL`;default:return`INFO`}}formatMessage(e,...t){let n=this.formatPrefix(),r=(0,c.isDefined)(n)?`${n} ${e}`:e;return this.formatPrint(r,...t)}formatPrint(e,...t){return(0,c.isEmpty)(t)?e:`${e} ${t.map(e=>JSON.stringify(e)).join(` `)}`}withContext=(e,t,n)=>{let r=n.value,i=this.storage;return n.value=function(...e){let t=i.getStore();if(t){let n={...t};return i.run(n,()=>r.apply(this,e))}let n={traceId:wt(),requestId:Ct()};return i.run(n,()=>r.apply(this,e))},n};addContext(e){let t=this.storage.getStore();(0,c.isDefined)(t)&&(t.category=e.category??t.category,t.subCategory=e.subCategory??t.subCategory,t.testedMethodClass=e.testedMethodClass??t.testedMethodClass,t.testedFunction=e.testedFunction??t.testedFunction,t.userId=e.userId??t.userId)}captureContext({withNewRequestId:e=!1}={}){let t=this.storage.getStore();return t?{...t,...e&&{requestId:Ct()}}:void 0}async runWithContext(e,t){return(0,c.isDefined)(e)?this.storage.run(e,t):t()}isLevelEnabled(e){switch(e){case xt.DEFAULT:return!0;case xt.VERBOSE:return yt().isVerbose()||yt().isDebug();case xt.DEBUG:return yt().isDebug()}}createLogObject(e){return{info:(t,...n)=>{this.isLevelEnabled(e)&&this.printOrBuffer(St.INFO,this.formatPrint(t,...n))},warn:(t,...n)=>{this.isLevelEnabled(e)&&this.printOrBuffer(St.WARN,this.formatPrint(t,...n))}}}printOrBuffer(e,t){this.printBuffer.printOrBuffer(e,t)}formatPrefix(){let e=this.storage.getStore();if(!(0,c.isDefined)(e))return``;let t=[];return(0,c.isDefined)(e.traceId)&&t.push(`[${e.traceId}]`),(0,c.isDefined)(e.requestId)&&t.push(`[${e.requestId}]`),(0,c.isDefined)(e.category)&&t.push(`[${e.category}]`),(0,c.isDefined)(e.subCategory)&&t.push(`[${e.subCategory}]`),(0,c.isDefined)(e.testedMethodClass)&&t.push(`[${e.testedMethodClass}]`),(0,c.isDefined)(e.testedFunction)&&t.push(`[${e.testedFunction}]`),t.join(` `)}}({consoleEnabled:!1,azureEnabled:!0,azureConnectionString:`InstrumentationKey=c18a3332-f844-498f-98e0-d818996cf526;IngestionEndpoint=https://eastus2-3.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/;ApplicationId=2150ffe0-cb0f-4b00-9562-d3385b383d74`});function kt(e){return function(t,n,r){return(0,c.isDefined)(e)&&H.addContext(e),H.withContext(t,n,r)}}var U=class e{rootPath;absolutePath;static EARLY_FILENAME_VAR=`$early_filename`;constructor(e){this.rootPath=a.default.normalizeTrim(yt().getRootPath());let t=a.default.normalizeTrim(e),n=a.default.normalizeTrim(this.rootPath);if(t===n||t.startsWith(n+a.default.sep))this.absolutePath=t;else{let e=t.replace(/^\//,``);this.absolutePath=a.default.resolve(this.rootPath,e)}}static fromSourceFile(t){let n=a.default.normalizeTrim(t.getFilePath());return new e(a.default.relative(a.default.normalizeTrim(yt().getRootPath()),n))}static fromAbsolutePath(t){let n=a.default.normalizeTrim(t);return new e(a.default.relative(a.default.normalizeTrim(yt().getRootPath()),n))}static fromRelativePath(t){return new e(t)}getRelativeFilePath(){return a.default.relative(this.rootPath,this.absolutePath)}getAbsoluteFilePath(){return this.absolutePath}async isFileExists(){try{return(await o.default.stat(this.absolutePath)).isFile()}catch{return!1}}async isDirectoryExists(){try{return(await o.default.stat(this.absolutePath)).isDirectory()}catch{return!1}}async createDirectory(e){await o.default.mkdir(this.absolutePath,{recursive:e?.recursive??!0})}async getText(){try{return await o.default.readFile(this.absolutePath,`utf8`)}catch{return``}}async upsert(e){let t=a.default.dirname(this.absolutePath);await o.default.mkdir(t,{recursive:!0}),await(await this.isFileExists()?o.default.appendFile(this.absolutePath,e):o.default.writeFile(this.absolutePath,e)),H.info.defaultLog(`Upserted file`,{path:this.getRelativeFilePath()})}async replace(e){let t=a.default.dirname(this.absolutePath);await o.default.mkdir(t,{recursive:!0}),await o.default.writeFile(this.absolutePath,e),H.info.defaultLog(`Replaced file`,{path:this.getRelativeFilePath()})}async delete(){try{await o.default.unlink(this.absolutePath),H.info.defaultLog(`Deleted file`,{path:this.getRelativeFilePath()})}catch{}}};let At={WIN32:`win32`,DARWIN:`darwin`,LINUX:`linux`},jt={JAVASCRIPT:`javascript`,TYPESCRIPT:`typescript`,PYTHON:`python`},Mt=e=>{let t=yt().getRootPath();return a.default.resolve(t,e)},Nt=e=>{let t=yt().getRootPath(),n=a.default.normalize(e);return a.default.relative(t,n)},Pt=e=>({".js":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".jsx":`javascript`,".ts":`typescript`,".tsx":`typescript`,".py":`python`})[e.toLowerCase()]??`javascript`;function Ft(e){return Pt((0,a.extname)(e))}function It(e){return Pt((0,a.extname)(e))===`typescript`}function Lt(e){return Pt((0,a.extname)(e))===jt.PYTHON}function Rt(e){let t=yt().getRootPath();if(!(0,c.isDefined)(t))throw Error(`Workspace root path is not defined`);if((0,c.isEmpty)(e))return a.default.normalize(t);let n=a.default.normalize(t),r=a.default.normalize(e);if(process.platform===At.WIN32){let t=n.split(`:`)[0].toUpperCase(),i=r.split(`:`)[0].toUpperCase();if(t!==i&&!i.startsWith(t))return e}return a.default.relative(n,r)}function zt(e){return e.startsWith(`../`)?`../${e}`:e.startsWith(`./`)?`.${e}`:e}function Bt(e){let t=a.default.normalize(Mt(e)),n=a.default.normalize((0,x.default)([`package.json`,`project.json`],{cwd:t})??``);if(!n)return``;let r=Nt((0,a.dirname)(n));return r.startsWith(`/`)?r.slice(1):r}function Vt(e,t,n){if(!Ut(e))return e;let r=n===``?t:t.replace(n,``),i=n===``?Gt(r):Wt(r),o=r.split(`/`).slice(0,-1),s=Ht(e,`../`),c=s>0?o.slice(0,-s).join(`/`):(0,a.dirname)(r),l=e.replaceAll(`../`,``).replaceAll(`./`,``);return a.default.join(i,c,l)}function Ht(e,t){return e.split(t).length-1}function Ut(e){return e.startsWith(`../`)||e.startsWith(`./`)}function Wt(e){let t=Ht(e,`/`);return`../`.repeat(t-1)}function Gt(e){let t=Ht(e,`/`);return`../`.repeat(t+1)}function Kt(e){return e?.includes(`node_modules/`)}let qt=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),Jt=e=>process.platform===`win32`?`"${e.replaceAll(`"`,String.raw`\"`)}"`:`'${e.replaceAll(`'`,`'"'"'`)}'`;function Yt(e,t){let n=a.default.isAbsolute(e)?e:Mt(e);return(0,x.default)(t,{cwd:n})}function Xt(e,t){let n=Yt(e,t);if(!(0,c.isDefined)(n))return;let r=b.readFileSync(n,`utf8`);return JSON.parse(r)}function Zt(e){return Xt(e,`package.json`)}function Qt(e,t){let{dependencies:n={},devDependencies:r={}}=e;return Object.keys({...r,...n}).includes(t)}let $t=[{path:`eslint.config.js`,isFlat:!0},{path:`eslint.config.cjs`,isFlat:!0},{path:`eslint.config.mjs`,isFlat:!0},{path:`eslint.config.ts`,isFlat:!0},{path:`eslint.config.mts`,isFlat:!0},{path:`eslint.config.cts`,isFlat:!0},{path:`.eslintrc`,isFlat:!1},{path:`.eslintrc.js`,isFlat:!1},{path:`.eslintrc.cjs`,isFlat:!1},{path:`.eslintrc.mjs`,isFlat:!1},{path:`.eslintrc.json`,isFlat:!1},{path:`.eslintrc.yaml`,isFlat:!1},{path:`.eslintrc.yml`,isFlat:!1}],en=[`@typescript-eslint/no-undefined`,`unicorn/no-useless-undefined`,`no-undefined`];async function tn(e){for(let{path:t,isFlat:n}of $t){let r=a.default.join(e,t);if(await U.fromAbsolutePath(r).isFileExists())return{path:r,isFlat:n}}return Zt(e)?.eslint?{path:Yt(e,`package.json`),isFlat:!1}:{path:null,isFlat:!1}}let nn={GET_TESTABLES:`get-testables`,GET_COVERAGE:`get-coverage`,GENERATE_COVERAGE:`generate-coverage`,SET_COVERAGE:`set-coverage`,GENERATE_TESTS:`generate-tests`,INITIALIZATION:`initialization`,GET_TESTED_CODE_DATA_SOURCE:`get-tested-code-data-source`,DYNAMIC_PROMPT:`dynamic-prompt`,TEST_VALIDATION:`test-validation`,REGRESSION_IMPACT:`regression-impact`,REGRESSION_CATALOG:`regression-catalog`},rn={CODE_EXTRACTOR:`code-extractor`,CODE_REFINEMENT:`code-refinement`,TEST_MANAGEMENT:`test-management`,TEST_VALIDATOR:`test-validator`,CONFIG_FILE:`config-file`,COMMAND_EXECUTION:`command-execution`},an=[`.jsx`,`.tsx`],on=[`it`,`test`,`it.each`,`test.each`],sn=function(e){return e.Default=`default`,e.ObjectDefault=`object-default`,e.Named=`named`,e.Unknown=`unknown`,e.NotExported=`not-exported`,e}({}),cn=function(e){return e.PRIVATE=`private`,e.PROTECTED=`protected`,e.PUBLIC=`public`,e}({}),ln=function(e){return e.REACT=`react`,e.ANGULAR=`angular`,e}({}),un=`unknown`,dn=`tests`,W=(0,w.promisify)(C.default.exec);async function fn(e,{cwd:t=yt().getRootPath(),timeout:n=1e4}={}){return(await W(e,{cwd:t,maxBuffer:500*1024,timeout:n}))?.stdout?.toString()??``}let pn=e=>{let t=Mt(e);return(0,x.default)(`jest.config.+(js|ts|mjs|cjs|json)`,{cwd:t})},mn=e=>(0,c.isObject)(e)&&(0,c.isString)(e.rootDir),hn=async e=>{let t;if(H.addContext({subCategory:rn.CONFIG_FILE}),(0,c.isDefined)(e)){let n=pn(e);n!==null&&(t=(0,a.dirname)(n))}t??=yt().getRootPath();let n;try{if(n=await fn(`npx jest --showConfig`,{cwd:t}),!(0,c.isString)(n))throw H.info.defaultLog(`Jest config return is not a string`,n),Error(`Jest config return is not a string`);let e=JSON.parse(n);if((0,c.isObject)(e)&&(0,c.isArray)(e.configs)&&e.configs.every(e=>mn(e)))return{projectConfigs:e.configs,globalConfig:e.globalConfig,configs:e.configs}}catch(e){H.info.defaultLog(`Cannot read jest config`,(0,c.getErrorMessage)(e)),H.info.defaultLog(`Failed reading jest config`,e,(0,c.getErrorMessage)(e));return}H.info.defaultLog(`Invalid jest config or config in not supported format`)},gn=async()=>{let e=[yt().getRootPath()],t=a.default.join(`node_modules`,`.prisma`,`client`,`index.d.ts`),n=e.map(e=>a.default.join(e,t)).map(e=>U.fromAbsolutePath(e));return(await(0,c.filterAsync)(n,e=>e.isFileExists())).map(e=>e.getAbsoluteFilePath())},_n=async()=>{try{let e=yt().getRootPath();if(!(0,c.isDefined)(e))return[];let t=await(0,T.getSchemaWithPathOptional)(``,``,{cwd:e});if(!(0,c.isDefined)(t))return[];let n=t.schemas.map(e=>e[1]),r=new Set;for(let e of n){let n=(await(0,T.getConfig)({datamodel:e,ignoreEnvVarErrors:!0})).generators;for(let e of n)if((0,c.isDefined)(e.output?.value)){let n=a.default.join(a.default.resolve(t.schemaRootDir,e.output.value),`index.d.ts`);await U.fromAbsolutePath(n).isFileExists()&&r.add(n)}}return[...r]}catch(e){return H.error(`Failed to get prisma typings paths`,e),[]}},vn=async()=>(await Promise.all([gn(),_n()])).flat(),yn=async(e,t=!1,n)=>{let r=`!**/node_modules/**`;if(t)return new S.Project({useInMemoryFileSystem:!0,compilerOptions:n});let i=It(e),o=bn((0,a.dirname)(Mt(e)),yt().isSiblingFolderStructured());if(!i&&!(0,c.isDefined)(o)){let t=await Sn(e);if(!(0,c.isDefined)(t)||(0,c.isEmpty)(t))throw Error(`Cannot find source code path in jest config`);let n=new S.Project({compilerOptions:{allowJs:!0,maxNodeModuleJsDepth:0},useInMemoryFileSystem:!1});return n.addSourceFilesAtPaths([...t,r]),n}if(!i&&(0,c.isDefined)(o)){let t=new S.Project({tsConfigFilePath:o,compilerOptions:{allowJs:!0,maxNodeModuleJsDepth:0}}),n=await Sn(e);return t.addSourceFilesAtPaths([...n,r]),t}let s={maxNodeModuleJsDepth:0};if(yt().isRootFolderStructured()){let e=yt().getRootPath();s.rootDirs=[a.default.resolve(e,`src`),a.default.resolve(e,dn)]}let l=new S.Project({tsConfigFilePath:o,compilerOptions:s}),u=await vn();for(let e of u)l.addSourceFileAtPath(e);return l},bn=(e,t)=>{let n;try{n=xn(e)}catch{t&&(n=xn((0,a.dirname)(e)))}return n},xn=e=>{let t=e,n=/^(tsconfig|jsconfig).*\.json$/;for(;t!==(0,a.dirname)(t);){let e=(0,a.join)(t,`tsconfig.json`),r=(0,a.join)(t,`jsconfig.json`);if(!(0,b.existsSync)(t))return xn((0,a.dirname)(t));if((0,b.existsSync)(e))return e;if((0,b.existsSync)(r))return r;let i=(0,b.readdirSync)(t);for(let e of i)if(n.test(e))return(0,a.join)(t,e);t=(0,a.dirname)(t)}},Sn=async e=>{let t=await hn(e);if((0,c.isDefined)(t)){let e=t?.configs[0].roots.map(e=>a.default.join(e,`**/*.{ts,js,tsx,jsx}`));if(!(0,c.isEmpty)(e))return e}return[Mt(Bt(e))]};var Cn=t.__toESM(dt()),wn=t.__toESM(ft());let G=`The ts-morph project is not initialized.`,Tn=new class{storage=new s.AsyncLocalStorage;_project;clear(){this._project=void 0}async init(e,t,n){let r=Mt(e);if((0,c.isDefined)(this._project))return this._project.addSourceFileAtPathIfExists(r);this._project=await yn(e,t,n);let i=this.storage.getStore();if((0,c.isDefined)(i))return this._project.addSourceFileAtPathIfExists(r)}add(e,t){let n=Mt(e),r=this.storage.getStore()?.getProject();if(!(0,c.isDefined)(r))throw Error(G);return r.createSourceFile(n,t,{overwrite:!0})}update(e,t){let n=this.get(e);return n.replaceWithText(t),n}addFile(e){(0,c.isDefined)(this._project)&&this._project.addSourceFileAtPathIfExists(e)}removeFile(e){if(!(0,c.isDefined)(this._project))return;let t=this._project.getSourceFile(e);(0,c.isDefined)(t)&&this._project.removeSourceFile(t)}async refreshFromFileSystem(e){if(!(0,c.isDefined)(this._project))return;let t=Mt(e),n=this._project?.getSourceFile(e)??this._project?.getSourceFile(t);if((0,c.isDefined)(n)){let e=n.getFilePath();this._project.removeSourceFile(n),this._project.addSourceFileAtPath(e)}}get(e){let t=Mt(e),n=this.storage.getStore()?.getProject();if(!(0,c.isDefined)(n))throw Error(G+` store`);let r=n.getSourceFile(t);if(!(0,c.isDefined)(r))throw Error(`The source file is absent. ${e}`);return r}async save(e){await this.get(e).save()}async delete(e){await this.get(e).deleteImmediately()}getOrUndefined(e){let t=Mt(e);return this._project?.getSourceFile(t)}withContext=(e,t,n)=>{let r=n.value,i=this.storage;if((0,c.isDefined)(i.getStore()))return n;let a=()=>this._project;return n.value=function(...e){let t={getProject:a};return i.run(t,()=>r.apply(this,e))},n}},En=Tn.withContext,Dn=async e=>{class t{async fn(){return e()}}(0,wn.default)([En,(0,Cn.default)(`design:type`,Function),(0,Cn.default)(`design:paramtypes`,[]),(0,Cn.default)(`design:returntype`,Promise)],t.prototype,`fn`,null),await new t().fn()},On=e=>{let t=e?.asKind(S.SyntaxKind.ExpressionStatement)?.getExpression();if(!(0,c.isDefined)(t))return;let n=t.asKind(S.SyntaxKind.CallExpression)?.getArguments()?.at(-1),r=n?.asKind(S.SyntaxKind.ArrowFunction)?.getBody(),i=n?.asKind(S.SyntaxKind.FunctionExpression)?.getBody();return r?.asKind(S.SyntaxKind.Block)??i?.asKind(S.SyntaxKind.Block)},kn=e=>S.Node.isExpressionStatement(e)&&e.getFirstChildByKind(S.SyntaxKind.CallExpression)?.getFirstChildByKind(S.SyntaxKind.Identifier)?.getText()===`describe`,An=e=>e.getStatements().filter(e=>kn(e)),jn=e=>{let t=e.getExpression().getFirstChild()?.getText();return!(0,c.isDefined)(t)||(0,c.isEmpty)(t)?!1:on.some(e=>t.startsWith(e))},Mn=e=>{let t=On(e);return(0,c.isDefined)(t)?t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).some(e=>jn(e)):!1},Nn=e=>{let t=On(e);return(0,c.isDefined)(t)?t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).filter(e=>kn(e)&&Mn(e)):[]},Pn=e=>{let t=On(e);if((0,c.isDefined)(t))return t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).find(e=>kn(e)&&Mn(e))},Fn=e=>{let t=Pn(e);return(0,c.isDefined)(t)},In=e=>{let t=On(e);if(!(0,c.isDefined)(t))return!0;let n=t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement);if((0,c.isEmpty)(n))return!0;let r=new Set([`beforeEach`,`afterEach`,`beforeAll`,`afterAll`]);return n.every(e=>{let t=e.getExpressionIfKind(S.SyntaxKind.CallExpression)?.getExpressionIfKind(S.SyntaxKind.Identifier);return(0,c.isDefined)(t)?r.has(t.getText()):!1})},Ln=e=>{if(e.isNamedExport?.())return sn.Named;if(e.isDefaultExport?.())return sn.Default;let t=e?.getParent();if((0,c.isDefined)(t)){if(t.isNamedExport?.())return sn.Named;if(t.isDefaultExport?.())return sn.Default}return e.isExportDefaultObject?.()??zn(e.getSourceFile(),e.getName?.())?sn.ObjectDefault:sn.NotExported},Rn=(e,t)=>(0,c.isDefined)(e)?Ln(e):(0,c.isDefined)(t)?t.isNamedImport?sn.Named:sn.Default:sn.Unknown;function zn(e,t){let[n]=e.getExportAssignments()??[];return n?.getDescendantsOfKind(S.SyntaxKind.Identifier).some(e=>(e.getSymbol()?.getEscapedName()??e.getText())===t)}function Bn(e,t){let n=An(Tn.get(e)),r=n.find(e=>e.getText().includes(t))??n[0],i=Nn(r),a=[],o=(0,c.isEmpty)(i)?[r]:i;for(let e of o){let t=On(e);(0,c.isDefined)(t)&&a.push(...t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).filter(e=>jn(e)))}return a}let Vn=e=>e.getFirstDescendantByKind(S.SyntaxKind.StringLiteral)?.getLiteralValue(),Hn=e=>Vn(e),Un=e=>Vn(e),Wn=(e,t)=>{let n=e.getFullText().slice(0,Math.max(0,t)).split(`
|
|
32372
|
+
`);return a!==-1&&(t=B(t,i,r,a)),r+t+i};Object.defineProperties($e.prototype,Xe);let at=$e();$e({level:Ge?Ge.level:0});var ot=at;let st=()=>{},ct={info:st,verbose:st,debug:st},lt=[ot.cyan,ot.magenta,ot.green,ot.blue,ot.redBright,ot.cyanBright,ot.magentaBright,ot.greenBright];function V(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.codePointAt(n)??0,t=Math.imul(t,16777619);return lt[Math.abs(t)%lt.length]}function ut(e,t){let n=(0,c.isDefined)(t.parentName)?`${t.parentName}.${t.methodName}`:t.methodName,r=V(n)(`[${n}]`);return{info:(...t)=>e.info(r,...t),verbose:(...t)=>e.verbose(r,...t),debug:(...t)=>e.debug(r,...t)}}var dt=t.__commonJSMin(((e,t)=>{function n(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),ft=t.__commonJSMin(((e,t)=>{function n(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),pt=t.__toESM(dt()),mt=t.__toESM(ft()),ht,gt;let _t=class{config;constructor(e,t={}){if(!(0,c.isDefined)(e)){this.config=Te;return}let n=Ee(e);this.config=(0,c.merge)(Te,n,t)}getRootPath=()=>this.config.rootPath;isSiblingFolderStructured=()=>this.config.isSiblingFolderStructured;getGitURL=()=>this.config.context?.git?.remoteUrl??this.config.gitURL;getGitTopLevel=()=>this.config.context?.git?.topLevel??this.getRootPath();getTestFramework=()=>this.config.testFramework;getGreyTestBehaviour=()=>this.config.greyTestBehaviour;getRedTestBehaviour=()=>this.config.redTestBehaviour;shouldKeepErrorTests=()=>this.config.keepErrorTests;shouldKeepFailedTests=()=>this.config.keepFailedTests;shouldConditionalKeep=()=>this.config.conditionalKeep;getGeneratedTestStructure=()=>this.config.generatedTestStructure;getGenerateTestsLLMModelName=()=>this.config.generateTestsLLMModelName;isRootFolderStructured=()=>this.config.isRootFolderStructured;getLLMTemperature=()=>this.config.llmTemperature;getLLMTopP=()=>this.config.llmTopP;getClientSource=()=>this.config.clientSource;getBackendURL=()=>this.config.backendURL;getRequestSource=()=>this.config.requestSource;getUserPrompt=()=>this.config.userPrompt;getTestLocation=()=>this.config.testLocation;getCoverageThreshold=()=>this.config.coverageThreshold;getConcurrency=()=>this.config.concurrency;getTestFileFormat=()=>this.config.testFileFormat;getOutputType=()=>this.config.outputType;getShouldRefreshCoverage=()=>this.config.shouldRefreshCoverage;isKebabCaseFileName=()=>this.config.kebabCaseFileName;getEarlyTestFilenameSuffix=()=>this.config.earlyTestFilenameSuffix;getTestSuffix=()=>this.config.testSuffix;getIsAppendPrompt=()=>this.config.isAppendPrompt;getFixTestsLLMModelName=()=>this.config.fixTestsLLMModelName;getDynamicPromptIterations=()=>this.config.dynamicPromptIterations;getWSServerEndpoint=()=>this.config.backendURL.replace(`http://`,`ws://`).replace(`https://`,`wss://`);getAnthropicProxyUrl=()=>new URL(`/anthropic`,this.config.backendURL).href;getSecretToken=()=>this.config.secretToken;getLoggerConfig=()=>this.config.loggerConfig;getContext=()=>this.config.context;getTestCommand=()=>this.config.testCommand;getCoverageCommand=()=>this.config.coverageCommand;getLintCommand=()=>this.config.lintCommand;getPrettierCommand=()=>this.config.prettierCommand;shouldDisableLintRules=()=>this.config.disableLintRules;shouldIgnoreAsAnyLintErrors=()=>this.config.ignoreAsAnyLintErrors;allowUndefinedLintErrors=()=>this.config.allowUndefinedLintErrors;getIncludeEarlyTests=()=>this.config.includeEarlyTests??!1;shouldContinueOnTestErrors=()=>this.config.continueOnTestErrors;getPerFunctionTimeout=()=>this.config.perFunctionTimeout;shouldRemoveComments=()=>this.config.removeComments;getExperimentalAgentSdk=()=>this.config.experimentalAgentSdk;shouldCompressOutput=()=>this.config.compressOutput;getAgentSdkModel=()=>this.config.agentSdkModel;getAgentSdkBudget=()=>this.config.agentSdkBudget;getPluginPath=()=>this.config.pluginPath;getClaudeCodeExecutablePath=()=>this.config.claudeCodeExecutablePath;getJobId=()=>this.config.jobId;getLabel=()=>this.config.label;getProjectId=()=>this.config.projectId;getE2eCatalogIds=()=>this.config.e2eCatalogIds;updateContext=e=>{this.config.context=(0,c.merge)(this.config.context??{},e??{})};updateRootPath=e=>{this.config.rootPath=e};isDebug=()=>this.config.debug??!1;isVerbose=()=>this.config.verbose??!1;getOnTokenRefresh=()=>this.config.onTokenRefresh;getProgressLogger=e=>{let t=this.config.progressLogger??ct;return(0,c.isDefined)(e)?ut(t,e):t}};_t=(0,mt.default)([(0,u.injectable)(`Singleton`),(0,pt.default)(`design:paramtypes`,[typeof(ht=typeof Partial<`u`&&Partial)==`function`?ht:Object,typeof(gt=typeof Partial<`u`&&Partial)==`function`?gt:Object])],_t);var vt=new u.Container({autobind:!0,defaultScope:`Singleton`});let yt=()=>vt.get(_t);var bt=class{storage=new s.AsyncLocalStorage;isConsoleEnabled;constructor(e){this.isConsoleEnabled=e}orderedFlush={nextOrder:1,pending:new Map};resetOrder(){this.orderedFlush={nextOrder:1,pending:new Map}}async withBufferedPrinting(e,t){let n=[];try{return await this.storage.run(n,e)}finally{this.flushInOrder(t,n)}}printOrBuffer(e,t){let n=this.storage.getStore();if((0,c.isDefined)(n)){n.push({method:e,message:t});return}this.isConsoleEnabled&&console[e](t)}async flushInOrder(e,t){if(this.orderedFlush.nextOrder===e){this.flushBuffer(t),this.orderedFlush.nextOrder++,this.drainPendingFlushes();return}return new Promise(n=>{this.orderedFlush.pending.set(e,{buffer:t,resolve:n})})}drainPendingFlushes(){let e=this.orderedFlush.pending.get(this.orderedFlush.nextOrder);for(;(0,c.isDefined)(e);)this.orderedFlush.pending.delete(this.orderedFlush.nextOrder),this.flushBuffer(e.buffer),this.orderedFlush.nextOrder++,e.resolve(),e=this.orderedFlush.pending.get(this.orderedFlush.nextOrder)}flushBuffer(e){if(this.isConsoleEnabled)for(let t of e)console[t.method](t.message)}};let xt=function(e){return e.DEFAULT=`default`,e.VERBOSE=`verbose`,e.DEBUG=`debug`,e}({}),St=function(e){return e.INFO=`info`,e.WARN=`warn`,e}({});function Ct(){return(0,h.randomUUID)()}function wt(){let e=``;for(let t=0;t<8;t++)e+=`abcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*36));return e}var Tt=t.__toESM(dt()),Et=t.__toESM(ft()),Dt=class{export(e,t){for(let t of e){let e=t.body;if((0,c.isString)(e))console.info(e);else try{console.info(JSON.stringify(e))}catch{console.info(String(e))}}t({code:0})}shutdown(){return Promise.resolve()}};let Ot=class{loggerProvider;config;constructor(e){this.config=e,this.loggerProvider=new v.LoggerProvider({resource:(0,_.resourceFromAttributes)({[y.ATTR_SERVICE_NAME]:ge,[y.ATTR_SERVICE_VERSION]:_e})}),this.initializeExporters(),this.setGlobalLoggerProvider()}getLogger(e){return this.loggerProvider.getLogger(e)}initializeExporters(){let e=[];if(this.config.consoleEnabled){let t=new Dt;e.push(new v.SimpleLogRecordProcessor(t))}if(this.config.azureEnabled&&(0,c.isDefined)(this.config.azureConnectionString)){let t=new g.AzureMonitorLogExporter({connectionString:this.config.azureConnectionString});e.push(new v.BatchLogRecordProcessor(t))}this.loggerProvider=new v.LoggerProvider({processors:e})}setGlobalLoggerProvider(){l.logs.setGlobalLoggerProvider(this.loggerProvider)}};Ot=(0,Et.default)([(0,u.injectable)(),(0,Tt.default)(`design:paramtypes`,[Object])],Ot),t.__toESM(dt()),t.__toESM(ft());let H=new class{storage;otelService;otelLogger;isConsoleEnabled;printBuffer;default=this.createLogObject(xt.DEFAULT);verbose=this.createLogObject(xt.VERBOSE);constructor(e){this.storage=new s.AsyncLocalStorage,this.otelService=new Ot(e),this.otelLogger=this.otelService.getLogger(`ts-agent`),this.isConsoleEnabled=e.consoleEnabled,this.printBuffer=new bt(e.consoleEnabled)}resetPrintOrder(){this.printBuffer.resetOrder()}async withBufferedPrinting(e,t){return this.printBuffer.withBufferedPrinting(e,t)}info={startLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`Start ${e}`,...t),endLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`End ${e}`,...t),failedLog:(e,...t)=>this.log(l.SeverityNumber.INFO,`Failed ${e}`,...t),defaultLog:(e,...t)=>this.log(l.SeverityNumber.INFO,e,...t)};debug={startLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`Start ${e}`,...t),endLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`End ${e}`,...t),failedLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,`Failed ${e}`,...t),defaultLog:(e,...t)=>this.log(l.SeverityNumber.DEBUG,e,...t)};error(e,t,...n){let r=t instanceof Error?`${e} ${t.message} ${t.stack}`:`${e} ${JSON.stringify(t)}`;this.log(l.SeverityNumber.ERROR,r,...n)}getRequestId(){return this.storage.getStore()?.requestId??``}getTraceId(){return this.storage.getStore()?.traceId??``}log(e,t,...n){let r=this.formatMessage(t,...n);this.logToOpenTelemetry(e,r),!(!this.isConsoleEnabled||!this.isLevelEnabled(xt.DEBUG))&&console.info(r)}logToOpenTelemetry(e,t){let n=this.storage.getStore(),r={service:ge,version:_e};(0,c.isDefined)(n)&&((0,c.isDefined)(n.traceId)&&(r.traceId=n.traceId),(0,c.isDefined)(n.requestId)&&(r.requestId=n.requestId),(0,c.isDefined)(n.category)&&(r.category=n.category),(0,c.isDefined)(n.subCategory)&&(r.subCategory=n.subCategory),(0,c.isDefined)(n.testedMethodClass)&&(r.testedMethodClass=n.testedMethodClass),(0,c.isDefined)(n.testedFunction)&&(r.testedFunction=n.testedFunction),(0,c.isDefined)(n.userId)&&(r.userId=n.userId.toString())),this.otelLogger.emit({severityNumber:e,severityText:this.getSeverityText(e),body:t,attributes:r})}getSeverityText(e){switch(e){case l.SeverityNumber.TRACE:return`TRACE`;case l.SeverityNumber.DEBUG:return`DEBUG`;case l.SeverityNumber.INFO:return`INFO`;case l.SeverityNumber.WARN:return`WARN`;case l.SeverityNumber.ERROR:return`ERROR`;case l.SeverityNumber.FATAL:return`FATAL`;default:return`INFO`}}formatMessage(e,...t){let n=this.formatPrefix(),r=(0,c.isDefined)(n)?`${n} ${e}`:e;return this.formatPrint(r,...t)}formatPrint(e,...t){return(0,c.isEmpty)(t)?e:`${e} ${t.map(e=>JSON.stringify(e)).join(` `)}`}withContext=(e,t,n)=>{let r=n.value,i=this.storage;return n.value=function(...e){let t=i.getStore();if(t){let n={...t};return i.run(n,()=>r.apply(this,e))}let n={traceId:wt(),requestId:Ct()};return i.run(n,()=>r.apply(this,e))},n};addContext(e){let t=this.storage.getStore();(0,c.isDefined)(t)&&(t.category=e.category??t.category,t.subCategory=e.subCategory??t.subCategory,t.testedMethodClass=e.testedMethodClass??t.testedMethodClass,t.testedFunction=e.testedFunction??t.testedFunction,t.userId=e.userId??t.userId)}captureContext({withNewRequestId:e=!1}={}){let t=this.storage.getStore();return t?{...t,...e&&{requestId:Ct()}}:void 0}async runWithContext(e,t){return(0,c.isDefined)(e)?this.storage.run(e,t):t()}isLevelEnabled(e){switch(e){case xt.DEFAULT:return!0;case xt.VERBOSE:return yt().isVerbose()||yt().isDebug();case xt.DEBUG:return yt().isDebug()}}createLogObject(e){return{info:(t,...n)=>{this.isLevelEnabled(e)&&this.printOrBuffer(St.INFO,this.formatPrint(t,...n))},warn:(t,...n)=>{this.isLevelEnabled(e)&&this.printOrBuffer(St.WARN,this.formatPrint(t,...n))}}}printOrBuffer(e,t){this.printBuffer.printOrBuffer(e,t)}formatPrefix(){let e=this.storage.getStore();if(!(0,c.isDefined)(e))return``;let t=[];return(0,c.isDefined)(e.traceId)&&t.push(`[${e.traceId}]`),(0,c.isDefined)(e.requestId)&&t.push(`[${e.requestId}]`),(0,c.isDefined)(e.category)&&t.push(`[${e.category}]`),(0,c.isDefined)(e.subCategory)&&t.push(`[${e.subCategory}]`),(0,c.isDefined)(e.testedMethodClass)&&t.push(`[${e.testedMethodClass}]`),(0,c.isDefined)(e.testedFunction)&&t.push(`[${e.testedFunction}]`),t.join(` `)}}({consoleEnabled:process.env.LOG_CONSOLE===`true`,azureEnabled:!0,azureConnectionString:`InstrumentationKey=c18a3332-f844-498f-98e0-d818996cf526;IngestionEndpoint=https://eastus2-3.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/;ApplicationId=2150ffe0-cb0f-4b00-9562-d3385b383d74`});function kt(e){return function(t,n,r){return(0,c.isDefined)(e)&&H.addContext(e),H.withContext(t,n,r)}}var U=class e{rootPath;absolutePath;static EARLY_FILENAME_VAR=`$early_filename`;constructor(e){this.rootPath=a.default.normalizeTrim(yt().getRootPath());let t=a.default.normalizeTrim(e),n=a.default.normalizeTrim(this.rootPath);if(t===n||t.startsWith(n+a.default.sep))this.absolutePath=t;else{let e=t.replace(/^\//,``);this.absolutePath=a.default.resolve(this.rootPath,e)}}static fromSourceFile(t){let n=a.default.normalizeTrim(t.getFilePath());return new e(a.default.relative(a.default.normalizeTrim(yt().getRootPath()),n))}static fromAbsolutePath(t){let n=a.default.normalizeTrim(t);return new e(a.default.relative(a.default.normalizeTrim(yt().getRootPath()),n))}static fromRelativePath(t){return new e(t)}getRelativeFilePath(){return a.default.relative(this.rootPath,this.absolutePath)}getAbsoluteFilePath(){return this.absolutePath}async isFileExists(){try{return(await o.default.stat(this.absolutePath)).isFile()}catch{return!1}}async isDirectoryExists(){try{return(await o.default.stat(this.absolutePath)).isDirectory()}catch{return!1}}async createDirectory(e){await o.default.mkdir(this.absolutePath,{recursive:e?.recursive??!0})}async getText(){try{return await o.default.readFile(this.absolutePath,`utf8`)}catch{return``}}async upsert(e){let t=a.default.dirname(this.absolutePath);await o.default.mkdir(t,{recursive:!0}),await(await this.isFileExists()?o.default.appendFile(this.absolutePath,e):o.default.writeFile(this.absolutePath,e)),H.info.defaultLog(`Upserted file`,{path:this.getRelativeFilePath()})}async replace(e){let t=a.default.dirname(this.absolutePath);await o.default.mkdir(t,{recursive:!0}),await o.default.writeFile(this.absolutePath,e),H.info.defaultLog(`Replaced file`,{path:this.getRelativeFilePath()})}async delete(){try{await o.default.unlink(this.absolutePath),H.info.defaultLog(`Deleted file`,{path:this.getRelativeFilePath()})}catch{}}};let At={WIN32:`win32`,DARWIN:`darwin`,LINUX:`linux`},jt={JAVASCRIPT:`javascript`,TYPESCRIPT:`typescript`,PYTHON:`python`},Mt=e=>{let t=yt().getRootPath();return a.default.resolve(t,e)},Nt=e=>{let t=yt().getRootPath(),n=a.default.normalize(e);return a.default.relative(t,n)},Pt=e=>({".js":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".jsx":`javascript`,".ts":`typescript`,".tsx":`typescript`,".py":`python`})[e.toLowerCase()]??`javascript`;function Ft(e){return Pt((0,a.extname)(e))}function It(e){return Pt((0,a.extname)(e))===`typescript`}function Lt(e){return Pt((0,a.extname)(e))===jt.PYTHON}function Rt(e){let t=yt().getRootPath();if(!(0,c.isDefined)(t))throw Error(`Workspace root path is not defined`);if((0,c.isEmpty)(e))return a.default.normalize(t);let n=a.default.normalize(t),r=a.default.normalize(e);if(process.platform===At.WIN32){let t=n.split(`:`)[0].toUpperCase(),i=r.split(`:`)[0].toUpperCase();if(t!==i&&!i.startsWith(t))return e}return a.default.relative(n,r)}function zt(e){return e.startsWith(`../`)?`../${e}`:e.startsWith(`./`)?`.${e}`:e}function Bt(e){let t=a.default.normalize(Mt(e)),n=a.default.normalize((0,x.default)([`package.json`,`project.json`],{cwd:t})??``);if(!n)return``;let r=Nt((0,a.dirname)(n));return r.startsWith(`/`)?r.slice(1):r}function Vt(e,t,n){if(!Ut(e))return e;let r=n===``?t:t.replace(n,``),i=n===``?Gt(r):Wt(r),o=r.split(`/`).slice(0,-1),s=Ht(e,`../`),c=s>0?o.slice(0,-s).join(`/`):(0,a.dirname)(r),l=e.replaceAll(`../`,``).replaceAll(`./`,``);return a.default.join(i,c,l)}function Ht(e,t){return e.split(t).length-1}function Ut(e){return e.startsWith(`../`)||e.startsWith(`./`)}function Wt(e){let t=Ht(e,`/`);return`../`.repeat(t-1)}function Gt(e){let t=Ht(e,`/`);return`../`.repeat(t+1)}function Kt(e){return e?.includes(`node_modules/`)}let qt=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),Jt=e=>process.platform===`win32`?`"${e.replaceAll(`"`,String.raw`\"`)}"`:`'${e.replaceAll(`'`,`'"'"'`)}'`;function Yt(e,t){let n=a.default.isAbsolute(e)?e:Mt(e);return(0,x.default)(t,{cwd:n})}function Xt(e,t){let n=Yt(e,t);if(!(0,c.isDefined)(n))return;let r=b.readFileSync(n,`utf8`);return JSON.parse(r)}function Zt(e){return Xt(e,`package.json`)}function Qt(e,t){let{dependencies:n={},devDependencies:r={}}=e;return Object.keys({...r,...n}).includes(t)}let $t=[{path:`eslint.config.js`,isFlat:!0},{path:`eslint.config.cjs`,isFlat:!0},{path:`eslint.config.mjs`,isFlat:!0},{path:`eslint.config.ts`,isFlat:!0},{path:`eslint.config.mts`,isFlat:!0},{path:`eslint.config.cts`,isFlat:!0},{path:`.eslintrc`,isFlat:!1},{path:`.eslintrc.js`,isFlat:!1},{path:`.eslintrc.cjs`,isFlat:!1},{path:`.eslintrc.mjs`,isFlat:!1},{path:`.eslintrc.json`,isFlat:!1},{path:`.eslintrc.yaml`,isFlat:!1},{path:`.eslintrc.yml`,isFlat:!1}],en=[`@typescript-eslint/no-undefined`,`unicorn/no-useless-undefined`,`no-undefined`];async function tn(e){for(let{path:t,isFlat:n}of $t){let r=a.default.join(e,t);if(await U.fromAbsolutePath(r).isFileExists())return{path:r,isFlat:n}}return Zt(e)?.eslint?{path:Yt(e,`package.json`),isFlat:!1}:{path:null,isFlat:!1}}let nn={GET_TESTABLES:`get-testables`,GET_COVERAGE:`get-coverage`,GENERATE_COVERAGE:`generate-coverage`,SET_COVERAGE:`set-coverage`,GENERATE_TESTS:`generate-tests`,INITIALIZATION:`initialization`,GET_TESTED_CODE_DATA_SOURCE:`get-tested-code-data-source`,DYNAMIC_PROMPT:`dynamic-prompt`,TEST_VALIDATION:`test-validation`,REGRESSION_IMPACT:`regression-impact`,REGRESSION_CATALOG:`regression-catalog`},rn={CODE_EXTRACTOR:`code-extractor`,CODE_REFINEMENT:`code-refinement`,TEST_MANAGEMENT:`test-management`,TEST_VALIDATOR:`test-validator`,CONFIG_FILE:`config-file`,COMMAND_EXECUTION:`command-execution`},an=[`.jsx`,`.tsx`],on=[`it`,`test`,`it.each`,`test.each`],sn=function(e){return e.Default=`default`,e.ObjectDefault=`object-default`,e.Named=`named`,e.Unknown=`unknown`,e.NotExported=`not-exported`,e}({}),cn=function(e){return e.PRIVATE=`private`,e.PROTECTED=`protected`,e.PUBLIC=`public`,e}({}),ln=function(e){return e.REACT=`react`,e.ANGULAR=`angular`,e}({}),un=`unknown`,dn=`tests`,W=(0,w.promisify)(C.default.exec);async function fn(e,{cwd:t=yt().getRootPath(),timeout:n=1e4}={}){return(await W(e,{cwd:t,maxBuffer:500*1024,timeout:n}))?.stdout?.toString()??``}let pn=e=>{let t=Mt(e);return(0,x.default)(`jest.config.+(js|ts|mjs|cjs|json)`,{cwd:t})},mn=e=>(0,c.isObject)(e)&&(0,c.isString)(e.rootDir),hn=async e=>{let t;if(H.addContext({subCategory:rn.CONFIG_FILE}),(0,c.isDefined)(e)){let n=pn(e);n!==null&&(t=(0,a.dirname)(n))}t??=yt().getRootPath();let n;try{if(n=await fn(`npx jest --showConfig`,{cwd:t}),!(0,c.isString)(n))throw H.info.defaultLog(`Jest config return is not a string`,n),Error(`Jest config return is not a string`);let e=JSON.parse(n);if((0,c.isObject)(e)&&(0,c.isArray)(e.configs)&&e.configs.every(e=>mn(e)))return{projectConfigs:e.configs,globalConfig:e.globalConfig,configs:e.configs}}catch(e){H.info.defaultLog(`Cannot read jest config`,(0,c.getErrorMessage)(e)),H.info.defaultLog(`Failed reading jest config`,e,(0,c.getErrorMessage)(e));return}H.info.defaultLog(`Invalid jest config or config in not supported format`)},gn=async()=>{let e=[yt().getRootPath()],t=a.default.join(`node_modules`,`.prisma`,`client`,`index.d.ts`),n=e.map(e=>a.default.join(e,t)).map(e=>U.fromAbsolutePath(e));return(await(0,c.filterAsync)(n,e=>e.isFileExists())).map(e=>e.getAbsoluteFilePath())},_n=async()=>{try{let e=yt().getRootPath();if(!(0,c.isDefined)(e))return[];let t=await(0,T.getSchemaWithPathOptional)(``,``,{cwd:e});if(!(0,c.isDefined)(t))return[];let n=t.schemas.map(e=>e[1]),r=new Set;for(let e of n){let n=(await(0,T.getConfig)({datamodel:e,ignoreEnvVarErrors:!0})).generators;for(let e of n)if((0,c.isDefined)(e.output?.value)){let n=a.default.join(a.default.resolve(t.schemaRootDir,e.output.value),`index.d.ts`);await U.fromAbsolutePath(n).isFileExists()&&r.add(n)}}return[...r]}catch(e){return H.error(`Failed to get prisma typings paths`,e),[]}},vn=async()=>(await Promise.all([gn(),_n()])).flat(),yn=async(e,t=!1,n)=>{let r=`!**/node_modules/**`;if(t)return new S.Project({useInMemoryFileSystem:!0,compilerOptions:n});let i=It(e),o=bn((0,a.dirname)(Mt(e)),yt().isSiblingFolderStructured());if(!i&&!(0,c.isDefined)(o)){let t=await Sn(e);if(!(0,c.isDefined)(t)||(0,c.isEmpty)(t))throw Error(`Cannot find source code path in jest config`);let n=new S.Project({compilerOptions:{allowJs:!0,maxNodeModuleJsDepth:0},useInMemoryFileSystem:!1});return n.addSourceFilesAtPaths([...t,r]),n}if(!i&&(0,c.isDefined)(o)){let t=new S.Project({tsConfigFilePath:o,compilerOptions:{allowJs:!0,maxNodeModuleJsDepth:0}}),n=await Sn(e);return t.addSourceFilesAtPaths([...n,r]),t}let s={maxNodeModuleJsDepth:0};if(yt().isRootFolderStructured()){let e=yt().getRootPath();s.rootDirs=[a.default.resolve(e,`src`),a.default.resolve(e,dn)]}let l=new S.Project({tsConfigFilePath:o,compilerOptions:s}),u=await vn();for(let e of u)l.addSourceFileAtPath(e);return l},bn=(e,t)=>{let n;try{n=xn(e)}catch{t&&(n=xn((0,a.dirname)(e)))}return n},xn=e=>{let t=e,n=/^(tsconfig|jsconfig).*\.json$/;for(;t!==(0,a.dirname)(t);){let e=(0,a.join)(t,`tsconfig.json`),r=(0,a.join)(t,`jsconfig.json`);if(!(0,b.existsSync)(t))return xn((0,a.dirname)(t));if((0,b.existsSync)(e))return e;if((0,b.existsSync)(r))return r;let i=(0,b.readdirSync)(t);for(let e of i)if(n.test(e))return(0,a.join)(t,e);t=(0,a.dirname)(t)}},Sn=async e=>{let t=await hn(e);if((0,c.isDefined)(t)){let e=t?.configs[0].roots.map(e=>a.default.join(e,`**/*.{ts,js,tsx,jsx}`));if(!(0,c.isEmpty)(e))return e}return[Mt(Bt(e))]};var Cn=t.__toESM(dt()),wn=t.__toESM(ft());let G=`The ts-morph project is not initialized.`,Tn=new class{storage=new s.AsyncLocalStorage;_project;clear(){this._project=void 0}async init(e,t,n){let r=Mt(e);if((0,c.isDefined)(this._project))return this._project.addSourceFileAtPathIfExists(r);this._project=await yn(e,t,n);let i=this.storage.getStore();if((0,c.isDefined)(i))return this._project.addSourceFileAtPathIfExists(r)}add(e,t){let n=Mt(e),r=this.storage.getStore()?.getProject();if(!(0,c.isDefined)(r))throw Error(G);return r.createSourceFile(n,t,{overwrite:!0})}update(e,t){let n=this.get(e);return n.replaceWithText(t),n}addFile(e){(0,c.isDefined)(this._project)&&this._project.addSourceFileAtPathIfExists(e)}removeFile(e){if(!(0,c.isDefined)(this._project))return;let t=this._project.getSourceFile(e);(0,c.isDefined)(t)&&this._project.removeSourceFile(t)}async refreshFromFileSystem(e){if(!(0,c.isDefined)(this._project))return;let t=Mt(e),n=this._project?.getSourceFile(e)??this._project?.getSourceFile(t);if((0,c.isDefined)(n)){let e=n.getFilePath();this._project.removeSourceFile(n),this._project.addSourceFileAtPath(e)}}get(e){let t=Mt(e),n=this.storage.getStore()?.getProject();if(!(0,c.isDefined)(n))throw Error(G+` store`);let r=n.getSourceFile(t);if(!(0,c.isDefined)(r))throw Error(`The source file is absent. ${e}`);return r}async save(e){await this.get(e).save()}async delete(e){await this.get(e).deleteImmediately()}getOrUndefined(e){let t=Mt(e);return this._project?.getSourceFile(t)}withContext=(e,t,n)=>{let r=n.value,i=this.storage;if((0,c.isDefined)(i.getStore()))return n;let a=()=>this._project;return n.value=function(...e){let t={getProject:a};return i.run(t,()=>r.apply(this,e))},n}},En=Tn.withContext,Dn=async e=>{class t{async fn(){return e()}}(0,wn.default)([En,(0,Cn.default)(`design:type`,Function),(0,Cn.default)(`design:paramtypes`,[]),(0,Cn.default)(`design:returntype`,Promise)],t.prototype,`fn`,null),await new t().fn()},On=e=>{let t=e?.asKind(S.SyntaxKind.ExpressionStatement)?.getExpression();if(!(0,c.isDefined)(t))return;let n=t.asKind(S.SyntaxKind.CallExpression)?.getArguments()?.at(-1),r=n?.asKind(S.SyntaxKind.ArrowFunction)?.getBody(),i=n?.asKind(S.SyntaxKind.FunctionExpression)?.getBody();return r?.asKind(S.SyntaxKind.Block)??i?.asKind(S.SyntaxKind.Block)},kn=e=>S.Node.isExpressionStatement(e)&&e.getFirstChildByKind(S.SyntaxKind.CallExpression)?.getFirstChildByKind(S.SyntaxKind.Identifier)?.getText()===`describe`,An=e=>e.getStatements().filter(e=>kn(e)),jn=e=>{let t=e.getExpression().getFirstChild()?.getText();return!(0,c.isDefined)(t)||(0,c.isEmpty)(t)?!1:on.some(e=>t.startsWith(e))},Mn=e=>{let t=On(e);return(0,c.isDefined)(t)?t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).some(e=>jn(e)):!1},Nn=e=>{let t=On(e);return(0,c.isDefined)(t)?t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).filter(e=>kn(e)&&Mn(e)):[]},Pn=e=>{let t=On(e);if((0,c.isDefined)(t))return t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).find(e=>kn(e)&&Mn(e))},Fn=e=>{let t=Pn(e);return(0,c.isDefined)(t)},In=e=>{let t=On(e);if(!(0,c.isDefined)(t))return!0;let n=t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement);if((0,c.isEmpty)(n))return!0;let r=new Set([`beforeEach`,`afterEach`,`beforeAll`,`afterAll`]);return n.every(e=>{let t=e.getExpressionIfKind(S.SyntaxKind.CallExpression)?.getExpressionIfKind(S.SyntaxKind.Identifier);return(0,c.isDefined)(t)?r.has(t.getText()):!1})},Ln=e=>{if(e.isNamedExport?.())return sn.Named;if(e.isDefaultExport?.())return sn.Default;let t=e?.getParent();if((0,c.isDefined)(t)){if(t.isNamedExport?.())return sn.Named;if(t.isDefaultExport?.())return sn.Default}return e.isExportDefaultObject?.()??zn(e.getSourceFile(),e.getName?.())?sn.ObjectDefault:sn.NotExported},Rn=(e,t)=>(0,c.isDefined)(e)?Ln(e):(0,c.isDefined)(t)?t.isNamedImport?sn.Named:sn.Default:sn.Unknown;function zn(e,t){let[n]=e.getExportAssignments()??[];return n?.getDescendantsOfKind(S.SyntaxKind.Identifier).some(e=>(e.getSymbol()?.getEscapedName()??e.getText())===t)}function Bn(e,t){let n=An(Tn.get(e)),r=n.find(e=>e.getText().includes(t))??n[0],i=Nn(r),a=[],o=(0,c.isEmpty)(i)?[r]:i;for(let e of o){let t=On(e);(0,c.isDefined)(t)&&a.push(...t.getChildrenOfKind(S.SyntaxKind.ExpressionStatement).filter(e=>jn(e)))}return a}let Vn=e=>e.getFirstDescendantByKind(S.SyntaxKind.StringLiteral)?.getLiteralValue(),Hn=e=>Vn(e),Un=e=>Vn(e),Wn=(e,t)=>{let n=e.getFullText().slice(0,Math.max(0,t)).split(`
|
|
32373
32373
|
`);return{line:n.length,column:(n.at(-1)?.length??0)+1}},Gn=(e,t)=>{let n=t.getStart(),r=t.getEnd(),{line:i,column:a}=Wn(e,n),{line:o,column:s}=Wn(e,r);return{startLine:i,startColumn:a,startIndex:n,endLine:o,endColumn:s,endIndex:r}},Kn=e=>e.getDescendantsOfKind(S.SyntaxKind.ExpressionStatement).filter(e=>jn(e)),qn=(e,t,n,r)=>{let i=r?`.tsx`:`.ts`,a=t+Date.now()+(0,h.randomUUID)()+i;return e.createSourceFile(a,n)},Jn=e=>e.getDescendantsOfKind(S.SyntaxKind.CallExpression).reduce((e,t)=>{let n=t.getExpression(),r=n.getParentIfKind(S.SyntaxKind.VariableDeclaration);return(0,c.isDefined)(r)&&n.getText()===`require`&&e.push(r),e},[]),Yn=e=>{let t=e.getFirstChildByKind(S.SyntaxKind.CallExpression);if(!(0,c.isDefined)(t))return;let[n]=t.getArguments();if(!(!(0,c.isDefined)(n)||n.getKind()!==S.SyntaxKind.StringLiteral))return n.getText().slice(1,-1)},Xn=e=>{let t=[`${yt().getEarlyTestFilenameSuffix()}.ts`,`.test.ts`,`.spec.ts`,`.test.tsx`,`.spec.tsx`,`.test.js`,`.spec.js`,`.test.jsx`,`.spec.jsx`],n=e.getFilePath(),r=`_`+(0,h.randomUUID)()+`_temp`;for(let e of t)if(n.endsWith(e))return n.slice(0,-e.length)+r+e;let i=n.split(`.`);return i[i.length-2]+=r,i.join(`.`)},Zn=(e,t=e.getFullText())=>{let n=Xn(e);return e.getProject().createSourceFile(n,t)},Qn=e=>e.getSymbol()?.getDeclarations()?.[0]?.getSourceFile()??e.getAliasSymbol()?.getDeclarations()?.[0]?.getSourceFile(),$n=(e,t)=>{let n=e.getRelativePathTo(t.getFilePath());n=n.replaceAll(`\\`,`/`);let r=a.default.extname(n);return n=n.replaceAll(r,``),n.startsWith(`.`)||(n=`./`+n),n},er=[S.SyntaxKind.JsxElement,S.SyntaxKind.JsxOpeningElement,S.SyntaxKind.JsxClosingElement,S.SyntaxKind.JsxExpression,S.SyntaxKind.JsxSelfClosingElement,S.SyntaxKind.JsxAttributes,S.SyntaxKind.JsxAttribute,S.SyntaxKind.JsxFragment,S.SyntaxKind.JsxOpeningFragment,S.SyntaxKind.JsxClosingFragment,S.SyntaxKind.JsxNamespacedName,S.SyntaxKind.JsxSpreadAttribute,S.SyntaxKind.JsxText,S.SyntaxKind.JsxTextAllWhiteSpaces],tr=e=>er.some(t=>(0,c.isDefined)(e.getFirstDescendantByKind(t))),nr=e=>er.some(t=>(0,c.isDefined)(e.getParentIfKind(t))),rr=e=>{let t=e.compilerType;if(`id`in t&&(0,c.isNumber)(t.id)){let e=t.id;return e===0?null:e}return null},ir=new Set(`withRouter.connect.withAuth.withStyles.withTheme.forwardRef.styled.withErrorBoundary.withSuspense.withProps.withState.withHandlers.withContext.withApollo.withRedux.withIntl.withTranslation.withFormik.withViewport.withLogger.withMemo.withDefaults.withReduxForm.withPermissions.withData.withTracker.withServices.withFirebase.withNavigation.withHeader.withFooter`.split(`.`)),ar=`anonymousFunction`;var or=class{exportedDeclarations;constructor(e,t){this.sourceFile=e,this.moduleInfo=t;let n=this.moduleInfo.getExports();this.exportedDeclarations=[n.defaultExport,...n.namedExports].filter(Boolean)}getAllTestables(){return[...this.getClassesWithMethods(),...this.getFunctionsDeclarations(),...this.getFunctionsExpressions(),...this.getArrowFunctionsExpressions(),...this.getHOCs(),...this.getObjectMethods()]}getAllSerializedTestables(){return this.getAllTestables().map(e=>(0,c.removeNestedField)(e,[`node`,`parent`]))}getAllMethodsCount(){return this.getAllTestables().filter(e=>e.type!==`class`).length}getHOCs(){return this.sourceFile.getVariableStatements().filter(e=>{let t=e.getFirstDescendantByKind(S.SyntaxKind.CallExpression),n=t?.getFirstDescendantByKind(S.SyntaxKind.PropertyAccessExpression),r=t?.getFirstDescendantByKind(S.SyntaxKind.Identifier);return[n?.getText(),r?.getText()].some(e=>(0,c.isDefined)(e)?[...ir.values()].some(t=>e.includes(t)):!1)}).map(e=>{let t=e.getFirstDescendantByKind(S.SyntaxKind.VariableDeclaration)?.getFirstChildByKind(S.SyntaxKind.Identifier)?.getText(),n=this.isEntityExported(t)||e.isExported();return{...this.getLocationPivot(e),name:t,type:`function`,node:e,canCreateTests:n}})}getFunctionsDeclarations(){return this.sourceFile.getFunctions().map(e=>{let t=e.getName()??ar,n=this.isEntityExported(t)||e.isExported();return{...this.getLocationPivot(e),name:t,type:`function`,node:e,canCreateTests:n}})}getFunctionsExpressions(){return this.sourceFile.getDescendantsOfKind(S.SyntaxKind.FunctionExpression).filter(e=>e.getParentIfKind(S.SyntaxKind.ExportAssignment)?.isExportEquals()??!(this.isCallbackFunction(e)||this.isInnerFunction(e)||this.isJSXFunction(e))).map(e=>{let t=e.getName()??this.getArrowFunctionName(e)??ar,n=this.isEntityExported(t);return{...this.getLocationPivot(e),name:t,type:`function`,node:e,canCreateTests:n}})}getArrowFunctionsExpressions(){return this.sourceFile.getDescendantsOfKind(S.SyntaxKind.ArrowFunction).filter(e=>e.getParentIfKind(S.SyntaxKind.ExportAssignment)?.isExportEquals()??!(this.isCallbackFunction(e)||this.isInnerFunction(e)||this.isJSXFunction(e))).map(e=>{let t=this.getArrowFunctionName(e)??ar,n=this.isEntityExported(t)||this.isEntityExportedWithThis(e);return{...this.getLocationPivot(e),name:t,type:`function`,node:e,canCreateTests:n}})}isCallbackFunction(e){return e.getParent()?.getKind()===S.SyntaxKind.CallExpression}isJSXFunction(e){return nr(e)}isInnerFunction(e){let t=e.getParent(),n=0;for(;(0,c.isDefined)(t)&&t.getKind()!==S.SyntaxKind.SourceFile&&n<20;){if(t.getKind()===S.SyntaxKind.ArrowFunction)return!0;t=t.getParent(),n++}return!1}getArrowFunctionName(e){let t=e.getParent();if(t?.getKind()===S.SyntaxKind.BinaryExpression&&t?.getFirstChild()?.getKind()===S.SyntaxKind.PropertyAccessExpression)return e.getParent()?.getFirstChildByKind(S.SyntaxKind.PropertyAccessExpression)?.getName();let n=e.getFirstAncestorByKind(S.SyntaxKind.VariableDeclaration);if((0,c.isDefined)(n))return n.getName();let r=e.getFirstAncestorByKind(S.SyntaxKind.PropertyAssignment);if((0,c.isDefined)(r))return r.getName()}getClasses(){return this.sourceFile.getClasses().map(e=>{let t=e.getName(),n=this.isEntityExported(t)||e.isDefaultExport(),r=n?this.getClassMethods(e,n).some(e=>e.canCreateTests):!1;return{...this.getLocationPivot(e),name:t,type:`class`,node:e,canCreateTests:r}})}getClassesWithMethods(){return this.getClasses().flatMap(e=>[e,...this.getClassMethods(e.node,e.canCreateTests)])}getClassMethods(e,t){return e.getMethods().map(n=>{let r=n.hasModifier(S.SyntaxKind.PrivateKeyword),i=n.getName().startsWith(`#`),a=r||i;return{...this.getLocationPivot(n),parent:e,parentName:e.getName()??``,type:`method`,node:n,name:n.getName(),canCreateTests:t&&!a}})}getObjectMethods(){let e=this.sourceFile.getDescendantsOfKind(S.SyntaxKind.BinaryExpression).map(e=>e.getRight()).filter(e=>S.Node.isObjectLiteralExpression(e)),t=this.sourceFile.getExportAssignments().map(e=>e.getExpression()).filter(e=>S.Node.isObjectLiteralExpression(e));return[...e,...t].flatMap(e=>e.getProperties()).filter(e=>S.Node.isMethodDeclaration(e)).map(e=>({...this.getLocationPivot(e),type:`object-method`,node:e,name:e.getName(),canCreateTests:!0}))}getLocationPivot(e){return Gn(this.sourceFile,e)}isEntityExported(e){return(0,c.isDefined)(e)&&!(0,c.isEmpty)(e)?this.exportedDeclarations.includes(e):!1}isEntityExportedWithThis(e){let t=e.getParent()?.getChildren()??[];return t[0]?.getFirstChild()?.getKind()===S.SyntaxKind.ThisKeyword&&t[1]?.getKind()===S.SyntaxKind.EqualsToken&&t[2]===e}findTestable(e,t,n){return this.getAllTestables().find(r=>r.name===t&&r.type===e?r.type===`method`?r.parentName===n:!0:!1)}};let sr=`default`;var cr=class{constructor(e,t){this.sourceFile=e,this.isUsingJSX=t}getImports(){return[...this.getESMImportsNodes(),...this.getCJSImportsNodes()].map(e=>({name:`Import`,location:Gn(this.sourceFile,e),node:e,type:`import`,sourceValue:(S.Node.isImportDeclaration(e)?e.getModuleSpecifierValue():e.getFirstDescendantByKind(S.SyntaxKind.StringLiteral)?.getLiteralValue())??``}))}getCJSImportsNodes(){return this.sourceFile.getVariableStatements().filter(e=>(e.getFirstDescendantByKind(S.SyntaxKind.CallExpression)?.getExpression())?.getText()===`require`)}getESMImportsNodes(){return this.sourceFile.getImportDeclarations()}isESM(){let e=this.sourceFile.getImportDeclarations().length>0,t=this.sourceFile.getExportDeclarations().length>0||this.sourceFile.getExportedDeclarations().size>0,n=this.sourceFile.getDescendantsOfKind(S.SyntaxKind.ExportAssignment).length>0;return e||t||n}getCJSExports(){let e=[],t=``,n=`module.exports`,r=`exports`;for(let i of this.sourceFile.getDescendantsOfKind(S.SyntaxKind.ExpressionStatement)){let a=i.getExpression(),o=a.getText().trim(),s=a.asKind(S.SyntaxKind.BinaryExpression);if(!o.startsWith(n)&&!o.startsWith(r)||!(0,c.isDefined)(s))continue;let l=s.getLeft(),u=l.getText(),d=l.asKind(S.SyntaxKind.PropertyAccessExpression),f=d?.getName()??``,p=l.getKind()===S.SyntaxKind.PropertyAccessExpression,m=s.getRight(),h=p&&d?.getExpression().getText()===n,g=p&&d?.getExpression().getText()===r;if(h&&f===sr){t=m.getText();continue}if(h||g){e.push(f);continue}if(u!==n)continue;let _=t=>{let n=t.asKind(S.SyntaxKind.ObjectLiteralExpression);if((0,c.isDefined)(n))for(let t of n.getProperties()){if(t.getKind()===S.SyntaxKind.PropertyAssignment||t.getKind()===S.SyntaxKind.ShorthandPropertyAssignment||t.getKind()===S.SyntaxKind.MethodDeclaration){let n=t.getName();e.push(n)}if(t.getKind()===S.SyntaxKind.PropertyAssignment){let e=t.getInitializer();(0,c.isDefined)(e)&&_(e)}}},v=t=>{let n=t.asKind(S.SyntaxKind.FunctionDeclaration)?.getBody()?.asKind(S.SyntaxKind.Block);if((0,c.isDefined)(n))for(let t of n.getStatements()){let n=((t.asKind(S.SyntaxKind.ExpressionStatement)?.getExpression())?.asKind(S.SyntaxKind.BinaryExpression)?.getLeft())?.asKind(S.SyntaxKind.PropertyAccessExpression);n?.getExpression().getKind()===S.SyntaxKind.ThisKeyword&&e.push(n.getName())}},y=t=>{let n=t.asKind(S.SyntaxKind.FunctionDeclaration)?.getName();if((0,c.isDefined)(n))for(let t of this.sourceFile.getStatements()){let r=((t.asKind(S.SyntaxKind.ExpressionStatement)?.getExpression())?.asKind(S.SyntaxKind.BinaryExpression)?.getLeft())?.asKind(S.SyntaxKind.PropertyAccessExpression);r?.getExpression().getText()===`${n}.prototype`&&e.push(r.getName())}};if(m.getKind()===S.SyntaxKind.ObjectLiteralExpression){_(m);continue}if(m.getKind()===S.SyntaxKind.Identifier){let t=m.asKind(S.SyntaxKind.Identifier),n=t?.findReferences().map(e=>e.getDefinition().getNode().getParent()).filter(e=>(0,c.isDefined)(e)).filter(e=>e.getKind()===S.SyntaxKind.VariableDeclaration);if(!(0,c.isDefined)(n))continue;for(let t of n){let n=t.getInitializer()?.asKind(S.SyntaxKind.ObjectLiteralExpression);if((0,c.isDefined)(n)){for(let t of n.getProperties())if(t.getKind()===S.SyntaxKind.PropertyAssignment||t.getKind()===S.SyntaxKind.ShorthandPropertyAssignment){let n=t.getName();e.push(n)}}}let r=t?.findReferences().map(e=>e.getDefinition().getNode().getParent()).filter(e=>e?.getKind()===S.SyntaxKind.FunctionDeclaration);if(!(0,c.isDefined)(r))continue;for(let e of r)v(e),y(e)}if(m.isKind(S.SyntaxKind.NewExpression)){let e=m.asKind(S.SyntaxKind.NewExpression);(0,c.isDefined)(e)&&(t=e.getExpression().getText());continue}t=m.getText()}return{namedExports:e,defaultExport:t}}getESMExports(){let e=``,t=[],n=!1;for(let r of this.sourceFile.getExportAssignments()){r.isExportEquals()||(n=!0);let i=r.getExpression();if(i.getKind()===S.SyntaxKind.Identifier){e=i.getText();continue}let a=r.getFirstChildByKind(S.SyntaxKind.ObjectLiteralExpression);if((0,c.isDefined)(a)){for(let e of a.getProperties())if(e.getKind()===S.SyntaxKind.PropertyAssignment||e.getKind()===S.SyntaxKind.ShorthandPropertyAssignment||e.getKind()===S.SyntaxKind.MethodDeclaration){let n=e.getName();t.push(n)}}}let r=this.sourceFile.getExportedDeclarations();if(!(n&&r.size===1&&[...r.keys()][0]===sr))for(let[n,i]of r)if(n===sr){let t=(i[0]?.getFirstChildByKind(S.SyntaxKind.Identifier))?.getText()?.trim()??ar;(0,c.isDefined)(t)&&(e=t)}else t.push(n);return{defaultExport:e,namedExports:t}}hasRequire(){return this.sourceFile.getDescendantsOfKind(S.SyntaxKind.CallExpression).some(e=>e.getExpression().getText()===`require`)}transformRequiresToImports(){let e=qn(this.sourceFile.getProject(),`transformRequiresToImports`,this.sourceFile.getFullText(),this.isUsingJSX),t;try{let n=e.getVariableStatements();for(let e of n){let t=e.getFirstDescendantByKind(S.SyntaxKind.CallExpression),n=t?.getExpression();if(!(0,c.isDefined)(t)||!(0,c.isDefined)(n)||n.getText()!==`require`)continue;let r=t.getFirstDescendantByKind(S.SyntaxKind.StringLiteral)?.getLiteralValue();if(!(0,c.isDefined)(r))continue;let i=e.getDeclarations()?.[0]?.getNameNode()?.getText();if(!(0,c.isDefined)(i))continue;let a=`import ${i} from "${r}";`;e.replaceWithText(a)}t=e.getFullText()}finally{e.getProject().removeSourceFile(e)}return t}getExports(){return this.isESM()?this.getESMExports():this.getCJSExports()}},lr=class{tests;constructor(e){this.sourceFile=e}getDescribes(){return An(this.sourceFile).map(e=>{let t=Hn(e);return(0,c.isDefined)(t)?{node:e,name:t,location:Gn(this.sourceFile,e),type:`describe`}:null}).filter(e=>(0,c.isDefined)(e))}getTests(){return(0,c.isDefined)(this.tests)||(this.tests=Kn(this.sourceFile).map(e=>{let t=Gn(this.sourceFile,e),n=Un(e);return(0,c.isDefined)(n)?{node:e,name:n,location:t,type:`test`}:null}).filter(e=>(0,c.isDefined)(e))),this.tests}getDescribeTests(e){return Kn(e.node).map(e=>{let t=Un(e);return(0,c.isDefined)(t)?{node:e,name:t,location:Gn(this.sourceFile,e),type:`test`}:null}).filter(e=>(0,c.isDefined)(e))}},pr=class{sourceFile;tests;testables;moduleInfo;constructor(e,t){this.filePath=t;let n=!0;try{let t=new S.Project({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0,skipLoadingLibFiles:!0}),r=qn(t,`ast`,e,!0);tr(r)?this.sourceFile=r:(t.removeSourceFile(r),this.sourceFile=qn(t,`ast`,e,!1),n=!1)}catch{throw Error(`Cannot parse file content`)}this.moduleInfo=new cr(this.sourceFile,n),this.testables=new or(this.sourceFile,this.moduleInfo),this.tests=new lr(this.sourceFile)}isReactFile(){let e=(0,a.extname)(this.filePath??this.sourceFile.getFilePath());return an.includes(e)||this.isFileContainsImport(`react`)}isFileContainsImport(e){return this.moduleInfo.getImports().some(t=>t.sourceValue.includes(e))}checkIsJSDoc(e,t,n){return t===S.SyntaxKind.MultiLineCommentTrivia?e.slice(n,n+3)===`/**`&&e.slice(n,n+5)!==`/***/`:!1}getLineRange(e,t){let n=this.sourceFile.compilerNode,r=n.getLineStarts(),{line:i}=n.getLineAndCharacterOfPosition(e),{line:a}=n.getLineAndCharacterOfPosition(t);return{start:r[i]??0,end:r[a+1]??this.sourceFile.getEnd()}}stripComments(e=()=>!0){let t=new Set,n=[],r=this.sourceFile.getFullText(),i=(e,r)=>{for(let i of[...e.getLeadingCommentRanges(),...e.getTrailingCommentRanges()]){let e=i.getPos(),a=i.getEnd(),o=e+`,`+a;if(t.has(o))continue;t.add(o);let s=i.getText(),c=this.checkIsJSDoc(r,i.getKind(),e);n.push({start:e,end:a,text:s,width:i.getWidth(),isJSDoc:c})}};i(this.sourceFile,r),this.sourceFile.forEachDescendant(e=>i(e,r));let a=n.filter(e).map(e=>{let{start:t,end:n}=this.getLineRange(e.start,e.end);return(0,c.isEmpty)(r.slice(t,e.start).trim())&&(0,c.isEmpty)(r.slice(e.end,n).trim())?{start:t,end:n}:{start:e.start,end:e.end}}).toSorted((e,t)=>t.start-e.start);for(let e of a)this.sourceFile.removeText(e.start,e.end);return this.sourceFile.getFullText()}};let mr=e=>{let{node:t,parent:n,...r}=e;return r};var hr=class{GITIGNORE_FILE_NAME=`.gitignore`;gitignorePath;constructor(e){this.gitignorePath=(0,a.join)(e,this.GITIGNORE_FILE_NAME)}async add(e){try{let t=await o.default.readFile(this.gitignorePath,`utf8`);t.includes(e)||await o.default.writeFile(this.gitignorePath,`${t}\n${e}`)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;H.info.defaultLog(`Error reading gitignore file`,{message:t})}}};let gr=`.early.coverage`;var _r=class{getCoverageDirectoryPath(){let e=yt().getRootPath();return a.default.join(e,gr,`v8`)}getCoverageDirectoryForCommand(){return this.getCoverageDirectoryPath()}getExecutionCwd(){return yt().getRootPath()}},vr=class extends _r{getCoverageDirectoryForCommand(){let e=yt().getGitTopLevel(),t=yt().getRootPath(),n=a.default.relative(e,t);return a.default.join(n,gr,`v8`)}};function yr(){let e=yt().getCoverageCommand()?.split(/\s+/).includes(`nx`)??!1;return H.info.defaultLog(`Coverage path strategy: `+(e?`nx`:`standard`)),e?new vr:new _r}var br=class{report={};constructor(e,t){for(let[n,r]of Object.entries(e)){let e=a.default.normalize(n);if(e.toLowerCase().startsWith(t.toLowerCase())){let n=e.slice(t.length);this.report[n]=r}}}getEntries(){return Object.entries(this.report)}getStatsForTestable(e,t,n){let r=this.report[e];if(!(0,c.isDefined)(r))return null;let i=this.findFunctionDefinition(t,r.fnMap,n);if(!(0,c.isDefined)(i))return null;let a=0,o=0;for(let[e,t]of Object.entries(r.statementMap))if(this.isStatementInFunction(t,i)||this.isFunctionInStatement(t,i)){o++;let t=r.s[e];(0,c.isDefined)(t)&&t>0&&a++}return{percentage:this.toPercentage(a,o),totalStatements:o,coveredStatements:a}}getStatsForFile(e){let t=this.report[e];if(!(0,c.isDefined)(t))return{percentage:null,totalStatements:0,coveredStatements:0};let n=0,r=0;for(let[e]of Object.entries(t.statementMap)){r++;let i=t.s[e];(0,c.isDefined)(i)&&i>0&&n++}return{percentage:this.toPercentage(n,r),totalStatements:r,coveredStatements:n}}getStatsForDirectory(e){let t=0,n=0;for(let[r,i]of Object.entries(this.report))if(this.isSubdirectory(e,r)){n+=Object.keys(i.statementMap).length;for(let[e]of Object.entries(i.statementMap)){let n=i.s[e];(0,c.isDefined)(n)&&n>0&&t++}}return{percentage:this.toPercentage(t,n),totalStatements:n,coveredStatements:t}}calculateCoverageForFiles(e){let t=0,n=0,r=new Set(e.map(e=>this.normalizeFilePath(e)));for(let[e,i]of Object.entries(this.report)){let a=this.normalizeFilePath(e);if(r.has(a)){let e=Object.keys(i.statementMap).length;t+=e;for(let[e]of Object.entries(i.statementMap)){let t=i.s[e];(0,c.isDefined)(t)&&t>0&&n++}}}return{percentage:this.toPercentage(n,t),totalStatements:t,coveredStatements:n}}normalizeFilePath(e){return e.startsWith(`/`)?e.slice(1):e}isSubdirectory(e,t){let n=a.default.relative(e,t);return(0,c.isDefined)(n)?!n.startsWith(`..`)&&!a.default.isAbsolute(n):!1}isStatementInFunction(e,t){return!(e.start.line<t.loc.start.line||e.end.line>t.loc.end.line||e.start.line===t.loc.start.line&&e.start.column<t.loc.start.column||e.end.line===t.loc.end.line&&e.end.column>t.loc.end.column)}isFunctionInStatement(e,t){return!(t.loc.start.line<e.start.line||t.loc.end.line>e.end.line||t.loc.start.line===e.start.line&&t.loc.start.column<e.start.column||t.loc.end.line===e.end.line&&t.loc.end.column>e.end.column)}findFunctionDefinition(e,t,n){for(let[,n]of Object.entries(t))if(n.name===e)return n;return null}toPercentage(e,t,n=0){if(t===0)return null;let r=e/t;return Number(Math.round(r*100).toFixed(n))}};async function xr(e){let t=yt().getRootPath(),n=[];try{let e=new U(`.gitignore`);await e.isFileExists()&&(n=(await e.getText()).split(`
|
|
32374
32374
|
`).map(e=>e.trim()).filter(e=>(0,c.isDefined)(e)&&!e.startsWith(`#`)))}catch{}let r=[`node_modules`,`*.config.ts`,`**/*.mock.ts`,`**/*.mocks.ts`,`**/*.test.ts`,`**/*.spec.ts`,...n];return(await(0,E.default)(e,{cwd:t,absolute:!0,ignore:r})).map(e=>`/${a.default.relative(t,e)}`)}var Sr=class{nextSource=null;setNext(e){return this.nextSource=e,e}async getFromNext(e){return this.nextSource?this.nextSource.getFiles(e):[]}},Cr=class extends Sr{async getFiles(e){return xr(`**/*.{js,ts,jsx,tsx}`)}};let wr=/\.[jt]sx?$/;var Tr=class extends Sr{async getFiles(e){let t=Object.keys(e).filter(e=>wr.test(e));return t.length>0?t:this.getFromNext(e)}};function Er(){let e=new Tr,t=new Cr;return e.setNext(t),e}let Dr=String.raw`.*\.early\.(spec|test)\.[tj]sx?$`;var Or=class{EXEC_TIMEOUT_IN_MS=24e5;MAX_BUFFER_SIZE=2e4*1024;DEFAULT_ROOT_PATH=`/`;COVERAGE_ROOT_DIRECTORY_NAME=`.early.coverage`;COVERAGE_REPORT_FILE_NAME=`coverage-final.json`;pathStrategy=null;async init(){this.pathStrategy=yr()}getCoverageDirectoryPath(){if(!(0,c.isDefined)(this.pathStrategy))throw Error(`Provider not initialized. Call init() first.`);return this.pathStrategy.getCoverageDirectoryPath()}getCoverageDirectoryForCommand(){if(!(0,c.isDefined)(this.pathStrategy))throw Error(`Provider not initialized. Call init() first.`);return this.pathStrategy.getCoverageDirectoryForCommand()}getExecutionCwd(){if(!(0,c.isDefined)(this.pathStrategy))throw Error(`Provider not initialized. Call init() first.`);return this.pathStrategy.getExecutionCwd()}getCoverageReportPath(){return a.default.join(this.getCoverageDirectoryPath(),this.COVERAGE_REPORT_FILE_NAME)}async getCommand(e){let t=yt().getCoverageCommand(),n=(0,c.isDefined)(e)&&e.length>0?this.formatTestFiles(e):``;if((0,c.isDefined)(t)){let e=t.replaceAll(be,this.getCoverageDirectoryForCommand()).replaceAll(xe,n);return!t.includes(xe)&&n&&(e=`${e} ${n}`),e}return(await this.buildJestCoverageCommand(e)).replaceAll(be,this.getCoverageDirectoryForCommand())}async isReportExists(){try{return await o.default.access(this.getCoverageReportPath(),o.constants.R_OK),!0}catch{return!1}}async removeReport(){try{let e=U.fromAbsolutePath(this.getCoverageReportPath());await e.isFileExists()&&await e.delete()}catch(e){H.error(`Error removing coverage report`,e)}}async getReport(){try{let e=await U.fromAbsolutePath(this.getCoverageReportPath()).getText(),t=JSON.parse(e);return this.calculateCoverage(t)}catch{throw Error(`Coverage report file could not be read: ${this.getCoverageReportPath()}`)}}async generateReport(e){H.info.defaultLog(`Coverage: generation started`),await this.removeReport();let t=await this.getCommand(e);H.info.defaultLog(`Coverage command: ${t}`);try{await W(t,{cwd:this.getExecutionCwd(),timeout:this.EXEC_TIMEOUT_IN_MS,maxBuffer:this.MAX_BUFFER_SIZE}),H.info.defaultLog(`Coverage command generation success`)}catch(e){let n=e instanceof Error&&`code`in e?{code:e.code,signal:e.signal,killed:e.killed}:{code:`UNKNOWN_ERROR`};throw H.info.defaultLog(`Coverage generation exited with error: "${t}".`,n),Error(`Failed to generate coverage report: ${e.message}`)}finally{await new hr(yt().getGitTopLevel()).add(this.COVERAGE_ROOT_DIRECTORY_NAME)}}calculateCoverage(e){let t=new br(e,a.default.normalize(yt().getRootPath()).toLowerCase()),n=new Map;for(let[e,r]of t.getEntries()){let i=t.getStatsForFile(e),a=e.split(`/`).slice(0,-1);for(;a.length>0;){let e=a.join(`/`)||this.DEFAULT_ROOT_PATH;if(!n.has(e)){let r=t.getStatsForDirectory(e);n.set(e,{percentage:r.percentage,totalStatements:r.totalStatements,coveredStatements:r.coveredStatements})}a.pop()}let o=[];for(let{name:n}of Object.values(r.fnMap)){let r=t.getStatsForTestable(e,n);o.push({name:n,percentage:r?.percentage??null,totalStatements:r?.totalStatements??null,coveredStatements:r?.coveredStatements??null})}n.set(e,{percentage:i.percentage,totalStatements:i.totalStatements,coveredStatements:i.coveredStatements,testables:o})}return Object.fromEntries(n.entries())}async hasJestConfig(){let e=pn(yt().getRootPath());return(0,c.isDefined)(e)}async buildJestCoverageCommand(e){let t=[`node_modules`,`dist`];yt().getIncludeEarlyTests()||t.push(Dr);let n=t.map(e=>`"${e}"`).join(` `),r=yt().getRootPath(),i=await this.hasJestConfig(),a=(0,c.isDefined)(e)&&e.length>0?` ${this.formatTestFiles(e)}`:``;return i?`npx jest --coverage --coverageProvider=v8 --coveragePathIgnorePatterns ${n} --coverageReporters=json --coverageDirectory=${Jt(be)} --silent --passWithNoTests --maxWorkers=2 ${a}`:`npx jest --coverage --coverageProvider=v8 --coveragePathIgnorePatterns ${n} --coverageReporters=json --coverageDirectory=${Jt(be)} --rootDir=${Jt(r)} --silent --passWithNoTests --maxWorkers=2 ${a}`}async getCoverageTree(e){let t=await Er().getFiles(e),n=new Map;for(let r of t){let t=new pr(await new U(r).getText(),`getCoverageTree`).testables.getAllTestables(),i=r.split(`/`).slice(0,-1);for(;!(0,c.isEmpty)(i);){let t=i.join(`/`)||this.DEFAULT_ROOT_PATH,r=e[t];n.has(t)||n.set(t,{percentage:r?.percentage??null,totalStatements:r?.totalStatements??null,coveredStatements:r?.coveredStatements??null}),i.pop()}let a=[],o=t.map(e=>mr(e)),s=e[r];for(let e of o){let{name:t}=e;if(!(0,c.isDefined)(t))continue;let n=e.type===`method`?e.parentName:void 0,r=s?.testables?.find(e=>e.name===t),i={name:t,...(0,c.isDefined)(n)&&{parentName:n},percentage:r?.percentage??null,totalStatements:r?.totalStatements??null,coveredStatements:r?.coveredStatements??null};a.push(i)}n.set(r,{percentage:s?.percentage??null,totalStatements:s?.totalStatements??null,coveredStatements:s?.coveredStatements??null,testables:a})}return Object.fromEntries(n.entries())}getCoverageForFiles(e,t){let n=0,r=0,i=new Set(e.map(e=>this.normalizeFilePath(e)));for(let[e,a]of Object.entries(t)){let t=this.normalizeFilePath(e);i.has(t)&&(n+=a.totalStatements??0,r+=a.coveredStatements??0)}return{percentage:this.toPercentage(r,n),totalStatements:n,coveredStatements:r}}normalizeFilePath(e){return e.startsWith(`/`)?e.slice(1):e}formatTestFiles(e){return e.map(e=>Jt(e)).join(` `)}toPercentage(e,t,n=0){if(t===0)return null;let r=e/t;return Number(Math.round(r*100).toFixed(n))}},kr=class extends br{constructor(e,t){super(e,t)}findFunctionDefinition(e,t,n){for(let r of Object.values(t))if(r.name===e||(0,c.isDefined)(n)&&r.name.startsWith(`(anonymous`)&&r.loc.start.line===n)return r;return null}};let Ar=`npx vitest run --coverage.enabled --coverage.exclude="${Dr}" --coverage.reportsDirectory=${be} --coverage.reportOnFailure=true --coverage.reporter=json --maxWorkers=2 --passWithNoTests`;var jr=class extends Or{async init(){await super.init()}async getCommand(e){let t=yt().getCoverageCommand(),n=(0,c.isDefined)(e)&&e.length>0?this.formatTestFiles(e):``;if((0,c.isDefined)(t)){let e=t.replaceAll(be,this.getCoverageDirectoryForCommand()).replaceAll(xe,n);return!t.includes(xe)&&n&&(e=`${e} ${n}`),e}let r=Ar.replaceAll(be,this.getCoverageDirectoryForCommand());return n?`${r} ${n}`:r}async getReport(){try{let e=await U.fromAbsolutePath(this.getCoverageReportPath()).getText(),t=JSON.parse(e);return await this.calculateCoverageWithVitest(t)}catch{throw Error(`Coverage report file could not be read: ${this.getCoverageReportPath()}`)}}async calculateCoverageWithVitest(e){let t=a.default.normalize(yt().getRootPath()).toLowerCase(),n=new kr(e,t),r=this.buildAbsolutePathMap(e,t),i=[...n.getEntries()];return this.processEntries(i,n,r)}buildAbsolutePathMap(e,t){let n=new Map;for(let r of Object.keys(e)){let e=a.default.normalize(r);if(e.toLowerCase().startsWith(t.toLowerCase())){let i=e.slice(t.length);n.set(i,r)}}return n}async processEntries(e,t,n){let r=new Map;for(let[i]of e)this.addDirectoryCoverage(i,t,r),await this.addFileCoverage(i,t,n,r);return Object.fromEntries(r.entries())}addDirectoryCoverage(e,t,n){let r=e.split(`/`).slice(0,-1);for(;r.length>0;){let e=r.join(`/`)||`/`;if(!n.has(e)){let r=t.getStatsForDirectory(e);n.set(e,{percentage:r.percentage,totalStatements:r.totalStatements,coveredStatements:r.coveredStatements})}r.pop()}}async addFileCoverage(e,t,n,r){let i=t.getStatsForFile(e),a=n.get(e);if(!(0,c.isDefined)(a))return;let o=await this.readFileText(a);if(!(0,c.isDefined)(o)){r.set(e,{percentage:i.percentage,totalStatements:i.totalStatements,coveredStatements:i.coveredStatements,testables:[]});return}let s=this.extractTestables(o,e,t);r.set(e,{percentage:i.percentage,totalStatements:i.totalStatements,coveredStatements:i.coveredStatements,testables:s})}async readFileText(e){try{return await U.fromAbsolutePath(e).getText()}catch{return null}}extractTestables(e,t,n){let r=new pr(e,`getReport`).testables.getAllTestables(),i=[];for(let e of r){let r=e.name??``,a=e.type===`method`?e.parentName:void 0,o=n.getStatsForTestable(t,r,e.startLine);i.push({name:r,...(0,c.isDefined)(a)&&{parentName:a},percentage:o?.percentage??null,totalStatements:o?.totalStatements??null,coveredStatements:o?.coveredStatements??null})}return i}},Mr=function(e){return e.JEST=`jest`,e.VITEST=`vitest`,e}(Mr||{}),Nr=class{provider=null;async create(){let e=await this.detectProjectType();return H.info.defaultLog(`Coverage: project type`,e),e===Mr.JEST?this.provider=new Or:e===Mr.VITEST&&(this.provider=new jr),this.provider&&await this.provider.init(),H.info.defaultLog(`Coverage Provider: `+(e??`null`)),this.provider}async detectProjectType(){return await this.checkFileExists([`vitest.config.ts`,`vitest.config.js`])?Mr.VITEST:await this.checkFileExists([`package.json`,`jest.config.js`,`jest.config.ts`,`tsconfig.json`])?Mr.JEST:null}async checkFileExists(e){H.info.defaultLog(`Coverage: checking files`,e);for(let t of e)if(await new U(t).isFileExists())return!0;return!1}};let Pr={};var Fr=class{provider=null;coverage=null;async init(){(0,c.isDefined)(this.provider)||(this.provider=await new Nr().create())}async consumeReport(){if((0,c.isDefined)(this.provider))try{this.coverage=await this.provider.getReport(),await this.provider.removeReport()}catch(e){H.info.defaultLog(`Error reading coverage report`,{error:e})}}async generateCoverage(e){if(!(0,c.isDefined)(this.provider))return Pr;try{await this.provider.generateReport(e)}catch(e){let t=await this.provider.isReportExists();if(!yt().shouldContinueOnTestErrors()||!t)throw e;H.info.defaultLog(`Coverage: report exists but test command failed, continuing...`)}let t=null;try{await this.consumeReport()}catch(e){t=e instanceof Error?e:Error(String(e))}if(!(0,c.isDefined)(this.coverage))throw(0,c.isDefined)(t)?Error(`Coverage report is not available. Reason: ${t.message}`):Error(`Coverage report is not available`);return this.coverage}getCoverage(){return this.coverage}async getCoverageTree(){return!(0,c.isDefined)(this.provider)||!(0,c.isDefined)(this.coverage)?Pr:this.provider.getCoverageTree(this.coverage)}setCoverage(e){this.coverage=e}getCoverageForFiles(e){if(!(0,c.isDefined)(this.provider))throw Error(`Coverage provider not initialized`);if(!(0,c.isDefined)(this.coverage))throw Error(`Coverage report not available`);return this.provider.getCoverageForFiles(e,this.coverage)}},Ir=t.__toESM(dt()),Lr=t.__toESM(ft());let Rr=class{coverageService=new Fr;async generateCoverage(e){try{await this.coverageService.init(),await this.coverageService.generateCoverage(e)}catch(e){throw H.info.failedLog(`Failed to generate coverage`,e),e}}async setCoverage(e){try{await this.coverageService.init(),await this.coverageService.setCoverage(e)}catch(e){throw H.info.failedLog(`Failed to set coverage`,e),e}}async getCoverageTree(){try{await this.coverageService.init(),H.info.startLog(`Getting coverage tree`);let e=await this.coverageService.getCoverageTree();return H.info.endLog(`Getting coverage tree`),e??null}catch(e){throw H.info.failedLog(`Failed to get coverage tree`,e),e}}async getCoverageForFiles(e){try{return await this.coverageService.init(),this.coverageService.getCoverageForFiles(e)}catch(e){throw H.info.failedLog(`Failed to get coverage for files`,e),e}}};(0,Lr.default)([kt({category:nn.GENERATE_COVERAGE}),(0,Ir.default)(`design:type`,Function),(0,Ir.default)(`design:paramtypes`,[Array]),(0,Ir.default)(`design:returntype`,Promise)],Rr.prototype,`generateCoverage`,null),(0,Lr.default)([kt({category:nn.SET_COVERAGE}),(0,Ir.default)(`design:type`,Function),(0,Ir.default)(`design:paramtypes`,[Object]),(0,Ir.default)(`design:returntype`,Promise)],Rr.prototype,`setCoverage`,null),(0,Lr.default)([kt({category:nn.GET_COVERAGE}),(0,Ir.default)(`design:type`,Function),(0,Ir.default)(`design:paramtypes`,[]),(0,Ir.default)(`design:returntype`,Promise)],Rr.prototype,`getCoverageTree`,null),(0,Lr.default)([kt({category:nn.GET_COVERAGE}),(0,Ir.default)(`design:type`,Function),(0,Ir.default)(`design:paramtypes`,[Array]),(0,Ir.default)(`design:returntype`,Promise)],Rr.prototype,`getCoverageForFiles`,null),Rr=(0,Lr.default)([(0,u.injectable)()],Rr);let zr=new class{safeTrackEvent(e,t){}},Br={EMPTY_TEST:`0000`,DESCRIBE_NOT_FOUND:`0001`,TESTED_CODE_DATA_SOURCE_ERROR:`0002`,GENERATING_TESTS_REQUEST_ERROR:`0003`,GET_VERSION_REQUEST_ERROR:`0004`,GENERATING_HELPER_REQUEST_ERROR:`0005`,PREPARATIONS_FOR_GENERATING_TEST_DTO_ERROR:`0006`,ENHANCE_TESTS_REQUEST_ERROR:`0011`,EMPTY_FIXED_TESTS:`1000`,TESTABLE_NOT_FOUND:`1001`,TESTED_CODE_FILE_PATH_NOT_FOUND:`1002`,PREEN_TESTS_ERROR:`2001`,ORGANIZE_IMPORTS_ERROR:`2002`,NOT_ENOUGH_BALANCE_ERROR:`3000`,UNSUPPORTED_MODEL_ERROR:`4000`,TOO_MANY_USERS_ERROR:`4001`,PAYLOAD_TOO_LARGE_ERROR:`4002`,TEST_SUMMARY_DB_REQUEST_ERROR:`5000`,TEST_SUMMARY_INVALID_CREATED_BY_ERROR:`5001`,TEST_SUMMARY_INVALID_GIT_REMOTE_ERROR:`5002`,TEST_SUMMARY_INVALID_GIT_BRANCH_ERROR:`5003`,WS_DYNAMIC_PROMPT_GENERAL_ERROR:`6000`,WS_DYNAMIC_PROMPT_AUTH_ERROR:`6001`,PREPARATIONS_FOR_DYNAMIC_PROMPT_ERROR:`6002`,WS_DYNAMIC_PROMPT_VALIDATION_FAILED_ERROR:`6003`,WS_DYNAMIC_PROMPT_TIMEOUT_ERROR:`6004`,GITHUB_ACTION_TEST_SUMMARY_DB_REQUEST_ERROR:`7000`,GITHUB_ACTION_TEST_SUMMARY_READ_CONF_FILE:`7001`,GITHUB_ACTION_TEST_SUMMARY_INVALID_GIT_REMOTE_ERROR:`7002`,GITHUB_ACTION_TEST_SUMMARY_INVALID_GIT_BRANCH_ERROR:`7003`,GITHUB_ACTION_TEST_SUMMARY_READ_CONF_FILE_EMPTY_OPTIONS:`7004`,GITHUB_ACTION_TEST_SUMMARY_NO_COVERAGE_FOUND:`7005`},Vr={[Br.EMPTY_TEST]:`Oops! No tests were generated for "{{methodName}}". Code:{{code}} - We're on it!`,[Br.DESCRIBE_NOT_FOUND]:`Oops! Test suite not found for "{{methodName}}". Code:{{code}} - We're on it!`,[Br.TESTED_CODE_DATA_SOURCE_ERROR]:`Cannot get testable data for "{{methodName}}". Code:{{code}} - We're on it!`,[Br.GENERATING_TESTS_REQUEST_ERROR]:`Generating tests for method "{{methodName}}" - failed: "{{errorMessage}}". Code:{{code}} - We're on it!`,[Br.PREPARATIONS_FOR_GENERATING_TEST_DTO_ERROR]:`Generating tests for method "{{methodName}}" - failed: "{{errorMessage}}". Code:{{code}} - We're on it!`,[Br.GET_VERSION_REQUEST_ERROR]:`Failed to make request. Code:{{code}} - We're on it!`,[Br.GENERATING_HELPER_REQUEST_ERROR]:`Generating helpers for method "{{methodName}}" - failed: "{{errorMessage}}". Code:{{code}} - We're on it!`,[Br.ENHANCE_TESTS_REQUEST_ERROR]:`Enhance tests for method "{{methodName}}" - failed: "{{errorMessage}}". Code:{{code}} - We're on it!`,[Br.EMPTY_FIXED_TESTS]:`Oops! We got an empty API response for "{{methodName}}" test fixes. Code:{{code}} - We're on it!`,[Br.TESTABLE_NOT_FOUND]:`Oops! Testable code not found for "{{methodName}}". Code:{{code}} - We're on it!`,[Br.TESTED_CODE_FILE_PATH_NOT_FOUND]:`Oops! Testable code file path not found for "{{methodName}}". Code:{{code}}`,[Br.PREEN_TESTS_ERROR]:`Encountered a problem while processing "{{methodName}}". Code:{{code}} - We're on it!`,[Br.ORGANIZE_IMPORTS_ERROR]:`There was an issue with the processing "{{methodName}}". Code:{{code}} - We're on it!`,[Br.NOT_ENOUGH_BALANCE_ERROR]:`Usage test generation limit reached.`,[Br.UNSUPPORTED_MODEL_ERROR]:`We do not support this model at the moment.`,[Br.TOO_MANY_USERS_ERROR]:`Users limit reached. Please contact support.`,[Br.PAYLOAD_TOO_LARGE_ERROR]:`We could not generate tests due to code size.`,[Br.TEST_SUMMARY_DB_REQUEST_ERROR]:`We could not save test summary to database.`,[Br.TEST_SUMMARY_INVALID_CREATED_BY_ERROR]:`Invalid created by field.`,[Br.TEST_SUMMARY_INVALID_GIT_REMOTE_ERROR]:`Invalid git remote.`,[Br.TEST_SUMMARY_INVALID_GIT_BRANCH_ERROR]:`Invalid git branch.`,[Br.GITHUB_ACTION_TEST_SUMMARY_DB_REQUEST_ERROR]:`We could not save test summary to database.`,[Br.GITHUB_ACTION_TEST_SUMMARY_READ_CONF_FILE]:`Failed to read github action config file.`,[Br.GITHUB_ACTION_TEST_SUMMARY_INVALID_GIT_REMOTE_ERROR]:`Invalid git remote.`,[Br.GITHUB_ACTION_TEST_SUMMARY_INVALID_GIT_BRANCH_ERROR]:`Invalid git branch.`,[Br.GITHUB_ACTION_TEST_SUMMARY_READ_CONF_FILE_EMPTY_OPTIONS]:`Failed to parse options from github action conf file.`,[Br.GITHUB_ACTION_TEST_SUMMARY_NO_COVERAGE_FOUND]:`No coverage found. Please run coverage first.`,[Br.WS_DYNAMIC_PROMPT_GENERAL_ERROR]:`Failed initializing dynamic prompt.`,[Br.WS_DYNAMIC_PROMPT_AUTH_ERROR]:`Failed authorizing dynamic prompt.`,[Br.PREPARATIONS_FOR_DYNAMIC_PROMPT_ERROR]:`Failed preparing init dynamic prompt.`,[Br.WS_DYNAMIC_PROMPT_VALIDATION_FAILED_ERROR]:`Failed validating dynamic prompt dto.`,[Br.WS_DYNAMIC_PROMPT_TIMEOUT_ERROR]:`Dynamic prompt operation timed out.`};var Hr=class extends Error{constructor(e,t){let n=Ur(e,t);super(n),this.code=e}};let Ur=(e,t)=>{let n=Vr[e];for(let[r,i]of Object.entries({...t,code:e}))n=n.replace(`{{${r}}}`,i);return n},Wr=`x-request-id`;var Gr=class extends Error{constructor(){super(`Not authorized`)}};new TextEncoder;let Kr=new TextDecoder;function qr(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Jr(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Kr.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Kr.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return qr(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var Yr=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},Xr=class extends Yr{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`};let Zr=e=>typeof e==`object`&&!!e;function Qr(e){if(!Zr(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function $r(e){if(typeof e!=`string`)throw new Xr(`JWTs must use Compact JWS serialization, JWT must be a string`);let{1:t,length:n}=e.split(`.`);if(n===5)throw new Xr(`Only JWTs using Compact JWS serialization can be decoded`);if(n!==3)throw new Xr(`Invalid JWT`);if(!t)throw new Xr(`JWTs must contain a payload`);let r;try{r=Jr(t)}catch{throw new Xr(`Failed to base64url decode the payload`)}let i;try{i=JSON.parse(Kr.decode(r))}catch{throw new Xr(`Failed to parse the decoded payload as JSON`)}if(!Qr(i))throw new Xr(`Invalid JWT Claims Set`);return i}let ei=e=>{let t=$r(e).exp;return(0,c.isDefined)(t)?t*1e3:null},ti=e=>{if(!(0,c.isDefined)(e))return!0;let t=ei(e);return(0,c.isDefined)(t)?t<Date.now():!0};var ni=t.__toESM(ft());let ri=class{jwtToken=null;refreshTokenCallback=null;observer=new c.Observer;refreshTokenMutex=new A.Mutex;setJWTToken(e){this.jwtToken=e,this.observer.notifyAll(e)}async getJWTToken(){return(0,c.isDefined)(this.jwtToken)?(this.isTokenValid()||await this.refreshTokenMutex.runExclusive(async()=>{if((0,c.isDefined)(this.refreshTokenCallback))return await this.refreshTokenCallback(),this.jwtToken}),this.jwtToken):null}async getJWTTokenOrThrow(){let e=await this.getJWTToken();if(!(0,c.isDefined)(e))throw new Gr;return e}onJWTTokenSave(e){this.observer.addListener(e)}isTokenValid(){return!ti(this.jwtToken)}setRefreshTokenCallback(e){this.refreshTokenCallback=e}};ri=(0,ni.default)([(0,u.injectable)(`Singleton`)],ri);var ii=t.__commonJSMin(((e,t)=>{function n(e,t){return function(n,r){t(n,r,e)}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),ai=t.__toESM(dt()),oi=t.__toESM(ii()),si=t.__toESM(ft()),ci,li;let ui=class{axiosInstance;constructor(e,t){this.authStorage=e,this.globalConfigService=t,this.axiosInstance=O.default.create({baseURL:this.globalConfigService.getBackendURL(),headers:{"x-client-name":`ts-agent`,"x-client-version":_e,"Content-Type":`application/json`,"Content-Encoding":`gzip`},transformRequest:[e=>{if((0,c.isDefined)(e)){let t=D.default.createGzip();return t.write(JSON.stringify(e)),t.end(),t}else return e}]}),(0,k.default)(this.axiosInstance)}async apiCall({url:e,method:t,data:n,config:r}){let i=new O.AxiosHeaders({"x-request-source":this.globalConfigService.getRequestSource(),...r?.headers});if(!r?.ignoreAuth){let e=await this.authStorage.getJWTToken();(0,c.isDefined)(e)&&!(0,c.isEmpty)(e)&&(i.authorization=`Bearer ${e}`)}let a={...r,method:t,url:e,data:n,headers:i};try{return await this.axiosInstance.request(a)}catch(t){this.handleError(e,t,n)}}async get(e,t){return(await this.apiCall({url:e,method:`GET`,config:t})).data}async post(e,t,n){return(await this.apiCall({url:e,method:`POST`,data:t,config:n})).data}async put(e,t,n){return(await this.apiCall({url:e,method:`PUT`,data:t,config:n})).data}async delete(e,t){return(await this.apiCall({url:e,method:`DELETE`,config:t})).data}async patch(e,t,n){return(await this.apiCall({url:e,method:`PATCH`,data:t,config:n})).data}async head(e,t){return this.apiCall({url:e,method:`HEAD`,config:t})}async options(e,t){return this.apiCall({url:e,method:`OPTIONS`,config:t})}handleError(e,t,n){if(O.default.isAxiosError(t))if((0,c.isDefined)(t.response)){let{status:e,statusText:n,data:r}=t.response;throw e===O.HttpStatusCode.PaymentRequired?new Hr(Br.NOT_ENOUGH_BALANCE_ERROR):Error(`API request failed: ${e} ${n} - ${JSON.stringify(r)}`)}else if((0,c.isDefined)(t.request))throw Error(`API request failed: No response received from ${e}`);else throw Error(`API request failed: ${t instanceof Error?t.message:`Unknown error`}`);else if(t instanceof Error)throw TypeError(`API request failed: ${t.message}`);else throw TypeError(`API request failed: Unknown error occurred`)}onLogin(e){this.authStorage.onJWTTokenSave(t=>{(0,c.isDefined)(t)&&e()})}};ui=(0,si.default)([(0,u.injectable)(),(0,oi.default)(0,(0,u.inject)(ri)),(0,oi.default)(1,(0,u.inject)(_t)),(0,ai.default)(`design:paramtypes`,[typeof(ci=ri!==void 0&&ri)==`function`?ci:Object,typeof(li=_t!==void 0&&_t)==`function`?li:Object])],ui);let di={SUPER_ADMIN:1,ADMIN:2,USER:3},fi=[di.ADMIN,di.SUPER_ADMIN];var pi=t.__toESM(dt()),mi=t.__toESM(ii()),hi=t.__toESM(ft()),gi;let _i=class{mutex=new A.Mutex;user=null;constructor(e){this.apiService=e}async fetchUser(){let e=await this.apiService.get(`/api/v1/user/me`);return this.setUser(e),e}setUser(e){this.user=e,H.addContext({userId:e.id})}async getUser(){return(0,c.isDefined)(this.user)?this.user:await this.mutex.runExclusive(async()=>await this.fetchUser())}async isAdminUser(){let e=await this.getUser();return(0,c.isDefined)(e)?fi.includes(e?.role):!1}async isInOrganization(){let e=await this.getUser();return(0,c.isDefined)(e?.organization)}};_i=(0,hi.default)([(0,u.injectable)(),(0,mi.default)(0,(0,u.inject)(ui)),(0,pi.default)(`design:paramtypes`,[typeof(gi=ui!==void 0&&ui)==`function`?gi:Object])],_i);let vi=e=>(0,h.createHash)(`md5`).update(String(e)).digest(`hex`),yi=e=>({...bi(e),testFrameworkReceived:(0,c.isDefined)(e.testFrameworkReceived)?vi(e.testFrameworkReceived):void 0,testFrameworkExpected:(0,c.isDefined)(e.testFrameworkExpected)?vi(e.testFrameworkExpected):void 0}),bi=e=>({errorCode:e.errorCode,shortDescription:vi(e.shortDescription),fullDescription:vi(e.fullDescription)}),xi=e=>({name:vi(e.name),code:vi(e.code),status:e.status,errors:e.errors?.map(e=>yi(e)),lintErrors:e.lintErrors?.map(e=>Si(e))??null}),Si=e=>({errorCode:e.errorCode,fullDescription:vi(e.fullDescription),shortDescription:vi(e.shortDescription),severity:e.severity,exactCode:vi(e.exactCode)}),Ci=({describe:e,stdout:t})=>({describe:{path:e.path,code:vi(e.code),fullCode:vi(e.fullCode),status:e.status,errors:e.errors?.map(e=>bi(e)),tests:e.tests.map(e=>xi(e)),lintErrors:e.lintErrors?.map(e=>Si(e))??null},stdout:t});var wi=t.__toESM(dt()),Ti=t.__toESM(ii()),Ei=t.__toESM(ft()),Di,Ai,ji;let Mi=class{constructor(e,t,n){this.apiService=e,this.userService=t,this.globalConfigService=n}async saveTestMetrics({requestId:e,timeElapsed:t,validationReport:n,...r}){try{let i={timeElapsed:t,...n,...r};await this.userService.isInOrganization()&&(H.debug.defaultLog(`Filtering private data for B2B user`),i.testResult=(0,c.isDefined)(n?.testResult)?Ci(n.testResult):void 0),H.debug.startLog(`Sending metrics with request id ${e}`),await this.postWithRequestId(`/api/v1/tests/update-operation-metrics`,i,e),H.debug.defaultLog(`Test metrics have been saved`)}catch(e){H.error(`Test metrics cannot be saved`,e)}H.debug.endLog(`Sending metrics with request id ${e}`)}registerStartTime(e){let t=Date.now();return async({...n})=>{let r=Date.now()-t;return await this.saveTestMetrics({...n,requestId:e,timeElapsed:r}),r}}async logPackageDependencies(e){try{if(await this.userService.isInOrganization())return;let t=Zt(e);if(!(0,c.isDefined)(t))return;await this.updateRepositoryPackageJson(t)}catch(e){H.info.defaultLog(`Failed to log package dependencies.`,e);return}}async saveOperationMetricsTrace(e){let{parentRequestId:t,llmModel:n,testResultIteration:r=0,toolsOutput:i,testFileContent:a}=e;try{H.debug.startLog(`Sending operation metrics trace for testResultIteration ${r}`),await this.postWithRequestId(`/api/v1/tests/operation-metrics-trace`,{parentRequestId:t,iteration:r,llmModel:n,toolsOutput:i,testFileContent:a},t),H.debug.defaultLog(`Operation metrics trace saved for testResultIteration ${r}`)}catch(e){H.error(`Failed to save operation metrics trace for testResultIteration ${r}`,e)}H.debug.endLog(`Sending operation metrics trace for testResultIteration ${r}`)}async postWithRequestId(e,t,n){await this.apiService.post(e,t,{headers:{[Wr]:n}})}async updateRepositoryPackageJson(e){try{let t=this.globalConfigService.getContext();if(!(0,c.isDefined)(t?.git?.owner)||!(0,c.isDefined)(t?.git?.repository)){H.debug.defaultLog(`No git context available, skipping package.json update`);return}let n={owner:t.git.owner,repo:t.git.repository,packageJson:JSON.stringify(e)};await this.apiService.patch(`/api/v1/github-repos/package-json`,n),H.debug.defaultLog(`Successfully updated repository package.json`)}catch(e){H.info.defaultLog(`Failed to update repository package.json`,e)}}};Mi=(0,Ei.default)([(0,u.injectable)(),(0,Ti.default)(0,(0,u.inject)(ui)),(0,Ti.default)(1,(0,u.inject)(_i)),(0,Ti.default)(2,(0,u.inject)(_t)),(0,wi.default)(`design:paramtypes`,[typeof(Di=ui!==void 0&&ui)==`function`?Di:Object,typeof(Ai=_i!==void 0&&_i)==`function`?Ai:Object,typeof(ji=_t!==void 0&&_t)==`function`?ji:Object])],Mi);var Ni=class{queue;activeProcesses=[];itemAddedObserver=new c.Observer;itemExecutedObserver=new c.Observer;itemAbortedObserver=new c.Observer;abortControllers=new Map;getItemKey;constructor({concurrency:e,getItemKey:t}){this.queue=new ee.default({concurrency:e}),this.getItemKey=t}async add(e,t){let n=this.getItemKey(e);if(this.activeProcesses.includes(n))return;let r=new AbortController,i=H.captureContext({withNewRequestId:!0});return this.abortControllers.set(n,r),this.activeProcesses.push(n),this.itemAddedObserver.notifyAll(n),this.queue.add(async()=>{await H.runWithContext(i,async()=>{await t(r.signal)})},{signal:r.signal}).then(()=>{this.itemExecutedObserver.notifyAll(n)}).finally(()=>{this.activeProcesses=this.activeProcesses.filter(e=>e!==n),this.abortControllers.delete(n)})}shouldQueue(){return this.queue.pending>=this.queue.concurrency}onIdleEmit(e){this.queue.on(`idle`,()=>{e()})}has(e){let t=this.getItemKey(e);return this.activeProcesses.includes(t)}getActiveProcesses(){return this.activeProcesses}getProcessing(){return this.activeProcesses.slice(0,this.queue.concurrency)}getQueued(){return this.activeProcesses.slice(this.queue.concurrency)}onDone(e){this.itemExecutedObserver.addListener(e)}clearDoneListeners(){this.itemExecutedObserver.clear()}onAdded(e){this.itemAddedObserver.addListener(e)}onAborted(e){this.itemAbortedObserver.addListener(e)}abortAll(){this.queue.clear();for(let[,e]of this.abortControllers)e.abort();this.abortControllers.clear();for(let e of this.activeProcesses)this.itemAbortedObserver.notifyAll(e);this.activeProcesses=[]}abort(e){let t=this.getItemKey(e);this.activeProcesses=this.activeProcesses.filter(e=>e!==t),this.itemAbortedObserver.notifyAll(t);let n=this.abortControllers.get(t);(0,c.isDefined)(n)&&(n.abort(),this.abortControllers.delete(t))}clearQueued(){this.queue.clear();let e=this.getQueued();for(let t of e){let e=this.abortControllers.get(t);(0,c.isDefined)(e)&&(e.abort(),this.abortControllers.delete(t)),this.itemAbortedObserver.notifyAll(t)}this.activeProcesses=this.getProcessing()}getIdlePromise(){return this.queue.onIdle()}};let Pi=`npx jest ${ye} --coverage=false --verbose=false --watchAll=false --silent --json --forceExit --testPathIgnorePatterns=// --maxWorkers=1`;var Fi=class{fulfill(e){if(yt().getTestFramework()!==ce.JEST)return!1;let t=e,n=null,r=0;for(;r<25;){r++;let e=Yt(t,`package.json`);if(!(0,c.isDefined)(e)||e===n)return!1;let i=Zt(t);if((0,c.isDefined)(i)&&Qt(i,`jest`))return!0;n=e,t=a.default.dirname(a.default.dirname(e))}return!1}getTestCommand(){return{command:yt().getTestCommand()??Pi,framework:ce.JEST}}};let Ii=`npx vitest run ${ye} --reporter=junit --silent --pool=threads --maxWorkers=1 --coverage.enabled=false`,Li=new class{constructor(e){this.providers=e}getTestCommand(e){let t=this.getProvider(e);if(!(0,c.isDefined)(t))throw Error(`No CmdProvider found for file: ${e}`);return t.getTestCommand()}getProvider(e){return this.providers.find(t=>t.fulfill(e))}}([new class{fulfill(e){if(yt().getTestFramework()!==ce.VITEST)return!1;let t=e,n=null,r=0;for(;r<25;){r++;let e=Yt(t,`package.json`);if(!(0,c.isDefined)(e)||e===n)return!1;let i=Zt(t);if((0,c.isDefined)(i)&&Qt(i,`vitest`))return!0;n=e,t=a.default.dirname(a.default.dirname(e))}return!1}getTestCommand(){return{command:yt().getTestCommand()??Ii,framework:ce.VITEST}}},new Fi]);var Ri=class e{static of(...t){return new e(...t)}static all=e.of();static success=e.of(0);static suppress_1=e.of(0,1);allow(e){return this.allowed.length===0||this.allowed.includes(e)}allowed;constructor(...e){this.allowed=e}};let zi=`validate-tests`,Vi=e=>e instanceof Error&&`code`in e&&typeof e.code==`number`;var Hi=class e{constructor(e){this.relativePath=e}async runCommandOnFile(e,t=Ri.success,n=!1){let r=n?qt(a.default.normalize(this.relativePath)):a.default.normalize(this.relativePath),i=e.replaceAll(ye,Jt(r));try{H.debug.startLog(`Command been executed on test-file ${this.relativePath} ${e}`),H.info.defaultLog(`Running command on file ${this.relativePath}`,{renderedCommand:i});let{stdout:t,stderr:n}=await W(i,{cwd:yt().getRootPath(),timeout:3e5}),r=t||n;return H.debug.endLog(`Command been executed on test-file ${this.relativePath} ${e}: ${r}`),r}catch(n){if(!(Vi(n)&&(0,c.isDefined)(n.code)&&t.allow(n.code))){let t=`Failed run command "${e}" on file ${this.relativePath}`;throw H.error(t,n),n}let r=n.stdout||n.stderr;return H.debug.endLog(`Command been executed on test-file ${this.relativePath} ${e}: ${r}`),r}}getTempFileName(e,t,n){if(t){let t=a.default.join(p.default.tmpdir(),`early`),n=`${e}-${(0,h.randomUUID)()}`;return a.default.join(t,n)}let r=(0,c.isDefined)(n)&&!(0,c.isEmpty)(n),i=r&&a.default.isAbsolute(n)?a.default.dirname(n):a.default.join(yt().getRootPath(),a.default.dirname(n??``));if(!(0,c.isDefined)(i))throw Error(`Workspace root path is not defined`);let o=`.${e}-${(0,h.randomUUID)()}-${r?a.default.basename(n):`.ts`}`;return a.default.join(i,o)}async runCommandWithContent(t,n,r,i=!1){H.addContext({subCategory:rn.COMMAND_EXECUTION});let s={filePrefix:`generated-content`,useTemporaryOSFolder:!(0,c.isDefined)(r?.predefinedPath),validExitCodes:Ri.success,...r},l=this.getTempFileName(s.filePrefix,s.useTemporaryOSFolder,s.predefinedPath);try{H.info.defaultLog(`Creating temp file ${l}`),await o.default.mkdir(a.default.dirname(l),{recursive:!0}),await o.default.writeFile(l,t);let r=new e(l);return H.info.defaultLog(`Running command "${n}" on temp file`),await r.runCommandOnFile(n,s.validExitCodes,i)}catch(e){return H.error(`Failed running command "${n}" on temp file`,e),``}finally{try{await o.default.unlink(l)}catch(e){H.info.defaultLog(`Failed removing temp file`,e)}}}async runTestCommand(){H.addContext({subCategory:rn.COMMAND_EXECUTION});let e;try{e=Li.getTestCommand(this.relativePath)}catch(e){return e instanceof Error?e.message:`Framework is not supported yet`}return await this.runCommandOnFile(e.command,Ri.suppress_1,!0)}async runTestCommandOnTempFile(e){H.addContext({subCategory:rn.COMMAND_EXECUTION});let t;try{t=Li.getTestCommand(this.relativePath)}catch(e){return e instanceof Error?e.message:`Framework is not supported yet`}return await this.runCommandWithContent(e,t.command,{validExitCodes:Ri.suppress_1,filePrefix:zi,predefinedPath:this.relativePath},!0)}async runFormatCommand(){H.addContext({subCategory:rn.COMMAND_EXECUTION});let e=yt().getPrettierCommand();H.debug.startLog(`format command: ${e}`);let t=await this.runCommandOnFile(e,Ri.all);return H.debug.endLog(`format command: ${e}`),t}async runLintCommand(e=[]){H.addContext({subCategory:rn.COMMAND_EXECUTION});let t=yt().getLintCommand(),n=e.length>0?t+` `+e.join(` `):t;H.debug.startLog(`lint command: ${n}`);let r=await this.runCommandOnFile(n,Ri.all);return H.debug.endLog(`lint command: ${n}`),r}};let Ui=e=>{let t=e.name??``,n=e.type;return{methodType:n,methodName:t,parentName:n===`method`?e.parentName:void 0}};async function Wi(e,{methodType:t,methodName:n,parentName:r}){let i=new pr(await new U(e).getText()).testables.findTestable(t,n,r);if(!(0,c.isDefined)(i))throw new Hr(Br.TESTABLE_NOT_FOUND,{methodName:n});return i}function Gi(e,t){return(0,c.isDefined)(t)&&!(0,c.isEmpty)(t)?`${t}.${e}`:e}function Ki(e){if(!e||e.trim()===``)return[];let t=e.indexOf(`[`),n=e.lastIndexOf(`]`),r=t!==-1&&n!==-1&&n>t?e.slice(t,n+1):e;try{return JSON.parse(r)}catch(e){return H.error(`Failed to parse eslint JSON output`,e),null}}var qi=t.__toESM(ft());let Ji=class{contentCache=new Map;filePathIndex=new Map;computeContentHash(e){return vi(e)}getContentCacheKey(e,t){return`${e}:${t?`fix`:`nofix`}`}evictOldest(){let e=this.contentCache.keys().next().value;(0,c.isDefined)(e)&&(this.contentCache.delete(e),H.debug.defaultLog(`Lint cache evicted oldest entry (FIFO)`))}get(e,t,n){let r=this.computeContentHash(t),i=this.getContentCacheKey(r,n),a=this.contentCache.get(i);return(0,c.isDefined)(a)?(H.debug.defaultLog(`Lint cache hit for ${e}`),a.results):null}set(e,t,n,r){let i=this.computeContentHash(t),a=Date.now(),o=this.getContentCacheKey(i,n);if(!this.contentCache.has(o)&&this.contentCache.size>=100&&this.evictOldest(),this.contentCache.set(o,{results:r,contentHash:i,withFix:n,timestamp:a}),n){let e=this.getContentCacheKey(i,!1);!this.contentCache.has(e)&&this.contentCache.size>=100&&this.evictOldest(),this.contentCache.set(e,{results:r,contentHash:i,withFix:!1,timestamp:a})}this.filePathIndex.set(e,i)}invalidate(e){let t=this.filePathIndex.get(e);if(!(0,c.isDefined)(t))return;let n=this.getContentCacheKey(t,!0),r=this.getContentCacheKey(t,!1),i=this.contentCache.delete(n),a=this.contentCache.delete(r);this.filePathIndex.delete(e),(i||a)&&H.debug.defaultLog(`Lint cache invalidated for ${e}`)}invalidateAll(){let e=this.contentCache.size;this.contentCache.clear(),this.filePathIndex.clear(),e>0&&H.debug.defaultLog(`Lint cache cleared: ${e} entries removed`)}};Ji=(0,qi.default)([(0,u.injectable)()],Ji);let Yi=function(e){return e[e.ERROR=2]=`ERROR`,e[e.WARN=1]=`WARN`,e[e.OFF=0]=`OFF`,e}({});var Xi=t.__toESM(dt()),Zi=t.__toESM(ii()),Qi=t.__toESM(ft()),$i,ea;let ta=class{constructor(e,t){this.globalConfigService=e,this.lintCacheService=t}async disableRules(e){let t=[this.globalConfigService.shouldIgnoreAsAnyLintErrors()?`@typescript-eslint/no-explicit-any`:void 0,...this.globalConfigService.allowUndefinedLintErrors()?en:[]].filter(c.isDefined);this.globalConfigService.shouldDisableLintRules()?await this.disableAllLintRules(e):(0,c.isEmpty)(t)||await this.disableLintRules(e,t),await Tn.refreshFromFileSystem(e)}async disableAllLintRules(e){let t=await this.getRulesToDisable(e);if((0,c.isDefined)(t)){if((0,c.isEmpty)(t)){H.info.defaultLog(`No lint rules needed to be disabled`);return}await this.addDisableComment(e,t),H.info.defaultLog(`Added eslint-disable comment for rules: ${t.join(`, `)}`)}}async lintFiles(e,t){let n=U.fromRelativePath(e),r=await n.getText(),i=this.lintCacheService.get(e,r,t);if((0,c.isDefined)(i))return i;let a=t?[`--format`,`json`,`--fix`]:[`--format`,`json`],o=Ki(await new Hi(e).runLintCommand(a));if(!(0,c.isDefined)(o))return null;if(t){await Tn.refreshFromFileSystem(e);let r=await n.getText();this.lintCacheService.set(e,r,t,o)}else this.lintCacheService.set(e,r,t,o);return o}async lint(e,t){try{return await this.lintFiles(e,t)}catch(e){return H.error(`Failed to get lint results:`,e),null}}async fixLint(e){try{return await this.lint(e,!0)}catch(e){return H.error(`Failed to fix lint:`,e),null}}async getLintResults(e){try{return await this.lint(e,!1)}catch(e){return H.error(`Failed to get lint results:`,e),null}}async getRulesToDisable(e){let t=await this.getLintResults(e);if(!(0,c.isDefined)(t))return null;let n=(t[0]?.messages??[]).filter(e=>e.severity===Yi.ERROR);return[...new Set(n.map(e=>e.ruleId).filter(c.isDefined))]}async addDisableComment(e,t){let n=U.fromRelativePath(e),r=await n.getText(),i=`/* eslint-disable ${t.join(`, `)} */\n\n`;await n.replace(i+r),this.lintCacheService.invalidate(e)}hasDisableCommentForRules(e,t){let n=e.split(`
|
|
32375
32375
|
`);for(let e of n){let n=e.indexOf(`/*`),r=e.indexOf(`*/`);if(n===-1||r===-1)continue;let i=e.slice(n+2,r).trim();if(i.startsWith(`eslint-disable`)&&i.replace(`eslint-disable`,``).trim().split(`,`).map(e=>e.trim()).every(e=>t.includes(e)))return!0}return!1}async disableLintRules(e,t){if(!this.globalConfigService.shouldIgnoreAsAnyLintErrors())return;let n=U.fromRelativePath(e),r=await n.getText();if(this.hasDisableCommentForRules(r,t))return;let i=await this.getLintResults(e);if(!(0,c.isDefined)(i)){H.info.defaultLog(`No lint results returned`);return}let a=i[0]?.messages??[],o=t.filter(e=>a.some(t=>t.severity===Yi.ERROR&&t.ruleId===e));if((0,c.isEmpty)(o))return;let s=`/* eslint-disable ${o.join(`, `)} */\n\n`;await n.replace(s+r),this.lintCacheService.invalidate(e),H.info.defaultLog(`Added eslint-disable comment for ${o.join(`, `)} in ${e}`)}};ta=(0,Qi.default)([(0,u.injectable)(),(0,Zi.default)(0,(0,u.inject)(_t)),(0,Zi.default)(1,(0,u.inject)(Ji)),(0,Xi.default)(`design:paramtypes`,[typeof($i=_t!==void 0&&_t)==`function`?$i:Object,typeof(ea=Ji!==void 0&&Ji)==`function`?ea:Object])],ta);let na="${methodName}";`${na}`,`${na}`;function ra(e,t,n){let r=e.split(`
|
|
@@ -32990,7 +32990,7 @@ Anchor branch: ${t}
|
|
|
32990
32990
|
Reminder: the project boundary is STRICT. Every flow's \`trace.entryFiles\` MUST resolve inside \`${e}\`. Do not explore or catalog files in parent or sibling directories, even if they are part of a larger monorepo on disk. Drop any flow whose entry points fall outside this path.`}let g_=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`);function __(e){return e.length===0?``:[`<flow-library>`,` <!--`,` Persistent flow library for this (repo, anchor_branch). The values you see`,` here are already merged (user overrides shadow LLM proposals).`,``,` Rules:`,` - REUSE the listed flowId when you re-identify the same flow (do not invent`,` a new id for an existing flow).`,` - userOwnedFields lists fields the user has locked. Do NOT propose values`,` that conflict with what the user set; backend will ignore conflicting`,` proposals for these fields. Pick non-overlapping rank values where rank`,` is locked. Respect user-set importance unless you have a strong reason`,` and even then know your proposal will not stick.`,` - Flows you don't re-emit this run remain in the library with their prior`,` values — that's expected, not an error. Only emit the flows you'd put`,` in your top-20.`,` -->`,e.map(e=>{let t=e.userOverride===void 0?[]:Object.keys(e.userOverride),n=t.length>0?t.map(e=>g_(e)).join(`, `):`(none)`,r=e.userOverride?.name??e.name,i=e.userOverride?.description??e.description,a=e.userOverride?.importance??e.importance,o=e.userOverride?.importanceReason??e.importanceReason,s=e.userOverride?.rank??e.rank,c=i===null?``:` <description>${g_(i)}</description>`,l=o===null?``:` <importanceReason>${g_(o)}</importanceReason>`;return[` <flow>`,` <flowId>${g_(e.flowId)}</flowId>`,` <name>${g_(r)}</name>`,c,` <rank>${s}</rank>`,` <importance>${g_(a)}</importance>`,l,` <origin>${e.origin}</origin>`,` <userOwnedFields>${n}</userOwnedFields>`,` </flow>`].filter(Boolean).join(`
|
|
32991
32991
|
`)}).join(`
|
|
32992
32992
|
`),`</flow-library>`].join(`
|
|
32993
|
-
`)}var v_=t.__toESM(dt()),y_=t.__toESM(ii()),b_=t.__toESM(ft()),x_;let S_=[`Read`,`Glob`,`Grep`,`Bash`];function C_(e){let t=e.toLowerCase().trim().replaceAll(/\s+/g,`-`).replaceAll(/[^a-z0-9-]/g,``).replaceAll(/-+/g,`-`).replaceAll(/^-/g,``).replaceAll(/-$/g,``);return t.length>0?t:`flow`}let w_=class{constructor(e,t){this.globalConfigService=e,this.authStorage=t}agenticToolLog=[];async run(e){let{rootPath:t,anchorBranch:n}=e
|
|
32993
|
+
`)}var v_=t.__toESM(dt()),y_=t.__toESM(ii()),b_=t.__toESM(ft()),x_;let S_=[`Read`,`Glob`,`Grep`,`Bash`];function C_(e){let t=e.toLowerCase().trim().replaceAll(/\s+/g,`-`).replaceAll(/[^a-z0-9-]/g,``).replaceAll(/-+/g,`-`).replaceAll(/^-/g,``).replaceAll(/-$/g,``);return t.length>0?t:`flow`}let w_=class{constructor(e,t){this.globalConfigService=e,this.authStorage=t}agenticToolLog=[];async run(e){let{rootPath:t,anchorBranch:n}=e,r=e.agentLog??!1;r_(r);let i=await this.authStorage.getJWTToken();H.info.defaultLog(`[regression-agent] Starting catalog sync for ${t} on branch "${n}"`);let{query:a,getMessageContentBlocks:o,isResultMessage:s,isErrorResult:c}=await Promise.resolve().then(()=>vU()),l=m_(),u=h_(t,n),d=e.libraryFlows&&e.libraryFlows.length>0?__(e.libraryFlows):``,f=d?`${d}\n\n${u}`:u;H.info.defaultLog(`[regression-agent] Catalog SDK cwd (rootPath): ${t}`),a_(`catalog`,t);let p=a({prompt:f,options:{model:`claude-sonnet-4-6`,systemPrompt:l,allowedTools:[...S_],permissionMode:Ng,allowDangerouslySkipPermissions:!0,maxBudgetUsd:4,maxTurns:100,outputFormat:{type:`json_schema`,schema:s_},cwd:t,sessionId:(0,h.randomUUID)(),env:{...process.env,ANTHROPIC_BASE_URL:this.globalConfigService.getAnthropicProxyUrl(),ANTHROPIC_AUTH_TOKEN:i??``},stderr:e=>{H.info.defaultLog(`[regression-agent] STDERR: ${e}`)}}}),m,g,_=0,v,y=Date.now();for await(let e of p){let t=Date.now(),n=t-y;y=t;let i=String(e.type??``),a=e.error,l=a===void 0?``:` ⚠ error=${String(a)}`;r&&H.info.defaultLog(`[regression-agent] [${new Date(t).toISOString()}] [catalog-debug] SDK message (type: ${i}) — ${(n/1e3).toFixed(1)}s since previous${l}`);let u=o(e);if(u!==void 0&&u.length>0&&(_++,this.logAgenticTurn(_,u)),s(e)){if(c(e))throw new im(e.subtype,e.errors,e.total_cost_usd);if(m=e.total_cost_usd,typeof e.duration_ms==`number`&&(g=Math.round(e.duration_ms/1e3)),r){let t=e.duration_ms??0,n=e.duration_api_ms??0,r=e.num_turns;H.info.defaultLog(`[regression-agent] [catalog-debug] timing — total=${(t/1e3).toFixed(1)}s api=${(n/1e3).toFixed(1)}s non-api=${((t-n)/1e3).toFixed(1)}s turns=${String(r??`—`)}`)}v=T_(e.structured_output);break}}let b=v?{flows:v.flows,projectSummary:v.projectSummary,projectType:v.projectType,detectedEntryCount:v.detectedEntryCount}:{flows:[],projectSummary:``,projectType:`unknown`,detectedEntryCount:0};return this.normalizeFlowTypes(b.flows),this.normalizeFlowIds(b.flows),this.assignStepIds(b.flows),this.assignRanks(b.flows),{result:b,costUsd:m,durationSeconds:g,generatedPrompt:f}}getAgenticToolLog(){return this.agenticToolLog}logAgenticTurn(e,t){o_(`catalog`,e,t);for(let n of t){let t=n,r=String(t.type??``);if(r===`tool_use`){let n=String(t.name??``),r=t.input,i=r===void 0?``:JSON.stringify(r);this.agenticToolLog.push(`[Turn ${e}] TOOL: ${n}\n Input: ${i.slice(0,500)}`)}else if(r===`tool_result`){let e=typeof t.content==`string`?t.content:JSON.stringify(t.content??``),n=e.slice(0,300).replaceAll(`
|
|
32994
32994
|
`,` `);this.agenticToolLog.push(` Result: ${n}${e.length>300?`...`:``}`)}else if(r===`text`&&typeof t.text==`string`){let n=t.text.slice(0,200).replaceAll(`
|
|
32995
32995
|
`,` `);this.agenticToolLog.push(`[Turn ${e}] TEXT: ${n}${t.text.length>200?`...`:``}`)}}}normalizeFlowTypes(e){let t=new Set([`ENDPOINT`,`COMMAND`,`PAGE`,`EXPORT`,`HANDLER`,`JOB`,`JOURNEY`,`OTHER`]),n={endpoint:`ENDPOINT`,"api-endpoint":`ENDPOINT`,"api-group":`ENDPOINT`,"rest-api":`ENDPOINT`,api:`ENDPOINT`,route:`ENDPOINT`,http:`ENDPOINT`,rest:`ENDPOINT`,command:`COMMAND`,"cli-command":`COMMAND`,cli:`COMMAND`,cmd:`COMMAND`,page:`PAGE`,"web-page":`PAGE`,screen:`PAGE`,view:`PAGE`,export:`EXPORT`,"library-export":`EXPORT`,"public-api":`EXPORT`,handler:`HANDLER`,"event-handler":`HANDLER`,"real-time-stream":`HANDLER`,"real-time":`HANDLER`,webhook:`HANDLER`,event:`HANDLER`,stream:`HANDLER`,job:`JOB`,"background-job":`JOB`,cron:`JOB`,scheduled:`JOB`,worker:`JOB`,task:`JOB`,queue:`JOB`,journey:`JOURNEY`,"user-journey":`JOURNEY`,"business-process":`JOURNEY`,workflow:`JOURNEY`,pipeline:`JOURNEY`,process:`JOURNEY`};for(let r of e){let e=String(r.flowType??``).trim(),i=e.toUpperCase();t.has(i)?r.flowType=i:r.flowType=n[e.toLowerCase()]??`OTHER`}}normalizeFlowIds(e){let t=new Set;for(let n of e){let e=n,r;typeof e.flowId==`string`&&e.flowId.length>0?r=e.flowId:typeof e.flow_id==`string`&&e.flow_id.length>0&&(r=e.flow_id);let i=r??C_(n.name);t.has(i)&&(i=`${i}-${n.rank}`),t.add(i),n.flowId=i}}assignStepIds(e){for(let t of e)if(t.productFlow!==void 0)for(let e of t.productFlow.steps)e.stepId=(0,h.randomUUID)().slice(0,8)}assignRanks(e){e.sort((e,t)=>{let n=e.scoring?.finalScore??0;return(t.scoring?.finalScore??0)-n});for(let[t,n]of e.entries())n.rank=t+1}};w_=(0,b_.default)([(0,u.injectable)(),(0,y_.default)(0,(0,u.inject)(_t)),(0,y_.default)(1,(0,u.inject)(ri)),(0,v_.default)(`design:paramtypes`,[Object,typeof(x_=ri!==void 0&&ri)==`function`?x_:Object])],w_);function T_(e){if(typeof e!=`object`||!e)return;let t=e;if(Array.isArray(t.flows))return{flows:t.flows,projectSummary:typeof t.projectSummary==`string`?t.projectSummary:``,projectType:typeof t.projectType==`string`?t.projectType:`unknown`,detectedEntryCount:typeof t.detectedEntryCount==`number`?t.detectedEntryCount:0}}function E_(){return`You are a dependency tracer. Your only job is to find all local source files reachable from a set of entry files by following the project's dependency / reference chains. Be language- and framework-agnostic — adapt to whatever ecosystem this project uses.
|
|
32996
32996
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@earlyai/cli",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.5",
|
|
4
4
|
"description": "early cli",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@earlyai/core": "^1.5.0",
|
|
58
|
-
"@earlyai/ts-agent": "^0.
|
|
58
|
+
"@earlyai/ts-agent": "^0.107.0",
|
|
59
59
|
"@eslint/compat": "^1.3.2",
|
|
60
60
|
"@eslint/eslintrc": "^3.3.1",
|
|
61
61
|
"@eslint/js": "^9.34.0",
|