{"version":3,"file":"index.cjs","names":["#context","#options","fs","path","reader","fs","path","syncReader","fs","path","path","#head","#tail","#size","pLimit","resolve","promise: Promise<unknown>","pLimit","#options","path","EventEmitter","#core","#usedPluginNames","#promiseManager","#getSortedPlugins","#parse","extname","path","trim","transformReservedWord","items: Array<ReturnType<ParseResult<H>>>","#execute","#executeSync","parseResult: SafeParseResult<H>","#catcher","output: unknown","#addExecutedToCallStack","pluginNames: string[]","plugin","createLogger","pc","URLPath","definedConfig: Config","fsPlugin","typescriptParser","rootFile: KubbFile.File","files","write","#cachedLeaves","leaves: TreeNode[]","root: DirectoryTree","currentLevel: DirectoryTree[]","#options","barrelFile: KubbFile.File","item","path","resolve","toPath","process","fsPromises","path","fs","path","#cache","#cwd","#SLASHES","path","mod","os","module","#match"],"sources":["../src/BaseGenerator.ts","../src/config.ts","../src/fs/clean.ts","../src/fs/exists.ts","../src/fs/read.ts","../src/fs/utils.ts","../src/errors.ts","../../../node_modules/.pnpm/yocto-queue@1.2.1/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/p-limit@7.2.0/node_modules/p-limit/index.js","../src/utils/executeStrategies.ts","../src/PromiseManager.ts","../src/plugin.ts","../src/PluginManager.ts","../src/build.ts","../src/utils/TreeNode.ts","../src/BarrelManager.ts","../src/FileManager.ts","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js","../../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js","../src/PackageManager.ts"],"sourcesContent":["/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {\n  #options: TOptions = {} as TOptions\n  #context: TContext = {} as TContext\n\n  constructor(options?: TOptions, context?: TContext) {\n    if (context) {\n      this.#context = context\n    }\n\n    if (options) {\n      this.#options = options\n    }\n\n    return this\n  }\n\n  get options(): TOptions {\n    return this.#options\n  }\n\n  get context(): TContext {\n    return this.#context\n  }\n\n  set options(options: TOptions) {\n    this.#options = { ...this.#options, ...options }\n  }\n\n  abstract build(...params: unknown[]): unknown\n}\n","import type { InputPath, UserConfig } from './types.ts'\nimport type { PossiblePromise } from './utils/types.ts'\n\ntype Args = {\n  /**\n   * Path to `kubb.config.js`\n   */\n  config?: string\n  /**\n   * Watch changes on input\n   */\n  watch?: boolean\n\n  /**\n   * Log level to report when using the CLI\n   *\n   * `silent` will hide all information that is not relevant\n   *\n   * `info` will show all information possible(not related to the PluginManager)\n   *\n   * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n   * @default `silent`\n   */\n  logLevel?: string\n  /**\n   * Run Kubb with Bun\n   */\n  bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use vite.config.ts accepts a direct UserConfig object, or a function that returns it. The function receives a ConfigEnv object.\n */\nexport function defineConfig(\n  options:\n    | PossiblePromise<UserConfig | Array<UserConfig>>\n    | ((\n        /** The options derived from the CLI flags */\n        args: Args,\n      ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n  return options\n}\n\nexport function isInputPath(result: UserConfig | undefined): result is UserConfig<InputPath> {\n  return !!result && 'path' in (result?.input as any)\n}\n","import fs from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n  return fs.remove(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n  {\n    node: async (path: string) => {\n      return fs.pathExists(path)\n    },\n    bun: async (path: string) => {\n      const file = Bun.file(path)\n\n      return file.exists()\n    },\n  },\n  'node',\n)\n\nconst syncReader = switcher(\n  {\n    node: (path: string) => {\n      return fs.pathExistsSync(path)\n    },\n    bun: () => {\n      throw new Error('Bun cannot read sync')\n    },\n  },\n  'node',\n)\n\nexport async function exists(path: string): Promise<boolean> {\n  return reader(path)\n}\n\nexport function existsSync(path: string): boolean {\n  return syncReader(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n  {\n    node: async (path: string) => {\n      return fs.readFile(path, { encoding: 'utf8' })\n    },\n    bun: async (path: string) => {\n      const file = Bun.file(path)\n\n      return file.text()\n    },\n  },\n  'node',\n)\n\nconst syncReader = switcher(\n  {\n    node: (path: string) => {\n      return fs.readFileSync(path, { encoding: 'utf8' })\n    },\n    bun: () => {\n      throw new Error('Bun cannot read sync')\n    },\n  },\n  'node',\n)\n\nexport async function read(path: string): Promise<string> {\n  return reader(path)\n}\n\nexport function readSync(path: string): string {\n  return syncReader(path)\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n  const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n  const normalizedPath = normalize(path)\n\n  if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n    // linux and mac\n    return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n  }\n\n  // windows\n  return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n  if (!rootDir || !filePath) {\n    throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n  }\n\n  const relativePath = relative(rootDir, filePath)\n\n  // On Windows, paths are separated with a \"\\\"\n  // However, web browsers use \"/\" no matter the platform\n  const slashedPath = slash(relativePath, platform)\n\n  if (slashedPath.startsWith('../')) {\n    return slashedPath\n  }\n\n  return `./${slashedPath}`\n}\n","export class ValidationPluginError extends Error {}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tpeek() {\n\t\tif (!this.#head) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#head.value;\n\n\t\t// TODO: Node.js 18.\n\t\t// return this.#head?.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n\n\t* drain() {\n\t\twhile (this.#head) {\n\t\t\tyield this.dequeue();\n\t\t}\n\t}\n}\n","import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tvalidateConcurrency(concurrency);\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst resumeNext = () => {\n\t\t// Process the next queued function if we're under the concurrency limit\n\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\tactiveCount++;\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst next = () => {\n\t\tactiveCount--;\n\t\tresumeNext();\n\t};\n\n\tconst run = async (function_, resolve, arguments_) => {\n\t\t// Execute the function and capture the result promise\n\t\tconst result = (async () => function_(...arguments_))();\n\n\t\t// Resolve immediately with the promise (don't wait for completion)\n\t\tresolve(result);\n\n\t\t// Wait for the function to complete (success or failure)\n\t\t// We catch errors here to prevent unhandled rejections,\n\t\t// but the original promise rejection is preserved for the caller\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\t// Decrement active count and process next queued function\n\t\tnext();\n\t};\n\n\tconst enqueue = (function_, resolve, arguments_) => {\n\t\t// Queue the internal resolve function instead of the run function\n\t\t// to preserve the asynchronous execution context.\n\t\tnew Promise(internalResolve => { // eslint-disable-line promise/param-names\n\t\t\tqueue.enqueue(internalResolve);\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then\n\n\t\t// Start processing immediately if we haven't reached the concurrency limit\n\t\tif (activeCount < concurrency) {\n\t\t\tresumeNext();\n\t\t}\n\t};\n\n\tconst generator = (function_, ...arguments_) => new Promise(resolve => {\n\t\tenqueue(function_, resolve, arguments_);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue() {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t\tconcurrency: {\n\t\t\tget: () => concurrency,\n\n\t\t\tset(newConcurrency) {\n\t\t\t\tvalidateConcurrency(newConcurrency);\n\t\t\t\tconcurrency = newConcurrency;\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t// eslint-disable-next-line no-unmodified-loop-condition\n\t\t\t\t\twhile (activeCount < concurrency && queue.size > 0) {\n\t\t\t\t\t\tresumeNext();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tmap: {\n\t\t\tasync value(iterable, function_) {\n\t\t\t\tconst promises = Array.from(iterable, (value, index) => this(function_, value, index));\n\t\t\t\treturn Promise.all(promises);\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n\nexport function limitFunction(function_, options) {\n\tconst {concurrency} = options;\n\tconst limit = pLimit(concurrency);\n\n\treturn (...arguments_) => limit(() => function_(...arguments_));\n}\n\nfunction validateConcurrency(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n}\n","import pLimit from 'p-limit'\n\ntype PromiseFunc<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc<infer X, infer Y>> ? X | Y : never\n\ntype SeqOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): TOutput {\n  return promises.filter(Boolean).reduce(\n    (promise, func) => {\n      if (typeof func !== 'function') {\n        throw new Error('HookSeq needs a function that returns a promise `() => Promise<unknown>`')\n      }\n\n      return promise.then((state) => {\n        const calledFunc = func(state as TValue)\n\n        if (calledFunc) {\n          return calledFunc.then(Array.prototype.concat.bind(state))\n        }\n      })\n    },\n    Promise.resolve([] as unknown),\n  ) as TOutput\n}\n\ntype HookFirstOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>\n\n/**\n * Chains promises, first non-null result stops and returns\n */\nexport function hookFirst<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookFirstOutput<TInput, TValue>>(\n  promises: TInput,\n  nullCheck = (state: any) => state !== null,\n): TOutput {\n  let promise: Promise<unknown> = Promise.resolve(null) as Promise<unknown>\n\n  for (const func of promises.filter(Boolean)) {\n    promise = promise.then((state) => {\n      if (nullCheck(state)) {\n        return state\n      }\n\n      return func(state as TValue)\n    })\n  }\n\n  return promise as TOutput\n}\n\ntype HookParallelOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>\n\n/**\n * Runs an array of promise functions with optional concurrency limit.\n */\nexport function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookParallelOutput<TInput, TValue>>(\n  promises: TInput,\n  concurrency: number = Number.POSITIVE_INFINITY,\n): TOutput {\n  const limit = pLimit(concurrency)\n\n  const tasks = promises.filter(Boolean).map((promise) => limit(() => promise()))\n\n  return Promise.allSettled(tasks) as TOutput\n}\n\nexport type Strategy = 'seq' | 'first' | 'parallel'\n\nexport type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = TStrategy extends 'first'\n  ? HookFirstOutput<TInput, TValue>\n  : TStrategy extends 'seq'\n    ? SeqOutput<TInput, TValue>\n    : TStrategy extends 'parallel'\n      ? HookParallelOutput<TInput, TValue>\n      : never\n","import type { Strategy, StrategySwitch } from './utils/executeStrategies.ts'\nimport { hookFirst, hookParallel, hookSeq } from './utils/executeStrategies.ts'\n\ntype PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype Options<TState = any> = {\n  nullCheck?: (state: TState) => boolean\n}\n\nexport class PromiseManager<TState = any> {\n  #options: Options<TState> = {}\n\n  constructor(options: Options<TState> = {}) {\n    this.#options = options\n\n    return this\n  }\n\n  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(\n    strategy: TStrategy,\n    promises: TInput,\n    { concurrency = Number.POSITIVE_INFINITY }: { concurrency?: number } = {},\n  ): TOutput {\n    if (strategy === 'seq') {\n      return hookSeq<TInput, TValue, TOutput>(promises)\n    }\n\n    if (strategy === 'first') {\n      return hookFirst<TInput, TValue, TOutput>(promises, this.#options.nullCheck)\n    }\n\n    if (strategy === 'parallel') {\n      return hookParallel<TInput, TValue, TOutput>(promises, concurrency)\n    }\n\n    throw new Error(`${strategy} not implemented`)\n  }\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n  return result.status === 'rejected'\n}\n","import path from 'node:path'\n\nimport type { Fabric } from '@kubb/react-fabric'\nimport type { PluginManager } from './PluginManager.ts'\nimport type { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n  return (options = {}) => {\n    return factory(options)\n  }\n}\n\ntype Options = {\n  fabric: Fabric\n  config: PluginContext['config']\n  pluginManager: PluginManager\n  resolvePath: PluginContext['resolvePath']\n  resolveName: PluginContext['resolveName']\n  logger: PluginContext['logger']\n  getPlugins: () => Array<Plugin>\n  plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n  const { fabric, pluginManager, resolvePath, resolveName, logger } = options\n\n  return {\n    name: 'core',\n    options,\n    key: ['core'],\n    context() {\n      return {\n        get fabric() {\n          return fabric\n        },\n        get config() {\n          return options.config\n        },\n        get plugins() {\n          return options.getPlugins()\n        },\n        get plugin() {\n          // see pluginManger.#execute where we override with `.call` the context with the correct plugin\n          return options.plugin as NonNullable<Options['plugin']>\n        },\n        logger,\n        get fileManager() {\n          return fabric.context.fileManager\n        },\n        pluginManager,\n        async addFile(...files) {\n          const resolvedFiles = await fabric.context.fileManager.add(...files)\n\n          if (!Array.isArray(resolvedFiles)) {\n            return [resolvedFiles]\n          }\n\n          return resolvedFiles\n        },\n        resolvePath,\n        resolveName,\n      }\n    },\n    resolvePath(baseName) {\n      const root = path.resolve(options.config.root, options.config.output.path)\n\n      return path.resolve(root, baseName)\n    },\n    resolveName(name) {\n      return name\n    },\n  }\n})\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Fabric } from '@kubb/react-fabric'\nimport { ValidationPluginError } from './errors.ts'\nimport type { Logger } from './logger.ts'\nimport { isPromiseRejectedResult, PromiseManager } from './PromiseManager.ts'\nimport type { PluginCore } from './plugin.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { trim } from './transformers/trim.ts'\nimport type {\n  Config,\n  GetPluginFactoryOptions,\n  Plugin,\n  PluginFactoryOptions,\n  PluginLifecycle,\n  PluginLifecycleHooks,\n  PluginParameter,\n  PluginWithLifeCycle,\n  ResolveNameParams,\n  ResolvePathParams,\n  UserPlugin,\n  UserPluginWithLifeCycle,\n} from './types.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\ntype RequiredPluginLifecycle = Required<PluginLifecycle>\n\ntype Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq'\n\ntype Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {\n  message: string\n  strategy: Strategy\n  hookName: H\n  plugin: Plugin\n  parameters?: unknown[] | undefined\n  output?: unknown\n}\n\ntype ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H]\n\ntype SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {\n  result: Result\n  plugin: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n  fabric: Fabric\n  logger: Logger\n  /**\n   * @default Number.POSITIVE_INFINITY\n   */\n  concurrency?: number\n}\n\ntype Events = {\n  executing: [executer: Executer]\n  executed: [executer: Executer]\n  error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n  name: string\n  mode?: KubbFile.Mode\n  extname: KubbFile.Extname\n  pluginKey: Plugin['key']\n  options?: TOptions\n}\n\nexport class PluginManager {\n  readonly plugins = new Set<Plugin<GetPluginFactoryOptions<any>>>()\n  readonly events: EventEmitter<Events> = new EventEmitter()\n\n  readonly config: Config\n\n  readonly executed: Array<Executer> = []\n  readonly logger: Logger\n  readonly options: Options\n  readonly #core: Plugin<PluginCore>\n\n  readonly #usedPluginNames: Record<string, number> = {}\n  readonly #promiseManager: PromiseManager\n\n  constructor(config: Config, options: Options) {\n    this.config = config\n    this.options = options\n    this.logger = options.logger\n    this.#promiseManager = new PromiseManager({\n      nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n    })\n\n    const core = pluginCore({\n      fabric: options.fabric,\n      config,\n      logger: this.logger,\n      pluginManager: this,\n      resolvePath: this.resolvePath.bind(this),\n      resolveName: this.resolveName.bind(this),\n      getPlugins: this.#getSortedPlugins.bind(this),\n    })\n\n    // call core.context.call with empty context so we can transform `context()` to `context: {}`\n    this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n    ;[this.#core, ...(config.plugins || [])].forEach((plugin) => {\n      const parsedPlugin = this.#parse(plugin as UserPlugin, this, this.#core.context)\n\n      this.plugins.add(parsedPlugin)\n    })\n\n    return this\n  }\n\n  getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n    const baseName = `${name}${extname}` as const\n    const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n    if (!path) {\n      throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n    }\n\n    return {\n      path,\n      baseName,\n      meta: {\n        pluginKey,\n      },\n      sources: [],\n    }\n  }\n\n  resolvePath = <TOptions = object>(params: ResolvePathParams<TOptions>): KubbFile.OptionalPath => {\n    if (params.pluginKey) {\n      const paths = this.hookForPluginSync({\n        pluginKey: params.pluginKey,\n        hookName: 'resolvePath',\n        parameters: [params.baseName, params.mode, params.options as object],\n        message: `Resolving path '${params.baseName}'`,\n      })\n\n      if (paths && paths?.length > 1) {\n        this.logger.emit('debug', {\n          date: new Date(),\n          logs: [\n            `Cannot return a path where the 'pluginKey' ${\n              params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n            } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n          ],\n        })\n      }\n\n      return paths?.at(0)\n    }\n    return this.hookFirstSync({\n      hookName: 'resolvePath',\n      parameters: [params.baseName, params.mode, params.options as object],\n      message: `Resolving path '${params.baseName}'`,\n    }).result\n  }\n  //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path\n  resolveName = (params: ResolveNameParams): string => {\n    if (params.pluginKey) {\n      const names = this.hookForPluginSync({\n        pluginKey: params.pluginKey,\n        hookName: 'resolveName',\n        parameters: [trim(params.name), params.type],\n        message: `Resolving name '${params.name}' and type '${params.type}'`,\n      })\n\n      if (names && names?.length > 1) {\n        this.logger.emit('debug', {\n          date: new Date(),\n          logs: [\n            `Cannot return a name where the 'pluginKey' ${\n              params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n            } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n          ],\n        })\n      }\n\n      return transformReservedWord(names?.at(0) || params.name)\n    }\n\n    const name = this.hookFirstSync({\n      hookName: 'resolveName',\n      parameters: [trim(params.name), params.type],\n      message: `Resolving name '${params.name}' and type '${params.type}'`,\n    }).result\n\n    return transformReservedWord(name)\n  }\n\n  /**\n   * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n   */\n  on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n    this.events.on(eventName, handler as any)\n  }\n\n  /**\n   * Run a specific hookName for plugin x.\n   */\n  async hookForPlugin<H extends PluginLifecycleHooks>({\n    pluginKey,\n    hookName,\n    parameters,\n    message,\n  }: {\n    pluginKey: Plugin['key']\n    hookName: H\n    parameters: PluginParameter<H>\n    message: string\n  }): Promise<Array<ReturnType<ParseResult<H>> | null>> {\n    const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n    this.logger.emit('progress_start', { id: hookName, size: plugins.length, message: 'Running plugins...' })\n\n    const items: Array<ReturnType<ParseResult<H>>> = []\n\n    for (const plugin of plugins) {\n      const result = await this.#execute<H>({\n        strategy: 'hookFirst',\n        hookName,\n        parameters,\n        plugin,\n        message,\n      })\n\n      if (result !== undefined && result !== null) {\n        items.push(result)\n      }\n    }\n\n    this.logger.emit('progress_stop', { id: hookName })\n\n    return items\n  }\n  /**\n   * Run a specific hookName for plugin x.\n   */\n\n  hookForPluginSync<H extends PluginLifecycleHooks>({\n    pluginKey,\n    hookName,\n    parameters,\n    message,\n  }: {\n    pluginKey: Plugin['key']\n    hookName: H\n    parameters: PluginParameter<H>\n    message: string\n  }): Array<ReturnType<ParseResult<H>>> | null {\n    const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n    const result = plugins\n      .map((plugin) => {\n        return this.#executeSync<H>({\n          strategy: 'hookFirst',\n          hookName,\n          parameters,\n          plugin,\n          message,\n        })\n      })\n      .filter(Boolean)\n\n    return result\n  }\n\n  /**\n   * First non-null result stops and will return it's value.\n   */\n  async hookFirst<H extends PluginLifecycleHooks>({\n    hookName,\n    parameters,\n    skipped,\n    message,\n  }: {\n    hookName: H\n    parameters: PluginParameter<H>\n    skipped?: ReadonlySet<Plugin> | null\n    message: string\n  }): Promise<SafeParseResult<H>> {\n    const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n      return skipped ? skipped.has(plugin) : true\n    })\n\n    this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n    const promises = plugins.map((plugin) => {\n      return async () => {\n        const value = await this.#execute<H>({\n          strategy: 'hookFirst',\n          hookName,\n          parameters,\n          plugin,\n          message,\n        })\n\n        return Promise.resolve({\n          plugin,\n          result: value,\n        } as SafeParseResult<H>)\n      }\n    })\n\n    const result = await this.#promiseManager.run('first', promises)\n\n    this.logger.emit('progress_stop', { id: hookName })\n\n    return result\n  }\n\n  /**\n   * First non-null result stops and will return it's value.\n   */\n  hookFirstSync<H extends PluginLifecycleHooks>({\n    hookName,\n    parameters,\n    skipped,\n    message,\n  }: {\n    hookName: H\n    parameters: PluginParameter<H>\n    skipped?: ReadonlySet<Plugin> | null\n    message: string\n  }): SafeParseResult<H> {\n    let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n    const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n      return skipped ? skipped.has(plugin) : true\n    })\n\n    for (const plugin of plugins) {\n      parseResult = {\n        result: this.#executeSync<H>({\n          strategy: 'hookFirst',\n          hookName,\n          parameters,\n          plugin,\n          message,\n        }),\n        plugin,\n      } as SafeParseResult<H>\n\n      if (parseResult?.result != null) {\n        break\n      }\n    }\n\n    return parseResult\n  }\n\n  /**\n   * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\n   */\n  async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({\n    hookName,\n    parameters,\n    message,\n  }: {\n    hookName: H\n    parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined\n    message: string\n  }): Promise<Awaited<TOuput>[]> {\n    const plugins = this.#getSortedPlugins(hookName)\n    this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n    const promises = plugins.map((plugin) => {\n      return () =>\n        this.#execute({\n          strategy: 'hookParallel',\n          hookName,\n          parameters,\n          plugin,\n          message,\n        }) as Promise<TOuput>\n    })\n\n    const results = await this.#promiseManager.run('parallel', promises, { concurrency: this.options.concurrency })\n\n    results.forEach((result, index) => {\n      if (isPromiseRejectedResult<Error>(result)) {\n        const plugin = this.#getSortedPlugins(hookName)[index]\n\n        this.#catcher<H>(result.reason, plugin, hookName)\n      }\n    })\n\n    this.logger.emit('progress_stop', { id: hookName })\n\n    return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n  }\n\n  /**\n   * Chains plugins\n   */\n  async hookSeq<H extends PluginLifecycleHooks>({\n    hookName,\n    parameters,\n    message,\n  }: {\n    hookName: H\n    parameters?: PluginParameter<H>\n    message: string\n  }): Promise<void> {\n    const plugins = this.#getSortedPlugins(hookName)\n    this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n    const promises = plugins.map((plugin) => {\n      return () =>\n        this.#execute({\n          strategy: 'hookSeq',\n          hookName,\n          parameters,\n          plugin,\n          message,\n        })\n    })\n\n    await this.#promiseManager.run('seq', promises)\n\n    this.logger.emit('progress_stop', { id: hookName })\n  }\n\n  #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n    const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n    if (hookName) {\n      return plugins.filter((plugin) => hookName in plugin)\n    }\n    // TODO add test case for sorting with pre/post\n\n    return plugins\n      .map((plugin) => {\n        if (plugin.pre) {\n          const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName))\n\n          if (!isValid) {\n            throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, undefined, 2)})`)\n          }\n        }\n\n        return plugin\n      })\n      .sort((a, b) => {\n        if (b.pre?.includes(a.name)) {\n          return 1\n        }\n        if (b.post?.includes(a.name)) {\n          return -1\n        }\n        return 0\n      })\n  }\n\n  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined {\n    const plugins = [...this.plugins]\n    const [searchPluginName] = pluginKey\n\n    return plugins.find((item) => {\n      const [name] = item.key\n\n      return name === searchPluginName\n    })\n  }\n\n  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[] {\n    const plugins = [...this.plugins]\n    const [searchPluginName, searchIdentifier] = pluginKey\n\n    const pluginByPluginName = plugins\n      .filter((plugin) => hookName in plugin)\n      .filter((item) => {\n        const [name, identifier] = item.key\n\n        const identifierCheck = identifier?.toString() === searchIdentifier?.toString()\n        const nameCheck = name === searchPluginName\n\n        if (searchIdentifier) {\n          return identifierCheck && nameCheck\n        }\n\n        return nameCheck\n      })\n\n    if (!pluginByPluginName?.length) {\n      // fallback on the core plugin when there is no match\n\n      const corePlugin = plugins.find((plugin) => plugin.name === 'core' && hookName in plugin)\n\n      if (corePlugin) {\n        this.logger.emit('debug', {\n          date: new Date(),\n          logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],\n        })\n      } else {\n        this.logger.emit('debug', {\n          date: new Date(),\n          logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],\n        })\n      }\n      return corePlugin ? [corePlugin] : []\n    }\n\n    return pluginByPluginName\n  }\n\n  #addExecutedToCallStack(executer: Executer | undefined) {\n    if (executer) {\n      this.events.emit('executed', executer)\n      this.executed.push(executer)\n\n      this.logger.emit('progressed', { id: executer.hookName, message: `${executer.plugin.name}: ${executer.message}` })\n    }\n  }\n\n  /**\n   * Run an async plugin hook and return the result.\n   * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.\n   * @param args Arguments passed to the plugin hook.\n   * @param plugin The actual pluginObject to run.\n   */\n  // Implementation signature\n  #execute<H extends PluginLifecycleHooks>({\n    strategy,\n    hookName,\n    parameters,\n    plugin,\n    message,\n  }: {\n    strategy: Strategy\n    hookName: H\n    parameters: unknown[] | undefined\n    plugin: PluginWithLifeCycle\n    message: string\n  }): Promise<ReturnType<ParseResult<H>> | null> | null {\n    const hook = plugin[hookName]\n    let output: unknown\n\n    if (!hook) {\n      return null\n    }\n\n    this.events.emit('executing', { strategy, hookName, parameters, plugin, message })\n\n    const task = (async () => {\n      try {\n        if (typeof hook === 'function') {\n          const result = await Promise.resolve((hook as Function).apply({ ...this.#core.context, plugin }, parameters))\n\n          output = result\n\n          this.#addExecutedToCallStack({\n            parameters,\n            output,\n            strategy,\n            hookName,\n            plugin,\n            message,\n          })\n\n          return result\n        }\n\n        output = hook\n\n        this.#addExecutedToCallStack({\n          parameters,\n          output,\n          strategy,\n          hookName,\n          plugin,\n          message,\n        })\n\n        return hook\n      } catch (e) {\n        this.#catcher<H>(e as Error, plugin, hookName)\n        return null\n      }\n    })()\n\n    return task\n  }\n\n  /**\n   * Run a sync plugin hook and return the result.\n   * @param hookName Name of the plugin hook. Must be in `PluginHooks`.\n   * @param args Arguments passed to the plugin hook.\n   * @param plugin The acutal plugin\n   * @param replaceContext When passed, the plugin context can be overridden.\n   */\n  #executeSync<H extends PluginLifecycleHooks>({\n    strategy,\n    hookName,\n    parameters,\n    plugin,\n    message,\n  }: {\n    strategy: Strategy\n    hookName: H\n    parameters: PluginParameter<H>\n    plugin: PluginWithLifeCycle\n    message: string\n  }): ReturnType<ParseResult<H>> | null {\n    const hook = plugin[hookName]\n    let output: unknown\n\n    if (!hook) {\n      return null\n    }\n\n    this.events.emit('executing', { strategy, hookName, parameters, plugin, message })\n\n    try {\n      if (typeof hook === 'function') {\n        const fn = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as ReturnType<ParseResult<H>>\n\n        output = fn\n\n        this.#addExecutedToCallStack({\n          parameters,\n          output,\n          strategy,\n          hookName,\n          plugin,\n          message,\n        })\n\n        return fn\n      }\n\n      output = hook\n\n      this.#addExecutedToCallStack({\n        parameters,\n        output,\n        strategy,\n        hookName,\n        plugin,\n        message,\n      })\n\n      return hook\n    } catch (e) {\n      this.#catcher<H>(e as Error, plugin, hookName)\n\n      return null\n    }\n  }\n\n  #catcher<H extends PluginLifecycleHooks>(cause: Error, plugin?: Plugin, hookName?: H) {\n    const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n    this.logger.emit('error', text, cause)\n    this.events.emit('error', cause)\n  }\n\n  #parse<TPlugin extends UserPluginWithLifeCycle>(\n    plugin: TPlugin,\n    pluginManager: PluginManager,\n    context: PluginCore['context'] | undefined,\n  ): Plugin<GetPluginFactoryOptions<TPlugin>> {\n    const usedPluginNames = pluginManager.#usedPluginNames\n\n    setUniqueName(plugin.name, usedPluginNames)\n\n    const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]\n\n    if (plugin.context && typeof plugin.context === 'function') {\n      return {\n        ...plugin,\n        key,\n        context: (plugin.context as Function).call(context) as typeof plugin.context,\n      } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n    }\n\n    return {\n      ...plugin,\n      key,\n    } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n  }\n\n  static getDependedPlugins<\n    T1 extends PluginFactoryOptions,\n    T2 extends PluginFactoryOptions = never,\n    T3 extends PluginFactoryOptions = never,\n    TOutput = T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n  >(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput {\n    let pluginNames: string[] = []\n    if (typeof dependedPluginNames === 'string') {\n      pluginNames = [dependedPluginNames]\n    } else {\n      pluginNames = dependedPluginNames\n    }\n\n    return pluginNames.map((pluginName) => {\n      const plugin = plugins.find((plugin) => plugin.name === pluginName)\n      if (!plugin) {\n        throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`)\n      }\n      return plugin\n    }) as TOutput\n  }\n\n  static get hooks() {\n    return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n  }\n}\n","import { join, relative, resolve } from 'node:path'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { Fabric } from '@kubb/react-fabric'\nimport { createFabric } from '@kubb/react-fabric'\nimport { typescriptParser } from '@kubb/react-fabric/parsers'\nimport { fsPlugin } from '@kubb/react-fabric/plugins'\nimport pc from 'picocolors'\nimport { isDeepEqual } from 'remeda'\nimport { isInputPath } from './config.ts'\nimport { clean, exists, getRelativePath, write } from './fs/index.ts'\nimport type { Logger } from './logger.ts'\nimport { createLogger } from './logger.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport type { Config, Output, UserConfig } from './types.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\ntype BuildOptions = {\n  config: UserConfig\n  /**\n   * @default Logger without the spinner\n   */\n  logger?: Logger\n}\n\ntype BuildOutput = {\n  fabric: Fabric\n  files: Array<KubbFile.ResolvedFile>\n  pluginManager: PluginManager\n  /**\n   * Only for safeBuild\n   */\n  error?: Error\n}\n\ntype SetupResult = {\n  fabric: Fabric\n  pluginManager: PluginManager\n}\n\nexport async function setup(options: BuildOptions): Promise<SetupResult> {\n  const { config: userConfig, logger = createLogger() } = options\n\n  if (Array.isArray(userConfig.input)) {\n    console.warn(pc.yellow('This feature is still under development — use with caution'))\n  }\n\n  try {\n    if (isInputPath(userConfig) && !new URLPath(userConfig.input.path).isURL) {\n      await exists(userConfig.input.path)\n    }\n  } catch (e) {\n    if (isInputPath(userConfig)) {\n      throw new Error(\n        `Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${userConfig.input.path}`,\n        {\n          cause: e,\n        },\n      )\n    }\n  }\n\n  const definedConfig: Config = {\n    root: userConfig.root || process.cwd(),\n    ...userConfig,\n    output: {\n      write: true,\n      barrelType: 'named',\n      extension: {\n        '.ts': '.ts',\n      },\n      defaultBanner: 'simple',\n      ...userConfig.output,\n    },\n    plugins: userConfig.plugins as Config['plugins'],\n  }\n\n  if (definedConfig.output.clean) {\n    await clean(definedConfig.output.path)\n    await clean(join(definedConfig.root, '.kubb'))\n  }\n\n  const fabric = createFabric()\n  fabric.use(fsPlugin, { dryRun: !definedConfig.output.write })\n  fabric.use(typescriptParser)\n\n  const pluginManager = new PluginManager(definedConfig, { fabric, logger, concurrency: 5 })\n\n  return {\n    fabric,\n    pluginManager,\n  }\n}\n\nexport async function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput> {\n  const { fabric, files, pluginManager, error } = await safeBuild(options, overrides)\n\n  if (error) {\n    throw error\n  }\n\n  return {\n    fabric,\n    files,\n    pluginManager,\n    error,\n  }\n}\n\nexport async function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput> {\n  const { fabric, pluginManager } = overrides ? overrides : await setup(options)\n\n  const config = pluginManager.config\n\n  try {\n    await pluginManager.hookParallel({\n      hookName: 'buildStart',\n      parameters: [config],\n      message: 'buildStart',\n    })\n\n    if (config.output.barrelType) {\n      const root = resolve(config.root)\n      const rootPath = resolve(root, config.output.path, 'index.ts')\n\n      const barrelFiles = fabric.files.filter((file) => {\n        return file.sources.some((source) => source.isIndexable)\n      })\n\n      const rootFile: KubbFile.File = {\n        path: rootPath,\n        baseName: 'index.ts',\n        exports: barrelFiles\n          .flatMap((file) => {\n            const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly)\n\n            return file.sources\n              ?.map((source) => {\n                if (!file.path || !source.isIndexable) {\n                  return undefined\n                }\n\n                // validate of the file is coming from plugin x, needs pluginKey on every file TODO update typing\n                const plugin = [...pluginManager.plugins].find((item) => {\n                  const meta = file.meta as any\n                  return isDeepEqual(item.key, meta?.pluginKey)\n                })\n                const pluginOptions = plugin?.options as { output?: Output<any> }\n\n                if (!pluginOptions || pluginOptions?.output?.barrelType === false) {\n                  return undefined\n                }\n\n                return {\n                  name: config.output.barrelType === 'all' ? undefined : [source.name],\n                  path: getRelativePath(rootPath, file.path),\n                  isTypeOnly: config.output.barrelType === 'all' ? containsOnlyTypes : source.isTypeOnly,\n                } as KubbFile.Export\n              })\n              .filter(Boolean)\n          })\n          .filter(Boolean),\n        sources: [],\n        meta: {},\n      }\n\n      await fabric.addFile(rootFile)\n    }\n\n    fabric.context.events.on('process:start', ({ files }) => {\n      pluginManager.logger.emit('progress_start', { id: 'files', size: files.length, message: 'Writing files ...' })\n    })\n\n    fabric.context.events.on('process:progress', async ({ file, source }) => {\n      const message = file ? `Writing ${relative(config.root, file.path)}` : ''\n      pluginManager.logger.emit('progressed', { id: 'files', message })\n\n      if (source) {\n        await write(file.path, source, { sanity: false })\n      }\n    })\n\n    fabric.context.events.on('process:end', () => {\n      pluginManager.logger.emit('progress_stop', { id: 'files' })\n    })\n    const files = [...fabric.files]\n\n    await fabric.write({ extension: config.output.extension })\n\n    await pluginManager.hookParallel({ hookName: 'buildEnd', message: `Build stopped for ${config.name}` })\n\n    return {\n      fabric,\n      files,\n      pluginManager,\n    }\n  } catch (e) {\n    return {\n      fabric,\n      files: [],\n      pluginManager,\n      error: e as Error,\n    }\n  }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { getMode } from '../FileManager.ts'\n\ntype BarrelData = {\n  file?: KubbFile.File\n  /**\n   * @deprecated use file instead\n   */\n  type: KubbFile.Mode\n  path: string\n  name: string\n}\n\nexport class TreeNode {\n  data: BarrelData\n  parent?: TreeNode\n  children: Array<TreeNode> = []\n  #cachedLeaves?: Array<TreeNode> = undefined\n\n  constructor(data: BarrelData, parent?: TreeNode) {\n    this.data = data\n    this.parent = parent\n    return this\n  }\n\n  addChild(data: BarrelData): TreeNode {\n    const child = new TreeNode(data, this)\n    if (!this.children) {\n      this.children = []\n    }\n    this.children.push(child)\n    return child\n  }\n\n  get root(): TreeNode {\n    if (!this.parent) {\n      return this\n    }\n    return this.parent.root\n  }\n\n  get leaves(): Array<TreeNode> {\n    if (!this.children || this.children.length === 0) {\n      // this is a leaf\n      return [this]\n    }\n\n    if (this.#cachedLeaves) {\n      return this.#cachedLeaves\n    }\n\n    // if not a leaf, return all children's leaves recursively\n    const leaves: TreeNode[] = []\n    if (this.children) {\n      for (let i = 0, { length } = this.children; i < length; i++) {\n        leaves.push.apply(leaves, this.children[i]!.leaves)\n      }\n    }\n\n    this.#cachedLeaves = leaves\n\n    return leaves\n  }\n\n  forEach(callback: (treeNode: TreeNode) => void): this {\n    if (typeof callback !== 'function') {\n      throw new TypeError('forEach() callback must be a function')\n    }\n\n    // run this node through function\n    callback(this)\n\n    // do the same for all children\n    if (this.children) {\n      for (let i = 0, { length } = this.children; i < length; i++) {\n        this.children[i]?.forEach(callback)\n      }\n    }\n\n    return this\n  }\n\n  findDeep(predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean): TreeNode | undefined {\n    if (typeof predicate !== 'function') {\n      throw new TypeError('find() predicate must be a function')\n    }\n\n    return this.leaves.find(predicate)\n  }\n\n  forEachDeep(callback: (treeNode: TreeNode) => void): void {\n    if (typeof callback !== 'function') {\n      throw new TypeError('forEach() callback must be a function')\n    }\n\n    this.leaves.forEach(callback)\n  }\n\n  filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode> {\n    if (typeof callback !== 'function') {\n      throw new TypeError('filter() callback must be a function')\n    }\n\n    return this.leaves.filter(callback)\n  }\n\n  mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T> {\n    if (typeof callback !== 'function') {\n      throw new TypeError('map() callback must be a function')\n    }\n\n    return this.leaves.map(callback)\n  }\n\n  public static build(files: KubbFile.File[], root?: string): TreeNode | null {\n    try {\n      const filteredTree = buildDirectoryTree(files, root)\n\n      if (!filteredTree) {\n        return null\n      }\n\n      const treeNode = new TreeNode({\n        name: filteredTree.name,\n        path: filteredTree.path,\n        file: filteredTree.file,\n        type: getMode(filteredTree.path),\n      })\n\n      const recurse = (node: typeof treeNode, item: DirectoryTree) => {\n        const subNode = node.addChild({\n          name: item.name,\n          path: item.path,\n          file: item.file,\n          type: getMode(item.path),\n        })\n\n        if (item.children?.length) {\n          item.children?.forEach((child) => {\n            recurse(subNode, child)\n          })\n        }\n      }\n\n      filteredTree.children?.forEach((child) => {\n        recurse(treeNode, child)\n      })\n\n      return treeNode\n    } catch (e) {\n      throw new Error('Something went wrong with creating barrel files with the TreeNode class', { cause: e })\n    }\n  }\n}\n\nexport type DirectoryTree = {\n  name: string\n  path: string\n  file?: KubbFile.File\n  children: Array<DirectoryTree>\n}\n\nconst normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n\nexport function buildDirectoryTree(files: Array<KubbFile.File>, rootFolder = ''): DirectoryTree | null {\n  const normalizedRootFolder = normalizePath(rootFolder)\n  const rootPrefix = normalizedRootFolder.endsWith('/') ? normalizedRootFolder : `${normalizedRootFolder}/`\n\n  const filteredFiles = files.filter((file) => {\n    const normalizedFilePath = normalizePath(file.path)\n    return rootFolder ? normalizedFilePath.startsWith(rootPrefix) && !normalizedFilePath.endsWith('.json') : !normalizedFilePath.endsWith('.json')\n  })\n\n  if (filteredFiles.length === 0) {\n    return null // No files match the root folder\n  }\n\n  const root: DirectoryTree = {\n    name: rootFolder || '',\n    path: rootFolder || '',\n    children: [],\n  }\n\n  filteredFiles.forEach((file) => {\n    const path = file.path.slice(rootFolder.length)\n    const parts = path.split('/')\n    let currentLevel: DirectoryTree[] = root.children\n    let currentPath = rootFolder\n\n    parts.forEach((part, index) => {\n      if (index !== 0) {\n        currentPath += `/${part}`\n      } else {\n        currentPath += `${part}`\n      }\n\n      let existingNode = currentLevel.find((node) => node.name === part)\n\n      if (!existingNode) {\n        if (index === parts.length - 1) {\n          // If it's the last part, it's a file\n          existingNode = {\n            name: part,\n            file,\n            path: currentPath,\n          } as DirectoryTree\n        } else {\n          // Otherwise, it's a folder\n          existingNode = {\n            name: part,\n            path: currentPath,\n            children: [],\n          } as DirectoryTree\n        }\n        currentLevel.push(existingNode)\n      }\n\n      // Move to the next level if it's a folder\n      if (!existingNode.file) {\n        currentLevel = existingNode.children\n      }\n    })\n  })\n\n  return root\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\nimport { join } from 'node:path'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { FileMetaBase } from './FileManager.ts'\nimport { getRelativePath } from './fs/index.ts'\nimport type { Logger } from './logger.ts'\nimport { TreeNode } from './utils/TreeNode.ts'\n\ntype BarrelManagerOptions = {\n  logger?: Logger\n}\n\nexport class BarrelManager {\n  #options: BarrelManagerOptions\n\n  constructor(options: BarrelManagerOptions = {}) {\n    this.#options = options\n\n    return this\n  }\n\n  getFiles({ files: generatedFiles, root }: { files: KubbFile.File[]; root?: string; meta?: FileMetaBase | undefined }): Array<KubbFile.File> {\n    const { logger } = this.#options\n\n    const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n\n    TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {\n      if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {\n        return undefined\n      }\n\n      const barrelFile: KubbFile.File = {\n        path: join(treeNode.parent?.data.path, 'index.ts') as KubbFile.Path,\n        baseName: 'index.ts',\n        exports: [],\n        sources: [],\n      }\n      const previousBarrelFile = cachedFiles.get(barrelFile.path)\n      const leaves = treeNode.leaves\n\n      leaves.forEach((item) => {\n        if (!item.data.name) {\n          return undefined\n        }\n\n        const sources = item.data.file?.sources || []\n\n        if (!sources.some((source) => source.isIndexable)) {\n          logger?.emit(\n            'warning',\n            `No isIndexable source found(source should have a name and isIndexable):\\nFile: ${JSON.stringify(item.data.file, undefined, 2)}`,\n          )\n        }\n\n        sources.forEach((source) => {\n          if (!item.data.file?.path || !source.isIndexable || !source.name) {\n            return undefined\n          }\n          const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some(\n            (item) => item.name === source.name && item.isTypeOnly === source.isTypeOnly,\n          )\n\n          if (alreadyContainInPreviousBarrelFile) {\n            return undefined\n          }\n\n          if (!barrelFile.exports) {\n            barrelFile.exports = []\n          }\n\n          // true when we have a subdirectory that also contains barrel files\n          const isSubExport = !!treeNode.parent?.data.path?.split?.('/')?.length\n\n          if (isSubExport) {\n            barrelFile.exports.push({\n              name: [source.name],\n              path: getRelativePath(treeNode.parent?.data.path, item.data.path),\n              isTypeOnly: source.isTypeOnly,\n            })\n          } else {\n            barrelFile.exports.push({\n              name: [source.name],\n              path: `./${item.data.file.baseName}`,\n              isTypeOnly: source.isTypeOnly,\n            })\n          }\n\n          barrelFile.sources.push({\n            name: source.name,\n            isTypeOnly: source.isTypeOnly,\n            //TODO use parser to generate import\n            value: '',\n            isExportable: false,\n            isIndexable: false,\n          })\n        })\n      })\n\n      if (previousBarrelFile) {\n        previousBarrelFile.sources.push(...barrelFile.sources)\n        previousBarrelFile.exports?.push(...(barrelFile.exports || []))\n      } else {\n        cachedFiles.set(barrelFile.path, barrelFile)\n      }\n    })\n\n    return [...cachedFiles.values()]\n  }\n}\n","import { extname, join } from 'node:path'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport { BarrelManager } from './BarrelManager.ts'\nimport type { Logger } from './logger.ts'\nimport type { BarrelType, Plugin } from './types.ts'\n\nexport type FileMetaBase = {\n  pluginKey?: Plugin['key']\n}\n\ntype AddIndexesProps = {\n  type: BarrelType | false | undefined\n  /**\n   * Root based on root and output.path specified in the config\n   */\n  root: string\n  /**\n   * Output for plugin\n   */\n  output: {\n    path: string\n  }\n  group?: {\n    output: string\n    exportAs: string\n  }\n  logger?: Logger\n\n  meta?: FileMetaBase\n}\n\nexport function getMode(path: string | undefined | null): KubbFile.Mode {\n  if (!path) {\n    return 'split'\n  }\n  return extname(path) ? 'single' : 'split'\n}\n\nfunction trimExtName(text: string): string {\n  return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport async function getBarrelFiles(\n  files: Array<KubbFile.ResolvedFile>,\n  { type, meta = {}, root, output, logger }: AddIndexesProps,\n): Promise<KubbFile.File[]> {\n  if (!type || type === 'propagate') {\n    return []\n  }\n\n  const barrelManager = new BarrelManager({ logger })\n\n  const pathToBuildFrom = join(root, output.path)\n\n  if (trimExtName(pathToBuildFrom).endsWith('index')) {\n    logger?.emit('warning', 'Output has the same fileName as the barrelFiles, please disable barrel generation')\n\n    return []\n  }\n\n  const barrelFiles = barrelManager.getFiles({ files, root: pathToBuildFrom, meta })\n\n  if (type === 'all') {\n    return barrelFiles.map((file) => {\n      return {\n        ...file,\n        exports: file.exports?.map((exportItem) => {\n          return {\n            ...exportItem,\n            name: undefined,\n          }\n        }),\n      }\n    })\n  }\n\n  return barrelFiles.map((indexFile) => {\n    return {\n      ...indexFile,\n      meta,\n    }\n  })\n}\n","import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n","import pLimit from 'p-limit';\n\nclass EndError extends Error {\n\tconstructor(value) {\n\t\tsuper();\n\t\tthis.value = value;\n\t}\n}\n\n// The input can also be a promise, so we await it.\nconst testElement = async (element, tester) => tester(await element);\n\n// The input can also be a promise, so we `Promise.all()` them both.\nconst finder = async element => {\n\tconst values = await Promise.all(element);\n\tif (values[1] === true) {\n\t\tthrow new EndError(values[0]);\n\t}\n\n\treturn false;\n};\n\nexport default async function pLocate(\n\titerable,\n\ttester,\n\t{\n\t\tconcurrency = Number.POSITIVE_INFINITY,\n\t\tpreserveOrder = true,\n\t} = {},\n) {\n\tconst limit = pLimit(concurrency);\n\n\t// Start all the promises concurrently with optional limit.\n\tconst items = [...iterable].map(element => [element, limit(testElement, element, tester)]);\n\n\t// Check the promises either serially or concurrently.\n\tconst checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);\n\n\ttry {\n\t\tawait Promise.all(items.map(element => checkLimit(finder, element)));\n\t} catch (error) {\n\t\tif (error instanceof EndError) {\n\t\t\treturn error.value;\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","import {fileURLToPath} from 'node:url';\n\nexport function toPath(urlOrPath) {\n\treturn urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n}\n\nexport * from './default.js';\n","import path from 'node:path';\nimport {locatePath, locatePathSync} from 'locate-path';\nimport {toPath} from 'unicorn-magic';\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt ?? root));\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\nimport { read, readSync } from './fs/index.ts'\n\ntype PackageJSON = {\n  dependencies?: Record<string, string>\n  devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n  static #cache: Record<DependencyName, DependencyVersion> = {}\n\n  #cwd?: string\n  #SLASHES = new Set(['/', '\\\\'])\n  constructor(workspace?: string) {\n    if (workspace) {\n      this.#cwd = workspace\n    }\n\n    return this\n  }\n\n  set workspace(workspace: string) {\n    this.#cwd = workspace\n  }\n\n  get workspace(): string | undefined {\n    return this.#cwd\n  }\n\n  normalizeDirectory(directory: string): string {\n    if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n      return `${directory}/`\n    }\n\n    return directory\n  }\n\n  getLocation(path: string): string {\n    let location = path\n\n    if (this.#cwd) {\n      const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n      location = require.resolve(path)\n    }\n\n    return location\n  }\n\n  async import(path: string): Promise<any | undefined> {\n    try {\n      let location = this.getLocation(path)\n\n      if (os.platform() === 'win32') {\n        location = pathToFileURL(location).href\n      }\n\n      const module = await import(location)\n\n      return module?.default ?? module\n    } catch (e) {\n      console.error(e)\n      return undefined\n    }\n  }\n\n  async getPackageJSON(): Promise<PackageJSON | undefined> {\n    const pkgPath = await findUp(['package.json'], {\n      cwd: this.#cwd,\n    })\n    if (!pkgPath) {\n      return undefined\n    }\n\n    const json = await read(pkgPath)\n\n    return JSON.parse(json) as PackageJSON\n  }\n\n  getPackageJSONSync(): PackageJSON | undefined {\n    const pkgPath = findUpSync(['package.json'], {\n      cwd: this.#cwd,\n    })\n    if (!pkgPath) {\n      return undefined\n    }\n\n    const json = readSync(pkgPath)\n\n    return JSON.parse(json) as PackageJSON\n  }\n\n  static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n    PackageManager.#cache[dependency] = version\n  }\n\n  #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n    const dependencies = {\n      ...(packageJSON['dependencies'] || {}),\n      ...(packageJSON['devDependencies'] || {}),\n    }\n\n    if (typeof dependency === 'string' && dependencies[dependency]) {\n      return dependencies[dependency]\n    }\n\n    const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency))\n\n    return matchedDependency ? dependencies[matchedDependency] : undefined\n  }\n\n  async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n    if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n      return PackageManager.#cache[dependency]\n    }\n\n    const packageJSON = await this.getPackageJSON()\n\n    if (!packageJSON) {\n      return undefined\n    }\n\n    return this.#match(packageJSON, dependency)\n  }\n\n  getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n    if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n      return PackageManager.#cache[dependency]\n    }\n\n    const packageJSON = this.getPackageJSONSync()\n\n    if (!packageJSON) {\n      return undefined\n    }\n\n    return this.#match(packageJSON, dependency)\n  }\n\n  async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n    const packageVersion = await this.getVersion(dependency)\n\n    if (!packageVersion) {\n      return false\n    }\n\n    if (packageVersion === version) {\n      return true\n    }\n\n    const semVer = coerce(packageVersion)\n\n    if (!semVer) {\n      throw new Error(`${packageVersion} is not valid`)\n    }\n\n    return satisfies(semVer, version)\n  }\n  isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n    const packageVersion = this.getVersionSync(dependency)\n\n    if (!packageVersion) {\n      return false\n    }\n\n    if (version === 'next' && packageVersion === version) {\n      return true\n    }\n\n    const semVer = coerce(packageVersion)\n\n    if (!semVer) {\n      return false\n    }\n\n    return satisfies(semVer, version)\n  }\n}\n"],"x_google_ignoreList":[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