{"version":3,"sources":["../src/index.ts","../src/utils/noop.ts","../src/links/internal/observable.ts","../src/links/internal/operation.ts","../src/links/internal/create-chain.ts","../src/links/internal/operators.ts","../src/client.ts","../src/errors.ts","../src/http.ts","../src/constants.ts","../src/links/internal/transformer.ts","../src/utils/file.ts","../src/utils/http.ts","../src/utils/parse.ts","../src/ws.ts","../src/resolve.ts","../src/utils/null.ts","../src/links/internal/universal-requester.ts","../src/links/http-link.ts","../src/links/internal/batched-data-loader.ts","../src/links/http-batch-link.ts","../src/links/logger-link.ts","../src/links/split-link.ts","../src/path.ts","../src/path-params.ts","../src/treaty.ts"],"sourcesContent":["export * from './client'\nexport * from './errors'\nexport * from './http'\nexport * from './infer'\nexport * from './links'\nexport * from './path'\nexport * from './path-params'\nexport * from './request'\nexport * from './resolve'\nexport * from './treaty'\nexport * from './utils/empty-to-void'\nexport * from './utils/http'\n","export function noop() {\n  /* noop */\n}\n\nexport async function asyncNoop() {\n  /* noop */\n}\n\nexport function constNoop<T>(value: T): () => T {\n  return () => value\n}\n\nexport function asyncConstNoop<T>(value: T): () => Promise<T> {\n  return async () => value\n}\n\nexport type Noop = typeof noop\n"," \n\nimport { type Noop, noop } from '../../utils/noop'\n\nexport type TeardownLogic = Unsubscribable | Noop | void\n\nexport type UnaryFunction<TSource = any, TReturn = any> = (source: TSource) => TReturn\n\nexport type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<\n  TValue,\n  TError,\n  TValue,\n  TError\n>\n\nexport type OperatorFunction<\n  TValueBefore = any,\n  TErrorBefore = any,\n  TValueAfter = any,\n  TErrorAfter = any,\n> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>\n\nexport type Observer<TValue = any, TError = any> = {\n  next: (value: TValue) => void\n  error: (err: TError) => void\n  complete: () => void\n}\n\nexport type Unsubscribable = {\n  unsubscribe(): void\n}\n\nexport type InferObservableValue<TObservable> =\n  TObservable extends Observable<infer TValue, unknown> ? TValue : never\n\nexport function isObservable(x: unknown): x is Observable<unknown, unknown> {\n  return typeof x === 'object' && x !== null && 'subscribe' in x\n}\n\nexport function pipeReducer(previousValue: any, next: UnaryFunction) {\n  return next(previousValue)\n}\n\nexport function promisifyObservable<T>(observable: Observable<T>) {\n  let abort = noop\n\n  const promise = new Promise<T>((resolve, reject) => {\n    let isDone = false\n\n    const onDone = () => {\n      if (isDone) return\n      isDone = true\n      reject(new ObservableAbortError('This operation was aborted.'))\n      obs$.unsubscribe()\n    }\n\n    const obs$ = observable.subscribe({\n      next: (data) => {\n        isDone = true\n        resolve(data)\n        onDone()\n      },\n      error: (data) => {\n        isDone = true\n        reject(data)\n        onDone()\n      },\n      complete: () => {\n        isDone = true\n        onDone()\n      },\n    })\n\n    abort = onDone\n  })\n\n  return { promise, abort }\n}\n\nexport class ObservableAbortError extends Error {\n  constructor(message?: string) {\n    super(message)\n    this.name = 'ObservableAbortError'\n    Object.setPrototypeOf(this, ObservableAbortError.prototype)\n  }\n}\n\nexport class Subscribable<TValue = any, TError = any> {\n  constructor(public onSubscribe: (observer: Observer<TValue, TError>) => TeardownLogic) {}\n\n  subscribe(observer?: Partial<Observer<TValue, TError>>): Unsubscribable {\n    let teardownRef: TeardownLogic | null = null\n    let isDone = false\n    let unsubscribed = false\n    let teardownImmediately = false\n\n    const unsubscribe = () => {\n      if (unsubscribed) return\n\n      if (teardownRef === null) {\n        teardownImmediately = true\n        return\n      }\n\n      unsubscribed = true\n\n      if (typeof teardownRef === 'function') {\n        teardownRef()\n      } else if (teardownRef) {\n        teardownRef.unsubscribe()\n      }\n    }\n\n    teardownRef = this.onSubscribe({\n      next: (value) => {\n        if (isDone) return\n        observer?.next?.(value)\n      },\n      error: (err) => {\n        if (isDone) return\n        isDone = true\n        observer?.error?.(err)\n        unsubscribe()\n      },\n      complete: () => {\n        if (isDone) return\n        isDone = true\n        observer?.complete?.()\n        unsubscribe()\n      },\n    })\n\n    if (teardownImmediately) {\n      unsubscribe()\n    }\n\n    return {\n      unsubscribe,\n    }\n  }\n}\n\nexport class Observable<TValue = any, TError = any> extends Subscribable<TValue, TError> {\n  constructor(onSubscribe: (observer: Observer<TValue, TError>) => TeardownLogic) {\n    super(onSubscribe)\n  }\n\n  pipe(): Observable<TValue, TError>\n\n  pipe<TValue1, TError1>(\n    op1: OperatorFunction<TValue, TError, TValue1, TError1>,\n  ): Observable<TValue1, TError1>\n\n  pipe<TValue1, TError1, TValue2, TError2>(\n    op1: OperatorFunction<TValue, TError, TValue1, TError1>,\n    op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,\n  ): Observable<TValue2, TError2>\n\n  pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(\n    op1: OperatorFunction<TValue, TError, TValue1, TError1>,\n    op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,\n    op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,\n  ): Observable<TValue3, TError3>\n\n  pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(\n    op1: OperatorFunction<TValue, TError, TValue1, TError1>,\n    op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,\n    op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,\n    op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,\n  ): Observable<TValue4, TError4>\n\n  pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(\n    op1: OperatorFunction<TValue, TError, TValue1, TError1>,\n    op2: OperatorFunction<TValue1, TError1, TValue2, TError2>,\n    op3: OperatorFunction<TValue2, TError2, TValue3, TError3>,\n    op4: OperatorFunction<TValue3, TError3, TValue4, TError4>,\n    op5: OperatorFunction<TValue4, TError4, TValue5, TError5>,\n  ): Observable<TValue5, TError5>\n\n  pipe(...operations: OperatorFunction[]): Observable {\n    return operations.reduce(pipeReducer, this)\n  }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport type { EdenFetchError } from '../../errors'\nimport type { EdenRequestParams } from '../../resolve'\nimport type { Observable, Observer } from './observable'\n\nexport type OperationType = 'query' | 'mutation' | 'subscription'\n\nexport interface OperationContext extends Record<string, unknown> {}\n\nexport type Operation<T extends AnyElysia = any> = {\n  id: number\n  type: OperationType\n  params: EdenRequestParams<T>\n  context: OperationContext\n}\n\nexport type OperationLink<\n  TElysia extends AnyElysia = AnyElysia,\n  TInput = unknown,\n  TOutput = unknown,\n> = (\n  options: OperationLinkOptions<TElysia, TInput, TOutput>,\n) => OperationResultObservable<TElysia, TOutput>\n\nexport type OperationLinkOptions<\n  TElysia extends AnyElysia = AnyElysia,\n  _TInput = unknown,\n  TOutput = unknown,\n> = {\n  operation: Operation<TElysia>\n  next: (operation: Operation<TElysia>) => OperationResultObservable<TElysia, TOutput>\n}\n\nexport type OperationResultObservable<TElysia extends AnyElysia, TOutput> = Observable<\n  OperationResultEnvelope<TOutput>,\n  EdenClientError<TElysia>\n>\n\nexport type OperationResultObserver<TRoute extends AnyElysia, TOutput> = Observer<\n  OperationResultEnvelope<TOutput>,\n  EdenClientError<TRoute>\n>\n\nexport type OperationResultEnvelope<T = any> = (EdenResultMessage<T> | EdenSuccessResponse<T>) & {\n  context?: OperationContext\n}\n\nexport type EdenResultMessage<T> =\n  | { type: 'started'; data?: never }\n  | { type: 'stopped'; data?: never }\n  | { data: T; type: 'data' }\n\nexport type EdenSuccessResponse<T> = { data: T; type?: 'data' }\n\nexport type EdenLink<T extends AnyElysia = any, TMeta = {}> = ((\n  opts: EdenClientRuntime,\n) => OperationLink<T>) &\n  TMeta\n\nexport type EdenClientRuntime = {}\n\nexport type EdenClientOptions<T extends AnyElysia> = {\n  links: EdenLink<T>[]\n}\n\n/**\n * Type representing errors that can occur during Eden client operations.\n * This is the union of all possible error types from the Elysia route schema.\n *\n * @template _T - The Elysia app type (reserved for future use with route-specific error types)\n */\nexport type EdenClientError<_T extends AnyElysia = AnyElysia> = EdenFetchError<number, unknown> | Error\n\nexport class OperationError extends Error {\n  constructor(message?: string) {\n    super(message)\n  }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport { Observable } from './observable'\nimport {\n  type Operation,\n  OperationError,\n  type OperationLink,\n  type OperationResultObservable,\n} from './operation'\n\nexport type ChainOptions<TElysia extends AnyElysia, TInput = unknown, TOutput = unknown> = {\n  links: OperationLink<TElysia, TInput, TOutput>[]\n  operation: Operation<TElysia>\n}\n\nexport function createChain<TElysia extends AnyElysia, TInput = unknown, TOutput = unknown>(\n  options: ChainOptions<TElysia, TInput, TOutput>,\n): OperationResultObservable<TElysia, TOutput> {\n  const observable = new Observable((observer) => {\n    const execute = (index = 0, operation = options.operation) => {\n      const next = options.links[index]\n\n      if (next == null) {\n        throw new OperationError('No more links to execute - did you forget to add an ending link?')\n      }\n\n      const subscription = next({\n        operation,\n        next: (nextOp) => {\n          const nextObserver = execute(index + 1, nextOp)\n          return nextObserver\n        },\n      })\n\n      return subscription\n    }\n\n    const rootObservable = execute()\n\n    const $rootObservable = rootObservable.subscribe(observer)\n\n    return $rootObservable\n  })\n\n  return observable\n}\n","import type {\n  MonoTypeOperatorFunction,\n  Observer,\n  OperatorFunction,\n  Unsubscribable,\n} from './observable'\nimport { Observable } from './observable'\n\nexport function map<TValueBefore, TError, TValueAfter>(\n  project: (value: TValueBefore, index: number) => TValueAfter,\n): OperatorFunction<TValueBefore, TError, TValueAfter, TError> {\n  return (source) => {\n    const observable = new Observable((subscriber) => {\n      let index = 0\n\n      const subscription = source.subscribe({\n        next: (value) => {\n          subscriber.next(project(value, index++))\n        },\n        error: (error) => {\n          subscriber.error(error)\n        },\n        complete: () => {\n          subscriber.complete()\n        },\n      })\n      return subscription\n    })\n    return observable\n  }\n}\n\ninterface ShareOptions {}\n\nexport function share<TValue, TError>(\n  _options?: ShareOptions,\n): MonoTypeOperatorFunction<TValue, TError> {\n  return (source) => {\n    let refCount = 0\n\n    let subscription: Unsubscribable | null = null\n\n    const observers: Partial<Observer<TValue, TError>>[] = []\n\n    const startIfNeeded = () => {\n      if (subscription != null) return\n\n      // Make shallow copy of observers in case they unsubscribe during the loop.\n\n      subscription = source.subscribe({\n        next: (value) => {\n          for (const observer of [...observers]) {\n            observer.next?.(value)\n          }\n        },\n        error: (error) => {\n          for (const observer of [...observers]) {\n            observer.error?.(error)\n          }\n        },\n        complete: () => {\n          for (const observer of [...observers]) {\n            observer.complete?.()\n          }\n        },\n      })\n    }\n\n    const resetIfNeeded = () => {\n      if (refCount === 0 && subscription != null) {\n        const _sub = subscription\n        subscription = null\n        _sub.unsubscribe()\n      }\n    }\n\n    return new Observable((observer) => {\n      refCount++\n\n      observers.push(observer)\n\n      startIfNeeded()\n\n      return {\n        unsubscribe: () => {\n          refCount--\n\n          resetIfNeeded()\n\n          const index = observers.findIndex((observer) => observer === observer)\n\n          if (index >= 0) {\n            observers.splice(index, 1)\n          }\n        },\n      }\n    })\n  }\n}\n\nexport function tap<TValue, TError>(\n  observer: Partial<Observer<TValue, TError>>,\n): MonoTypeOperatorFunction<TValue, TError> {\n  return (source) => {\n    return new Observable((subscriber) => {\n      const subscription = source.subscribe({\n        next: (value) => {\n          observer.next?.(value)\n          subscriber.next(value)\n        },\n        error: (error) => {\n          observer.error?.(error)\n          subscriber.error(error)\n        },\n        complete: () => {\n          observer.complete?.()\n          subscriber.complete()\n        },\n      })\n      return subscription\n    })\n  }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport { createChain } from './links/internal/create-chain'\nimport { promisifyObservable, type Unsubscribable } from './links/internal/observable'\nimport type {\n  EdenClientError,\n  EdenClientOptions,\n  EdenClientRuntime,\n  OperationContext,\n  OperationLink,\n  OperationType,\n} from './links/internal/operation'\nimport { share } from './links/internal/operators'\nimport type { EdenResponse } from './request'\nimport type { EdenRequestParams } from './resolve'\n\nexport type EdenSubscriptionObserver<TValue, TError> = {\n  onStarted: () => void\n  onData: (value: TValue) => void\n  onError: (err: TError) => void\n  onStopped: () => void\n  onComplete: () => void\n}\n\nexport type EdenCreateClient<T extends AnyElysia = AnyElysia> = (\n  options: EdenClientOptions<T>,\n) => EdenClient<T>\n\nexport type EdenClientInternalRequestOptions<T extends AnyElysia = AnyElysia> = {\n  type: OperationType\n  context?: OperationContext\n  params: EdenRequestParams<T>\n}\n\nexport type EdenClientPromisifyRequestOptions<T extends AnyElysia = AnyElysia> = EdenClientInternalRequestOptions<T> & {\n  signal?: AbortSignal\n}\n\nexport type EdenClientRequestOptions = {\n  context?: OperationContext\n  signal?: AbortSignal\n}\n\nexport class EdenClient<TElysia extends AnyElysia = AnyElysia> {\n  private readonly links: OperationLink<TElysia>[]\n\n  public readonly runtime: EdenClientRuntime\n\n  private requestId: number\n\n  constructor(options: EdenClientOptions<TElysia>) {\n    this.requestId = 0\n\n    this.runtime = {}\n\n    this.links = options.links.map((link) => link(this.runtime))\n  }\n\n  private $request<TInput = unknown, TOutput = unknown>(\n    options: EdenClientInternalRequestOptions<TElysia>,\n  ) {\n    const chain$ = createChain<TElysia, TInput, TOutput>({\n      links: this.links as OperationLink<TElysia, TInput, TOutput>[],\n      operation: {\n        id: ++this.requestId,\n        ...options,\n        context: options.context ?? {},\n      },\n    })\n    return chain$.pipe(share())\n  }\n\n  private promisifyRequest<TInput = unknown, TOutput = unknown>(\n    options: EdenClientPromisifyRequestOptions<TElysia>,\n  ): Promise<TOutput> {\n    // Forward the signal\n    if (options.signal != null) {\n      options.params.fetch ??= {}\n      options.params.fetch.signal = options.signal\n    }\n\n    const signal = options.params.fetch?.signal\n\n    const req$ = this.$request<TInput, TOutput>(options)\n\n    const { promise, abort } = promisifyObservable<TOutput>(req$ as any)\n\n    const abortablePromise = new Promise<TOutput>((resolve, reject) => {\n      signal?.addEventListener('abort', abort)\n      promise.then(resolve).catch(reject)\n    })\n\n    return abortablePromise\n  }\n\n  public query(params: EdenRequestParams<TElysia>, options?: EdenClientRequestOptions) {\n    return this.promisifyRequest<any, EdenResponse>({\n      type: 'query',\n      params,\n      context: options?.context,\n      signal: options?.signal,\n    })\n  }\n\n  public mutation(params: EdenRequestParams<TElysia>, options?: EdenClientRequestOptions) {\n    return this.promisifyRequest({\n      type: 'mutation',\n      params,\n      context: options?.context,\n      signal: options?.signal,\n    })\n  }\n\n  public subscription(\n    params: EdenRequestParams<TElysia>,\n    options?: Partial<EdenSubscriptionObserver<unknown, EdenClientError<TElysia>>> &\n      EdenClientRequestOptions,\n  ): Unsubscribable {\n    const observable = this.$request({\n      type: 'subscription',\n      params,\n      context: options?.context,\n    })\n\n    const $observable = observable.subscribe({\n      next: (envelope) => {\n        if (envelope.type === 'started') {\n          options?.onStarted?.()\n        } else if (envelope.type === 'stopped') {\n          options?.onStopped?.()\n        } else {\n          options?.onData?.(envelope.data)\n        }\n      },\n      error: (err) => {\n        options?.onError?.(err)\n      },\n      complete: () => {\n        options?.onComplete?.()\n      },\n    })\n\n    return $observable\n  }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport type { Range } from './utils/types'\n\nexport class EdenFetchError<Status extends number = number, Value = unknown> extends Error {\n  constructor(\n    public status: Status,\n    public value: Value,\n  ) {\n    super(value + '')\n  }\n}\n\nexport class EdenFatalError extends Error {\n  static throw() {\n    return new EdenFatalError()\n  }\n\n  constructor() {\n    super(\n      'Something went wrong. Please submit an issue at https://github.com/aydee-app/eden-query/issues/new',\n    )\n  }\n}\n\nexport type MapError<T extends Record<number, unknown>> = [\n  {\n    [K in keyof T]-?: K extends ErrorRange ? K : never\n  }[keyof T],\n] extends [infer A extends number]\n  ? {\n      [K in A]: EdenFetchError<K, T[K]>\n    }[A]\n  : false\n\nexport type ErrorRange = Range<300, 599>\n\n/**\n * Type representing any error-like object that can be thrown by Eden client operations.\n * This includes EdenFetchError instances with any status code and value.\n *\n * @template _T - The Elysia app type (reserved for future use with route-specific error types)\n */\nexport type EdenClientErrorLike<_T extends AnyElysia = AnyElysia> = EdenFetchError<number, unknown> | Error\n\nexport const ERROR_SYMBOL = Symbol('TypeError')\n\nexport type TypeError<TMessage extends string> = TMessage & {\n  _: typeof ERROR_SYMBOL\n}\n","import type { Nullish } from './utils/null'\n\nexport interface HeadersInitEsque {\n  [Symbol.iterator](): IterableIterator<[string, string]>\n}\n\nexport type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>\n\nexport type AbortControllerEsque = new () => AbortControllerInstanceEsque\n\n/**\n * Allows you to abort one or more requests.\n */\nexport interface AbortControllerInstanceEsque {\n  /**\n   * The AbortSignal object associated with this object.\n   */\n  readonly signal: AbortSignal\n\n  /**\n   * Sets this object's AbortSignal's aborted flag and signals to\n   * any observers that the associated activity is to be aborted.\n   */\n  abort(): void\n}\n\nexport type HTTPLinkBaseOptions = {\n  /**\n   * Define AbortController implementation.\n   */\n  AbortController?: AbortControllerEsque | null\n\n  /**\n   * Send all requests `as POST`s requests regardless of the procedure type.\n   * The HTTP handler must separately allow overriding the method.\n   *\n   * @see https://trpc.io/docs/rpc\n   */\n  methodOverride?: 'POST'\n}\n\nexport function getAbortController(\n  abortControllerPolyfill?: AbortControllerEsque | Nullish,\n): AbortControllerEsque | null {\n  if (abortControllerPolyfill) {\n    return abortControllerPolyfill\n  }\n\n  if (typeof window !== 'undefined' && window.AbortController) {\n    return window.AbortController\n  }\n\n  if (typeof globalThis !== 'undefined' && globalThis.AbortController) {\n    return globalThis.AbortController\n  }\n\n  return null\n}\n\nexport const httpQueryMethods = ['get', 'options', 'head'] as const\n\nexport const httpMutationMethods = ['post', 'put', 'patch', 'delete'] as const\n\nexport const httpSubscriptionMethods = ['connect', 'subscribe'] as const\n\nexport const httpMethods = [\n  ...httpQueryMethods,\n  ...httpMutationMethods,\n  ...httpSubscriptionMethods,\n] as const\n\n/**\n * Recognized HTTP methods for queries.\n */\nexport type HttpQueryMethod = (typeof httpQueryMethods)[number]\n\n/**\n * Recognized HTTP methods for mutations.\n */\nexport type HttpMutationMethod = (typeof httpMutationMethods)[number]\n\n/**\n * Recognized HTTP methods for subscriptions.\n */\nexport type HttpSubscriptionMethod = (typeof httpSubscriptionMethods)[number]\n\n/**\n * All recognized HTTP methods.\n */\nexport type HttMethod = (typeof httpMethods)[number]\n","export const GET_OR_HEAD_HTTP_METHODS = ['get', 'head', 'subscribe'] as const\n\nexport const HTTP_METHODS = [\n  ...GET_OR_HEAD_HTTP_METHODS,\n  'post',\n  'put',\n  'delete',\n  'patch',\n  'options',\n  'connect',\n] as const\n\nexport const LOOPBACK_ADDRESSES = ['localhost', '127.0.0.1', '0.0.0.0']\n\nexport const IS_SERVER = typeof FileList === 'undefined'\n\nexport const CLIENT_WARNING =\n  'Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead.'\n\nexport const DEMO_DOMAIN = 'http://e.ly'\n\nexport const ISO8601_REGEX =\n  /(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))/\n\nexport const FORMAL_DATE_REGEX =\n  /(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s\\d{2}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\sGMT(?:\\+|-)\\d{4}\\s\\([^)]+\\)/\n\nexport const SHORTENED_DATE_REGEX =\n  /^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\\s-](?:0?[1-9]|1[0-2])[/\\s-](?:19|20)\\d{2})|(?:(?:19|20)\\d{2}[/\\s-](?:0?[1-9]|1[0-2])[/\\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\\s[AP]M)?)?$/\n\nexport const BATCH_ENDPOINT = '/batch'\n","/**\n * @see https://github.com/trpc/trpc/blob/next/packages/server/src/unstable-core-do-not-import/transformer.ts\n */\n\n/**\n * Data-transformers share the same interface, but have different semantics depending\n * on where they are executed during a request.\n */\nexport type DataTransformer = {\n  /**\n   * Convert a raw value from the program into a JSON-serializable value.\n   *\n   * The raw JSON value needs to be a valid input into {@link JSON.stringify}.\n   */\n  serialize: (object: any) => any\n\n  /**\n   * Take a raw JSON value and convert it into the desired value to be used in the program.\n   *\n   * The raw JSON value can be anything returned from {@link JSON.parse}.\n   */\n  deserialize: (object: any) => any\n}\n\ninterface InputDataTransformer extends DataTransformer {\n  /**\n   * This function runs **on the client** before sending the data to the server.\n   *\n   * This should return a JSON-serializable value, e.g. a string.\n   */\n  serialize: (object: any) => any\n\n  /**\n   * This function runs **on the server** to transform the data before it is passed to the resolver\n   */\n  deserialize: (object: any) => any\n}\n\ninterface OutputDataTransformer extends DataTransformer {\n  /**\n   * This function runs **on the server** before sending the data to the client.\n   *\n   * This should return a JSON-serializable value, e.g. a string.\n   */\n  serialize: (object: any) => any\n\n  /**\n   * This function runs **only on the client** to transform the data sent from the server.\n   */\n  deserialize: (object: any) => any\n}\n\nexport interface CombinedDataTransformer {\n  /**\n   * Specify how the data sent from the client to the server should be transformed.\n   */\n  input: InputDataTransformer\n  /**\n   * Specify how the data sent from the server to the client should be transformed.\n   */\n  output: OutputDataTransformer\n}\n\nexport type DataTransformerOptions = CombinedDataTransformer | DataTransformer\n\nconst defaultTransformer: DataTransformer = {\n  serialize: (value) => value,\n  deserialize: (value) => value,\n}\n\nconst defaultDataTransformer: CombinedDataTransformer = {\n  input: defaultTransformer,\n  output: defaultTransformer,\n}\n\nexport function getDataTransformer(transformer?: DataTransformerOptions): CombinedDataTransformer {\n  if (transformer == null) {\n    return defaultDataTransformer\n  }\n\n  if ('serialize' in transformer) {\n    return { input: transformer, output: transformer }\n  }\n\n  return transformer\n}\n","import { IS_SERVER } from '../constants'\n\nexport function isFile(v: any) {\n  if (IS_SERVER) return v instanceof Blob\n\n  return v instanceof FileList || v instanceof File\n}\n\nexport function hasFile(object?: Record<string, any>): boolean {\n  if (!object) {\n    return false\n  }\n\n  for (const key in object) {\n    if (isFile(object[key])) return true\n\n    if (Array.isArray(object[key]) && (object[key] as unknown[]).find(isFile)) return true\n  }\n\n  return false\n}\n","import { GET_OR_HEAD_HTTP_METHODS, HTTP_METHODS } from '../constants'\n\nexport function isHttpMethod(value: unknown): boolean {\n  return HTTP_METHODS.includes(value as any)\n}\n\nexport function isGetOrHeadMethod(value: unknown): boolean {\n  return GET_OR_HEAD_HTTP_METHODS.includes(value as any)\n}\n","import { FORMAL_DATE_REGEX, ISO8601_REGEX, SHORTENED_DATE_REGEX } from '../constants'\n\nfunction isNumericString(message: string) {\n  return message.trim().length !== 0 && !Number.isNaN(Number(message))\n}\n\nfunction isStringifiedObject(value: string): boolean {\n  const start = value.charCodeAt(0)\n  const end = value.charCodeAt(value.length - 1)\n\n  return (start === 123 && end === 125) || (start === 91 && end === 93)\n}\n\nexport function parseStringifiedDate(value: unknown): Date | null {\n  if (typeof value !== 'string') {\n    return null\n  }\n\n  // Remove quote from stringified date\n  const temp = value.replace(/\"/g, '')\n\n  if (ISO8601_REGEX.test(temp) || FORMAL_DATE_REGEX.test(temp) || SHORTENED_DATE_REGEX.test(temp)) {\n    const date = new Date(temp)\n\n    if (!Number.isNaN(date.getTime())) {\n      return date\n    }\n  }\n\n  return null\n}\n\nexport function parseStringifiedObject(data: string) {\n  return JSON.parse(data, (_, value) => {\n    const date = parseStringifiedDate(value)\n\n    if (date) {\n      return date\n    }\n\n    return value\n  })\n}\n\nexport function parseStringifiedValue(value: string) {\n  if (!value) {\n    return value\n  }\n\n  if (isNumericString(value)) {\n    return +value\n  }\n\n  if (value === 'true') {\n    return true\n  }\n\n  if (value === 'false') {\n    return false\n  }\n\n  const date = parseStringifiedDate(value)\n\n  if (date) {\n    return date\n  }\n\n  if (isStringifiedObject(value)) {\n    try {\n      return parseStringifiedObject(value)\n    } catch {\n      // noop\n    }\n  }\n\n  return value\n}\n\nexport function parseMessageEvent(event: MessageEvent) {\n  const messageString = event.data.toString()\n\n  return messageString === 'null' ? null : parseStringifiedValue(messageString)\n}\n","/**\n * Eden WS implementation.\n *\n * @see https://github.com/elysiajs/eden/blob/7b982cf6469d809cd561dd0ad59e83178ad56489/src/treaty2/ws.ts#L5\n */\nimport type { InputSchema, MaybeArray } from 'elysia'\n\nimport {\n  type CombinedDataTransformer,\n  type DataTransformerOptions,\n  getDataTransformer,\n} from './links'\nimport { parseMessageEvent } from './utils/parse'\n\n/**\n * Configuration for EdenWS.\n */\nexport type EdenWsOptions = {\n  /**\n   * Custom transformer for messages.\n   */\n  transformer?: DataTransformerOptions\n}\n\n/**\n * Strongly-typed websocket event.\n *\n * Messages will be formatted, all other events will not be transformed.\n */\nexport type WSEvent<K extends keyof WebSocketEventMap, Data = unknown> = K extends 'message'\n  ? OnMessage<Data>\n  : WebSocketEventMap[K]\n\n/**\n * Attempt to parse the message, in addition to providing the original raw value (string).\n */\nexport interface OnMessage<Data = unknown> extends MessageEvent {\n  data: Data\n  rawData: MessageEvent['data']\n}\n\n/**\n * Custom implementation of the EdenWS class.\n *\n * Some properties are auto-bound methods so you can pass them as callbacks without \"this is undefined\" errors.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#cannot_be_used_as_methods\n *\n * @example\n * ```ts\n * import { EdenWs } from '@aydee-app/eden'\n *\n * const edenWs = new EdenWS()\n *\n * ['a', 'b', 'c'].forEach(edenWs.send)\n * ```\n */\nexport class EdenWS<T extends InputSchema<any> = {}> {\n  ws: WebSocket\n\n  transformer?: CombinedDataTransformer\n\n  constructor(\n    public url: string,\n    public options?: EdenWsOptions,\n  ) {\n    this.ws = new WebSocket(url)\n    this.transformer = options?.transformer ? getDataTransformer(options?.transformer) : undefined\n  }\n\n  /**\n   * Close the websocket connection.\n   */\n  close() {\n    this.ws.close()\n    return this\n  }\n\n  /**\n   * Send (strongly-typed) message(s) over the websocket connection.\n   */\n  send = async (data: MaybeArray<T['body']>) => {\n    if (Array.isArray(data)) {\n      await this.sendMany(data)\n    } else {\n      await this.sendSingle(data)\n    }\n    return this\n  }\n\n  /**\n   * Send a single (strongly-typed) message.\n   */\n  sendMany = async (data: T['body'][]) => {\n    await Promise.allSettled(data.map(this.sendSingle))\n    return this\n  }\n\n  /**\n   * Send a single (strongly-typed) message.\n   */\n  sendSingle = async (data: T['body']) => {\n    const message = await this.transformSent(data)\n    this.ws.send(message)\n    return this\n  }\n\n  /**\n   * Register a callback function that is called when a message is received.\n   */\n  subscribe(\n    onMessage: (event: WSEvent<'message', T['response']>) => void,\n    options?: boolean | AddEventListenerOptions,\n  ) {\n    return this.on('message', onMessage, options)\n  }\n\n  /**\n   * Register a strongly typed callback function to be called on the specified websocket event.\n   *\n   * Alias for {@link addEventListener}.\n   */\n  on<K extends keyof WebSocketEventMap>(\n    type: K,\n    listener: (event: WSEvent<K, T['response']>) => void,\n    options?: boolean | AddEventListenerOptions,\n  ) {\n    return this.addEventListener(type, listener, options)\n  }\n\n  /**\n   * Remove a registered event-listener.\n   *\n   * Alias for {@link removeEventListener}.\n   */\n  off<K extends keyof WebSocketEventMap>(\n    type: K,\n    listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,\n    options?: boolean | EventListenerOptions,\n  ) {\n    this.removeEventListener(type, listener, options)\n    return this\n  }\n\n  /**\n   * Register a strongly typed callback function to be called on the specified websocket event.\n   */\n  addEventListener<K extends keyof WebSocketEventMap>(\n    type: K,\n    listener: (event: WSEvent<K, T['response']>) => void,\n    options?: boolean | AddEventListenerOptions,\n  ) {\n    const resolvedEventListener = async (ws: WebSocketEventMap[K]) => {\n      let event: any = ws\n\n      if (type === 'message') {\n        const data = (await this.transformReceived(event)) ?? parseMessageEvent(event)\n        event = { ...ws, data }\n      }\n\n      listener(event)\n    }\n\n    this.ws.addEventListener(type, resolvedEventListener, options)\n    return this\n  }\n\n  /**\n   * Remove a registered event-listener.\n   */\n  removeEventListener<K extends keyof WebSocketEventMap>(\n    type: K,\n    listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,\n    options?: boolean | EventListenerOptions,\n  ) {\n    this.ws.removeEventListener(type, listener, options)\n    return this\n  }\n\n  /**\n   * Transform outgoing messages sent from the client to the server.\n   *\n   * @internal\n   */\n  transformSent = async (data: T['body']) => {\n    const serialize = this.transformer?.input.serialize\n\n    let transformed: any\n\n    try {\n      transformed = await serialize?.(data)\n    } catch (_err) {\n      // noop\n    }\n\n    if (transformed == null) {\n      transformed ??= typeof data === 'object' ? JSON.stringify(data) : data.toString()\n    }\n\n    return transformed\n  }\n\n  /**\n   * Transform incoming messages received from the server.\n   *\n   * @internal\n   */\n  transformReceived = async (event: MessageEvent) => {\n    const deserialize = this.transformer?.output.deserialize\n\n    if (deserialize == null) return\n\n    try {\n      let messageString = event.data\n\n      if (typeof messageString !== 'string') {\n        messageString = event.data.toString()\n      }\n\n      const transformed = await deserialize(messageString)\n      return transformed\n    } catch (_err) {\n      return\n    }\n  }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport type { EdenConfig } from './config'\nimport { DEMO_DOMAIN, IS_SERVER, LOOPBACK_ADDRESSES } from './constants'\nimport { EdenFetchError } from './errors'\nimport type { InferRouteBody, InferRouteOptions } from './infer'\nimport { getDataTransformer } from './links/internal/transformer'\nimport type { EdenRequestOptions, EdenResponse } from './request'\nimport { hasFile } from './utils/file'\nimport { isGetOrHeadMethod } from './utils/http'\nimport { parseStringifiedValue } from './utils/parse'\nimport { EdenWS } from './ws'\n\nfunction createNewFile(v: File) {\n  if (IS_SERVER) {\n    return v\n  }\n\n  return new Promise<File>((resolve) => {\n    const reader = new FileReader()\n\n    reader.onload = () => {\n      const filebits = reader.result != null ? [reader.result] : []\n      const name = v.name\n      const lastModified = v.lastModified\n      const type = v.type\n\n      const file = new File(filebits, name, { lastModified, type })\n\n      resolve(file)\n    }\n\n    reader.readAsArrayBuffer(v)\n  })\n}\n\nasync function processHeaders(\n  configHeaders: EdenConfig['headers'],\n  path: string,\n  options: RequestInit = {},\n  headers: Record<string, string> = {},\n): Promise<Record<string, string>> {\n  if (Array.isArray(configHeaders)) {\n    for (const value of configHeaders)\n      if (!Array.isArray(value)) {\n        headers = await processHeaders(value, path, options, headers)\n      } else {\n        const key = value[0]\n        if (typeof key === 'string') {\n          headers[key.toLowerCase()] = value[1] as string\n        } else {\n          for (const [k, value] of key) {\n            if (k) {\n              headers[k.toLowerCase()] = value as string\n            }\n          }\n        }\n      }\n\n    return headers\n  }\n\n  if (!configHeaders) {\n    return headers\n  }\n\n  switch (typeof configHeaders) {\n    case 'function': {\n      if (configHeaders instanceof Headers) {\n        return processHeaders(configHeaders, path, options, headers)\n      }\n\n      const customHeaders = await configHeaders(path, options)\n\n      if (customHeaders) {\n        return processHeaders(customHeaders, path, options, headers)\n      }\n\n      return headers\n    }\n\n    case 'object': {\n      if (configHeaders instanceof Headers) {\n        configHeaders.forEach((value, key) => {\n          headers[key.toLowerCase()] = value\n        })\n\n        return headers\n      }\n\n      for (const [key, value] of Object.entries(configHeaders)) {\n        headers[key.toLowerCase()] = value\n      }\n\n      return headers\n    }\n\n    default: {\n      return headers\n    }\n  }\n}\n\nexport async function* streamResponse(response: Response) {\n  const body = response.body\n\n  if (!body) return\n\n  const reader = body.getReader()\n  const decoder = new TextDecoder()\n\n  try {\n    while (true) {\n      const { done, value } = await reader.read()\n\n      if (done) break\n\n      const data = decoder.decode(value)\n\n      yield parseStringifiedValue(data)\n    }\n  } finally {\n    reader.releaseLock()\n  }\n}\n\nfunction buildQueryString(query?: any) {\n  let q = ''\n\n  if (!query) {\n    return q\n  }\n\n  for (const [key, value] of Object.entries(query)) {\n    if (Array.isArray(value)) {\n      for (const v of value) {\n        q += (q ? '&' : '?') + `${encodeURIComponent(key)}=${encodeURIComponent(v)}`\n      }\n    } else if (typeof value === 'object') {\n      const stringifiedValue = JSON.stringify(value)\n      q += (q ? '&' : '?') + `${encodeURIComponent(key)}=${encodeURIComponent(stringifiedValue)}`\n    } else if (value != null) {\n      q += (q ? '&' : '?') + `${encodeURIComponent(key)}=${encodeURIComponent(`${value}`)}`\n    }\n  }\n\n  return q\n}\n\nexport async function parseResponse<T extends AnyElysia = AnyElysia, TRaw extends boolean = false>(\n  response: Response,\n  params?: EdenRequestParams<T, TRaw>,\n) {\n  if (params?.onResponse != null) {\n    const onResponse = Array.isArray(params.onResponse) ? params.onResponse : [params.onResponse]\n\n    for (const value of onResponse) {\n      try {\n        const data = await value(response.clone())\n        if (data != null) {\n          return { data, error: null, status: response.status }\n        }\n      } catch (err) {\n        const error = err instanceof EdenFetchError ? err : new EdenFetchError(422, err)\n        return { data: null, error, status: response.status }\n      }\n    }\n  }\n\n  let data: any\n\n  switch (response.headers.get('Content-Type')?.split(';')[0]) {\n    case 'text/event-stream': {\n      data = streamResponse(response)\n      break\n    }\n\n    case 'application/json': {\n      data = await response.json()\n\n      const transformer = getDataTransformer(params?.transformer)\n\n      const deserialize = transformer?.output.deserialize\n\n      if (deserialize != null) {\n        data = deserialize(data)\n      }\n\n      break\n    }\n\n    case 'application/octet-stream': {\n      data = await response.arrayBuffer()\n      break\n    }\n\n    case 'multipart/form-data': {\n      const temp = await response.formData()\n\n      data = {}\n\n      temp.forEach((value, key) => {\n        data[key] = value\n      })\n\n      break\n    }\n\n    default: {\n      data = await response.text().then(parseStringifiedValue)\n    }\n  }\n\n  if (response.status >= 300 || response.status < 200) {\n    const error = new EdenFetchError(response.status, data)\n    return {\n      data: null,\n      error,\n      status: response.status,\n      statusText: response.statusText,\n    }\n  } else {\n    return {\n      data,\n      error: null,\n      status: response.status,\n      statusText: response.statusText,\n    }\n  }\n}\n\n/**\n * Parameters that control how an Eden request is resolved.\n */\nexport type EdenRequestParams<\n  T extends AnyElysia = AnyElysia,\n  TRaw extends boolean = false,\n> = EdenRequestOptions<T, TRaw> & {\n  /**\n   */\n  domain?: T | string\n\n  /**\n   * Fetch options for a \"query\" method, i.e. \"GET\", \"HEAD\", \"OPTIONS\".\n   */\n  options?: InferRouteOptions\n\n  /**\n   * The request body for \"POST\", \"PATCH\", etc. requests.\n   */\n  body?: InferRouteBody\n\n  /**\n   */\n  path?: string\n\n  /**\n   */\n  method?: string\n}\n\nexport async function resolveEdenRequest<\n  T extends AnyElysia = AnyElysia,\n  TRaw extends boolean = false,\n>(params: EdenRequestParams<T, TRaw>): Promise<EdenResponse<TRaw> | EdenWS> {\n  let path = params.path ?? ''\n\n  if (params.options?.params != null) {\n    Object.entries(params.options.params).forEach(([key, value]) => {\n      if (value != null) {\n        path = path.replace(`:${key}`, String(value))\n      }\n    })\n  }\n\n  const isGetOrHead = isGetOrHeadMethod(params.method)\n\n  const headers = await processHeaders(params.headers, path, params.options?.headers)\n\n  const q = buildQueryString(params.options?.query)\n\n  if (params.method === 'subscribe') {\n    const domain = typeof params.domain === 'string' ? params.domain : DEMO_DOMAIN\n\n    const protocol = domain.startsWith('https://')\n      ? 'wss://'\n      : domain.startsWith('http://')\n        ? 'ws://'\n        : LOOPBACK_ADDRESSES.find((address) => domain.includes(address))\n          ? 'ws://'\n          : 'wss://'\n\n    const origin = domain.replace(/^([^]+):\\/\\//, protocol)\n\n    const url = origin + path + q\n\n    return new EdenWS(url)\n  }\n\n  let fetchInit = {\n    method: params.method?.toUpperCase(),\n    body: params.body as any,\n    ...params.fetch,\n    headers,\n  } satisfies BunFetchRequestInit\n\n  fetchInit.headers = {\n    ...headers,\n    ...(await processHeaders(params.options?.headers, path, fetchInit)),\n  }\n\n  if (isGetOrHead) {\n    delete fetchInit.body\n  }\n\n  if (params.onRequest) {\n    const onRequest = Array.isArray(params.onRequest) ? params.onRequest : [params.onRequest]\n\n    for (const value of onRequest) {\n      const temp = await value(path, fetchInit)\n\n      if (typeof temp === 'object')\n        fetchInit = {\n          ...fetchInit,\n          ...temp,\n          headers: {\n            ...fetchInit.headers,\n            ...(await processHeaders(temp?.headers, path, fetchInit)),\n          },\n        }\n    }\n  }\n\n  // ? Duplicate because end-user might add a body in onRequest\n  if (isGetOrHead) {\n    delete fetchInit.body\n  }\n\n  // Don't handle raw FormData if given.\n  if (FormData != null && params.body instanceof FormData) {\n    // noop\n  } else if (hasFile(params.body as any)) {\n    const formData = new FormData()\n\n    // FormData is 1 level deep\n    for (const [key, field] of Object.entries(fetchInit.body)) {\n      if (IS_SERVER) {\n        formData.append(key, field as any)\n\n        continue\n      }\n\n      if (field instanceof File) {\n        formData.append(key, await createNewFile(field as any))\n\n        continue\n      }\n\n      if (field instanceof FileList) {\n        for (let i = 0; i < field.length; i++)\n          formData.append(key as any, await createNewFile((field as any)[i]))\n\n        continue\n      }\n\n      if (Array.isArray(field)) {\n        for (let i = 0; i < field.length; i++) {\n          const value = (field as any)[i]\n\n          formData.append(key as any, value instanceof File ? await createNewFile(value) : value)\n        }\n\n        continue\n      }\n\n      formData.append(key, field as string)\n    }\n\n    // We don't do this because we need to let the browser set the content type with the correct boundary\n    // fetchInit.headers['content-type'] = 'multipart/form-data'\n    fetchInit.body = formData\n  } else if (typeof params.body === 'object') {\n    fetchInit.headers['content-type'] = 'application/json'\n\n    const transformer = getDataTransformer(params.transformer)\n\n    const body = transformer ? transformer.input.serialize(params.body) : params.body\n\n    fetchInit.body = JSON.stringify(body)\n  } else if (params.body !== null) {\n    fetchInit.headers['content-type'] = 'text/plain'\n  }\n\n  if (isGetOrHead) {\n    delete fetchInit.body\n  }\n\n  if (params.onRequest) {\n    const onRequest = Array.isArray(params.onRequest) ? params.onRequest : [params.onRequest]\n\n    for (const value of onRequest) {\n      const temp = await value(path, fetchInit)\n\n      if (typeof temp === 'object')\n        fetchInit = {\n          ...fetchInit,\n          ...temp,\n          headers: {\n            ...fetchInit.headers,\n            ...(await processHeaders(temp?.headers, path, fetchInit)),\n          } as Record<string, string>,\n        }\n    }\n  }\n\n  const domain = typeof params.domain === 'string' ? params.domain : ''\n\n  const url = domain + path + q\n\n  const elysia = typeof params.domain === 'string' ? undefined : params.domain\n\n  const fetcher = params.fetcher ?? globalThis.fetch\n\n  const response = await (elysia?.handle(new Request(url, fetchInit)) ?? fetcher(url, fetchInit))\n\n  const edenResponse = await parseResponse(response, params)\n\n  if (edenResponse.data !== null) {\n    return {\n      ...edenResponse,\n      ...(params.raw && { response, headers: response.headers, statusText: response.statusText }),\n    } as EdenResponse\n  }\n\n  if (response.status >= 300 || response.status < 200) {\n    edenResponse.error = new EdenFetchError(response.status, edenResponse.data)\n    edenResponse.data = null\n  }\n\n  return {\n    ...edenResponse,\n    ...(params.raw && { response, headers: response.headers, statusText: response.statusText }),\n  } as EdenResponse\n}\n","export type Nullish = null | undefined | void\n\nexport function notNull<T>(value: T): value is NonNullable<T> {\n  return value != null\n}\n","import type { EdenConfig as EdenRequestOptions } from '../../config'\nimport type { HTTPLinkBaseOptions } from '../../http'\nimport type { EdenResponse } from '../../request'\nimport { type EdenRequestParams, resolveEdenRequest } from '../../resolve'\nimport type { Noop } from '../../utils/noop'\nimport type { Operation } from './operation'\n\nexport type Requester = (options: RequesterOptions) => PromiseAndCancel<EdenResponse>\n\nexport type RequesterOptions = Operation & HTTPLinkBaseOptions & EdenRequestOptions\n\nexport type PromiseAndCancel<T> = {\n  promise: Promise<T>\n  cancel: Noop\n}\n\n/**\n * Default eden HTTP requester normalizes operation options to params.\n */\nexport const universalRequester: Requester = (options) => {\n  const {\n    id: _id,\n    type: _type,\n    AbortController,\n    methodOverride,\n    params,\n    ...defaultParams\n  } = options\n\n  const abortController = AbortController ? new AbortController() : null\n\n  let done = false\n\n  const cancel = () => {\n    if (!done) {\n      abortController?.abort()\n    }\n  }\n\n  /**\n   * @TODO\n   *\n   * Deep merge fetch, headers, onRequest, onResponse ?\n   */\n  const resolvedParams: EdenRequestParams = { ...defaultParams, ...params }\n\n  if (options.params.fetch?.signal) {\n    options.params.fetch.signal.addEventListener('abort', cancel)\n    resolvedParams.fetch = { ...resolvedParams.fetch, signal: abortController?.signal }\n  }\n\n  if (methodOverride != null) {\n    resolvedParams.method = methodOverride\n  }\n\n  const promise = new Promise<EdenResponse>((resolve, reject) => {\n    resolveEdenRequest(resolvedParams)\n      .then((response) => {\n        done = true\n        resolve(response as EdenResponse)\n      })\n      .catch((err) => {\n        done = true\n        reject(err)\n      })\n  })\n\n  return { promise, cancel }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport type { EdenQueryStoreKey } from '../constraints'\nimport { getAbortController, type HTTPHeaders, type HTTPLinkBaseOptions } from '../http'\nimport type { EdenRequestOptions } from '../request'\nimport type { NonEmptyArray } from '../utils/types'\nimport { Observable, type Observer } from './internal/observable'\nimport type { EdenLink, Operation, OperationLink } from './internal/operation'\nimport type { DataTransformerOptions } from './internal/transformer'\nimport { type Requester, universalRequester } from './internal/universal-requester'\n\nexport type HTTPLinkFactoryOptions = {\n  requester: Requester\n}\n\nexport type HTTPLinkOptions<\n  T extends AnyElysia = AnyElysia,\n  /**\n   * @todo Maybe check if T['store'][EdenQueryStoreKey] matches a certain interface?\n   */\n  TTransformer = T['store'][typeof EdenQueryStoreKey]['transformer'],\n> = HTTPLinkBaseOptions &\n  Omit<EdenRequestOptions<T>, 'headers' | 'transformer'> & {\n    /**\n     * @todo: Merge this headers type into {@link EdenRequestOptions}\n     */\n    headers?:\n      | HTTPHeaders\n      | ((operations: NonEmptyArray<Operation>) => HTTPHeaders | Promise<HTTPHeaders>)\n  } & (TTransformer extends DataTransformerOptions\n    ? { transformer: TTransformer }\n    : {\n        transformer?: DataTransformerOptions\n      })\n\nexport type HTTPLinkFactory = <T extends AnyElysia>(options?: HTTPLinkOptions<T>) => EdenLink<T>\n\nexport function httpLinkFactory(factoryOptions: HTTPLinkFactoryOptions): HTTPLinkFactory {\n  const factory: HTTPLinkFactory = (linkOptions = {} as any) => {\n    const link: EdenLink = (_runtime) => {\n      const resolveOperation = (operation: Operation, observer: Observer<any, any>) => {\n        const { fetch, domain, AbortController, methodOverride, ...defaultParams } = linkOptions\n\n        const { id, context, type, params } = operation\n\n        const options = {\n          fetch,\n          AbortController: getAbortController(AbortController),\n          methodOverride,\n          id,\n          context,\n          type,\n          params: { ...defaultParams, domain, ...params },\n        }\n\n        const { promise, cancel } = factoryOptions.requester(options)\n\n        promise\n          .then((result) => {\n            observer.next(result)\n            observer.complete()\n          })\n          .catch((cause) => {\n            observer.error(cause)\n          })\n\n        return cancel\n      }\n\n      const operationLink: OperationLink = ({ operation }) => {\n        const observable = new Observable(resolveOperation.bind(undefined, operation))\n        return observable\n      }\n\n      return operationLink\n    }\n\n    return link\n  }\n\n  return factory\n}\n\n/**\n * @see https://trpc.io/docs/v11/client/links/httpLink\n */\nexport const safeHttpLink = httpLinkFactory({ requester: universalRequester })\n\n/**\n * @see https://trpc.io/docs/v11/client/links/httpLink\n */\nexport function httpLink<T extends AnyElysia>(options?: HTTPLinkOptions<T, true>): EdenLink<T> {\n  return safeHttpLink(options as any)\n}\n","import { EdenFatalError } from '../../errors'\nimport type { Noop } from '../../utils/noop'\n\nexport type Batch<TKey, TValue> = {\n  items: BatchItem<TKey, TValue>[]\n  cancel: Noop\n}\n\nexport type BatchItem<TKey, TValue> = {\n  aborted: boolean\n  key: TKey\n  resolve: ((value: TValue) => void) | null\n  reject: ((error: Error) => void) | null\n  batch: Batch<TKey, TValue> | null\n}\n\nexport type BatchLoader<TKey = any, TValue = any> = {\n  /**\n   * Determines whether the current operation fits in the same batch.\n   */\n  validate: (keys: TKey[]) => boolean\n\n  /**\n   * Queues a request.\n   */\n  fetch: BatchFetcher<TKey, TValue>\n}\n\nexport type BatchFetcher<TKey, TValue> = (\n  keys: TKey[],\n  unitResolver: (index: number, value: NonNullable<TValue>) => void,\n) => {\n  promise: Promise<TValue[]>\n  cancel: Noop\n}\n\nexport class BatchError extends Error {\n  constructor(message?: string) {\n    super(message)\n  }\n}\n\n/**\n * {@see https://github.com/graphql/dataloader}\n *\n * Less configuration, no caching, and allows you to cancel requests.\n * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled.\n */\nexport function batchedDataLoader<TKey, TValue>(loader: BatchLoader<TKey, TValue>) {\n  let pendingItems: BatchItem<TKey, TValue>[] = []\n  let dispatchTimer: ReturnType<typeof setTimeout> | null = null\n\n  const destroyTimerAndPendingItems = () => {\n    clearTimeout(dispatchTimer as any)\n    dispatchTimer = null\n    pendingItems = []\n  }\n\n  /**\n   * Iterate through the items and split them into groups based on the `batchLoader`'s validate function\n   */\n  const groupItems = (items: BatchItem<TKey, TValue>[]) => {\n    const groupedItems: BatchItem<TKey, TValue>[][] = [[]]\n\n    let i = 0\n    let item: BatchItem<TKey, TValue> | undefined\n    let lastGroup: BatchItem<TKey, TValue>[] | undefined\n\n    for (; i < items.length && (lastGroup = groupedItems.at(-1)) && (item = items[i]); ++i) {\n      // Item was aborted before it was dispatched.\n      if (item.aborted) {\n        item.reject?.(new BatchError('Aborted'))\n        continue\n      }\n\n      // Create a new group to test whether the resulting group would be valid;\n      // do not mutate the original group reference if it is not.\n      const lastGroupWithNewItem = [...lastGroup, item]\n\n      const keys = lastGroupWithNewItem.map((item) => item.key)\n\n      const isValid = loader.validate(keys)\n\n      // Add consecutive, valid items that have not been aborted to the end of the queue.\n      if (isValid) {\n        lastGroup.push(item)\n        continue\n      }\n\n      // Failed to add any items to an existing group.\n      if (lastGroup.length === 0) {\n        item.reject?.(new BatchError('Invalid item failed to be added to batch.'))\n        continue\n      }\n\n      const newGroup = [item]\n      const newKeys = [item.key]\n\n      const isNewGroupValid = loader.validate(newKeys)\n\n      if (isNewGroupValid) {\n        groupedItems.push(newGroup)\n      } else {\n        item.reject?.(new BatchError('Invalid item failed to be added to batch.'))\n        groupedItems.push([])\n      }\n    }\n\n    return groupedItems\n  }\n\n  const dispatch = () => {\n    const groupedItems = groupItems(pendingItems)\n\n    destroyTimerAndPendingItems()\n\n    // Create batches for each group of items\n    for (const items of groupedItems) {\n      if (items.length === 0) continue\n\n      const batch: Batch<TKey, TValue> = { items, cancel: EdenFatalError.throw }\n\n      for (const item of items) {\n        item.batch = batch\n      }\n\n      const unitResolver = (index: number, value: NonNullable<TValue>) => {\n        const item = batch.items[index]\n\n        if (item == null) return\n\n        item.resolve?.(value)\n        item.batch = null\n        item.reject = null\n        item.resolve = null\n      }\n\n      const { promise, cancel } = loader.fetch(\n        batch.items.map((item) => item.key),\n        unitResolver,\n      )\n\n      batch.cancel = cancel\n\n      promise\n        .then((result) => {\n          for (let i = 0; i < result.length; i++) {\n            const value = result[i]\n            if (value != null) {\n              unitResolver(i, value)\n            }\n          }\n\n          for (const item of batch.items) {\n            item.reject?.(new Error('Missing result'))\n            item.batch = null\n          }\n        })\n        .catch((cause) => {\n          for (const item of batch.items) {\n            item.reject?.(cause)\n            item.batch = null\n          }\n        })\n    }\n  }\n\n  const load = (key: TKey) => {\n    const item: BatchItem<TKey, TValue> = {\n      aborted: false,\n      key,\n      batch: null,\n      resolve: EdenFatalError.throw,\n      reject: EdenFatalError.throw,\n    }\n\n    const promise = new Promise<TValue>((resolve, reject) => {\n      item.reject = reject\n      item.resolve = resolve\n      pendingItems.push(item)\n    })\n\n    dispatchTimer ??= setTimeout(dispatch)\n\n    const cancel = () => {\n      item.aborted = true\n\n      // All items in the batch have been cancelled\n      if (item.batch?.items.every((item) => item.aborted)) {\n        item.batch.cancel()\n        item.batch = null\n      }\n    }\n\n    return { promise, cancel }\n  }\n\n  return { load }\n}\n","import type { AnyElysia } from 'elysia'\n\nimport { BATCH_ENDPOINT } from '../constants'\nimport type { EdenQueryStoreKey } from '../constraints'\nimport type { TypeError } from '../errors'\nimport type { HTTPHeaders } from '../http'\nimport type { BatchPluginOptions } from '../plugins'\nimport { type EdenRequestOptions, type EdenResponse } from '../request'\nimport { type EdenRequestParams, resolveEdenRequest } from '../resolve'\nimport { notNull } from '../utils/null'\nimport type { NonEmptyArray } from '../utils/types'\nimport { httpLinkFactory } from './http-link'\nimport { batchedDataLoader, type BatchLoader } from './internal/batched-data-loader'\nimport type { EdenLink, Operation, OperationType } from './internal/operation'\nimport { type DataTransformerOptions, getDataTransformer } from './internal/transformer'\nimport {\n  type Requester,\n  type RequesterOptions,\n  universalRequester,\n} from './internal/universal-requester'\n\n/**\n * @remarks Do not derive this from HTTPLinkOptions, because it breaks the types for some reason...\n *\n * @template TTransformer\n * @todo Maybe check if T['store'][EdenQueryStoreKey] matches a certain interface?\n */\nexport type HttpBatchLinkOptions<\n  T extends AnyElysia = AnyElysia,\n  TTransformer = T['store'][typeof EdenQueryStoreKey]['transformer'],\n> = Omit<EdenRequestOptions, 'headers' | 'method' | 'transformer'> & {\n  /**\n   * Path for the batch endpoint.\n   *\n   * @example /batch\n   */\n  endpoint?: string\n\n  /**\n   * Configure the maximum URL length if making batch requests with GET.\n   */\n  maxURLLength?: number\n\n  /**\n   * @todo: Merge this headers type into {@link EdenRequestOptions}\n   */\n  headers?:\n    | HTTPHeaders\n    | ((operations: NonEmptyArray<Operation>) => HTTPHeaders | Promise<HTTPHeaders>)\n\n  method?: BatchMethod\n} & (TTransformer extends false\n    ? {\n        transformer?: DataTransformerOptions\n      }\n    : TTransformer extends DataTransformerOptions\n      ? { transformer: TTransformer }\n      : {\n          transformer?: DataTransformerOptions\n        })\n\nexport type BatchMethod = 'GET' | 'POST'\n\n/**\n * If using GET request to batch, the request data will be encoded in query parameters.\n * This is only possible if all requests are GET requests.\n *\n * The query will look like this\n *\n * // GET request to /api/b?name=elysia, i.e. query of name=elysia\n *\n * batch=1&0.path=/api/b&0.method=GET&0.query.name=elysia\n */\nexport function generateGetBatchRequestInformation(operations: Operation[]) {\n  const query: Record<string, any> = {}\n\n  const headers = new Headers()\n\n  operations.forEach((operation, index) => {\n    let operationPath = operation.params.path ?? ''\n\n    // Handle path params.\n    for (const key in operation.params.options?.params) {\n      const placeholder = `:${key}`\n      const param = operation.params.options.params[key as never]\n      if (param != null) {\n        operationPath = operationPath.replace(placeholder, param)\n      }\n    }\n\n    query[`${index}.path`] = operationPath\n\n    if (operation.params.method != null) {\n      query[`${index}.method`] = operation.params.method\n    }\n\n    for (const key in operation.params.options?.query) {\n      const value = operation.params.options.query[key as never]\n      if (value != null) {\n        query[`${index}.query.${key}`] = value\n      }\n    }\n\n    // Handle headers.\n\n    /**\n     * These headers may be set at the root of the client as defaults.\n     */\n    const defaultHeaders =\n      typeof operation.params.headers === 'function'\n        ? operation.params.headers(operationPath, operation.params.fetch)\n        : operation.params.headers\n\n    /**\n     * These headers are set on this specific request.\n     */\n    const requestHeaders = operation.params.options?.headers\n\n    const resolvedHeaders = { ...defaultHeaders, ...requestHeaders }\n\n    for (const key in resolvedHeaders) {\n      const header = resolvedHeaders[key as never]\n      if (header != null) {\n        headers.append(key, header)\n      }\n    }\n  })\n\n  return { body: null, query, headers }\n}\n\n/**\n * If using POST request to batch, most of the request data will be encoded in the FormData body.\n *\n * It will look like this:\n *\n * {\n *   // POST request to /api/a with a JSON body of { value: 0 }\n *\n *   '0.path': '/api/a',\n *   '0.method': 'POST',\n *   '0.body_type': 'JSON',\n *   '0.body': '{ value: 0 }'\n *\n *   // GET request to /api/b?name=elysia, i.e. query of name=elysia\n *\n *   '1.path': '/api/b',\n *   '1.method': 'GET',\n *   '1.query.name': 'elysia'\n * }\n */\nexport function generatePostBatchRequestInformation(\n  operations: Operation[],\n  options?: HttpBatchLinkOptions,\n) {\n  const body = new FormData()\n\n  const headers = new Headers()\n\n  operations.forEach((operation, index) => {\n    let operationPath = operation.params.path ?? ''\n\n    // Specify method of the request.\n    if (operation.params.method != null) {\n      body.append(`${index}.method`, operation.params.method)\n    }\n\n    // Handle path parameters.\n    for (const key in operation.params.options?.params) {\n      const placeholder = `:${key}`\n      const param = operation.params.options.params[key as never]\n      if (param != null) {\n        operationPath = operationPath.replace(placeholder, param)\n      }\n    }\n\n    // Specify the path of the request.\n    body.append(`${index}.path`, operationPath)\n\n    // Handle query parameters.\n    for (const key in operation.params.options?.query) {\n      const value = operation.params.options.query[key as never]\n\n      if (value != null) {\n        body.append(`${index}.query.${key}`, value)\n      }\n    }\n\n    // Handle headers.\n\n    /**\n     * These headers may be set at the root of the client as defaults.\n     */\n    const defaultHeaders =\n      typeof operation.params.headers === 'function'\n        ? operation.params.headers(operationPath, operation.params.fetch)\n        : operation.params.headers\n\n    /**\n     * These headers are set on this specific request.\n     */\n    const requestHeaders = operation.params.options?.headers\n\n    const resolvedHeaders = { ...defaultHeaders, ...requestHeaders }\n\n    for (const key in resolvedHeaders) {\n      const header = resolvedHeaders[key as never]\n      if (header != null) {\n        headers.append(key, header)\n      }\n    }\n\n    // Handle body.\n\n    if (operation.params?.body == null) return\n\n    const rawTransformer = options?.transformer ?? operation.params.transformer\n\n    const transformer = getDataTransformer(rawTransformer)\n\n    if (operation.params.body instanceof FormData) {\n      body.append(`${index}.body_type`, 'formdata')\n\n      operation.params.body.forEach((value, key) => {\n        const serialized = transformer.input.serialize(value)\n\n        // FormData is special and can handle additional data types, like Files.\n        // So we will not JSON.stringify the serialized result.\n        body.set(`${index}.body.${key}`, serialized)\n      })\n    } else {\n      body.append(`${index}.body_type`, 'json')\n\n      const serialized = transformer.input.serialize(operation.params.body)\n      const stringified = JSON.stringify(serialized)\n\n      body.set(`${index}.body`, stringified)\n    }\n  })\n\n  return { body, query: {}, headers }\n}\n\nconst generateBatchRequestInformation = {\n  GET: generateGetBatchRequestInformation,\n  POST: generatePostBatchRequestInformation,\n}\n\nfunction createBatchRequester(options: HttpBatchLinkOptions = {}): Requester {\n  const resolvedFactoryOptions = { maxURLLength: Infinity, ...options }\n\n  const { endpoint, maxURLLength, headers, transformer, method, domain, ...requestOptions } =\n    resolvedFactoryOptions\n\n  const createBatchLoader = (_type: OperationType): BatchLoader<Operation> => {\n    return {\n      validate: (batchOps) => {\n        // Escape hatch for quick calculations.\n        if (maxURLLength === Infinity) return true\n\n        const requestInformation = generateGetBatchRequestInformation(batchOps)\n\n        const searchParams = new URLSearchParams(requestInformation.query)\n\n        const path = endpoint ?? BATCH_ENDPOINT\n\n        const url = `${path}${searchParams.size ? '?' : ''}${searchParams}`\n\n        return url.length <= maxURLLength\n      },\n      fetch: (batchOps) => {\n        if (batchOps.length === 1) {\n          const [firstOperation] = batchOps\n\n          if (firstOperation != null) {\n            const requesterOptions: RequesterOptions = {\n              transformer,\n              ...requestOptions,\n              ...firstOperation,\n            }\n\n            // Forward domain.\n            if (domain != null) {\n              requesterOptions.params = { ...requesterOptions.params, domain }\n            }\n\n            const singleResult = universalRequester(requesterOptions)\n\n            // Batched-data-loader expects an array of results,\n            // which will each be resolved to the corresponding promise.\n            const promise = singleResult.promise.then((result) => [result])\n\n            return { promise, cancel: singleResult.cancel }\n          }\n        }\n\n        const signals = batchOps.map((b) => b.params.fetch?.signal).filter(notNull)\n\n        const abortController = signals.length ? new AbortController() : null\n\n        signals.forEach((signal) => {\n          signal.addEventListener('abort', () => {\n            abortController?.abort()\n          })\n        })\n\n        const cancel = () => {\n          abortController?.abort()\n        }\n\n        const defaultBatchMethod: BatchMethod = method ?? 'POST'\n\n        /**\n         * If any operations are a POST requests, can't batch with GET request...\n         */\n        const resolvedMethod: BatchMethod =\n          defaultBatchMethod === 'GET'\n            ? batchOps.find((op) => op.params.method === 'POST')\n              ? 'POST'\n              : 'GET'\n            : 'POST'\n\n        const batchInformationGenerator = generateBatchRequestInformation[resolvedMethod]\n\n        const information = batchInformationGenerator(batchOps, resolvedFactoryOptions)\n\n        const path = endpoint ?? BATCH_ENDPOINT\n\n        const defaultHeaders =\n          headers == null\n            ? undefined\n            : typeof headers === 'function'\n              ? headers(batchOps as NonEmptyArray<Operation>)\n              : headers\n\n        // Force to await headers.\n        const awaitDefaultHeaders = async () => await defaultHeaders\n\n        const promise = awaitDefaultHeaders().then(async (defaultHeaders) => {\n          const { body, query } = information\n\n          for (const key in defaultHeaders) {\n            const header = defaultHeaders[key as never]\n            if (header != null) {\n              information.headers.append(key, header)\n            }\n          }\n\n          const resolvedParams: EdenRequestParams<any, true> = {\n            domain,\n            transformer,\n            path,\n            method: resolvedMethod,\n            options: { query },\n            body,\n            headers: information.headers,\n            ...requestOptions,\n            raw: true,\n          }\n\n          if (signals.length) {\n            resolvedParams.fetch ??= {}\n            resolvedParams.fetch.signal = abortController?.signal\n          }\n\n          const result = await resolveEdenRequest(resolvedParams)\n\n          /**\n           * result.data should be an array of JSON data from each request in the batch.\n           */\n          if (!('data' in result) || !Array.isArray(result.data)) {\n            return []\n          }\n\n          const batchedData: EdenResponse<true>[] = result.data\n\n          const resolvedTransformer = getDataTransformer(transformer)\n\n          /**\n           * The batch plugin also encodes its data into a JSON.\n           *\n           * @example\n           * If the data from a batched request is [3, 'OK', false],\n           * the batch plugin should return a JSON like\n           * [\n           *   { data: 3, error: null, status: 200, statusText: 'OK' },\n           *   { data: 'OK', error: null, status: 200, statusText: 'OK' }\n           *   { data: false, error: null, status: 200, statusText: 'OK' }\n           * ]\n           */\n          const transformedResponses = batchedData.map((batchedResult, index) => {\n            // The raw data from each request has not be de-serialized yet.\n            // De-serialize it so every entry is the finalized result.\n            if (resolvedTransformer != null && batchedResult.data != null) {\n              batchedResult.data = resolvedTransformer.output.deserialize(batchedResult.data)\n            }\n\n            const operation = batchOps[index]\n\n            // If this specific operation wanted the raw information, append the required properties.\n            if (operation?.params.raw) {\n              // Recreate custom headers object.\n              const headers = new Headers()\n\n              /**\n               * If the header value has a numeric prefix, only assign it if it matches the operation index,\n               * otherwise, assign it.\n               *\n               * The batch plugin will add a numeric prefix to organize the headers.\n               *\n               * @example\n               * '0.set-cookie': 'abc' should be a header only for request 0.\n               * 'set-cookie': should be a header for all the batched requests.\n               */\n              result.headers.forEach((value, key) => {\n                const [prefix, name] = key.split('.')\n\n                if (Number(prefix) === index && name != null) {\n                  headers.set(name, value)\n                } else {\n                  headers.set(key, value)\n                }\n              })\n\n              /**\n               * TODO: how to guarantee that this value is the correct body?\n               */\n              const body =\n                resolvedTransformer != null\n                  ? resolvedTransformer.output.serialize(batchedResult.data)\n                  : JSON.stringify(batchedResult.data)\n\n              /**\n               * Create a new response using the re-serialized body.\n               */\n              const response = new Response(body, {\n                status: batchedResult.status,\n                statusText: batchedResult.statusText,\n                headers,\n              })\n\n              batchedResult.headers = headers\n              batchedResult.response = response\n            }\n\n            return batchedResult\n          })\n\n          return transformedResponses\n        })\n\n        return { promise, cancel }\n      },\n    }\n  }\n\n  const queryBatchLoader = createBatchLoader('query')\n  const mutationBatchLoader = createBatchLoader('mutation')\n  const subscriptionBatchLoader = createBatchLoader('subscription')\n\n  const query = batchedDataLoader(queryBatchLoader)\n  const mutation = batchedDataLoader(mutationBatchLoader)\n  const subscription = batchedDataLoader(subscriptionBatchLoader)\n\n  const loaders = { query, subscription, mutation }\n\n  return (options) => loaders[options.type].load(options)\n}\n\n/**\n * @see https://trpc.io/docs/v11/client/links/httpLink\n */\nexport const safeHttpBatchLink = <T extends AnyElysia>(\n  options?: HttpBatchLinkOptions<T>,\n): T['store'][typeof EdenQueryStoreKey]['batch'] extends true | BatchPluginOptions\n  ? EdenLink<T>\n  : TypeError<'Batch plugin not detected on Elysia.js app instance'> => {\n  const batchRequester = createBatchRequester(options)\n  return httpLinkFactory({ requester: batchRequester })() as any\n}\n\n/**\n * @see https://trpc.io/docs/v11/client/links/httpLink\n */\nexport function httpBatchLink<T extends AnyElysia>(\n  options?: HttpBatchLinkOptions<T, false>,\n): EdenLink<T> {\n  return safeHttpBatchLink(options as any) as any\n}\n","import type { AnyElysia } from 'elysia'\n\nimport { constNoop } from '../utils/noop'\nimport { Observable } from './internal/observable'\nimport type {\n  EdenClientError,\n  EdenLink,\n  Operation,\n  OperationResultEnvelope,\n} from './internal/operation'\nimport { tap } from './internal/operators'\n\ntype ConsoleEsque = {\n  log: (...args: any[]) => void\n  error: (...args: any[]) => void\n}\n\ntype EnableFnOptions =\n  | {\n      direction: 'down'\n      result: OperationResultEnvelope<unknown> | unknown\n    }\n  | (Operation & {\n      direction: 'up'\n    })\n\ntype EnabledFn = (opts: EnableFnOptions) => boolean\n\ntype LoggerLinkFnOptions = Operation &\n  (\n    | {\n        /**\n         * Request result\n         */\n        direction: 'down'\n        result: OperationResultEnvelope<unknown> | unknown\n        elapsedMs: number\n      }\n    | {\n        /**\n         * Request was just initialized\n         */\n        direction: 'up'\n      }\n  )\n\ntype LoggerLinkFn = (opts: LoggerLinkFnOptions) => void\n\ntype ColorMode = 'ansi' | 'css' | 'none'\n\nexport interface LoggerLinkOptions {\n  logger?: LoggerLinkFn\n\n  enabled?: EnabledFn\n\n  /**\n   * Used in the built-in defaultLogger\n   */\n  console?: ConsoleEsque\n\n  /**\n   * Color mode\n   * @default typeof window === 'undefined' ? 'ansi' : 'css'\n   */\n  colorMode?: ColorMode\n\n  /**\n   * Include context in the log - defaults to false unless `colorMode` is 'css'\n   */\n  withContext?: boolean\n}\n\nconst palettes = {\n  css: {\n    query: ['72e3ff', '3fb0d8'],\n    mutation: ['c5a3fc', '904dfc'],\n    subscription: ['ff49e1', 'd83fbe'],\n  },\n  ansi: {\n    regular: {\n      // Cyan background, black and white text respectively\n      query: ['\\x1b[30;46m', '\\x1b[97;46m'],\n\n      // Magenta background, black and white text respectively\n      mutation: ['\\x1b[30;45m', '\\x1b[97;45m'],\n\n      // Green background, black and white text respectively\n      subscription: ['\\x1b[30;42m', '\\x1b[97;42m'],\n    },\n    bold: {\n      query: ['\\x1b[1;30;46m', '\\x1b[1;97;46m'],\n      mutation: ['\\x1b[1;30;45m', '\\x1b[1;97;45m'],\n      subscription: ['\\x1b[1;30;42m', '\\x1b[1;97;42m'],\n    },\n  },\n} as const\n\nexport type ExtendedLoggerFnOptions = LoggerLinkFnOptions & {\n  colorMode: ColorMode\n  withContext?: boolean\n}\n\nfunction constructPartsAndArgs(opts: ExtendedLoggerFnOptions) {\n  const { direction, type, withContext, id, params } = opts\n\n  const parts: string[] = []\n  const args: any[] = []\n\n  const path = params.path ?? ''\n\n  if (opts.colorMode === 'none') {\n    parts.push(direction === 'up' ? '>>' : '<<', type, `#${id}`, path)\n  } else if (opts.colorMode === 'ansi') {\n    const [lightRegular, darkRegular] = palettes.ansi.regular[type]\n    const [lightBold, darkBold] = palettes.ansi.bold[type]\n    const reset = '\\x1b[0m'\n\n    parts.push(\n      direction === 'up' ? lightRegular : darkRegular,\n      direction === 'up' ? '>>' : '<<',\n      type,\n      direction === 'up' ? lightBold : darkBold,\n      `#${id}`,\n      path,\n      reset,\n    )\n  } else {\n    // css color mode\n    const [light, dark] = palettes.css[type]\n    const css = `\n    background-color: #${direction === 'up' ? light : dark};\n    color: ${direction === 'up' ? 'black' : 'white'};\n    padding: 2px;\n  `\n\n    parts.push('%c', direction === 'up' ? '>>' : '<<', type, `#${id}`, `%c${path}%c`, '%O')\n    args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`)\n  }\n\n  if (direction === 'up') {\n    args.push(withContext ? { params, context: opts.context } : { params })\n  } else {\n    args.push({\n      params,\n      result: opts.result,\n      elapsedMs: opts.elapsedMs,\n      ...(withContext && { context: opts.context }),\n    })\n  }\n\n  return { parts, args }\n}\n\nexport type LoggerOptions = {\n  c?: ConsoleEsque\n  colorMode?: ColorMode\n  withContext?: boolean\n}\n\n/**\n * Maybe this should be moved to it's own package?\n */\nfunction defaultLogger(options: LoggerOptions): LoggerLinkFn {\n  const { c = console, colorMode = 'css', withContext } = options\n\n  return (props) => {\n    const params = props.params\n\n    const { parts, args } = constructPartsAndArgs({ ...props, colorMode, params, withContext })\n\n    const fn: 'error' | 'log' =\n      props.direction === 'down' &&\n      props.result &&\n      (props.result instanceof Error ||\n        (typeof props.result === 'object' && props.result !== null && 'error' in props.result))\n        ? 'error'\n        : 'log'\n\n    c[fn].apply(null, [parts.join(' ')].concat(args))\n  }\n}\n\n/**\n * @see https://trpc.io/docs/v11/client/links/loggerLink\n */\nexport function loggerLink<T extends AnyElysia>(options?: LoggerLinkOptions): EdenLink<T> {\n  const enabled = options?.enabled ?? constNoop(true)\n\n  const colorMode = options?.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css')\n\n  const withContext = options?.withContext ?? colorMode === 'css'\n\n  const logger = options?.logger ?? defaultLogger({ c: options?.console, colorMode, withContext })\n\n  return (_runtime) => {\n    return ({ operation, next }) => {\n      return new Observable((observer) => {\n        if (enabled({ ...operation, direction: 'up' })) {\n          logger({ ...operation, direction: 'up' })\n        }\n\n        const requestStartTime = Date.now()\n\n        function logResult(result: OperationResultEnvelope<unknown>) {\n          const elapsedMs = Date.now() - requestStartTime\n\n          if (enabled({ ...operation, direction: 'down', result })) {\n            logger({ ...operation, direction: 'down', elapsedMs, result })\n          }\n        }\n\n        function logError(error: EdenClientError<T>) {\n          const elapsedMs = Date.now() - requestStartTime\n\n          if (enabled({ ...operation, direction: 'down', result: error })) {\n            logger({ ...operation, direction: 'down', elapsedMs, result: error })\n          }\n        }\n\n        return next(operation)\n          .pipe(\n            tap({\n              next: (result) => {\n                logResult(result)\n              },\n              error: (error) => {\n                logError(error)\n              },\n            }),\n          )\n          .subscribe(observer)\n      })\n    }\n  }\n}\n","import type { AnyElysia, MaybeArray } from 'elysia'\n\nimport { createChain } from './internal/create-chain'\nimport { Observable } from './internal/observable'\nimport type { EdenLink, Operation } from './internal/operation'\n\nfunction asArray<TType>(value: TType | TType[]) {\n  return Array.isArray(value) ? value : [value]\n}\n\nexport type SplitLinkOptions<T extends AnyElysia> = {\n  /**\n   */\n  condition: (operation: Operation) => boolean\n\n  /**\n   * The link(s) to execute next if {@link SplitLinkOptions.condition} function returns `true`.\n   */\n  true: MaybeArray<EdenLink<T>>\n\n  /**\n   * The link(s) to execute next if {@link SplitLinkOptions.condition} function returns `false`.\n   */\n  false: MaybeArray<EdenLink<T>>\n}\n\nexport function splitLink<T extends AnyElysia = AnyElysia>(\n  options: SplitLinkOptions<T>,\n): EdenLink<T> {\n  return (runtime) => {\n    const linksIfTrue = asArray(options.true).map((link) => link(runtime))\n    const linksIfFalse = asArray(options.false).map((link) => link(runtime))\n\n    const linksByCondition = { true: linksIfTrue, false: linksIfFalse }\n\n    return ({ operation }) => {\n      return new Observable((observer) => {\n        const condition = options.condition(operation)\n\n        const links = linksByCondition[`${condition}`]\n\n        return createChain({ operation, links }).subscribe(observer)\n      })\n    }\n  }\n}\n","import { isHttpMethod } from './utils/http'\n\n/**\n * The result of parsing a paths array.\n */\nexport type ParsedPathAndMethod = {\n  /**\n   * Array of path segments that make up the path.\n   *\n   * @example ['api', 'hello', 'index', 'get'] -> ['api', 'hello', 'index']\n   */\n  paths: string[]\n\n  /**\n   * The (absolute) path represented as a single string.\n   *\n   * @example ['api', 'hello', 'index', 'get'] ->'/api/hello/index'\n   */\n  path: string\n\n  /**\n   * The method from the original paths array, if found.\n   *\n   * @example ['api', 'hello', 'index', 'get'] -> 'get'\n   */\n  method?: string\n}\n\n/**\n * Given an array of path segments, where the last segment is possibly a method,\n * parse it into proper labels.\n *\n * @example\n *\n * const originalPaths = ['api', 'hello', 'index', 'get']\n *\n * const path = '/api/hello/index'\n *\n * const method = 'get'\n */\nexport function parsePathsAndMethod(paths: string[] | readonly string[]): ParsedPathAndMethod {\n  /**\n   * Don't mutate the original array.\n   */\n  const pathsCopy = [...paths]\n\n  /**\n   * This may be the method, or part of a route.\n   *\n   * e.g. since invalidations can be partial and not include it.\n   *\n   * @example\n   *\n   * Let there be a GET endpoint at /api/hello/world\n   *\n   * GET request to /api/hello/world -> paths = ['api', 'hello', 'world', 'get']\n   *\n   * Invalidation request for all routes under /api/hello -> paths = ['api', 'hello']\n   *\n   * In the GET request, the last item is the method and can be safely popped.\n   * In the invalidation, the last item is actually part of the path, so it needs to be preserved.\n   */\n  const lastSegment = paths[paths.length - 1]\n\n  const lastSegmentIsHttpMethod = isHttpMethod(lastSegment)\n\n  /**\n   * If the last segment is an HTTP method, it's not part of the final path\n   * and should be removed before determining the path.\n   */\n  if (lastSegmentIsHttpMethod) {\n    pathsCopy.pop()\n  }\n\n  const path = '/' + pathsCopy.join('/')\n\n  const result: ParsedPathAndMethod = { paths: pathsCopy, path }\n\n  if (lastSegmentIsHttpMethod && typeof lastSegment === 'string') {\n    result.method = lastSegment\n  }\n\n  return result\n}\n","/**\n *\n * An eden-treaty proxy may look like these examples:\n *\n * eden.api.products.get({ limit: 5 })\n * eden.api.product({ id: 'product-id' }).details.get({ limit: 5 })\n *\n * In the first example, the proxy is called like a function at the very end, so it is trivial\n * to infer that the arguments are the query parameters for fetch request.\n *\n * In the second example, there are two function calls, and we need to heuristically determine whether\n * it is a function call to insert a path parameter, or the actual end.\n *\n * Heuristic: A path parameter function call needs exactly one object with exactly one key passed as an argument.\n */\nexport function getPathParam(args: unknown[]) {\n  if (args.length !== 1) {\n    return\n  }\n\n  const argument = args[0]\n\n  if (argument == null || typeof argument !== 'object') {\n    return\n  }\n\n  const argumentKeys = Object.keys(argument)\n\n  const pathParam = argumentKeys[0]\n\n  if (argumentKeys.length !== 1 || pathParam == null) {\n    return\n  }\n\n  return { param: argument as any, key: argumentKeys[0] }\n}\n\n/**\n * Only maps over keys that represents valid route params. i.e. path segments that begin with colon.\n */\nexport type ExtractEdenTreatyRouteParams<T> = {\n  [K in keyof T as K extends `:${string}` ? K : never]: T[K]\n}\n\n/**\n * Create an object that maps the name of the route param to possible values (string or number).\n *\n * @example\n *\n * '/products/:id'\n *\n * :id is a path parameter, and this would return { id: string | number }\n *\n * Eden will recognize this object as a path parameter.\n *\n * @see https://elysiajs.com/eden/treaty/overview.html#dynamic-path\n */\nexport type ExtractEdenTreatyRouteParamsInput<T> = {\n  [K in keyof T as K extends `:${infer TParam}` ? TParam : never]: string | number\n}\n","import type { AnyElysia, RouteSchema } from 'elysia'\n\nimport { EdenClient } from './client'\nimport type { TypeError } from './errors'\nimport { type HttpMutationMethod, type HttpQueryMethod, type HttpSubscriptionMethod } from './http'\nimport type { InferRouteBody, InferRouteOptions, InferRouteResponse } from './infer'\nimport { httpLink, type HTTPLinkOptions } from './links'\nimport { parsePathsAndMethod } from './path'\nimport {\n  type ExtractEdenTreatyRouteParams,\n  type ExtractEdenTreatyRouteParamsInput,\n  getPathParam,\n} from './path-params'\nimport type { EdenRequestOptions } from './request'\nimport type { EdenRequestParams } from './resolve'\nimport type { EmptyToVoid } from './utils/empty-to-void'\nimport { isGetOrHeadMethod, isHttpMethod } from './utils/http'\nimport type { Optional } from './utils/optional'\nimport type { EdenWS } from './ws'\n\n/**\n * RPC proxy derived from {@link AnyElysia._routes} for accessing an Elysia.js API.\n */\nexport type EdenTreatyClient<T extends AnyElysia> = T extends {\n  _routes: infer TSchema extends Record<string, any>\n}\n  ? EdenTreatyHooksProxy<TSchema>\n  : TypeError<'Please install Elysia before using Eden'>\n\n/**\n * Recursively iterate over all keys in {@link AnyElyisa._routes}, processing path parameters\n * and regular path segments separately.\n *\n * Regular path parameters will be mapped to a nested object, and then intersected\n * with anything generated by dynamic path parameters.\n *\n * @template TSchema The current level of {@link AnyElysia._routes} being processed.\n * @template TPath The current path segments up to this point (excluding dynamic path parameters).\n * @template TRouteParams Keys that are considered path parameters instead of regular path segments.\n */\nexport type EdenTreatyHooksProxy<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = ExtractEdenTreatyRouteParams<TSchema>,\n> = EdenTreatyPathHooks<TSchema, TPath, TRouteParams> &\n  EdenTreatyHooksPathParameterHook<TSchema, TPath, TRouteParams>\n\n/**\n * Recursively handle regular path segments (i.e. NOT path parameters).\n *\n * If the value is a {@link RouteSchema}, then it's a \"leaf\" that does not need to be\n * recursively processed. The result should be the key, an HTTP method, mapped to a\n * strongly-typed function.\n *\n * @template TSchema The current level of {@link AnyElysia._routes} being processed.\n * @template TPath The current path segments up to this point (excluding dynamic path parameters).\n * @template TRouteParams Keys that are considered path parameters instead of regular path segments.\n */\ntype EdenTreatyPathHooks<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = ExtractEdenTreatyRouteParams<TSchema>,\n> = {\n  [K in Exclude<keyof TSchema, keyof TRouteParams>]: TSchema[K] extends RouteSchema\n    ? EdenTreatyQueryRouteLeaf<TSchema[K], K>\n    : EdenTreatyHooksProxy<TSchema[K], [...TPath, K]>\n}\n\n/**\n * {@link EdenTreatyHooksProxy} intersects the object created by {@link EdenTreatyPathHooks}\n * for regular path parameters with anything created by this type for dynamic path parameters.\n *\n * If there are no dynamic path parameters, then return an empty object.\n * Intersecting with empty object does nothing.\n *\n * Otherwise, return a function that returns the next level of the proxy, omitting\n * the current dynamic path parameter.\n *\n * @template TSchema The current level of {@link AnyElysia._routes} being processed.\n * @template TPath The current path segments up to this point (excluding dynamic path parameters).\n * @template TRouteParams Keys that are considered path parameters instead of regular path segments.\n */\ntype EdenTreatyHooksPathParameterHook<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = {},\n> = {} extends TRouteParams\n  ? {}\n  : (\n      params: ExtractEdenTreatyRouteParamsInput<TRouteParams>,\n    ) => EdenTreatyHooksProxy<TSchema[Extract<keyof TRouteParams, keyof TSchema>], TPath>\n\n/**\n * When a {@link RouteSchema} is found, map it to leaves and stop recursive processing.\n * Leaves are function calls that abstract the native {@link fetch} API.\n *\n * Based on the HTTP request \"category\", e.g. \"query\", \"mutation\", \"subscription\", or \"unknown\",\n * return the corresponding leaf.\n *\n * @template TRoute The {@link RouteSchema} that was found.\n * @template TMethod The most recent key that was mapped to the {@link TRoute}. e.g. \"get\", \"post\", etc.\n */\nexport type EdenTreatyQueryRouteLeaf<\n  TRoute extends RouteSchema,\n  TMethod,\n> = TMethod extends HttpQueryMethod\n  ? EdenTreatyQueryLeaf<TRoute>\n  : TMethod extends HttpMutationMethod\n    ? EdenTreatyMutationLeaf<TRoute>\n    : TMethod extends HttpSubscriptionMethod\n      ? EdenTreatySubscriptionLeaf<TRoute>\n      : EdenTreatyUnknownLeaf<TRoute>\n\n/**\n * Strongly-typed function for queries (i.e. \"GET\" requests).\n */\nexport type EdenTreatyQueryLeaf<TRoute extends RouteSchema> = (\n  options: EmptyToVoid<Optional<InferRouteOptions<TRoute>, 'params'>>,\n) => Promise<InferRouteResponse<TRoute>>\n\n/**\n * Strongly-typed function for mutations (i.e. \"POST\", \"PATCH\", etc. requests).\n */\nexport type EdenTreatyMutationLeaf<TRoute extends RouteSchema> = (\n  body: EmptyToVoid<InferRouteBody<TRoute>>,\n  options: EmptyToVoid<Optional<InferRouteOptions, 'params'>>,\n) => Promise<InferRouteResponse<TRoute>>\n\n/**\n * Strongly-typed function for subscriptions (i.e. \"CONNECT\", \"SUBSCRIBE\", etc. requests).\n *\n * @TODO: Available hooks assuming that the route supports `createSubscription`.\n */\nexport type EdenTreatySubscriptionLeaf<TRoute extends RouteSchema> = (\n  options: EmptyToVoid<Optional<InferRouteOptions<TRoute>, 'params'>>,\n) => EdenWS<TRoute>\n\n/**\n * Strongly-typed function for unknown request.\n *\n * @todo What should it actually be...\n */\nexport type EdenTreatyUnknownLeaf<TRoute extends RouteSchema> = EdenTreatyQueryLeaf<TRoute> &\n  EdenTreatyQueryLeaf<TRoute> &\n  EdenTreatyMutationLeaf<TRoute> &\n  EdenTreatySubscriptionLeaf<TRoute>\n\n/**\n * @param client\n *\n * @param config\n *\n * @param [paths=[]] Path parameter strings including the current path parameter as a placeholder.\n * @example [ 'products', ':id', ':cursor' ]\n *\n * @param [pathParams=[]] An array of objects representing path parameter replacements.\n * @example [ { id: 123 }, { cursor: '456' } ]\n */\nexport function createEdenTreatyProxy<T extends AnyElysia>(\n  client: EdenClient<T>,\n  config?: EdenRequestOptions<T>,\n  paths: string[] = [],\n  pathParams: Record<string, any>[] = [],\n) {\n  const edenTreatyProxy = new Proxy(() => {}, {\n    get: (_target, path: string, _receiver): any => {\n      // Copy the paths so that it will not be mutated in a nested proxy.\n      // Only add the current path if is not \"index\".\n      const nextPaths = path === 'index' ? [...paths] : [...paths, path]\n\n      //  Return a nested proxy that has the new paths.\n      return createEdenTreatyProxy(client, config, nextPaths, pathParams)\n    },\n    apply: (_target, _thisArg, args) => {\n      // Parse the information from the paths array up to this point.\n      const { path, method } = parsePathsAndMethod(paths)\n\n      // Determine if the current args could be specifying dynamic path parameters.\n      const pathParam = getPathParam(args)\n\n      // If it is a valid path parameter argument and the HTTP method is not recognized,\n      // then return a nested proxy that includes the path parameter replacement.\n      if (pathParam?.key != null && !isHttpMethod(method)) {\n        const allPathParams = [...pathParams, pathParam.param]\n        const pathsWithParams = [...paths, `:${pathParam.key}`]\n        return createEdenTreatyProxy(client, config, pathsWithParams, allPathParams)\n      }\n\n      // Otherwise, assume that this is intended to be a request and handle it.\n\n      let options: any = undefined\n      let body: any = undefined\n\n      if (isGetOrHeadMethod(method)) {\n        options = args[0]\n      } else {\n        body = args[0]\n        options = args[1]\n      }\n\n      const params: EdenRequestParams<T> = {\n        body,\n        options,\n        path,\n        method,\n        ...config,\n      }\n\n      return client.query(params)\n    },\n  })\n\n  return edenTreatyProxy\n}\n\n/**\n * @param clientOrHttpLinkOptions Either an untyped {@link EdenClient} or options for an httpLink to initialize a default client.\n * @param options Request options.\n */\nexport function createEdenTreaty<T extends AnyElysia>(\n  clientOrHttpLinkOptions?: EdenClient<T> | HTTPLinkOptions<T>,\n  options?: EdenRequestOptions<T>,\n): EdenTreatyClient<T> {\n  if (clientOrHttpLinkOptions instanceof EdenClient) {\n    const proxy = createEdenTreatyProxy(clientOrHttpLinkOptions, options)\n    return proxy as any\n  }\n\n  const defaultClient = new EdenClient({ links: [httpLink(clientOrHttpLinkOptions)] })\n\n  const proxy = createEdenTreatyProxy(defaultClient, options)\n  return proxy as any\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,OAAO;AAEvB;AAMO,SAAS,UAAa,OAAmB;AAC9C,SAAO,MAAM;AACf;;;ACyBO,SAAS,aAAa,GAA+C;AAC1E,SAAO,OAAO,MAAM,YAAY,MAAM,QAAQ,eAAe;AAC/D;AAEO,SAAS,YAAY,eAAoB,MAAqB;AACnE,SAAO,KAAK,aAAa;AAC3B;AAEO,SAAS,oBAAuB,YAA2B;AAChE,MAAI,QAAQ;A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ACrD,cAAM,kBAAkB,CAAC,GAAG,OAAO,IAAI,UAAU,GAAG,EAAE;AACtD,eAAO,sBAAsB,QAAQ,QAAQ,iBAAiB,aAAa;AAAA,MAC7E;AAIA,UAAI,UAAe;AACnB,UAAI,OAAY;AAEhB,UAAI,kBAAkB,MAAM,GAAG;AAC7B,kBAAU,KAAK,CAAC;AAAA,MAClB,OAAO;AACL,eAAO,KAAK,CAAC;AACb,kBAAU,KAAK,CAAC;AAAA,MAClB;AAEA,YAAM,SAA+B;AAAA,QACnC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAEA,aAAO,OAAO,MAAM,MAAM;AAAA,IAC5B;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAMO,SAAS,iBACd,yBACA,SACqB;AACrB,MAAI,mCAAmC,YAAY;AACjD,UAAMC,SAAQ,sBAAsB,yBAAyB,OAAO;AACpE,WAAOA;AAAA,EACT;AAEA,QAAM,gBAAgB,IAAI,WAAW,EAAE,OAAO,CAAC,SAAS,uBAAuB,CAAC,EAAE,CAAC;AAEnF,QAAM,QAAQ,sBAAsB,eAAe,OAAO;AAC1D,SAAO;AACT;","names":["observer","value","data","domain","url","AbortController","AbortController","item","promise","defaultHeaders","query","headers","body","options","proxy"]}