{"version":3,"sources":["../src/index.ts","../../eden/src/utils/noop.ts","../../eden/src/links/internal/observable.ts","../../eden/src/links/internal/operation.ts","../../eden/src/links/internal/create-chain.ts","../../eden/src/links/internal/operators.ts","../../eden/src/constants.ts","../../eden/src/errors.ts","../../eden/src/http.ts","../../eden/src/links/internal/transformer.ts","../../eden/src/utils/file.ts","../../eden/src/utils/http.ts","../../eden/src/utils/parse.ts","../../eden/src/resolve.ts","../../eden/src/utils/null.ts","../../eden/src/links/internal/universal-requester.ts","../../eden/src/links/http-link.ts","../../eden/src/links/internal/batched-data-loader.ts","../../eden/src/links/http-batch-link.ts","../../eden/src/links/logger-link.ts","../../eden/src/links/split-link.ts","../../eden/src/ws.ts","../../eden/src/client.ts","../../eden/src/path.ts","../../eden/src/path-params.ts","../../eden/src/treaty.ts","../src/integration/internal/query-key.ts","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/utils.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/globals.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/dom.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/lifecycle.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/shared/boolean_attributes.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/internal/Component.js","../../../node_modules/.bun/svelte@4.2.20/node_modules/svelte/src/runtime/store/index.js","../src/utils/is-store.ts","../src/utils/path-param.ts","../src/implementation/treaty/root-hooks.ts","../src/context.ts","../src/integration/hooks/create-infinite-query.ts","../src/integration/hooks/create-mutation.ts","../src/integration/hooks/create-query.ts","../src/integration/internal/query-hook-extension.ts","../src/implementation/treaty/create-queries.ts","../src/implementation/treaty/query-utils.ts","../src/implementation/treaty/index.ts"],"sourcesContent":["export * from './implementation/treaty'\nexport * from '@aydee-app/eden'\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","/* eslint-disable no-dupe-class-members */\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    let 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 { 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 * TODO: placeholder for TRPCClientError<TInferrable>.\n */\nexport type EdenClientError<_T extends AnyElysia> = any\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","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","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 * @todo\n */\nexport type EdenClientErrorLike<_T extends AnyElysia> = any\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","/**\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","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  let 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 { EdenLink, Operation, OperationResultEnvelope } 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>\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>\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 || '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        return next(operation)\n          .pipe(\n            tap({\n              next: (result) => {\n                logResult(result)\n              },\n              error: (result) => {\n                logResult(result)\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","/**\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 { 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 = any> = {\n  type: OperationType\n  context?: OperationContext\n  params: EdenRequestParams<T>\n}\n\nexport type EdenClientPromisifyRequestOptions = EdenClientInternalRequestOptions & {\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<any, any, any>[],\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,\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, 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, 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 { 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 = {\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","import { type InferRouteOptions, isHttpMethod } from '@aydee-app/eden'\n\n/**\n * A well-defined query type used when creating query keys for a specific type of operation.\n */\nexport type EdenKnownQueryType = 'query' | 'infinite'\n\n/**\n * Valid query types for creating query keys.\n */\nexport type EdenQueryType = EdenKnownQueryType | 'any'\n\n/**\n * QueryKey used internally. Consists of a tuple with an array key and metadata.\n */\nexport type EdenQueryKey<\n  TKey extends readonly any[] = readonly string[],\n  TInput = unknown,\n  TType extends EdenKnownQueryType = EdenKnownQueryType,\n> = [key: TKey, metadata?: { input?: TInput; type?: TType }]\n\nexport type EdenQueryKeyOptions = InferRouteOptions & { body?: any }\n\nexport type EdenMutationKey = [readonly string[]]\n\nfunction isArray<T>(value: T | T[] | readonly T[]): value is T[] | readonly T[] {\n  return Array.isArray(value)\n}\n\nexport function getQueryKey(\n  pathOrEndpoint: string | string[] | readonly string[],\n  options?: EdenQueryKeyOptions,\n  type?: EdenQueryType,\n): EdenQueryKey {\n  const path = isArray(pathOrEndpoint) ? pathOrEndpoint : pathOrEndpoint.split('/')\n  const hasInput = options?.body != null || options?.params != null || options?.query != null\n  const hasType = Boolean(type) && type !== 'any'\n\n  if (!hasInput && !hasType) return [path]\n\n  const input = { body: options?.body, params: options?.params, query: options?.query }\n  return [path, { ...(hasInput && { input }), ...(hasType && { type }) }]\n}\n\nexport function createEdenQueryKey(paths: string[], args: any, type: EdenQueryType = 'any') {\n  const pathsCopy: any[] = [...paths]\n\n  /**\n   * Only sometimes method, i.e. since invalidations can be partial and not include it.\n   * @example 'get'\n   */\n  const method = pathsCopy[pathsCopy.length - 1]\n\n  if (isHttpMethod(method)) {\n    pathsCopy.pop()\n  }\n\n  const queryKey = getQueryKey(pathsCopy, args[0], type)\n\n  return queryKey\n}\n\nexport function getMutationKey(\n  path: string | string[] | readonly string[],\n  options?: EdenQueryKeyOptions,\n): EdenMutationKey {\n  return getQueryKey(path, options, 'any') as any\n}\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\n\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\n/**\n * @param {any} value\n * @returns {value is PromiseLike<any>}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable<T>} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","/** @type {typeof globalThis} */\nexport const globals =\n\ttypeof window !== 'undefined'\n\t\t? window\n\t\t: typeof globalThis !== 'undefined'\n\t\t? globalThis\n\t\t: // @ts-ignore Node typings have this\n\t\t  global;\n","import { globals } from './globals.js';\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nexport class ResizeObserverSingleton {\n\t/**\n\t * @private\n\t * @readonly\n\t * @type {WeakMap<Element, import('./private.js').Listener>}\n\t */\n\t_listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n\t/**\n\t * @private\n\t * @type {ResizeObserver}\n\t */\n\t_observer = undefined;\n\n\t/** @type {ResizeObserverOptions} */\n\toptions;\n\n\t/** @param {ResizeObserverOptions} options */\n\tconstructor(options) {\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * @param {Element} element\n\t * @param {import('./private.js').Listener} listener\n\t * @returns {() => void}\n\t */\n\tobserve(element, listener) {\n\t\tthis._listeners.set(element, listener);\n\t\tthis._getObserver().observe(element, this.options);\n\t\treturn () => {\n\t\t\tthis._listeners.delete(element);\n\t\t\tthis._observer.unobserve(element); // this line can probably be removed\n\t\t};\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_getObserver() {\n\t\treturn (\n\t\t\tthis._observer ??\n\t\t\t(this._observer = new ResizeObserver((entries) => {\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tResizeObserverSingleton.entries.set(entry.target, entry);\n\t\t\t\t\tthis._listeners.get(entry.target)?.(entry);\n\t\t\t\t}\n\t\t\t}))\n\t\t);\n\t}\n}\n\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n","import { contenteditable_truthy_values, has_prop } from './utils.js';\n\nimport { ResizeObserverSingleton } from './ResizeObserverSingleton.js';\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\n\n/**\n * @returns {void}\n */\nexport function start_hydrating() {\n\tis_hydrating = true;\n}\n\n/**\n * @returns {void}\n */\nexport function end_hydrating() {\n\tis_hydrating = false;\n}\n\n/**\n * @param {number} low\n * @param {number} high\n * @param {(index: number) => number} key\n * @param {number} value\n * @returns {number}\n */\nfunction upper_bound(low, high, key, value) {\n\t// Return first index of value larger than input value in the range [low, high)\n\twhile (low < high) {\n\t\tconst mid = low + ((high - low) >> 1);\n\t\tif (key(mid) <= value) {\n\t\t\tlow = mid + 1;\n\t\t} else {\n\t\t\thigh = mid;\n\t\t}\n\t}\n\treturn low;\n}\n\n/**\n * @param {NodeEx} target\n * @returns {void}\n */\nfunction init_hydrate(target) {\n\tif (target.hydrate_init) return;\n\ttarget.hydrate_init = true;\n\t// We know that all children have claim_order values since the unclaimed have been detached if target is not <head>\n\n\tlet children = /** @type {ArrayLike<NodeEx2>} */ (target.childNodes);\n\t// If target is <head>, there may be children without claim_order\n\tif (target.nodeName === 'HEAD') {\n\t\tconst my_children = [];\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst node = children[i];\n\t\t\tif (node.claim_order !== undefined) {\n\t\t\t\tmy_children.push(node);\n\t\t\t}\n\t\t}\n\t\tchildren = my_children;\n\t}\n\t/*\n\t * Reorder claimed children optimally.\n\t * We can reorder claimed children optimally by finding the longest subsequence of\n\t * nodes that are already claimed in order and only moving the rest. The longest\n\t * subsequence of nodes that are claimed in order can be found by\n\t * computing the longest increasing subsequence of .claim_order values.\n\t *\n\t * This algorithm is optimal in generating the least amount of reorder operations\n\t * possible.\n\t *\n\t * Proof:\n\t * We know that, given a set of reordering operations, the nodes that do not move\n\t * always form an increasing subsequence, since they do not move among each other\n\t * meaning that they must be already ordered among each other. Thus, the maximal\n\t * set of nodes that do not move form a longest increasing subsequence.\n\t */\n\t// Compute longest increasing subsequence\n\t// m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n\tconst m = new Int32Array(children.length + 1);\n\t// Predecessor indices + 1\n\tconst p = new Int32Array(children.length);\n\tm[0] = -1;\n\tlet longest = 0;\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst current = children[i].claim_order;\n\t\t// Find the largest subsequence length such that it ends in a value less than our current value\n\t\t// upper_bound returns first greater value, so we subtract one\n\t\t// with fast path for when we are on the current longest subsequence\n\t\tconst seq_len =\n\t\t\t(longest > 0 && children[m[longest]].claim_order <= current\n\t\t\t\t? longest + 1\n\t\t\t\t: upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1;\n\t\tp[i] = m[seq_len] + 1;\n\t\tconst new_len = seq_len + 1;\n\t\t// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n\t\tm[new_len] = i;\n\t\tlongest = Math.max(new_len, longest);\n\t}\n\t// The longest increasing subsequence of nodes (initially reversed)\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst lis = [];\n\t// The rest of the nodes, nodes that will be moved\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst to_move = [];\n\tlet last = children.length - 1;\n\tfor (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n\t\tlis.push(children[cur - 1]);\n\t\tfor (; last >= cur; last--) {\n\t\t\tto_move.push(children[last]);\n\t\t}\n\t\tlast--;\n\t}\n\tfor (; last >= 0; last--) {\n\t\tto_move.push(children[last]);\n\t}\n\tlis.reverse();\n\t// We sort the nodes being moved to guarantee that their insertion order matches the claim order\n\tto_move.sort((a, b) => a.claim_order - b.claim_order);\n\t// Finally, we move the nodes\n\tfor (let i = 0, j = 0; i < to_move.length; i++) {\n\t\twhile (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) {\n\t\t\tj++;\n\t\t}\n\t\tconst anchor = j < lis.length ? lis[j] : null;\n\t\ttarget.insertBefore(to_move[i], anchor);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @returns {void}\n */\nexport function append(target, node) {\n\ttarget.appendChild(node);\n}\n\n/**\n * @param {Node} target\n * @param {string} style_sheet_id\n * @param {string} styles\n * @returns {void}\n */\nexport function append_styles(target, style_sheet_id, styles) {\n\tconst append_styles_to = get_root_for_style(target);\n\tif (!append_styles_to.getElementById(style_sheet_id)) {\n\t\tconst style = element('style');\n\t\tstyle.id = style_sheet_id;\n\t\tstyle.textContent = styles;\n\t\tappend_stylesheet(append_styles_to, style);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {ShadowRoot | Document}\n */\nexport function get_root_for_style(node) {\n\tif (!node) return document;\n\tconst root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n\tif (root && /** @type {ShadowRoot} */ (root).host) {\n\t\treturn /** @type {ShadowRoot} */ (root);\n\t}\n\treturn node.ownerDocument;\n}\n\n/**\n * @param {Node} node\n * @returns {CSSStyleSheet}\n */\nexport function append_empty_stylesheet(node) {\n\tconst style_element = element('style');\n\t// For transitions to work without 'style-src: unsafe-inline' Content Security Policy,\n\t// these empty tags need to be allowed with a hash as a workaround until we move to the Web Animations API.\n\t// Using the hash for the empty string (for an empty tag) works in all browsers except Safari.\n\t// So as a workaround for the workaround, when we append empty style tags we set their content to /* empty */.\n\t// The hash 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=' will then work even in Safari.\n\tstyle_element.textContent = '/* empty */';\n\tappend_stylesheet(get_root_for_style(node), style_element);\n\treturn style_element.sheet;\n}\n\n/**\n * @param {ShadowRoot | Document} node\n * @param {HTMLStyleElement} style\n * @returns {CSSStyleSheet}\n */\nfunction append_stylesheet(node, style) {\n\tappend(/** @type {Document} */ (node).head || node, style);\n\treturn style.sheet;\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @returns {void}\n */\nexport function append_hydration(target, node) {\n\tif (is_hydrating) {\n\t\tinit_hydrate(target);\n\t\tif (\n\t\t\ttarget.actual_end_child === undefined ||\n\t\t\t(target.actual_end_child !== null && target.actual_end_child.parentNode !== target)\n\t\t) {\n\t\t\ttarget.actual_end_child = target.firstChild;\n\t\t}\n\t\t// Skip nodes of undefined ordering\n\t\twhile (target.actual_end_child !== null && target.actual_end_child.claim_order === undefined) {\n\t\t\ttarget.actual_end_child = target.actual_end_child.nextSibling;\n\t\t}\n\t\tif (node !== target.actual_end_child) {\n\t\t\t// We only insert if the ordering of this node should be modified or the parent node is not target\n\t\t\tif (node.claim_order !== undefined || node.parentNode !== target) {\n\t\t\t\ttarget.insertBefore(node, target.actual_end_child);\n\t\t\t}\n\t\t} else {\n\t\t\ttarget.actual_end_child = node.nextSibling;\n\t\t}\n\t} else if (node.parentNode !== target || node.nextSibling !== null) {\n\t\ttarget.appendChild(node);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @param {Node} [anchor]\n * @returns {void}\n */\nexport function insert(target, node, anchor) {\n\ttarget.insertBefore(node, anchor || null);\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @param {NodeEx} [anchor]\n * @returns {void}\n */\nexport function insert_hydration(target, node, anchor) {\n\tif (is_hydrating && !anchor) {\n\t\tappend_hydration(target, node);\n\t} else if (node.parentNode !== target || node.nextSibling != anchor) {\n\t\ttarget.insertBefore(node, anchor || null);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {void}\n */\nexport function detach(node) {\n\tif (node.parentNode) {\n\t\tnode.parentNode.removeChild(node);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function destroy_each(iterations, detaching) {\n\tfor (let i = 0; i < iterations.length; i += 1) {\n\t\tif (iterations[i]) iterations[i].d(detaching);\n\t}\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element(name) {\n\treturn document.createElement(name);\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @param {string} is\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element_is(name, is) {\n\treturn document.createElement(name, { is });\n}\n\n/**\n * @template T\n * @template {keyof T} K\n * @param {T} obj\n * @param {K[]} exclude\n * @returns {Pick<T, Exclude<keyof T, K>>}\n */\nexport function object_without_properties(obj, exclude) {\n\tconst target = /** @type {Pick<T, Exclude<keyof T, K>>} */ ({});\n\tfor (const k in obj) {\n\t\tif (\n\t\t\thas_prop(obj, k) &&\n\t\t\t// @ts-ignore\n\t\t\texclude.indexOf(k) === -1\n\t\t) {\n\t\t\t// @ts-ignore\n\t\t\ttarget[k] = obj[k];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * @template {keyof SVGElementTagNameMap} K\n * @param {K} name\n * @returns {SVGElement}\n */\nexport function svg_element(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\n/**\n * @param {string} data\n * @returns {Text}\n */\nexport function text(data) {\n\treturn document.createTextNode(data);\n}\n\n/**\n * @returns {Text} */\nexport function space() {\n\treturn text(' ');\n}\n\n/**\n * @returns {Text} */\nexport function empty() {\n\treturn text('');\n}\n\n/**\n * @param {string} content\n * @returns {Comment}\n */\nexport function comment(content) {\n\treturn document.createComment(content);\n}\n\n/**\n * @param {EventTarget} node\n * @param {string} event\n * @param {EventListenerOrEventListenerObject} handler\n * @param {boolean | AddEventListenerOptions | EventListenerOptions} [options]\n * @returns {() => void}\n */\nexport function listen(node, event, handler, options) {\n\tnode.addEventListener(event, handler, options);\n\treturn () => node.removeEventListener(event, handler, options);\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function prevent_default(fn) {\n\treturn function (event) {\n\t\tevent.preventDefault();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopPropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_immediate_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopImmediatePropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function self(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.target === this) fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function trusted(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.isTrusted) fn.call(this, event);\n\t};\n}\n\n/**\n * @param {Element} node\n * @param {string} attribute\n * @param {string} [value]\n * @returns {void}\n */\nexport function attr(node, attribute, value) {\n\tif (value == null) node.removeAttribute(attribute);\n\telse if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_attributes(node, attributes) {\n\t// @ts-ignore\n\tconst descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n\tfor (const key in attributes) {\n\t\tif (attributes[key] == null) {\n\t\t\tnode.removeAttribute(key);\n\t\t} else if (key === 'style') {\n\t\t\tnode.style.cssText = attributes[key];\n\t\t} else if (key === '__value') {\n\t\t\t/** @type {any} */ (node).value = node[key] = attributes[key];\n\t\t} else if (\n\t\t\tdescriptors[key] &&\n\t\t\tdescriptors[key].set &&\n\t\t\talways_set_through_set_attribute.indexOf(key) === -1\n\t\t) {\n\t\t\tnode[key] = attributes[key];\n\t\t} else {\n\t\t\tattr(node, key, attributes[key]);\n\t\t}\n\t}\n}\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_svg_attributes(node, attributes) {\n\tfor (const key in attributes) {\n\t\tattr(node, key, attributes[key]);\n\t}\n}\n\n/**\n * @param {Record<string, unknown>} data_map\n * @returns {void}\n */\nexport function set_custom_element_data_map(node, data_map) {\n\tObject.keys(data_map).forEach((key) => {\n\t\tset_custom_element_data(node, key, data_map[key]);\n\t});\n}\n\n/**\n * @returns {void} */\nexport function set_custom_element_data(node, prop, value) {\n\tconst lower = prop.toLowerCase(); // for backwards compatibility with existing behavior we do lowercase first\n\tif (lower in node) {\n\t\tnode[lower] = typeof node[lower] === 'boolean' && value === '' ? true : value;\n\t} else if (prop in node) {\n\t\tnode[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n\t} else {\n\t\tattr(node, prop, value);\n\t}\n}\n\n/**\n * @param {string} tag\n */\nexport function set_dynamic_element_data(tag) {\n\treturn /-/.test(tag) ? set_custom_element_data_map : set_attributes;\n}\n\n/**\n * @returns {void}\n */\nexport function xlink_attr(node, attribute, value) {\n\tnode.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\n\n/**\n * @param {HTMLElement} node\n * @returns {string}\n */\nexport function get_svelte_dataset(node) {\n\treturn node.dataset.svelteH;\n}\n\n/**\n * @returns {unknown[]} */\nexport function get_binding_group_value(group, __value, checked) {\n\tconst value = new Set();\n\tfor (let i = 0; i < group.length; i += 1) {\n\t\tif (group[i].checked) value.add(group[i].__value);\n\t}\n\tif (!checked) {\n\t\tvalue.delete(__value);\n\t}\n\treturn Array.from(value);\n}\n\n/**\n * @param {HTMLInputElement[]} group\n * @returns {{ p(...inputs: HTMLInputElement[]): void; r(): void; }}\n */\nexport function init_binding_group(group) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\treturn {\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\t_inputs.forEach((input) => group.push(input));\n\t\t},\n\t\t/* remove */ r() {\n\t\t\t_inputs.forEach((input) => group.splice(group.indexOf(input), 1));\n\t\t}\n\t};\n}\n\n/**\n * @param {number[]} indexes\n * @returns {{ u(new_indexes: number[]): void; p(...inputs: HTMLInputElement[]): void; r: () => void; }}\n */\nexport function init_binding_group_dynamic(group, indexes) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _group = get_binding_group(group);\n\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\n\tfunction get_binding_group(group) {\n\t\tfor (let i = 0; i < indexes.length; i++) {\n\t\t\tgroup = group[indexes[i]] = group[indexes[i]] || [];\n\t\t}\n\t\treturn group;\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction push() {\n\t\t_inputs.forEach((input) => _group.push(input));\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction remove() {\n\t\t_inputs.forEach((input) => _group.splice(_group.indexOf(input), 1));\n\t}\n\treturn {\n\t\t/* update */ u(new_indexes) {\n\t\t\tindexes = new_indexes;\n\t\t\tconst new_group = get_binding_group(group);\n\t\t\tif (new_group !== _group) {\n\t\t\t\tremove();\n\t\t\t\t_group = new_group;\n\t\t\t\tpush();\n\t\t\t}\n\t\t},\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\tpush();\n\t\t},\n\t\t/* remove */ r: remove\n\t};\n}\n\n/** @returns {number} */\nexport function to_number(value) {\n\treturn value === '' ? null : +value;\n}\n\n/** @returns {any[]} */\nexport function time_ranges_to_array(ranges) {\n\tconst array = [];\n\tfor (let i = 0; i < ranges.length; i += 1) {\n\t\tarray.push({ start: ranges.start(i), end: ranges.end(i) });\n\t}\n\treturn array;\n}\n\n/**\n * @param {Element} element\n * @returns {ChildNode[]}\n */\nexport function children(element) {\n\treturn Array.from(element.childNodes);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {void}\n */\nfunction init_claim_info(nodes) {\n\tif (nodes.claim_info === undefined) {\n\t\tnodes.claim_info = { last_index: 0, total_claimed: 0 };\n\t}\n}\n\n/**\n * @template {ChildNodeEx} R\n * @param {ChildNodeArray} nodes\n * @param {(node: ChildNodeEx) => node is R} predicate\n * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node\n * @param {() => R} create_node\n * @param {boolean} dont_update_last_index\n * @returns {R}\n */\nfunction claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {\n\t// Try to find nodes in an order such that we lengthen the longest increasing subsequence\n\tinit_claim_info(nodes);\n\tconst result_node = (() => {\n\t\t// We first try to find an element after the previous one\n\t\tfor (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// Otherwise, we try to find one before\n\t\t// We iterate in reverse so that we don't go too far back\n\t\tfor (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t} else if (replacement === undefined) {\n\t\t\t\t\t// Since we spliced before the last_index, we decrease it\n\t\t\t\t\tnodes.claim_info.last_index--;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// If we can't find any matching node, we create a new one\n\t\treturn create_node();\n\t})();\n\tresult_node.claim_order = nodes.claim_info.total_claimed;\n\tnodes.claim_info.total_claimed += 1;\n\treturn result_node;\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @param {(name: string) => Element | SVGElement} create_element\n * @returns {Element | SVGElement}\n */\nfunction claim_element_base(nodes, name, attributes, create_element) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Element | SVGElement} */\n\t\t(node) => node.nodeName === name,\n\t\t/** @param {Element} node */\n\t\t(node) => {\n\t\t\tconst remove = [];\n\t\t\tfor (let j = 0; j < node.attributes.length; j++) {\n\t\t\t\tconst attribute = node.attributes[j];\n\t\t\t\tif (!attributes[attribute.name]) {\n\t\t\t\t\tremove.push(attribute.name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tremove.forEach((v) => node.removeAttribute(v));\n\t\t\treturn undefined;\n\t\t},\n\t\t() => create_element(name)\n\t);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_svg_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, svg_element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Text}\n */\nexport function claim_text(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Text} */\n\t\t(node) => node.nodeType === 3,\n\t\t/** @param {Text} node */\n\t\t(node) => {\n\t\t\tconst data_str = '' + data;\n\t\t\tif (node.data.startsWith(data_str)) {\n\t\t\t\tif (node.data.length !== data_str.length) {\n\t\t\t\t\treturn node.splitText(data_str.length);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnode.data = data_str;\n\t\t\t}\n\t\t},\n\t\t() => text(data),\n\t\ttrue // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n\t);\n}\n\n/**\n * @returns {Text} */\nexport function claim_space(nodes) {\n\treturn claim_text(nodes, ' ');\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Comment}\n */\nexport function claim_comment(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Comment} */\n\t\t(node) => node.nodeType === 8,\n\t\t/** @param {Comment} node */\n\t\t(node) => {\n\t\t\tnode.data = '' + data;\n\t\t\treturn undefined;\n\t\t},\n\t\t() => comment(data),\n\t\ttrue\n\t);\n}\n\nfunction get_comment_idx(nodes, text, start) {\n\tfor (let i = start; i < nodes.length; i += 1) {\n\t\tconst node = nodes[i];\n\t\tif (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n * @param {boolean} is_svg\n * @returns {HtmlTagHydration}\n */\nexport function claim_html_tag(nodes, is_svg) {\n\t// find html opening tag\n\tconst start_index = get_comment_idx(nodes, 'HTML_TAG_START', 0);\n\tconst end_index = get_comment_idx(nodes, 'HTML_TAG_END', start_index + 1);\n\tif (start_index === -1 || end_index === -1) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\n\tinit_claim_info(nodes);\n\tconst html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n\tdetach(html_tag_nodes[0]);\n\tdetach(html_tag_nodes[html_tag_nodes.length - 1]);\n\tconst claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n\tif (claimed_nodes.length === 0) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\tfor (const n of claimed_nodes) {\n\t\tn.claim_order = nodes.claim_info.total_claimed;\n\t\tnodes.claim_info.total_claimed += 1;\n\t}\n\treturn new HtmlTagHydration(is_svg, claimed_nodes);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data(text, data) {\n\tdata = '' + data;\n\tif (text.data === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data_contenteditable(text, data) {\n\tdata = '' + data;\n\tif (text.wholeText === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @param {string} attr_value\n * @returns {void}\n */\nexport function set_data_maybe_contenteditable(text, data, attr_value) {\n\tif (~contenteditable_truthy_values.indexOf(attr_value)) {\n\t\tset_data_contenteditable(text, data);\n\t} else {\n\t\tset_data(text, data);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_input_value(input, value) {\n\tinput.value = value == null ? '' : value;\n}\n\n/**\n * @returns {void} */\nexport function set_input_type(input, type) {\n\ttry {\n\t\tinput.type = type;\n\t} catch (e) {\n\t\t// do nothing\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_style(node, key, value, important) {\n\tif (value == null) {\n\t\tnode.style.removeProperty(key);\n\t} else {\n\t\tnode.style.setProperty(key, value, important ? 'important' : '');\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_option(select, value, mounting) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\tif (option.__value === value) {\n\t\t\toption.selected = true;\n\t\t\treturn;\n\t\t}\n\t}\n\tif (!mounting || value !== undefined) {\n\t\tselect.selectedIndex = -1; // no option should be selected\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_options(select, value) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\toption.selected = ~value.indexOf(option.__value);\n\t}\n}\n\nexport function select_value(select) {\n\tconst selected_option = select.querySelector(':checked');\n\treturn selected_option && selected_option.__value;\n}\n\nexport function select_multiple_value(select) {\n\treturn [].map.call(select.querySelectorAll(':checked'), (option) => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\n\n/**\n * @type {boolean} */\nlet crossorigin;\n\n/**\n * @returns {boolean} */\nexport function is_crossorigin() {\n\tif (crossorigin === undefined) {\n\t\tcrossorigin = false;\n\t\ttry {\n\t\t\tif (typeof window !== 'undefined' && window.parent) {\n\t\t\t\tvoid window.parent.document;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tcrossorigin = true;\n\t\t}\n\t}\n\treturn crossorigin;\n}\n\n/**\n * @param {HTMLElement} node\n * @param {() => void} fn\n * @returns {() => void}\n */\nexport function add_iframe_resize_listener(node, fn) {\n\tconst computed_style = getComputedStyle(node);\n\tif (computed_style.position === 'static') {\n\t\tnode.style.position = 'relative';\n\t}\n\tconst iframe = element('iframe');\n\tiframe.setAttribute(\n\t\t'style',\n\t\t'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n\t\t\t'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;'\n\t);\n\tiframe.setAttribute('aria-hidden', 'true');\n\tiframe.tabIndex = -1;\n\tconst crossorigin = is_crossorigin();\n\n\t/**\n\t * @type {() => void}\n\t */\n\tlet unsubscribe;\n\tif (crossorigin) {\n\t\tiframe.src = \"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>\";\n\t\tunsubscribe = listen(\n\t\t\twindow,\n\t\t\t'message',\n\t\t\t/** @param {MessageEvent} event */ (event) => {\n\t\t\t\tif (event.source === iframe.contentWindow) fn();\n\t\t\t}\n\t\t);\n\t} else {\n\t\tiframe.src = 'about:blank';\n\t\tiframe.onload = () => {\n\t\t\tunsubscribe = listen(iframe.contentWindow, 'resize', fn);\n\t\t\t// make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n\t\t\t// see https://github.com/sveltejs/svelte/issues/4233\n\t\t\tfn();\n\t\t};\n\t}\n\tappend(node, iframe);\n\treturn () => {\n\t\tif (crossorigin) {\n\t\t\tunsubscribe();\n\t\t} else if (unsubscribe && iframe.contentWindow) {\n\t\t\tunsubscribe();\n\t\t}\n\t\tdetach(iframe);\n\t};\n}\nexport const resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'content-box'\n});\nexport const resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'border-box'\n});\nexport const resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton(\n\t{ box: 'device-pixel-content-box' }\n);\nexport { ResizeObserverSingleton };\n\n/**\n * @returns {void} */\nexport function toggle_class(element, name, toggle) {\n\t// The `!!` is required because an `undefined` flag means flipping the current state.\n\telement.classList.toggle(name, !!toggle);\n}\n\n/**\n * @template T\n * @param {string} type\n * @param {T} [detail]\n * @param {{ bubbles?: boolean, cancelable?: boolean }} [options]\n * @returns {CustomEvent<T>}\n */\nexport function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n\treturn new CustomEvent(type, { detail, bubbles, cancelable });\n}\n\n/**\n * @param {string} selector\n * @param {HTMLElement} parent\n * @returns {ChildNodeArray}\n */\nexport function query_selector_all(selector, parent = document.body) {\n\treturn Array.from(parent.querySelectorAll(selector));\n}\n\n/**\n * @param {string} nodeId\n * @param {HTMLElement} head\n * @returns {any[]}\n */\nexport function head_selector(nodeId, head) {\n\tconst result = [];\n\tlet started = 0;\n\tfor (const node of head.childNodes) {\n\t\tif (node.nodeType === 8 /* comment node */) {\n\t\t\tconst comment = node.textContent.trim();\n\t\t\tif (comment === `HEAD_${nodeId}_END`) {\n\t\t\t\tstarted -= 1;\n\t\t\t\tresult.push(node);\n\t\t\t} else if (comment === `HEAD_${nodeId}_START`) {\n\t\t\t\tstarted += 1;\n\t\t\t\tresult.push(node);\n\t\t\t}\n\t\t} else if (started > 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\treturn result;\n}\n/** */\nexport class HtmlTag {\n\t/**\n\t * @private\n\t * @default false\n\t */\n\tis_svg = false;\n\t/** parent for creating node */\n\te = undefined;\n\t/** html tag nodes */\n\tn = undefined;\n\t/** target */\n\tt = undefined;\n\t/** anchor */\n\ta = undefined;\n\tconstructor(is_svg = false) {\n\t\tthis.is_svg = is_svg;\n\t\tthis.e = this.n = null;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tthis.h(html);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @param {HTMLElement | SVGElement} target\n\t * @param {HTMLElement | SVGElement} anchor\n\t * @returns {void}\n\t */\n\tm(html, target, anchor = null) {\n\t\tif (!this.e) {\n\t\t\tif (this.is_svg)\n\t\t\t\tthis.e = svg_element(/** @type {keyof SVGElementTagNameMap} */ (target.nodeName));\n\t\t\t/** #7364  target for <template> may be provided as #document-fragment(11) */ else\n\t\t\t\tthis.e = element(\n\t\t\t\t\t/** @type {keyof HTMLElementTagNameMap} */ (\n\t\t\t\t\t\ttarget.nodeType === 11 ? 'TEMPLATE' : target.nodeName\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\tthis.t =\n\t\t\t\ttarget.tagName !== 'TEMPLATE'\n\t\t\t\t\t? target\n\t\t\t\t\t: /** @type {HTMLTemplateElement} */ (target).content;\n\t\t\tthis.c(html);\n\t\t}\n\t\tthis.i(anchor);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\th(html) {\n\t\tthis.e.innerHTML = html;\n\t\tthis.n = Array.from(\n\t\t\tthis.e.nodeName === 'TEMPLATE' ? this.e.content.childNodes : this.e.childNodes\n\t\t);\n\t}\n\n\t/**\n\t * @returns {void} */\n\ti(anchor) {\n\t\tfor (let i = 0; i < this.n.length; i += 1) {\n\t\t\tinsert(this.t, this.n[i], anchor);\n\t\t}\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tp(html) {\n\t\tthis.d();\n\t\tthis.h(html);\n\t\tthis.i(this.a);\n\t}\n\n\t/**\n\t * @returns {void} */\n\td() {\n\t\tthis.n.forEach(detach);\n\t}\n}\n\nexport class HtmlTagHydration extends HtmlTag {\n\t/** @type {Element[]} hydration claimed nodes */\n\tl = undefined;\n\n\tconstructor(is_svg = false, claimed_nodes) {\n\t\tsuper(is_svg);\n\t\tthis.e = this.n = null;\n\t\tthis.l = claimed_nodes;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tif (this.l) {\n\t\t\tthis.n = this.l;\n\t\t} else {\n\t\t\tsuper.c(html);\n\t\t}\n\t}\n\n\t/**\n\t * @returns {void} */\n\ti(anchor) {\n\t\tfor (let i = 0; i < this.n.length; i += 1) {\n\t\t\tinsert_hydration(this.t, this.n[i], anchor);\n\t\t}\n\t}\n}\n\n/**\n * @param {NamedNodeMap} attributes\n * @returns {{}}\n */\nexport function attribute_to_object(attributes) {\n\tconst result = {};\n\tfor (const attribute of attributes) {\n\t\tresult[attribute.name] = attribute.value;\n\t}\n\treturn result;\n}\n\nconst escaped = {\n\t'\"': '&quot;',\n\t'&': '&amp;',\n\t'<': '&lt;'\n};\n\nconst regex_attribute_characters_to_escape = /[\"&<]/g;\n\n/**\n * Note that the attribute itself should be surrounded in double quotes\n * @param {any} attribute\n */\nfunction escape_attribute(attribute) {\n\treturn String(attribute).replace(regex_attribute_characters_to_escape, (match) => escaped[match]);\n}\n\n/**\n * @param {Record<string, string>} attributes\n */\nexport function stringify_spread(attributes) {\n\tlet str = ' ';\n\tfor (const key in attributes) {\n\t\tif (attributes[key] != null) {\n\t\t\tstr += `${key}=\"${escape_attribute(attributes[key])}\" `;\n\t\t}\n\t}\n\n\treturn str;\n}\n\n/**\n * @param {HTMLElement} element\n * @returns {{}}\n */\nexport function get_custom_elements_slots(element) {\n\tconst result = {};\n\telement.childNodes.forEach(\n\t\t/** @param {Element} node */ (node) => {\n\t\t\tresult[node.slot || 'default'] = true;\n\t\t}\n\t);\n\treturn result;\n}\n\nexport function construct_svelte_component(component, props) {\n\treturn new component(props);\n}\n\n/**\n * @typedef {Node & {\n * \tclaim_order?: number;\n * \thydrate_init?: true;\n * \tactual_end_child?: NodeEx;\n * \tchildNodes: NodeListOf<NodeEx>;\n * }} NodeEx\n */\n\n/** @typedef {ChildNode & NodeEx} ChildNodeEx */\n\n/** @typedef {NodeEx & { claim_order: number }} NodeEx2 */\n\n/**\n * @typedef {ChildNodeEx[] & {\n * \tclaim_info?: {\n * \t\tlast_index: number;\n * \t\ttotal_claimed: number;\n * \t};\n * }} ChildNodeArray\n */\n","import { custom_event } from './dom.js';\n\nexport let current_component;\n\n/** @returns {void} */\nexport function set_current_component(component) {\n\tcurrent_component = component;\n}\n\nexport function get_current_component() {\n\tif (!current_component) throw new Error('Function called outside component initialization');\n\treturn current_component;\n}\n\n/**\n * Schedules a callback to run immediately before the component is updated after any state change.\n *\n * The first time the callback runs will be before the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#beforeupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function beforeUpdate(fn) {\n\tget_current_component().$$.before_update.push(fn);\n}\n\n/**\n * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.\n * It must be called during the component's initialisation (but doesn't need to live *inside* the component;\n * it can be called from an external module).\n *\n * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.\n *\n * `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api).\n *\n * https://svelte.dev/docs/svelte#onmount\n * @template T\n * @param {() => import('./private.js').NotFunction<T> | Promise<import('./private.js').NotFunction<T>> | (() => any)} fn\n * @returns {void}\n */\nexport function onMount(fn) {\n\tget_current_component().$$.on_mount.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately after the component has been updated.\n *\n * The first time the callback runs will be after the initial `onMount`\n *\n * https://svelte.dev/docs/svelte#afterupdate\n * @param {() => any} fn\n * @returns {void}\n */\nexport function afterUpdate(fn) {\n\tget_current_component().$$.after_update.push(fn);\n}\n\n/**\n * Schedules a callback to run immediately before the component is unmounted.\n *\n * Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the\n * only one that runs inside a server-side component.\n *\n * https://svelte.dev/docs/svelte#ondestroy\n * @param {() => any} fn\n * @returns {void}\n */\nexport function onDestroy(fn) {\n\tget_current_component().$$.on_destroy.push(fn);\n}\n\n/**\n * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname).\n * Event dispatchers are functions that can take two arguments: `name` and `detail`.\n *\n * Component events created with `createEventDispatcher` create a\n * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).\n * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).\n * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)\n * property and can contain any type of data.\n *\n * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:\n * ```ts\n * const dispatch = createEventDispatcher<{\n *  loaded: never; // does not take a detail argument\n *  change: string; // takes a detail argument of type string, which is required\n *  optional: number | null; // takes an optional detail argument of type number\n * }>();\n * ```\n *\n * https://svelte.dev/docs/svelte#createeventdispatcher\n * @template {Record<string, any>} [EventMap=any]\n * @returns {import('./public.js').EventDispatcher<EventMap>}\n */\nexport function createEventDispatcher() {\n\tconst component = get_current_component();\n\treturn (type, detail, { cancelable = false } = {}) => {\n\t\tconst callbacks = component.$$.callbacks[type];\n\t\tif (callbacks) {\n\t\t\t// TODO are there situations where events could be dispatched\n\t\t\t// in a server (non-DOM) environment?\n\t\t\tconst event = custom_event(/** @type {string} */ (type), detail, { cancelable });\n\t\t\tcallbacks.slice().forEach((fn) => {\n\t\t\t\tfn.call(component, event);\n\t\t\t});\n\t\t\treturn !event.defaultPrevented;\n\t\t}\n\t\treturn true;\n\t};\n}\n\n/**\n * Associates an arbitrary `context` object with the current component and the specified `key`\n * and returns that object. The context is then available to children of the component\n * (including slotted content) with `getContext`.\n *\n * Like lifecycle functions, this must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#setcontext\n * @template T\n * @param {any} key\n * @param {T} context\n * @returns {T}\n */\nexport function setContext(key, context) {\n\tget_current_component().$$.context.set(key, context);\n\treturn context;\n}\n\n/**\n * Retrieves the context that belongs to the closest parent component with the specified `key`.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#getcontext\n * @template T\n * @param {any} key\n * @returns {T}\n */\nexport function getContext(key) {\n\treturn get_current_component().$$.context.get(key);\n}\n\n/**\n * Retrieves the whole context map that belongs to the closest parent component.\n * Must be called during component initialisation. Useful, for example, if you\n * programmatically create a component and want to pass the existing context to it.\n *\n * https://svelte.dev/docs/svelte#getallcontexts\n * @template {Map<any, any>} [T=Map<any, any>]\n * @returns {T}\n */\nexport function getAllContexts() {\n\treturn get_current_component().$$.context;\n}\n\n/**\n * Checks whether a given `key` has been set in the context of a parent component.\n * Must be called during component initialisation.\n *\n * https://svelte.dev/docs/svelte#hascontext\n * @param {any} key\n * @returns {boolean}\n */\nexport function hasContext(key) {\n\treturn get_current_component().$$.context.has(key);\n}\n\n// TODO figure out if we still want to support\n// shorthand events, or if we want to implement\n// a real bubbling mechanism\n/**\n * @param component\n * @param event\n * @returns {void}\n */\nexport function bubble(component, event) {\n\tconst callbacks = component.$$.callbacks[event.type];\n\tif (callbacks) {\n\t\t// @ts-ignore\n\t\tcallbacks.slice().forEach((fn) => fn.call(this, event));\n\t}\n}\n","const _boolean_attributes = /** @type {const} */ ([\n\t'allowfullscreen',\n\t'allowpaymentrequest',\n\t'async',\n\t'autofocus',\n\t'autoplay',\n\t'checked',\n\t'controls',\n\t'default',\n\t'defer',\n\t'disabled',\n\t'formnovalidate',\n\t'hidden',\n\t'inert',\n\t'ismap',\n\t'loop',\n\t'multiple',\n\t'muted',\n\t'nomodule',\n\t'novalidate',\n\t'open',\n\t'playsinline',\n\t'readonly',\n\t'required',\n\t'reversed',\n\t'selected'\n]);\n\n/**\n * List of HTML boolean attributes (e.g. `<input disabled>`).\n * Source: https://html.spec.whatwg.org/multipage/indices.html\n *\n * @type {Set<string>}\n */\nexport const boolean_attributes = new Set([..._boolean_attributes]);\n\n/** @typedef {typeof _boolean_attributes[number]} BooleanAttributes */\n","import {\n\tadd_render_callback,\n\tflush,\n\tflush_render_callbacks,\n\tschedule_update,\n\tdirty_components\n} from './scheduler.js';\nimport { current_component, set_current_component } from './lifecycle.js';\nimport { blank_object, is_empty, is_function, run, run_all, noop } from './utils.js';\nimport {\n\tchildren,\n\tdetach,\n\tstart_hydrating,\n\tend_hydrating,\n\tget_custom_elements_slots,\n\tinsert,\n\telement,\n\tattr\n} from './dom.js';\nimport { transition_in } from './transitions.js';\n\n/** @returns {void} */\nexport function bind(component, name, callback) {\n\tconst index = component.$$.props[name];\n\tif (index !== undefined) {\n\t\tcomponent.$$.bound[index] = callback;\n\t\tcallback(component.$$.ctx[index]);\n\t}\n}\n\n/** @returns {void} */\nexport function create_component(block) {\n\tblock && block.c();\n}\n\n/** @returns {void} */\nexport function claim_component(block, parent_nodes) {\n\tblock && block.l(parent_nodes);\n}\n\n/** @returns {void} */\nexport function mount_component(component, target, anchor) {\n\tconst { fragment, after_update } = component.$$;\n\tfragment && fragment.m(target, anchor);\n\t// onMount happens before the initial afterUpdate\n\tadd_render_callback(() => {\n\t\tconst new_on_destroy = component.$$.on_mount.map(run).filter(is_function);\n\t\t// if the component was destroyed immediately\n\t\t// it will update the `$$.on_destroy` reference to `null`.\n\t\t// the destructured on_destroy may still reference to the old array\n\t\tif (component.$$.on_destroy) {\n\t\t\tcomponent.$$.on_destroy.push(...new_on_destroy);\n\t\t} else {\n\t\t\t// Edge case - component was destroyed immediately,\n\t\t\t// most likely as a result of a binding initialising\n\t\t\trun_all(new_on_destroy);\n\t\t}\n\t\tcomponent.$$.on_mount = [];\n\t});\n\tafter_update.forEach(add_render_callback);\n}\n\n/** @returns {void} */\nexport function destroy_component(component, detaching) {\n\tconst $$ = component.$$;\n\tif ($$.fragment !== null) {\n\t\tflush_render_callbacks($$.after_update);\n\t\trun_all($$.on_destroy);\n\t\t$$.fragment && $$.fragment.d(detaching);\n\t\t// TODO null out other refs, including component.$$ (but need to\n\t\t// preserve final state?)\n\t\t$$.on_destroy = $$.fragment = null;\n\t\t$$.ctx = [];\n\t}\n}\n\n/** @returns {void} */\nfunction make_dirty(component, i) {\n\tif (component.$$.dirty[0] === -1) {\n\t\tdirty_components.push(component);\n\t\tschedule_update();\n\t\tcomponent.$$.dirty.fill(0);\n\t}\n\tcomponent.$$.dirty[(i / 31) | 0] |= 1 << i % 31;\n}\n\n// TODO: Document the other params\n/**\n * @param {SvelteComponent} component\n * @param {import('./public.js').ComponentConstructorOptions} options\n *\n * @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values.\n * @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised.\n * This will be the `add_css` function from the compiled component.\n *\n * @returns {void}\n */\nexport function init(\n\tcomponent,\n\toptions,\n\tinstance,\n\tcreate_fragment,\n\tnot_equal,\n\tprops,\n\tappend_styles = null,\n\tdirty = [-1]\n) {\n\tconst parent_component = current_component;\n\tset_current_component(component);\n\t/** @type {import('./private.js').T$$} */\n\tconst $$ = (component.$$ = {\n\t\tfragment: null,\n\t\tctx: [],\n\t\t// state\n\t\tprops,\n\t\tupdate: noop,\n\t\tnot_equal,\n\t\tbound: blank_object(),\n\t\t// lifecycle\n\t\ton_mount: [],\n\t\ton_destroy: [],\n\t\ton_disconnect: [],\n\t\tbefore_update: [],\n\t\tafter_update: [],\n\t\tcontext: new Map(options.context || (parent_component ? parent_component.$$.context : [])),\n\t\t// everything else\n\t\tcallbacks: blank_object(),\n\t\tdirty,\n\t\tskip_bound: false,\n\t\troot: options.target || parent_component.$$.root\n\t});\n\tappend_styles && append_styles($$.root);\n\tlet ready = false;\n\t$$.ctx = instance\n\t\t? instance(component, options.props || {}, (i, ret, ...rest) => {\n\t\t\t\tconst value = rest.length ? rest[0] : ret;\n\t\t\t\tif ($$.ctx && not_equal($$.ctx[i], ($$.ctx[i] = value))) {\n\t\t\t\t\tif (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);\n\t\t\t\t\tif (ready) make_dirty(component, i);\n\t\t\t\t}\n\t\t\t\treturn ret;\n\t\t  })\n\t\t: [];\n\t$$.update();\n\tready = true;\n\trun_all($$.before_update);\n\t// `false` as a special case of no DOM component\n\t$$.fragment = create_fragment ? create_fragment($$.ctx) : false;\n\tif (options.target) {\n\t\tif (options.hydrate) {\n\t\t\tstart_hydrating();\n\t\t\t// TODO: what is the correct type here?\n\t\t\t// @ts-expect-error\n\t\t\tconst nodes = children(options.target);\n\t\t\t$$.fragment && $$.fragment.l(nodes);\n\t\t\tnodes.forEach(detach);\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t$$.fragment && $$.fragment.c();\n\t\t}\n\t\tif (options.intro) transition_in(component.$$.fragment);\n\t\tmount_component(component, options.target, options.anchor);\n\t\tend_hydrating();\n\t\tflush();\n\t}\n\tset_current_component(parent_component);\n}\n\nexport let SvelteElement;\n\nif (typeof HTMLElement === 'function') {\n\tSvelteElement = class extends HTMLElement {\n\t\t/** The Svelte component constructor */\n\t\t$$ctor;\n\t\t/** Slots */\n\t\t$$s;\n\t\t/** The Svelte component instance */\n\t\t$$c;\n\t\t/** Whether or not the custom element is connected */\n\t\t$$cn = false;\n\t\t/** Component props data */\n\t\t$$d = {};\n\t\t/** `true` if currently in the process of reflecting component props back to attributes */\n\t\t$$r = false;\n\t\t/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */\n\t\t$$p_d = {};\n\t\t/** @type {Record<string, Function[]>} Event listeners */\n\t\t$$l = {};\n\t\t/** @type {Map<Function, Function>} Event listener unsubscribe functions */\n\t\t$$l_u = new Map();\n\n\t\tconstructor($$componentCtor, $$slots, use_shadow_dom) {\n\t\t\tsuper();\n\t\t\tthis.$$ctor = $$componentCtor;\n\t\t\tthis.$$s = $$slots;\n\t\t\tif (use_shadow_dom) {\n\t\t\t\tthis.attachShadow({ mode: 'open' });\n\t\t\t}\n\t\t}\n\n\t\taddEventListener(type, listener, options) {\n\t\t\t// We can't determine upfront if the event is a custom event or not, so we have to\n\t\t\t// listen to both. If someone uses a custom event with the same name as a regular\n\t\t\t// browser event, this fires twice - we can't avoid that.\n\t\t\tthis.$$l[type] = this.$$l[type] || [];\n\t\t\tthis.$$l[type].push(listener);\n\t\t\tif (this.$$c) {\n\t\t\t\tconst unsub = this.$$c.$on(type, listener);\n\t\t\t\tthis.$$l_u.set(listener, unsub);\n\t\t\t}\n\t\t\tsuper.addEventListener(type, listener, options);\n\t\t}\n\n\t\tremoveEventListener(type, listener, options) {\n\t\t\tsuper.removeEventListener(type, listener, options);\n\t\t\tif (this.$$c) {\n\t\t\t\tconst unsub = this.$$l_u.get(listener);\n\t\t\t\tif (unsub) {\n\t\t\t\t\tunsub();\n\t\t\t\t\tthis.$$l_u.delete(listener);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.$$l[type]) {\n\t\t\t\tconst idx = this.$$l[type].indexOf(listener);\n\t\t\t\tif (idx >= 0) {\n\t\t\t\t\tthis.$$l[type].splice(idx, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tasync connectedCallback() {\n\t\t\tthis.$$cn = true;\n\t\t\tif (!this.$$c) {\n\t\t\t\t// We wait one tick to let possible child slot elements be created/mounted\n\t\t\t\tawait Promise.resolve();\n\t\t\t\tif (!this.$$cn || this.$$c) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfunction create_slot(name) {\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tlet node;\n\t\t\t\t\t\tconst obj = {\n\t\t\t\t\t\t\tc: function create() {\n\t\t\t\t\t\t\t\tnode = element('slot');\n\t\t\t\t\t\t\t\tif (name !== 'default') {\n\t\t\t\t\t\t\t\t\tattr(node, 'name', name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * @param {HTMLElement} target\n\t\t\t\t\t\t\t * @param {HTMLElement} [anchor]\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tm: function mount(target, anchor) {\n\t\t\t\t\t\t\t\tinsert(target, node, anchor);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\td: function destroy(detaching) {\n\t\t\t\t\t\t\t\tif (detaching) {\n\t\t\t\t\t\t\t\t\tdetach(node);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn obj;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst $$slots = {};\n\t\t\t\tconst existing_slots = get_custom_elements_slots(this);\n\t\t\t\tfor (const name of this.$$s) {\n\t\t\t\t\tif (name in existing_slots) {\n\t\t\t\t\t\t$$slots[name] = [create_slot(name)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (const attribute of this.attributes) {\n\t\t\t\t\t// this.$$data takes precedence over this.attributes\n\t\t\t\t\tconst name = this.$$g_p(attribute.name);\n\t\t\t\t\tif (!(name in this.$$d)) {\n\t\t\t\t\t\tthis.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, 'toProp');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Port over props that were set programmatically before ce was initialized\n\t\t\t\tfor (const key in this.$$p_d) {\n\t\t\t\t\tif (!(key in this.$$d) && this[key] !== undefined) {\n\t\t\t\t\t\tthis.$$d[key] = this[key]; // don't transform, these were set through JavaScript\n\t\t\t\t\t\tdelete this[key]; // remove the property that shadows the getter/setter\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.$$c = new this.$$ctor({\n\t\t\t\t\ttarget: this.shadowRoot || this,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...this.$$d,\n\t\t\t\t\t\t$$slots,\n\t\t\t\t\t\t$$scope: {\n\t\t\t\t\t\t\tctx: []\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Reflect component props as attributes\n\t\t\t\tconst reflect_attributes = () => {\n\t\t\t\t\tthis.$$r = true;\n\t\t\t\t\tfor (const key in this.$$p_d) {\n\t\t\t\t\t\tthis.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];\n\t\t\t\t\t\tif (this.$$p_d[key].reflect) {\n\t\t\t\t\t\t\tconst attribute_value = get_custom_element_value(\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tthis.$$d[key],\n\t\t\t\t\t\t\t\tthis.$$p_d,\n\t\t\t\t\t\t\t\t'toAttribute'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (attribute_value == null) {\n\t\t\t\t\t\t\t\tthis.removeAttribute(this.$$p_d[key].attribute || key);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.setAttribute(this.$$p_d[key].attribute || key, attribute_value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.$$r = false;\n\t\t\t\t};\n\t\t\t\tthis.$$c.$$.after_update.push(reflect_attributes);\n\t\t\t\treflect_attributes(); // once initially because after_update is added too late for first render\n\n\t\t\t\tfor (const type in this.$$l) {\n\t\t\t\t\tfor (const listener of this.$$l[type]) {\n\t\t\t\t\t\tconst unsub = this.$$c.$on(type, listener);\n\t\t\t\t\t\tthis.$$l_u.set(listener, unsub);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.$$l = {};\n\t\t\t}\n\t\t}\n\n\t\t// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte\n\t\t// and setting attributes through setAttribute etc, this is helpful\n\t\tattributeChangedCallback(attr, _oldValue, newValue) {\n\t\t\tif (this.$$r) return;\n\t\t\tattr = this.$$g_p(attr);\n\t\t\tthis.$$d[attr] = get_custom_element_value(attr, newValue, this.$$p_d, 'toProp');\n\t\t\tthis.$$c?.$set({ [attr]: this.$$d[attr] });\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.$$cn = false;\n\t\t\t// In a microtask, because this could be a move within the DOM\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (!this.$$cn && this.$$c) {\n\t\t\t\t\tthis.$$c.$destroy();\n\t\t\t\t\tthis.$$c = undefined;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t$$g_p(attribute_name) {\n\t\t\treturn (\n\t\t\t\tObject.keys(this.$$p_d).find(\n\t\t\t\t\t(key) =>\n\t\t\t\t\t\tthis.$$p_d[key].attribute === attribute_name ||\n\t\t\t\t\t\t(!this.$$p_d[key].attribute && key.toLowerCase() === attribute_name)\n\t\t\t\t) || attribute_name\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * @param {string} prop\n * @param {any} value\n * @param {Record<string, CustomElementPropDefinition>} props_definition\n * @param {'toAttribute' | 'toProp'} [transform]\n */\nfunction get_custom_element_value(prop, value, props_definition, transform) {\n\tconst type = props_definition[prop]?.type;\n\tvalue = type === 'Boolean' && typeof value !== 'boolean' ? value != null : value;\n\tif (!transform || !props_definition[prop]) {\n\t\treturn value;\n\t} else if (transform === 'toAttribute') {\n\t\tswitch (type) {\n\t\t\tcase 'Object':\n\t\t\tcase 'Array':\n\t\t\t\treturn value == null ? null : JSON.stringify(value);\n\t\t\tcase 'Boolean':\n\t\t\t\treturn value ? '' : null;\n\t\t\tcase 'Number':\n\t\t\t\treturn value == null ? null : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase 'Object':\n\t\t\tcase 'Array':\n\t\t\t\treturn value && JSON.parse(value);\n\t\t\tcase 'Boolean':\n\t\t\t\treturn value; // conversion already handled above\n\t\t\tcase 'Number':\n\t\t\t\treturn value != null ? +value : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n}\n\n/**\n * @internal\n *\n * Turn a Svelte component into a custom element.\n * @param {import('./public.js').ComponentType} Component  A Svelte component constructor\n * @param {Record<string, CustomElementPropDefinition>} props_definition  The props to observe\n * @param {string[]} slots  The slots to create\n * @param {string[]} accessors  Other accessors besides the ones for props the component has\n * @param {boolean} use_shadow_dom  Whether to use shadow DOM\n * @param {(ce: new () => HTMLElement) => new () => HTMLElement} [extend]\n */\nexport function create_custom_element(\n\tComponent,\n\tprops_definition,\n\tslots,\n\taccessors,\n\tuse_shadow_dom,\n\textend\n) {\n\tlet Class = class extends SvelteElement {\n\t\tconstructor() {\n\t\t\tsuper(Component, slots, use_shadow_dom);\n\t\t\tthis.$$p_d = props_definition;\n\t\t}\n\t\tstatic get observedAttributes() {\n\t\t\treturn Object.keys(props_definition).map((key) =>\n\t\t\t\t(props_definition[key].attribute || key).toLowerCase()\n\t\t\t);\n\t\t}\n\t};\n\tObject.keys(props_definition).forEach((prop) => {\n\t\tObject.defineProperty(Class.prototype, prop, {\n\t\t\tget() {\n\t\t\t\treturn this.$$c && prop in this.$$c ? this.$$c[prop] : this.$$d[prop];\n\t\t\t},\n\t\t\tset(value) {\n\t\t\t\tvalue = get_custom_element_value(prop, value, props_definition);\n\t\t\t\tthis.$$d[prop] = value;\n\t\t\t\tthis.$$c?.$set({ [prop]: value });\n\t\t\t}\n\t\t});\n\t});\n\taccessors.forEach((accessor) => {\n\t\tObject.defineProperty(Class.prototype, accessor, {\n\t\t\tget() {\n\t\t\t\treturn this.$$c?.[accessor];\n\t\t\t}\n\t\t});\n\t});\n\tif (extend) {\n\t\t// @ts-expect-error - assigning here is fine\n\t\tClass = extend(Class);\n\t}\n\tComponent.element = /** @type {any} */ (Class);\n\treturn Class;\n}\n\n/**\n * Base class for Svelte components. Used when dev=false.\n *\n * @template {Record<string, any>} [Props=any]\n * @template {Record<string, any>} [Events=any]\n */\nexport class SvelteComponent {\n\t/**\n\t * ### PRIVATE API\n\t *\n\t * Do not use, may change at any time\n\t *\n\t * @type {any}\n\t */\n\t$$ = undefined;\n\t/**\n\t * ### PRIVATE API\n\t *\n\t * Do not use, may change at any time\n\t *\n\t * @type {any}\n\t */\n\t$$set = undefined;\n\n\t/** @returns {void} */\n\t$destroy() {\n\t\tdestroy_component(this, 1);\n\t\tthis.$destroy = noop;\n\t}\n\n\t/**\n\t * @template {Extract<keyof Events, string>} K\n\t * @param {K} type\n\t * @param {((e: Events[K]) => void) | null | undefined} callback\n\t * @returns {() => void}\n\t */\n\t$on(type, callback) {\n\t\tif (!is_function(callback)) {\n\t\t\treturn noop;\n\t\t}\n\t\tconst callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);\n\t\tcallbacks.push(callback);\n\t\treturn () => {\n\t\t\tconst index = callbacks.indexOf(callback);\n\t\t\tif (index !== -1) callbacks.splice(index, 1);\n\t\t};\n\t}\n\n\t/**\n\t * @param {Partial<Props>} props\n\t * @returns {void}\n\t */\n\t$set(props) {\n\t\tif (this.$$set && !is_empty(props)) {\n\t\t\tthis.$$.skip_bound = true;\n\t\t\tthis.$$set(props);\n\t\t\tthis.$$.skip_bound = false;\n\t\t}\n\t}\n}\n\n/**\n * @typedef {Object} CustomElementPropDefinition\n * @property {string} [attribute]\n * @property {boolean} [reflect]\n * @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type]\n */\n","import {\n\trun_all,\n\tsubscribe,\n\tnoop,\n\tsafe_not_equal,\n\tis_function,\n\tget_store_value\n} from '../internal/index.js';\n\nconst subscriber_queue = [];\n\n/**\n * Creates a `Readable` store that allows reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#readable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readable(value, start) {\n\treturn {\n\t\tsubscribe: writable(value, start).subscribe\n\t};\n}\n\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#writable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier<T>} [start]\n * @returns {import('./public.js').Writable<T>}\n */\nexport function writable(value, start = noop) {\n\t/** @type {import('./public.js').Unsubscriber} */\n\tlet stop;\n\t/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */\n\tconst subscribers = new Set();\n\t/** @param {T} new_value\n\t * @returns {void}\n\t */\n\tfunction set(new_value) {\n\t\tif (safe_not_equal(value, new_value)) {\n\t\t\tvalue = new_value;\n\t\t\tif (stop) {\n\t\t\t\t// store is ready\n\t\t\t\tconst run_queue = !subscriber_queue.length;\n\t\t\t\tfor (const subscriber of subscribers) {\n\t\t\t\t\tsubscriber[1]();\n\t\t\t\t\tsubscriber_queue.push(subscriber, value);\n\t\t\t\t}\n\t\t\t\tif (run_queue) {\n\t\t\t\t\tfor (let i = 0; i < subscriber_queue.length; i += 2) {\n\t\t\t\t\t\tsubscriber_queue[i][0](subscriber_queue[i + 1]);\n\t\t\t\t\t}\n\t\t\t\t\tsubscriber_queue.length = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {import('./public.js').Updater<T>} fn\n\t * @returns {void}\n\t */\n\tfunction update(fn) {\n\t\tset(fn(value));\n\t}\n\n\t/**\n\t * @param {import('./public.js').Subscriber<T>} run\n\t * @param {import('./private.js').Invalidator<T>} [invalidate]\n\t * @returns {import('./public.js').Unsubscriber}\n\t */\n\tfunction subscribe(run, invalidate = noop) {\n\t\t/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */\n\t\tconst subscriber = [run, invalidate];\n\t\tsubscribers.add(subscriber);\n\t\tif (subscribers.size === 1) {\n\t\t\tstop = start(set, update) || noop;\n\t\t}\n\t\trun(value);\n\t\treturn () => {\n\t\t\tsubscribers.delete(subscriber);\n\t\t\tif (subscribers.size === 0 && stop) {\n\t\t\t\tstop();\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t};\n\t}\n\treturn { set, update, subscribe };\n}\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues<S>) => T} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable<T>}\n */\n\n/**\n * @template {import('./private.js').Stores} S\n * @template T\n * @param {S} stores\n * @param {Function} fn\n * @param {T} [initial_value]\n * @returns {import('./public.js').Readable<T>}\n */\nexport function derived(stores, fn, initial_value) {\n\tconst single = !Array.isArray(stores);\n\t/** @type {Array<import('./public.js').Readable<any>>} */\n\tconst stores_array = single ? [stores] : stores;\n\tif (!stores_array.every(Boolean)) {\n\t\tthrow new Error('derived() expects stores as input, got a falsy value');\n\t}\n\tconst auto = fn.length < 2;\n\treturn readable(initial_value, (set, update) => {\n\t\tlet started = false;\n\t\tconst values = [];\n\t\tlet pending = 0;\n\t\tlet cleanup = noop;\n\t\tconst sync = () => {\n\t\t\tif (pending) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcleanup();\n\t\t\tconst result = fn(single ? values[0] : values, set, update);\n\t\t\tif (auto) {\n\t\t\t\tset(result);\n\t\t\t} else {\n\t\t\t\tcleanup = is_function(result) ? result : noop;\n\t\t\t}\n\t\t};\n\t\tconst unsubscribers = stores_array.map((store, i) =>\n\t\t\tsubscribe(\n\t\t\t\tstore,\n\t\t\t\t(value) => {\n\t\t\t\t\tvalues[i] = value;\n\t\t\t\t\tpending &= ~(1 << i);\n\t\t\t\t\tif (started) {\n\t\t\t\t\t\tsync();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tpending |= 1 << i;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tstarted = true;\n\t\tsync();\n\t\treturn function stop() {\n\t\t\trun_all(unsubscribers);\n\t\t\tcleanup();\n\t\t\t// We need to set this to false because callbacks can still happen despite having unsubscribed:\n\t\t\t// Callbacks might already be placed in the queue which doesn't know it should no longer\n\t\t\t// invoke this derived store.\n\t\t\tstarted = false;\n\t\t};\n\t});\n}\n\n/**\n * Takes a store and returns a new one derived from the old one that is readable.\n *\n * https://svelte.dev/docs/svelte-store#readonly\n * @template T\n * @param {import('./public.js').Readable<T>} store  - store to make readonly\n * @returns {import('./public.js').Readable<T>}\n */\nexport function readonly(store) {\n\treturn {\n\t\tsubscribe: store.subscribe.bind(store)\n\t};\n}\n\nexport { get_store_value as get };\n","import type { StoreOrVal } from '@tanstack/svelte-query'\nimport type { Readable } from 'svelte/store'\n\nexport function isStore<T>(obj: StoreOrVal<T>): obj is Readable<T> {\n  return (\n    obj != null &&\n    typeof obj === 'object' &&\n    'subscribe' in obj &&\n    typeof obj.subscribe === 'function'\n  )\n}\n","import type { StoreOrVal } from '@tanstack/svelte-query'\nimport { derived, get, type Readable, readable } from 'svelte/store'\n\nimport type { EdenTreatyQueryRootHooks } from '../implementation/treaty'\nimport { isStore } from './is-store'\nimport type { LiteralUnion } from './literal-union'\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  /**\n   * Extract the value of a writable.\n   */\n  const argumentValue = isStore(argument) ? get(argument) : argument\n\n  if (argumentValue == null || typeof argumentValue !== 'object') {\n    return\n  }\n\n  const argumentKeys = Object.keys(argumentValue)\n\n  const pathParam = argumentKeys[0]\n\n  if (argumentKeys.length !== 1 || pathParam == null) {\n    return\n  }\n\n  // At this point, assume that it's either a StoreOrVal with a valid object representing route params.\n\n  return { param: argument as any, key: argumentKeys[0] }\n}\n\nconst hooksToMutateArgs: (keyof EdenTreatyQueryRootHooks | LiteralUnion<string> | symbol)[] = [\n  'createQuery',\n  'createInfiniteQuery',\n  'createMutation',\n]\n/**\n * Directly mutate the arguments passed to the root hooks.\n *\n * Make sure that the interpretation of args matches up with the implementation of root hooks.\n */\nexport function mutateArgs(\n  hook: keyof EdenTreatyQueryRootHooks | LiteralUnion<string> | symbol,\n  args: unknown[],\n  params: StoreOrVal<Record<string, any>>[],\n) {\n  const input = args[0]\n\n  if (input == null && params.length === 0 && !hooksToMutateArgs.includes(hook)) {\n    return args\n  }\n\n  const isInputStore = isStore(input)\n\n  if (!isInputStore && !params.length) {\n    return args\n  }\n\n  const queryStore = isInputStore ? input : readable(input)\n\n  const paramsStores: Readable<Record<string, any>>[] = []\n\n  const staticParams: Record<string, any>[] = []\n\n  for (const param of params) {\n    if (isStore(param)) {\n      paramsStores.push(param)\n    } else {\n      staticParams.push(param)\n    }\n  }\n\n  const paramsStore = derived(paramsStores, ($paramsStores) => {\n    const resolvedParams: Record<string, any> = {}\n\n    for (const param of $paramsStores) {\n      for (const key in param) {\n        resolvedParams[key] = param[key]\n      }\n    }\n\n    return resolvedParams\n  })\n\n  const inputStore = derived([queryStore, paramsStore], ([query, params]) => {\n    for (const param of staticParams) {\n      for (const key in param) {\n        params[key] = param[key]\n      }\n    }\n    return { query, params }\n  })\n\n  args[0] = inputStore\n\n  return args\n}\n","import {\n  EdenClient,\n  type EdenClientError,\n  type EdenCreateClient,\n  httpBatchLink,\n  type HttpBatchLinkOptions,\n  httpLink,\n  type HTTPLinkOptions,\n  type InferRouteOptions,\n  parsePathsAndMethod,\n} from '@aydee-app/eden'\nimport {\n  createInfiniteQuery as __createInfiniteQuery,\n  createQueries as __createQueries,\n  createQuery as __createQuery,\n  type SkipToken,\n  type StoreOrVal,\n  useQueryClient,\n} from '@tanstack/svelte-query'\nimport type { AnyElysia } from 'elysia'\nimport { getContext as __getContext, setContext as __setContext } from 'svelte'\nimport { derived, readable } from 'svelte/store'\n\nimport type { EdenQueryConfig } from '../../config'\nimport {\n  createUtilityFunctions,\n  EDEN_CONTEXT_KEY,\n  type EdenContextProps,\n  type EdenContextState,\n} from '../../context'\nimport {\n  type EdenCreateInfiniteQueryOptions,\n  edenCreateInfiniteQueryOptions,\n  type EdenCreateInfiniteQueryResult,\n} from '../../integration/hooks/create-infinite-query'\nimport {\n  createEdenMutation,\n  type EdenCreateMutationOptions,\n  edenCreateMutationOptions,\n  type EdenCreateMutationResult,\n} from '../../integration/hooks/create-mutation'\nimport {\n  type EdenCreateQueryOptions,\n  edenCreateQueryOptions,\n  type EdenCreateQueryResult,\n} from '../../integration/hooks/create-query'\nimport type { EdenCreateQueryOptionsForCreateQueries } from '../../integration/internal/create-query-options-for-create-queries'\nimport { getEdenQueryHookExtension } from '../../integration/internal/query-hook-extension'\nimport { isStore } from '../../utils/is-store'\nimport {\n  createTreatySvelteQueryCreateQueriesProxy,\n  type EdenTreatySvelteQueryCreateQueries,\n} from './create-queries'\nimport { createEdenTreatyQueryUtils, type EdenTreatySvelteQueryUtils } from './query-utils'\n\nexport function createEdenTreatyQueryRootHooks<\n  TElysia extends AnyElysia,\n  TSSRContext = unknown,\n  TError = EdenClientError<TElysia>,\n>(config?: EdenQueryConfig<TElysia>) {\n  type ProviderContext = EdenContextState<TElysia, TSSRContext>\n\n  const createClient: EdenCreateClient<TElysia> = (options) => {\n    return new EdenClient(options)\n  }\n\n  const createHttpClient = (options?: HTTPLinkOptions) => {\n    return new EdenClient({\n      links: [httpLink(options)],\n    })\n  }\n\n  /**\n   * @warning\n   * Ensure that the Elysia.js server uses the batch plugin;\n   * the types will not verify whether or not this is detected.\n   */\n  const createHttpBatchClient = (options?: HttpBatchLinkOptions) => {\n    return new EdenClient({\n      links: [httpBatchLink(options) as any],\n    })\n  }\n\n  const createContext = (\n    props: EdenContextProps<TElysia, TSSRContext>,\n    configOverride = config,\n  ): EdenContextState<TElysia, TSSRContext> => {\n    const { abortOnUnmount = false, client, queryClient } = props\n\n    const options = { client, queryClient, abortOnUnmount }\n\n    const utilityFunctions = createUtilityFunctions(options, configOverride)\n\n    return {\n      abortOnUnmount,\n      client,\n      queryClient,\n      ...utilityFunctions,\n    }\n  }\n\n  const createUtils = (\n    props: EdenContextProps<TElysia, TSSRContext>,\n    configOverride = config,\n  ): EdenTreatySvelteQueryUtils<TElysia, TSSRContext> => {\n    const context = createContext(props, configOverride)\n    const utils = createEdenTreatyQueryUtils(context, configOverride)\n    return utils\n  }\n\n  const setContext = (\n    props: EdenContextProps<TElysia, TSSRContext>,\n    configOverride = config,\n  ): EdenContextState<TElysia, TSSRContext> => {\n    const context = createContext(props, configOverride)\n    return __setContext(EDEN_CONTEXT_KEY, context)\n  }\n\n  const getRawContext = (): ProviderContext => {\n    return __getContext(EDEN_CONTEXT_KEY)\n  }\n\n  /**\n   * tRPC creates a new proxy from the provided context for all `useUtils` calls.\n   *\n   * @see https://github.com/trpc/trpc/blob/52a57eaa9c12394778abf5f0e6b52ec6f46288ed/packages/react-query/src/createTRPCReact.tsx#L509\n   */\n  const getContext = (context = getRawContext(), configOverride = config) => {\n    return createEdenTreatyQueryUtils(context, configOverride)\n  }\n\n  const createQuery = (\n    originalPaths: readonly string[],\n    input?: StoreOrVal<InferRouteOptions | SkipToken>,\n    options?: StoreOrVal<EdenCreateQueryOptions<unknown, unknown, TError>>,\n  ): EdenCreateQueryResult<unknown, TError> => {\n    const context = getRawContext()\n\n    const parsed = parsePathsAndMethod(originalPaths)\n\n    const queryClient = context.queryClient ?? useQueryClient()\n\n    const edenQueryHookExtension = getEdenQueryHookExtension({ path: parsed.paths })\n\n    type HookResult = EdenCreateQueryResult<any, TError>\n\n    if (!isStore(input) && !isStore(options)) {\n      const queryOptions = edenCreateQueryOptions(parsed, context, input, options, config)\n\n      const hook = __createQuery(queryOptions, queryClient) as HookResult\n\n      hook.eden = edenQueryHookExtension\n\n      return hook\n    }\n\n    const inputStore = isStore(input) ? input : readable(input)\n\n    const optionsStore = isStore(options) ? options : readable(options)\n\n    const queryOptionsStore = derived([inputStore, optionsStore], ([$input, $options]) => {\n      const queryOptions = edenCreateQueryOptions(parsed, context, $input, $options, config)\n      return queryOptions\n    })\n\n    const hook = __createQuery(queryOptionsStore, queryClient) as HookResult\n\n    hook.eden = edenQueryHookExtension\n\n    return hook\n  }\n\n  const createQueries: EdenTreatySvelteQueryCreateQueries<TElysia> = (queriesCallback) => {\n    const context = getRawContext()\n\n    const { queryClient, client } = context\n\n    const proxy = createTreatySvelteQueryCreateQueriesProxy(client)\n\n    const queries: readonly EdenCreateQueryOptionsForCreateQueries<any, any>[] =\n      queriesCallback(proxy)\n\n    return __createQueries({ queries: queries as any }, queryClient) as any\n  }\n\n  const createInfiniteQuery = (\n    originalPaths: readonly string[],\n    input?: StoreOrVal<InferRouteOptions | SkipToken>,\n    options?: StoreOrVal<EdenCreateInfiniteQueryOptions<unknown, unknown, TError>>,\n  ): EdenCreateInfiniteQueryResult<unknown, TError, unknown> => {\n    const context = getRawContext()\n\n    const parsed = parsePathsAndMethod(originalPaths)\n\n    const queryClient = context.queryClient ?? useQueryClient()\n\n    const edenQueryHookExtension = getEdenQueryHookExtension({ path: parsed.paths })\n\n    type HookResult = EdenCreateInfiniteQueryResult<unknown, TError, unknown>\n\n    if (!isStore(input) && !isStore(options)) {\n      const queryOptions = edenCreateInfiniteQueryOptions(parsed, context, input, options, config)\n\n      const hook = __createInfiniteQuery(queryOptions, queryClient) as HookResult\n\n      hook.eden = edenQueryHookExtension\n\n      return hook\n    }\n\n    const inputStore = isStore(input) ? input : readable(input)\n\n    const optionsStore = isStore(options) ? options : readable(options)\n\n    const queryOptionsStore = derived([inputStore, optionsStore], ([$input, $options]) => {\n      const queryOptions = edenCreateInfiniteQueryOptions(parsed, context, $input, $options, config)\n      return queryOptions\n    })\n\n    const hook = __createInfiniteQuery(queryOptionsStore, queryClient) as HookResult\n\n    hook.eden = edenQueryHookExtension\n\n    return hook\n  }\n\n  const createMutation = (\n    originalPaths: readonly string[],\n    options?: StoreOrVal<EdenCreateMutationOptions<unknown, TError, unknown, unknown>>,\n  ): EdenCreateMutationResult<unknown, TError, unknown, unknown, unknown> => {\n    const context = getRawContext()\n\n    const parsed = parsePathsAndMethod(originalPaths)\n\n    const queryClient = context.queryClient ?? useQueryClient()\n\n    const edenQueryHookExtension = getEdenQueryHookExtension({ path: parsed.paths })\n\n    type HookResult = EdenCreateMutationResult<unknown, TError, unknown, unknown, any>\n\n    if (!isStore(options)) {\n      const mutationOptions = edenCreateMutationOptions(parsed, context, options, config)\n\n      const hook = createEdenMutation(mutationOptions, queryClient) as HookResult\n\n      hook.eden = edenQueryHookExtension\n\n      return hook\n    }\n\n    const optionsStore = isStore(options) ? options : readable(options)\n\n    const mutationOptionsStore = derived(optionsStore, ($options) => {\n      const mutationOptions = edenCreateMutationOptions(parsed, context, $options, config)\n      return mutationOptions\n    })\n\n    const hook = createEdenMutation(mutationOptionsStore, queryClient) as HookResult\n\n    hook.eden = edenQueryHookExtension\n\n    return hook\n  }\n\n  return {\n    createClient,\n    createHttpClient,\n    createHttpBatchClient,\n    createContext,\n    createUtils,\n    setContext,\n    getContext,\n    getUtils: getContext,\n    createQuery,\n    createQueries,\n    createMutation,\n    createInfiniteQuery,\n  }\n}\n\nexport type EdenTreatyQueryRootHooks<\n  TElysia extends AnyElysia = AnyElysia,\n  TSSRContext = unknown,\n> = ReturnType<typeof createEdenTreatyQueryRootHooks<TElysia, TSSRContext>>\n","import {\n  type EdenClient,\n  type EdenClientError,\n  type EdenRequestParams,\n  parsePathsAndMethod,\n} from '@aydee-app/eden'\nimport type {\n  CancelOptions,\n  FetchQueryOptions,\n  InfiniteData,\n  InvalidateOptions,\n  InvalidateQueryFilters,\n  MutationOptions,\n  QueryClient,\n  QueryFilters,\n  QueryKey,\n  RefetchOptions,\n  RefetchQueryFilters,\n  ResetOptions,\n  SetDataOptions,\n  Updater,\n} from '@tanstack/svelte-query'\nimport type { AnyElysia } from 'elysia'\n\nimport type { EdenQueryConfig } from './config'\nimport type { EdenFetchInfiniteQueryOptions } from './integration/hooks/fetch-infinite'\nimport type { EdenFetchQueryOptions } from './integration/hooks/fetch-query'\nimport type { EdenMutationKey, EdenQueryKey, EdenQueryType } from './integration/internal/query-key'\n\nexport const EDEN_CONTEXT_KEY = Symbol('EDEN_CONTEXT')\n\nexport type EdenContextPropsBase<TElysia extends AnyElysia, _TSSRContext = unknown> = {\n  /**\n   * Untyped client for making requests.\n   */\n  client: EdenClient<TElysia>\n\n  /**\n   * Whether to forward the `signal` from svelte-query to fetch call.\n   *\n   * @default false\n   *\n   * @deprecated pass abortOnUnmount to `createTRPCReact` instead\n   */\n  abortOnUnmount?: boolean\n}\n\nexport type EdenContextProps<TRouter extends AnyElysia, TSSRContext> = EdenContextPropsBase<\n  TRouter,\n  TSSRContext\n> & {\n  /**\n   * The svelte-query `QueryClient`\n   */\n  queryClient: QueryClient\n}\n\nexport type EdenContextState<TRouter extends AnyElysia, TSSRContext = undefined> = Required<\n  EdenContextProps<TRouter, TSSRContext>\n> &\n  EdenQueryUtils<TRouter>\n\nexport type EdenQueryUtils<TRouter extends AnyElysia> = {\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchquery\n   */\n  fetchQuery: (\n    queryKey: EdenQueryKey,\n    opts?: EdenFetchQueryOptions<unknown, EdenClientError<TRouter>>,\n  ) => Promise<unknown>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchinfinitequery\n   */\n  fetchInfiniteQuery: (\n    queryKey: EdenQueryKey,\n    opts?: EdenFetchInfiniteQueryOptions<unknown, unknown, EdenClientError<TRouter>>,\n  ) => Promise<InfiniteData<unknown, unknown>>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching\n   */\n  prefetchQuery: (\n    queryKey: EdenQueryKey,\n    opts?: EdenFetchQueryOptions<unknown, EdenClientError<TRouter>>,\n  ) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchinfinitequery\n   */\n  prefetchInfiniteQuery: (\n    queryKey: EdenQueryKey,\n    opts?: EdenFetchInfiniteQueryOptions<unknown, unknown, EdenClientError<TRouter>>,\n  ) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientensurequerydata\n   */\n  ensureQueryData: (\n    queryKey: EdenQueryKey,\n    opts?: EdenFetchQueryOptions<unknown, EdenClientError<TRouter>>,\n  ) => Promise<unknown>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-invalidation\n   */\n  invalidateQueries: (\n    queryKey: EdenQueryKey,\n    filters?: InvalidateQueryFilters,\n    options?: InvalidateOptions,\n  ) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientresetqueries\n   */\n  resetQueries: (\n    queryKey: EdenQueryKey,\n    filters?: QueryFilters,\n    options?: ResetOptions,\n  ) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientrefetchqueries\n   */\n  refetchQueries: (\n    queryKey: EdenQueryKey,\n    filters?: RefetchQueryFilters,\n    options?: RefetchOptions,\n  ) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-cancellation\n   */\n  cancelQuery: (queryKey: EdenQueryKey, options?: CancelOptions) => Promise<void>\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata\n   */\n  setQueryData: (\n    queryKey: EdenQueryKey,\n    updater: Updater<unknown, unknown>,\n    options?: SetDataOptions,\n  ) => void\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetqueriesdata\n   */\n  setQueriesData: (\n    queryKey: EdenQueryKey,\n    filters: QueryFilters,\n    updater: Updater<unknown, unknown>,\n    options?: SetDataOptions,\n  ) => [QueryKey, unknown][]\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata\n   */\n  getQueryData: (queryKey: EdenQueryKey) => unknown\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata\n   */\n  setInfiniteQueryData: (\n    queryKey: EdenQueryKey,\n    updater: Updater<InfiniteData<unknown> | undefined, InfiniteData<unknown> | undefined>,\n    options?: SetDataOptions,\n  ) => void\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata\n   */\n  getInfiniteQueryData: (queryKey: EdenQueryKey) => InfiniteData<unknown> | undefined\n\n  /**\n   * @link https://tanstack.com/query/latest/docs/reference/QueryClient/#queryclientsetmutationdefaults\n   */\n  setMutationDefaults: (\n    mutationKey: EdenMutationKey,\n    options:\n      | MutationOptions\n      | ((args: { canonicalMutationFn: (input: unknown) => Promise<unknown> }) => MutationOptions),\n  ) => void\n\n  /**\n   * @link https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientgetmutationdefaults\n   */\n  getMutationDefaults: (mutationKey: EdenMutationKey) => MutationOptions | undefined\n\n  /**\n   * @link https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientismutating\n   */\n  isMutating: (filters: { mutationKey: EdenMutationKey }) => number\n}\n\nexport const contextProps: (keyof EdenContextPropsBase<any, any>)[] = ['client', 'abortOnUnmount']\n\nexport function getQueryType(utilName: string): EdenQueryType {\n  switch (utilName) {\n    case 'fetch':\n    case 'ensureData':\n    case 'prefetch':\n    case 'getData':\n    case 'setData':\n    case 'setQueriesData':\n      return 'query'\n\n    case 'fetchInfinite':\n    case 'prefetchInfinite':\n    case 'getInfiniteData':\n    case 'setInfiniteData':\n      return 'infinite'\n\n    case 'setMutationDefaults':\n    case 'getMutationDefaults':\n    case 'isMutating':\n    case 'cancel':\n    case 'invalidate':\n    case 'refetch':\n    case 'reset':\n      return 'any'\n  }\n\n  return 'any'\n}\n\n/**\n * Creates a set of utility functions that can be used to interact with `react-query`\n * @param options the `TRPCClient` and `QueryClient` to use\n * @returns a set of utility functions that can be used to interact with `react-query`\n * @internal\n */\nexport function createUtilityFunctions<T extends AnyElysia>(\n  options: EdenContextProps<T, any>,\n  config?: EdenQueryConfig,\n): EdenQueryUtils<T> {\n  const { client, queryClient } = options\n\n  return {\n    fetchQuery: async (queryKey, options = {}) => {\n      const { path, method } = parsePathsAndMethod(queryKey[0])\n\n      const { eden, ...queryOptions } = options\n\n      const edenQueryOptions: FetchQueryOptions<unknown, any, unknown, QueryKey, never> = {\n        queryKey,\n        queryFn: async (queryFunctionContext) => {\n          let options: any = queryKey[1]?.input\n\n          const params: EdenRequestParams = {\n            ...config,\n            options,\n            path,\n            method,\n            ...eden,\n          }\n\n          const shouldForwardSignal = eden?.abortOnUnmount ?? config?.abortOnUnmount\n\n          if (shouldForwardSignal) {\n            params.fetch = { ...params.fetch, signal: queryFunctionContext.signal }\n          }\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        ...queryOptions,\n      }\n\n      return await queryClient.fetchQuery(edenQueryOptions)\n    },\n\n    fetchInfiniteQuery: async (queryKey, options = {}) => {\n      const { path, method } = parsePathsAndMethod(queryKey[0])\n\n      const { eden, ...queryOptions } = options\n\n      return await queryClient.fetchInfiniteQuery({\n        queryKey,\n        queryFn: async (context) => {\n          const options: any = { ...(queryKey[1]?.input ?? {}) }\n\n          const params = {\n            ...config,\n            options,\n            path,\n            method,\n            ...eden,\n          } satisfies EdenRequestParams\n\n          if (context.pageParam != null) {\n            if (params.options.query != null) {\n              ;(params.options.query as any)['cursor'] = context.pageParam\n              ;(params.options.query as any)['direction'] = context.direction\n            }\n\n            if (params.options.params != null) {\n              ;(params.options.params as any)['cursor'] = context.pageParam\n              ;(params.options.params as any)['direction'] = context.direction\n            }\n          }\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        initialPageParam: options?.initialCursor ?? null,\n        ...queryOptions,\n      })\n    },\n\n    prefetchQuery: async (queryKey, options = {}) => {\n      const { path, method } = parsePathsAndMethod(queryKey[0])\n\n      const { eden, ...queryOptions } = options\n\n      return await queryClient.prefetchQuery({\n        queryKey,\n        queryFn: async () => {\n          const options: any = { ...(queryKey[1]?.input ?? {}) }\n\n          const params = {\n            ...config,\n            options,\n            path,\n            method,\n            ...eden,\n          } satisfies EdenRequestParams\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        ...queryOptions,\n      })\n    },\n\n    prefetchInfiniteQuery: async (queryKey, options = {}) => {\n      const { path, method } = parsePathsAndMethod(queryKey[0])\n\n      const { eden, ...queryOptions } = options\n\n      return await queryClient.prefetchInfiniteQuery({\n        queryKey,\n        queryFn: async (queryFunctionContext) => {\n          const options: any = { ...(queryKey[1]?.input ?? {}) }\n\n          const params = {\n            ...config,\n            options,\n            path,\n            method,\n            ...eden,\n          } satisfies EdenRequestParams\n\n          if (queryFunctionContext.pageParam != null) {\n            if (params.options.query != null) {\n              ;(params.options.query as any)['cursor'] = queryFunctionContext.pageParam\n              ;(params.options.query as any)['direction'] = queryFunctionContext.direction\n            }\n\n            if (params.options.params != null) {\n              ;(params.options.params as any)['cursor'] = queryFunctionContext.pageParam\n              ;(params.options.params as any)['direction'] = queryFunctionContext.direction\n            }\n          }\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        initialPageParam: options?.initialCursor ?? null,\n        ...queryOptions,\n      })\n    },\n\n    ensureQueryData: async (queryKey, options = {}) => {\n      const { path, method } = parsePathsAndMethod(queryKey[0])\n\n      const { eden, ...queryOptions } = options\n\n      return await queryClient.ensureQueryData({\n        queryKey,\n        queryFn: async () => {\n          let options: any = queryKey[1]?.input\n\n          const params = {\n            ...config,\n            options,\n            path,\n            method,\n            ...eden,\n          } satisfies EdenRequestParams\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        ...queryOptions,\n      })\n    },\n\n    invalidateQueries: async (queryKey, filters, options) => {\n      return await queryClient.invalidateQueries({ ...filters, queryKey }, options)\n    },\n\n    resetQueries: async (queryKey, filters, options) => {\n      return await queryClient.resetQueries({ ...filters, queryKey }, options)\n    },\n\n    refetchQueries: async (queryKey, filters, options) => {\n      return await queryClient.refetchQueries({ ...filters, queryKey }, options)\n    },\n\n    cancelQuery: async (queryKey, options) => {\n      return await queryClient.cancelQueries({ queryKey }, options)\n    },\n\n    setQueryData: (queryKey, updater, options) => {\n      return queryClient.setQueryData(queryKey, updater as any, options)\n    },\n\n    setQueriesData: (queryKey, filters, updater, options) => {\n      return queryClient.setQueriesData({ ...filters, queryKey }, updater, options)\n    },\n\n    getQueryData: (queryKey) => {\n      return queryClient.getQueryData(queryKey)\n    },\n\n    setInfiniteQueryData: (queryKey, updater, options) => {\n      return queryClient.setQueryData(queryKey, updater as any, options)\n    },\n\n    getInfiniteQueryData: (queryKey) => {\n      return queryClient.getQueryData(queryKey)\n    },\n\n    setMutationDefaults: (mutationKey, options) => {\n      const path = '/' + mutationKey[0].join('/')\n\n      const canonicalMutationFn = async (input: unknown) => {\n        return await client.mutation({ path, body: input })\n      }\n\n      const mutationOptions =\n        typeof options === 'function' ? options({ canonicalMutationFn }) : options\n\n      return queryClient.setMutationDefaults(mutationKey, mutationOptions)\n    },\n\n    getMutationDefaults: (mutationKey) => {\n      return queryClient.getMutationDefaults(mutationKey)\n    },\n\n    isMutating: (filters) => {\n      return queryClient.isMutating({ ...filters, exact: true })\n    },\n  }\n}\n","import type {\n  EdenRequestParams,\n  EmptyToVoid,\n  InferRouteError,\n  InferRouteOptions,\n  InferRouteOutput,\n  ParsedPathAndMethod,\n} from '@aydee-app/eden'\nimport {\n  type CreateInfiniteQueryOptions,\n  type CreateInfiniteQueryResult,\n  type InfiniteData,\n  type InfiniteQueryObserverSuccessResult,\n  type SkipToken,\n  skipToken,\n  type StoreOrVal,\n} from '@tanstack/svelte-query'\nimport type { RouteSchema } from 'elysia'\n\nimport type { EdenQueryConfig } from '../../config'\nimport type { EdenContextState } from '../../context'\nimport type { DistributiveOmit } from '../../utils/types'\nimport type { ExtractQueryCursor, ReservedInfiniteQueryKeys } from '../internal/infinite-query'\nimport type { EdenQueryBaseOptions } from '../internal/query-base-options'\nimport type { WithEdenQueryExtension } from '../internal/query-hook-extension'\nimport { getQueryKey } from '../internal/query-key'\n\nexport interface EdenCreateInfiniteQueryOptions<TInput, TOutput, TError>\n  extends DistributiveOmit<\n      CreateInfiniteQueryOptions<\n        TOutput,\n        TError,\n        TOutput,\n        any,\n        ExtractQueryCursor<TInput>\n      >,\n      'queryKey' | 'initialPageParam'\n    >,\n    EdenQueryBaseOptions {\n  initialCursor?: ExtractQueryCursor<TInput>\n}\n\nexport type EdenCreateInfiniteQueryResult<TData, TError, TInput> = WithEdenQueryExtension<\n  CreateInfiniteQueryResult<\n    InfiniteData<TData, NonNullable<ExtractQueryCursor<TInput>> | null>,\n    TError\n  >\n>\n\nexport type EdenCreateInfiniteQuerySuccessResult<TData, TError, TInput> = WithEdenQueryExtension<\n  InfiniteQueryObserverSuccessResult<\n    InfiniteData<TData, NonNullable<ExtractQueryCursor<TInput>> | null>,\n    TError\n  >\n>\n\nexport type EdenCreateInfiniteQuery<\n  TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n  // The exposed public type for `createInfiniteQuery` only needs the `query` from the input options.\n  TInput = InferRouteOptions<TRoute>['query'],\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n  TInfiniteInput = InferRouteOptions<TRoute, ReservedInfiniteQueryKeys>['query'],\n> = (\n  input: StoreOrVal<EmptyToVoid<TInfiniteInput> | SkipToken>,\n  options: EdenCreateInfiniteQueryOptions<TInput, TOutput, TError>,\n) => EdenCreateInfiniteQueryResult<TOutput, TError, TInput>\n\nexport function edenCreateInfiniteQueryOptions(\n  parsedPathsAndMethod: ParsedPathAndMethod,\n  context: EdenContextState<any, any>,\n  // The helper `createInfiniteQueryOptions` receives the entire options object.\n  input?: InferRouteOptions | SkipToken,\n  options?: EdenCreateInfiniteQueryOptions<unknown, unknown, any>,\n  config?: EdenQueryConfig,\n): CreateInfiniteQueryOptions {\n  const { abortOnUnmount, client, queryClient } = context\n\n  const { paths, path, method } = parsedPathsAndMethod\n\n  const isInputSkipToken = input === skipToken && typeof input !== 'object'\n\n  const queryKey = getQueryKey(paths, isInputSkipToken ? undefined : input, 'query')\n\n  const defaultOptions = queryClient.getQueryDefaults(queryKey)\n\n  const initialQueryOptions = { ...defaultOptions, ...options }\n\n  const { eden, ...queryOptions } = initialQueryOptions\n\n  const resolvedQueryOptions = {\n    ...queryOptions,\n    initialPageParam: queryOptions.initialCursor ?? null,\n    queryKey,\n  } as CreateInfiniteQueryOptions\n\n  if (isInputSkipToken) {\n    resolvedQueryOptions.queryFn = input\n    return resolvedQueryOptions\n  }\n\n  resolvedQueryOptions.queryFn = async (queryFunctionContext) => {\n    const params: EdenRequestParams = {\n      ...config,\n      path,\n      method,\n      options: { ...input },\n      ...eden,\n    }\n\n    const shouldForwardSignal = config?.abortOnUnmount ?? eden?.abortOnUnmount ?? abortOnUnmount\n\n    if (shouldForwardSignal) {\n      params.fetch = { ...params.fetch, signal: queryFunctionContext.signal }\n    }\n\n    // FIXME: scuffed way to set cursor. Not sure how to tell if the cursor will be\n    // in the route params or query.\n    // e.g. /api/pages/:cursor -> /api/pages/1 or /api/pages?cursor=1\n\n    if (queryFunctionContext.pageParam != null) {\n      if (params.options?.query) {\n        ;(params.options.query as any)['cursor'] = queryFunctionContext.pageParam\n      } else if (params.options?.params) {\n        ;(params.options.params as any)['cursor'] = queryFunctionContext.pageParam\n      }\n    }\n\n    const result = await client.query(params)\n\n    if (result.error != null) {\n      throw result.error\n    }\n\n    return result.data\n  }\n\n  return resolvedQueryOptions\n}\n","import type {\n  EdenRequestParams,\n  InferRouteBody,\n  InferRouteError,\n  InferRouteOptions,\n  InferRouteOutput,\n  ParsedPathAndMethod,\n} from '@aydee-app/eden'\nimport {\n  type CreateBaseMutationResult,\n  createMutation,\n  type CreateMutationOptions,\n  type CreateMutationResult,\n  type DefaultError,\n  type MutateOptions,\n  type QueryClient,\n  type StoreOrVal,\n  useQueryClient,\n} from '@tanstack/svelte-query'\nimport type { RouteSchema } from 'elysia'\nimport { derived, type Readable } from 'svelte/store'\n\nimport type { EdenContextState } from '../../context'\nimport type { Override } from '../../utils/types'\nimport type { EdenQueryBaseOptions } from '../internal/query-base-options'\nimport type { WithEdenQueryExtension } from '../internal/query-hook-extension'\nimport { getMutationKey } from '../internal/query-key'\n\nexport type EdenCreateMutationOptions<\n  TInput,\n  TError,\n  TOutput,\n  TContext = unknown,\n> = CreateMutationOptions<TOutput, TError, TInput, TContext> & EdenQueryBaseOptions\n\nexport type EdenCreateMutationResult<TData, TError, TVariables, TContext, TInput> =\n  WithEdenQueryExtension<\n    Readable<\n      Override<\n        CreateBaseMutationResult<TData, TError, TVariables, TContext>,\n        {\n          mutateAsync: EdenAsyncMutationFunction<TData, TError, TVariables, TInput>\n          mutate: EdenMutationFunction<TData, TError, TVariables, TInput>\n        }\n      >\n    >\n  >\n\nexport type EdenCreateMutation<\n  TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n  TVariables = InferRouteBody<TRoute>,\n  TInput = Partial<Pick<InferRouteOptions<TRoute>, 'params'>> &\n    Omit<InferRouteOptions<TRoute>, 'params'>,\n  TData = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n> = <TContext = unknown>(\n  options?: EdenCreateMutationOptions<TVariables, TError, TData, TContext>,\n) => EdenCreateMutationResult<TData, TError, TVariables, TContext, TInput>\n\nexport type EdenAsyncMutationFunction<TData, TError, TVariables, TInput> = <TContext = TData>(\n  variables: TVariables,\n  options: {} extends TInput\n    ?\n        | void\n        | (TData &\n            MutateOptions<TData, TError, EdenCreateMutationVariables<TVariables, TInput>, TContext>)\n    : TData &\n        MutateOptions<TData, TError, EdenCreateMutationVariables<TVariables, TInput>, TContext>,\n) => Promise<TContext>\n\nexport type EdenMutationFunction<TData, TError, TVariables, TInput> = <TContext = unknown>(\n  variables: TContext,\n  options: {} extends TInput\n    ?\n        | void\n        | (TData &\n            MutateOptions<TData, TError, EdenCreateMutationVariables<TVariables, TInput>, TContext>)\n    : TData &\n        MutateOptions<TData, TError, EdenCreateMutationVariables<TVariables, TInput>, TContext>,\n) => void\n\n/**\n * @internal\n *\n * Need to be able to provide multiple arguments to `useMutation`, since\n * Eden's mutations accept a body as the first argument, and additional options\n * as the second argument -- which are sometimes required.\n *\n * To accomplish this, eden-query intercepts the hook call to grab the args as a single object,\n * then destructures it in custom `mutate` and `asyncMutate` implementations.\n *\n * This \"hack\" is needed since the vanilla `useMutation` hook doesn't allow multiple args :(\n */\nexport type EdenCreateMutationVariables<TBody = any, TOptions = {}> = {\n  /**\n   * The first argument provided to the `useMutation` hook, i.e. the request body.\n   */\n  body: TBody\n} & ({} extends TOptions\n  ? {\n      /**\n       * The second argument provided to the `useMutation` hook, i.e. request options.\n       */\n      options?: TOptions\n    }\n  : {\n      /**\n       * The second argument provided to the `useMutation` hook, i.e. request options.\n       */\n      options: TOptions\n    })\n\n/**\n * In order to extend the {@link createMutation} API to allow query/headers to be\n * passed in and forwarded properly, create custom wrapper around {@link createMutation} that\n * can accept multiple arguments.\n */\nexport function createEdenMutation<\n  TData = unknown,\n  TError = DefaultError,\n  TVariables = void,\n  TContext = unknown,\n>(\n  options: StoreOrVal<CreateMutationOptions<TData, TError, TVariables, TContext>>,\n  queryClient?: QueryClient,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n  const mutation = createMutation(options, queryClient)\n\n  /**\n   * Custom eden-query-useMutation coalesces multiple args into one object for the vanilla\n   * `useMutation` hook.\n   */\n  const edenMutation = derived(mutation, ($mutation) => {\n    return {\n      ...$mutation,\n      mutate: (body: any, options?: any) => {\n        const variables: EdenCreateMutationVariables = { body, options }\n        return $mutation.mutate(variables as TVariables, options)\n      },\n      mutateAsync: async (body: any, options?: any) => {\n        const variables: EdenCreateMutationVariables = { body, options }\n        return await $mutation.mutateAsync(variables as TVariables, options)\n      },\n    }\n  })\n\n  return edenMutation\n}\n\nexport function edenCreateMutationOptions(\n  parsedPathsAndMethod: ParsedPathAndMethod,\n  context: EdenContextState<any, any>,\n  options: EdenCreateMutationOptions<any, any, any> = {},\n  config?: any,\n): CreateMutationOptions {\n  const { client, queryClient = useQueryClient() } = context\n\n  const { paths, path, method } = parsedPathsAndMethod\n\n  const mutationKey = getMutationKey(paths)\n\n  const mutationDefaults = queryClient.getMutationDefaults(mutationKey)\n\n  const defaultOptions = queryClient.defaultMutationOptions(mutationDefaults)\n\n  const { eden, ...mutationOptions } = options\n\n  const resolvedMutationOptions: CreateMutationOptions = {\n    mutationKey,\n    mutationFn: async (variables: any = {}) => {\n      const { body, options } = variables as EdenCreateMutationVariables\n\n      const params = {\n        ...config,\n        options,\n        body,\n        path,\n        method,\n        ...eden,\n      } satisfies EdenRequestParams\n\n      const result = await client.query(params)\n\n      if (!('data' in result)) {\n        return result\n      }\n\n      if (result.error != null) {\n        throw result.error\n      }\n\n      return result.data\n    },\n    onSuccess: (data, variables, onMutateResult, context) => {\n      const onSuccess = options?.onSuccess ?? defaultOptions.onSuccess\n\n      if (config?.overrides?.useMutation?.onSuccess == null) {\n        return onSuccess?.(data, variables, onMutateResult, context)\n      }\n\n      const meta: any = options?.meta ?? defaultOptions.meta\n\n      const originalFn = () => onSuccess?.(data, variables, onMutateResult, context)\n\n      return config.overrides.useMutation.onSuccess({ meta, originalFn, queryClient })\n    },\n    ...mutationOptions,\n  }\n\n  return resolvedMutationOptions\n}\n","import {\n  type EdenRequestParams,\n  type EmptyToVoid,\n  type InferRouteError,\n  type InferRouteOptions,\n  type InferRouteOutput,\n  type ParsedPathAndMethod,\n} from '@aydee-app/eden'\nimport {\n  type CreateBaseQueryOptions,\n  type CreateQueryOptions,\n  type CreateQueryResult,\n  type DefinedCreateQueryResult,\n  type InitialDataFunction,\n  type SkipToken,\n  skipToken,\n  type StoreOrVal,\n} from '@tanstack/svelte-query'\nimport type { RouteSchema } from 'elysia'\n\nimport type { EdenQueryConfig } from '../../config'\nimport type { EdenContextState } from '../../context'\nimport type { DistributiveOmit } from '../../utils/types'\nimport type { EdenQueryBaseOptions } from '../internal/query-base-options'\nimport type { WithEdenQueryExtension } from '../internal/query-hook-extension'\nimport { getQueryKey } from '../internal/query-key'\n\nexport type EdenCreateQueryOptions<\n  TOutput,\n  TData,\n  TError,\n  TQueryOptsData = TOutput,\n> = DistributiveOmit<\n  CreateBaseQueryOptions<TOutput, TError, TData, TQueryOptsData, any>,\n  'queryKey'\n> &\n  EdenQueryBaseOptions\n\nexport type EdenDefinedCreateQueryOptions<\n  TOutput,\n  TData,\n  TError,\n  TQueryOptsData = TOutput,\n> = DistributiveOmit<\n  CreateBaseQueryOptions<TOutput, TError, TData, TQueryOptsData, any>,\n  'queryKey'\n> &\n  EdenQueryBaseOptions & {\n    initialData: InitialDataFunction<TQueryOptsData> | TQueryOptsData\n  }\n\nexport type EdenCreateQueryResult<TData, TError> = WithEdenQueryExtension<\n  CreateQueryResult<TData, TError>\n>\n\nexport type EdenDefinedCreateQueryResult<TData, TError> = WithEdenQueryExtension<\n  DefinedCreateQueryResult<TData, TError>\n>\n\nexport interface EdenCreateQuery<\n  TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n  // The publicly exposed `createQuery` hook only accepts the `query` object.\n  TInput = InferRouteOptions<TRoute>['query'],\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n> {\n  <TQueryFnData extends TOutput = TOutput, TData = TQueryFnData>(\n    input: StoreOrVal<EmptyToVoid<TInput>>,\n    options: EdenDefinedCreateQueryOptions<TQueryFnData, TData, TError, TOutput>,\n  ): EdenDefinedCreateQueryResult<TData, TError>\n\n  <TQueryFnData extends TOutput = TOutput, TData = TQueryFnData>(\n    input: StoreOrVal<EmptyToVoid<TInput> | SkipToken>,\n    options?: EdenCreateQueryOptions<TQueryFnData, TData, TError, TOutput>,\n  ): EdenCreateQueryResult<TData, TError>\n}\n\nexport function edenCreateQueryOptions(\n  parsedPathsAndMethod: ParsedPathAndMethod,\n  context: EdenContextState<any, any>,\n  // The internal helper to `createQueryOptions` receives the entire input object, including `query` and `params`.\n  input?: InferRouteOptions | SkipToken,\n  options?: EdenCreateQueryOptions<unknown, unknown, any>,\n  config?: EdenQueryConfig,\n): CreateQueryOptions {\n  const { abortOnUnmount, client, queryClient } = context\n\n  const { paths, path, method } = parsedPathsAndMethod\n\n  const isInputSkipToken = input === skipToken && typeof input !== 'object'\n\n  const queryKey = getQueryKey(paths, isInputSkipToken ? undefined : input, 'query')\n\n  const defaultOptions = queryClient.getQueryDefaults(queryKey)\n\n  const initialQueryOptions = { ...defaultOptions, ...options }\n\n  const { eden, ...queryOptions } = initialQueryOptions\n\n  const resolvedQueryOptions = { ...queryOptions, queryKey }\n\n  if (isInputSkipToken) {\n    resolvedQueryOptions.queryFn = input\n    return resolvedQueryOptions\n  }\n\n  resolvedQueryOptions.queryFn = async (queryFunctionContext) => {\n    const params: EdenRequestParams = {\n      ...config,\n      path,\n      method,\n      options: input,\n      ...eden,\n    }\n\n    const shouldForwardSignal = config?.abortOnUnmount ?? eden?.abortOnUnmount ?? abortOnUnmount\n\n    if (shouldForwardSignal) {\n      params.fetch = { ...params.fetch, signal: queryFunctionContext.signal }\n    }\n\n    const result = await client.query(params)\n\n    if (result.error != null) {\n      throw result.error\n    }\n\n    return result.data\n  }\n\n  return resolvedQueryOptions\n}\n","/**\n * Additional properties appended to react-query hooks by the library.\n *\n * The hooks are scoped to an `eden` property on the hook.\n *\n * @example\n *\n * const hello = eden.hello.useQuery()\n *\n * const edenPath = hello.eden.path\n */\nexport type WithEdenQueryExtension<T = {}> = T & {\n  /**\n   * Additional object appended by eden-query.\n   */\n  eden: EdenExtendedQueryHooks\n}\n\n/**\n * Additional hooks added to the original react-query hook result.\n */\nexport type EdenExtendedQueryHooks = {\n  /**\n   * The path used to make the request.\n   *\n   * @example\n   *\n   * '/api/a/index'\n   */\n  path: string\n}\n\nexport type EdenQueryHookInput = {\n  path: readonly string[]\n}\n\nexport function getEdenQueryHookExtension(input: EdenQueryHookInput): EdenExtendedQueryHooks {\n  const path = input.path.join('.')\n\n  const edenQueryExtension: EdenExtendedQueryHooks = { path }\n\n  return edenQueryExtension\n}\n","import {\n  type EdenClient,\n  type EdenRequestParams,\n  type EmptyToVoid,\n  type ExtractEdenTreatyRouteParams,\n  type ExtractEdenTreatyRouteParamsInput,\n  type HttpMutationMethod,\n  type HttpQueryMethod,\n  type HttpSubscriptionMethod,\n  type InferRouteError,\n  type InferRouteOptions,\n  type InferRouteOutput,\n  parsePathsAndMethod,\n  type TypeError,\n} from '@aydee-app/eden'\nimport type {\n  CreateQueryOptions,\n  QueriesOptions,\n  QueriesResults,\n  QueryKey,\n  QueryOptions,\n} from '@tanstack/svelte-query'\nimport type { AnyElysia, RouteSchema } from 'elysia'\nimport type { Readable } from 'svelte/store'\n\nimport type { EdenQueryConfig } from '../../config'\nimport type { CreateQueryOptionsForCreateQueries } from '../../integration/internal/create-query-options-for-create-queries'\nimport type { EdenQueryBaseOptions } from '../../integration/internal/query-base-options'\nimport { type EdenQueryKey, getQueryKey } from '../../integration/internal/query-key'\n\n/**\n * A function that accepts a callback that's called with a proxy object.\n * Invoking the proxy object returns strongly typed query options.\n */\nexport type EdenTreatySvelteQueryCreateQueries<T extends AnyElysia> = <\n  TData extends any[],\n  TCombinedResult = QueriesResults<TData>,\n>(\n  callback: (t: EdenTreatySvelteQueryCreateQueriesProxy<T>) => readonly [...QueriesOptions<TData>],\n) => Readable<TCombinedResult>\n\n/**\n * RPC proxy derived from {@link AnyElysia._routes} that generates query options for `createQueries`.\n * This proxy is passed to the callback provided to the eden-treaty-svelte-query `createQueries` helper.\n */\nexport type EdenTreatySvelteQueryCreateQueriesProxy<T extends AnyElysia> = T extends {\n  _routes: infer TSchema extends Record<string, any>\n}\n  ? EdenTreatySvelteQueryCreateQueriesProxyMapping<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 */\nexport type EdenTreatySvelteQueryCreateQueriesProxyMapping<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = ExtractEdenTreatyRouteParams<TSchema>,\n> = EdenTreatySvelteQueryCreateQueriesPathHooks<TSchema, TPath, TRouteParams> &\n  EdenTreatySvelteQueryCreateQueriesPathParameterHook<TSchema, TPath, TRouteParams>\n\n/**\n * This intersects the object created by {@link EdenTreatySvelteQueryCreateQueriesPathHooks}\n * (for regular path parameters) to handle 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 EdenTreatySvelteQueryCreateQueriesPathParameterHook<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = {},\n> = {} extends TRouteParams\n  ? {}\n  : (\n      params: ExtractEdenTreatyRouteParamsInput<TRouteParams>,\n    ) => EdenTreatySvelteQueryCreateQueriesProxyMapping<\n      TSchema[Extract<keyof TRouteParams, keyof TSchema>],\n      TPath\n    >\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 svelte-query hooks.\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 EdenTreatySvelteQueryCreateQueriesPathHooks<\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    ? EdenTreatySvelteQueryCreateQueriesLeaf<TSchema[K], K, TPath>\n    : EdenTreatySvelteQueryCreateQueriesProxyMapping<TSchema[K], [...TPath, K]>\n}\n/**\n * When a {@link RouteSchema} is found, map it to leaves and stop recursive processing.\n * Based on the HTTP method, leaves may be functions that return {@link CreateQueryOptions}.\n *\n * @template TRoute The {@link RouteSchema} that was found.\n * @template TPath The current path segments up to this point (excluding dynamic path parameters).\n */\nexport type EdenTreatySvelteQueryCreateQueriesLeaf<\n  TRoute extends RouteSchema,\n  TMethod,\n  TPath extends any[] = [],\n> = TMethod extends HttpQueryMethod\n  ? EdenTreatySvelteQueryCreateQueriesQueryLeaf<TRoute, TPath>\n  : TMethod extends HttpMutationMethod\n    ? EdenTreatySvelteQueryCreateQueriesMutationLeaf<TRoute, TPath>\n    : TMethod extends HttpSubscriptionMethod\n      ? EdenTreatySvelteQueryCreateQueriesSubscriptionLeaf<TRoute, TPath>\n      : EdenTreatySvelteQueryCreateQueriesUnknownLeaf<TRoute, TPath>\n\n/**\n * Routes that support queries, e.g. \"GET\" requests, will be mapped to a function that returns {@link CreateQueryOptions}.\n */\nexport type EdenTreatySvelteQueryCreateQueriesQueryLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TInput = InferRouteOptions<TRoute>['query'],\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n  TKey extends QueryKey = EdenQueryKey<TPath>,\n> = (\n  input: EmptyToVoid<TInput>,\n  opts?: CreateQueryOptionsForCreateQueries<TOutput, TInput, TError>,\n) => CreateQueryOptions<TOutput, TError, TOutput, TKey>\n\n/**\n * Routes that support mutations, e.g. anything besides \"GET\" requests, will be mapped to something unknown for now...\n *\n * @todo Decide what mutations should be mapped to...\n */\nexport type EdenTreatySvelteQueryCreateQueriesMutationLeaf<\n  _TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n> = {}\n\n/**\n * Routes that support queries, e.g. anything besides \"GET\" requests, will be mapped to something unknown for now...\n *\n * @todo Decide what subscriptions should be mapped to...\n */\nexport type EdenTreatySvelteQueryCreateQueriesSubscriptionLeaf<\n  _TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n> = {}\n\n/**\n * Routes that support unknown HTTP methods will be mapped to something unknown for now...\n *\n * @todo Decide what unknown methods should be mapped to...\n */\nexport type EdenTreatySvelteQueryCreateQueriesUnknownLeaf<\n  _TRoute extends RouteSchema,\n  _TPath extends any[] = [],\n> = {}\n\n/**\n * Utility type for strongly-typing args in the proxy.\n * @internal\n */\ntype CreateQueriesProxyArgs = [InferRouteOptions, (Partial<QueryOptions> & EdenQueryBaseOptions)?]\n\nexport function createTreatySvelteQueryCreateQueriesProxy<T extends AnyElysia = AnyElysia>(\n  client: EdenClient<T>,\n  paths: string[] = [],\n  config?: EdenQueryConfig<T>,\n): EdenTreatySvelteQueryCreateQueriesProxy<T> {\n  const edenTreatySvelteQueryCreateQueriesProxy = new Proxy(() => {}, {\n    get: (_target, path: string, _receiver) => {\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 createTreatySvelteQueryCreateQueriesProxy(client, nextPaths)\n    },\n    apply: (_target, _thisArg, args: CreateQueriesProxyArgs) => {\n      const { path, method } = parsePathsAndMethod(paths)\n\n      const options = args[0]\n\n      const { eden, ...queryOptionsOverrides } = args[1] ?? {}\n\n      const queryOptions: QueryOptions = {\n        queryKey: getQueryKey(paths, options, 'query'),\n        queryFn: async (context) => {\n          const params: EdenRequestParams = {\n            ...config,\n            ...eden,\n            options,\n            path,\n            method,\n            fetcher: eden?.fetcher ?? config?.fetcher ?? globalThis.fetch,\n          }\n\n          const shouldForwardSignal = config?.abortOnUnmount ?? eden?.abortOnUnmount\n\n          if (shouldForwardSignal) {\n            params.fetch = { ...params.fetch, signal: context.signal }\n          }\n\n          const result = await client.query(params)\n\n          if (result.error != null) {\n            throw result.error\n          }\n\n          return result.data\n        },\n        ...queryOptionsOverrides,\n      }\n\n      return queryOptions\n    },\n  })\n\n  return edenTreatySvelteQueryCreateQueriesProxy as any\n}\n","import {\n  createEdenTreaty,\n  EdenClient,\n  type EdenTreatyClient,\n  type EmptyToVoid,\n  type ExtractEdenTreatyRouteParams,\n  type ExtractEdenTreatyRouteParamsInput,\n  type HttpMutationMethod,\n  type HttpQueryMethod,\n  type InferRouteBody,\n  type InferRouteError,\n  type InferRouteOptions,\n  type InferRouteOutput,\n  parsePathsAndMethod,\n} from '@aydee-app/eden'\nimport {\n  type CancelOptions,\n  type CreateInfiniteQueryOptions,\n  type CreateQueryOptions,\n  dehydrate,\n  type DehydratedState,\n  type InfiniteData,\n  type InvalidateOptions,\n  type InvalidateQueryFilters,\n  type Query,\n  QueryClient,\n  type QueryFilters,\n  type QueryKey,\n  type RefetchOptions,\n  type RefetchQueryFilters,\n  type ResetOptions,\n  type SetDataOptions,\n  type Updater,\n} from '@tanstack/svelte-query'\nimport type { AnyElysia, RouteSchema } from 'elysia'\n\nimport type { EdenQueryConfig } from '../../config'\nimport {\n  contextProps,\n  type EdenContextPropsBase,\n  type EdenContextState,\n  getQueryType,\n} from '../../context'\nimport type { EdenCreateInfiniteQueryOptions } from '../../integration/hooks/create-infinite-query'\nimport type { EdenCreateMutationOptions } from '../../integration/hooks/create-mutation'\nimport type { EdenFetchInfiniteQueryOptions } from '../../integration/hooks/fetch-infinite'\nimport type { EdenFetchQueryOptions } from '../../integration/hooks/fetch-query'\nimport type {\n  ExtractCursorType,\n  InfiniteCursorKey,\n  ReservedInfiniteQueryKeys,\n} from '../../integration/internal/infinite-query'\nimport {\n  type EdenQueryKey,\n  getMutationKey,\n  getQueryKey,\n} from '../../integration/internal/query-key'\nimport { getPathParam } from '../../utils/path-param'\nimport type { DeepPartial, Override, ProtectedIntersection } from '../../utils/types'\n\nexport type EdenTreatySvelteQueryUtils<\n  TElysia extends AnyElysia,\n  TSSRContext,\n> = ProtectedIntersection<\n  DecoratedEdenTreatySvelteQueryContextProps<TElysia, TSSRContext>,\n  EdenTreatySvelteQueryUtilsProxy<TElysia['_routes']>\n>\n\nexport type DecoratedEdenTreatySvelteQueryContextProps<\n  TElysia extends AnyElysia,\n  TSSRContext,\n> = Omit<EdenContextPropsBase<TElysia, TSSRContext>, 'client'> & {\n  client: EdenTreatyClient<TElysia>\n}\n\nexport type EdenTreatySvelteQueryContextProps<\n  TElysia extends AnyElysia,\n  TSSRContext,\n> = EdenContextPropsBase<TElysia, TSSRContext> & {\n  client: EdenClient<TElysia>\n}\n\nexport type EdenTreatySvelteQueryUtilsProxy<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = ExtractEdenTreatyRouteParams<TSchema>,\n> = EdenTreatyQueryUtilsUniversalUtils & {\n  [K in keyof TSchema]: TSchema[K] extends RouteSchema\n    ? EdenTreatyQueryUtilsMapping<TSchema[K], TPath, K>\n    : EdenTreatySvelteQueryUtilsProxy<TSchema[K], [...TPath, K]>\n} & ({} extends TRouteParams\n    ? {}\n    : (\n        params: ExtractEdenTreatyRouteParamsInput<TRouteParams>,\n      ) => EdenTreatySvelteQueryUtilsProxy<\n        TSchema[Extract<keyof TRouteParams, keyof TSchema>],\n        TPath\n      >)\n\ntype EdenTreatyQueryUtilsMapping<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TMethod = '',\n  TInput = InferRouteOptions<TRoute>['query'],\n> = TMethod extends HttpQueryMethod\n  ? EdenTreatyQueryUtilsQueryUtils<TRoute, TPath> &\n      (InfiniteCursorKey extends keyof TInput\n        ? EdenTreatyQueryUtilsInfiniteUtils<TRoute, TPath>\n        : {})\n  : TMethod extends HttpMutationMethod\n    ? EdenQueryUtilsMutationUtils<TRoute, TPath>\n    : never\n\nexport type EdenTreatyQueryUtilsQueryUtils<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TInput = InferRouteOptions<TRoute>['query'],\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n  TKey extends QueryKey = EdenQueryKey<TPath, TInput>,\n> = {\n  fetch: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenFetchQueryOptions<TOutput, TError>,\n  ) => Promise<TOutput>\n\n  prefetch: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenFetchQueryOptions<TOutput, TError>,\n  ) => Promise<void>\n\n  ensureData: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenFetchQueryOptions<TOutput, TError>,\n  ) => Promise<TOutput>\n\n  invalidate: (\n    input?: DeepPartial<TInput>,\n    filters?: Override<\n      InvalidateQueryFilters,\n      {\n        predicate?: (query: Query<TInput, TError, TInput, TKey>) => boolean\n      }\n    >,\n    options?: InvalidateOptions,\n  ) => Promise<void>\n\n  refetch: (\n    input?: TInput,\n    filters?: RefetchQueryFilters,\n    options?: RefetchOptions,\n  ) => Promise<void>\n\n  cancel: (input?: TInput, filters?: QueryFilters, options?: CancelOptions) => Promise<void>\n\n  reset: (input?: TInput, options?: ResetOptions) => Promise<void>\n\n  setData: (\n    input: TInput,\n    updater: Updater<TOutput | undefined, TOutput | undefined>,\n    options?: SetDataOptions,\n  ) => void\n\n  /**\n   * @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata\n   */\n  setQueriesData(\n    input: TInput,\n    filters: QueryFilters,\n    updater: Updater<TOutput | undefined, TOutput | undefined>,\n    options?: SetDataOptions,\n  ): [QueryKey, TOutput]\n\n  getData: (input: EmptyToVoid<TInput>) => TOutput | undefined\n\n  options: (\n    input: EmptyToVoid<TInput>,\n    options?: CreateQueryOptions<TOutput, TError>,\n  ) => CreateQueryOptions<TOutput, TError>\n}\n\nexport type EdenTreatyQueryUtilsInfiniteUtils<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TInput = InferRouteOptions<TRoute, ReservedInfiniteQueryKeys>['query'],\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n  TKey extends QueryKey = EdenQueryKey<TPath, TInput>,\n> = {\n  fetchInfinite: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenFetchInfiniteQueryOptions<TInput, TOutput, TError>,\n  ) => Promise<InfiniteData<TOutput, NonNullable<ExtractCursorType<TInput>>>>\n\n  prefetchInfinite: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenFetchQueryOptions<TOutput, TError>,\n  ) => Promise<void>\n\n  getInfiniteData: (\n    input: EmptyToVoid<TInput>,\n  ) => InfiniteData<TOutput, NonNullable<ExtractCursorType<TInput>>> | undefined\n\n  setInfiniteData: (\n    input: TInput,\n    updater: Updater<\n      InfiniteData<TOutput, NonNullable<ExtractCursorType<TInput>>> | undefined,\n      InfiniteData<TOutput, NonNullable<ExtractCursorType<TInput>>> | undefined\n    >,\n    options?: SetDataOptions,\n  ) => void\n\n  infiniteOptions: (\n    input: EmptyToVoid<TInput>,\n    options?: EdenCreateInfiniteQueryOptions<TInput, TOutput, TError>,\n  ) => CreateInfiniteQueryOptions<TOutput, TError, TOutput, TKey>\n}\n\nexport type EdenQueryUtilsMutationUtils<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TBody = InferRouteBody<TRoute>,\n  TOutput = InferRouteOutput<TRoute>,\n  TError = InferRouteError<TRoute>,\n  _TKey extends QueryKey = EdenQueryKey<TPath, TBody>,\n> = {\n  setMutationDefaults(\n    options:\n      | EdenCreateMutationOptions<TBody, TError, TOutput>\n      | ((args: {\n          canonicalMutationFn: NonNullable<\n            EdenCreateMutationOptions<TBody, TError, TOutput>['mutationFn']\n          >\n        }) => EdenCreateMutationOptions<TBody, TError, TOutput>),\n  ): void\n\n  getMutationDefaults(): EdenCreateMutationOptions<TBody, TError, TOutput> | undefined\n\n  isMutating(): number\n}\n\n/**\n * Utility hooks available at all levels of the utilities proxy.\n */\nexport type EdenTreatyQueryUtilsUniversalUtils = {\n  /**\n   * Invalidate the full router\n   * @link https://trpc.io/docs/v10/useContext#query-invalidation\n   * @link https://tanstack.com/query/v5/docs/framework/react/guides/query-invalidation\n   */\n  invalidate(\n    input?: undefined,\n    filters?: InvalidateQueryFilters,\n    options?: InvalidateOptions,\n  ): Promise<void>\n}\n\nexport function createEdenTreatyQueryUtils<TRouter extends AnyElysia, TSSRContext>(\n  context: EdenContextState<TRouter, TSSRContext>,\n  config?: EdenQueryConfig<TRouter>,\n): EdenTreatySvelteQueryUtils<TRouter, TSSRContext> {\n  const clientProxy = createEdenTreaty(context.client)\n\n  const queryClient = context.queryClient ?? new QueryClient()\n\n  const dehydrated = config?.dehydrated === true ? dehydrate(queryClient) : config?.dehydrated\n\n  const topLevelProperties = {\n    queryClient,\n    dehydrated,\n  }\n\n  const proxy = createEdenTreatyQueryUtilsProxy(context, config)\n\n  const utils = new Proxy(() => {}, {\n    get: (_target, path: string, _receiver): any => {\n      const contextName = path as (typeof contextProps)[number]\n\n      if (Object.prototype.hasOwnProperty.call(topLevelProperties, path)) {\n        return topLevelProperties[path as never]\n      }\n\n      switch (contextName) {\n        case 'client': {\n          return clientProxy\n        }\n\n        default: {\n          if (contextProps.includes(contextName)) {\n            return context[contextName]\n          }\n          return proxy[path as never]\n        }\n      }\n    },\n  })\n\n  return utils as any\n}\n\nexport function mergeDehydrated(\n  source: DehydratedState | QueryClient,\n  destination: DehydratedState,\n): DehydratedState {\n  const dehydratedSource = 'mount' in source ? dehydrate(source) : source\n\n  destination.queries.push(...dehydratedSource.queries)\n  destination.mutations.push(...dehydratedSource.mutations)\n\n  return destination\n}\n\nexport function createEdenTreatyQueryUtilsProxy<TRouter extends AnyElysia, TSSRContext>(\n  context: EdenContextState<TRouter, TSSRContext>,\n  config?: EdenQueryConfig<TRouter>,\n  originalPaths: string[] = [],\n  pathParams: Record<string, any>[] = [],\n): EdenTreatySvelteQueryUtils<TRouter, TSSRContext> {\n  const queryClient = context.queryClient ?? new QueryClient()\n\n  const dehydrated =\n    config?.dehydrated != null && typeof config.dehydrated !== 'boolean'\n      ? config.dehydrated\n      : undefined\n\n  const mergeSSRCache = <T>(result: T) => {\n    if (dehydrated != null) {\n      mergeDehydrated(queryClient, dehydrated)\n    }\n    return result\n  }\n\n  const edenTreatyQueryUtilsProxy = new Proxy(() => {}, {\n    get: (_target, path: string, _receiver) => {\n      const nextPaths = path === 'index' ? [...originalPaths] : [...originalPaths, path]\n      return createEdenTreatyQueryUtilsProxy(context, config, nextPaths, pathParams)\n    },\n    apply: (_target, _thisArg, args) => {\n      const pathParam = getPathParam(args)\n\n      if (pathParam?.key != null) {\n        const allPathParams = [...pathParams, pathParam.param]\n        const pathsWithParams = [...originalPaths, `:${pathParam.key}`]\n        return createEdenTreatyQueryUtilsProxy(context, config, pathsWithParams, allPathParams)\n      }\n\n      const argsCopy = [...args]\n\n      /**\n       * @example ['api', 'hello', 'get', 'invalidate']\n       */\n      const pathsCopy = [...originalPaths]\n\n      /**\n       * @example\n       *\n       * Original array: ['api', 'hello', 'get', 'invalidate']\n       *\n       * Hook: 'invalidate'\n       *\n       * Resulting array: ['api', 'hello', 'get']\n       */\n      const hook = pathsCopy.pop() ?? ''\n\n      /**\n       * This will trim the method from the {@link pathsCopy} if it still exists.\n       *\n       * @example\n       *\n       * Previous array: ['api', 'hello', 'get']\n       *\n       * Method: 'get'\n       *\n       * Resulting array: ['api', 'hello']\n       */\n      const { paths } = parsePathsAndMethod(pathsCopy)\n\n      const queryType = getQueryType(hook)\n\n      // The rest of the args are passed directly to the function.\n      const firstArg = argsCopy.shift()\n\n      let input: any = undefined\n\n      if (firstArg != null) {\n        input ??= {}\n        input.query = firstArg\n      }\n\n      if (pathParams.length) {\n        input ??= {}\n        input.params = {}\n\n        for (const param of pathParams) {\n          for (const key in param) {\n            input.params[key] = param[key]\n          }\n        }\n      }\n\n      const queryKey = getQueryKey(paths, input, queryType)\n\n      switch (hook) {\n        case 'fetch': {\n          return context.fetchQuery(queryKey, ...argsCopy).then(mergeSSRCache)\n        }\n\n        case 'fetchInfinite': {\n          return context.fetchInfiniteQuery(queryKey, argsCopy[0]).then(mergeSSRCache)\n        }\n\n        case 'prefetch': {\n          return context.prefetchQuery(queryKey, ...argsCopy).then(mergeSSRCache)\n        }\n\n        case 'prefetchInfinite': {\n          return context.prefetchInfiniteQuery(queryKey, argsCopy[0]).then(mergeSSRCache)\n        }\n\n        case 'ensureData': {\n          return context.ensureQueryData(queryKey, ...argsCopy).then(mergeSSRCache)\n        }\n\n        case 'invalidate': {\n          return context.invalidateQueries(queryKey, ...argsCopy)\n        }\n\n        case 'reset': {\n          return context.resetQueries(queryKey, ...argsCopy)\n        }\n\n        case 'refetch': {\n          return context.refetchQueries(queryKey, ...argsCopy)\n        }\n\n        case 'cancel': {\n          return context.cancelQuery(queryKey, ...argsCopy)\n        }\n\n        case 'setData': {\n          return context.setQueryData(queryKey, argsCopy[0], argsCopy[1])\n        }\n\n        case 'setQueriesData': {\n          return context.setQueriesData(queryKey, argsCopy[0], argsCopy[1], argsCopy[2])\n        }\n\n        case 'setInfiniteData': {\n          return context.setInfiniteQueryData(queryKey, argsCopy[0], argsCopy[1])\n        }\n\n        case 'getData': {\n          return context.getQueryData(queryKey)\n        }\n\n        case 'getInfiniteData': {\n          return context.getInfiniteQueryData(queryKey)\n        }\n\n        case 'setMutationDefaults': {\n          return context.setMutationDefaults(getMutationKey(paths), input)\n        }\n\n        case 'getMutationDefaults': {\n          return context.getMutationDefaults(getMutationKey(paths))\n        }\n\n        case 'isMutating': {\n          return context.isMutating({ mutationKey: getMutationKey(paths) })\n        }\n\n        default: {\n          throw new TypeError(`eden.${originalPaths.join('.')} is not a function`)\n        }\n      }\n    },\n  })\n\n  return edenTreatyQueryUtilsProxy as any\n}\n","import type {\n  EdenClient,\n  EdenCreateClient,\n  EdenRequestOptions,\n  ExtractEdenTreatyRouteParams,\n  ExtractEdenTreatyRouteParamsInput,\n  HttpBatchLinkOptions,\n  HTTPLinkOptions,\n  HttpMutationMethod,\n  HttpQueryMethod,\n  HttpSubscriptionMethod,\n  InferRouteOptions,\n  TypeError,\n} from '@aydee-app/eden'\nimport type { StoreOrVal } from '@tanstack/svelte-query'\nimport type { AnyElysia, RouteSchema } from 'elysia'\nimport type { Prettify } from 'elysia/types'\n\nimport type { EdenQueryConfig } from '../../config'\nimport type { EdenContextProps, EdenContextState } from '../../context'\nimport type { EdenCreateInfiniteQuery } from '../../integration/hooks/create-infinite-query'\nimport type { EdenCreateMutation } from '../../integration/hooks/create-mutation'\nimport type { EdenCreateQuery } from '../../integration/hooks/create-query'\nimport type { InfiniteCursorKey } from '../../integration/internal/infinite-query'\nimport type {\n  EdenMutationKey,\n  EdenQueryKey,\n  EdenQueryKeyOptions,\n  EdenQueryType,\n} from '../../integration/internal/query-key'\nimport {\n  getMutationKey as internalGetMutationKey,\n  getQueryKey as internalGetQueryKey,\n} from '../../integration/internal/query-key'\nimport { getPathParam, mutateArgs } from '../../utils/path-param'\nimport type { EdenTreatySvelteQueryCreateQueries } from './create-queries'\nimport type { EdenTreatySvelteQueryUtils } from './query-utils'\nimport { createEdenTreatyQueryRootHooks, type EdenTreatyQueryRootHooks } from './root-hooks'\n\n/**\n * The treaty-query API provides utility methods that are available at the root, as well as\n * a strongly-typed proxy representing the {@link AnyElysia} API.\n */\nexport type EdenTreatySvelteQuery<\n  TElysia extends AnyElysia,\n  TSSRContext,\n> = EdenTreatySvelteQueryBase<TElysia, TSSRContext> & EdenTreatySvelteQueryHooks<TElysia>\n\n/**\n * Utilities available at the eden-treaty + svelte-query root.\n */\nexport interface EdenTreatySvelteQueryBase<TElysia extends AnyElysia, TSSRContext> {\n  /**\n   * Get utilities provided via the context API.\n   *\n   * @see https://trpc.io/docs/v11/client/react/useUtils\n   */\n  getUtils(): EdenTreatySvelteQueryUtils<TElysia, TSSRContext>\n\n  /**\n   * Get utilities provided via the context API.\n   *\n   * @deprecated renamed to {@link getUtils} and will be removed in a future tRPC version\n   *\n   * @see https://trpc.io/docs/v11/client/react/useUtils\n   */\n  getContext(): EdenTreatySvelteQueryUtils<TElysia, TSSRContext>\n\n  /**\n   * Returns everything that will be provided from context.\n   *\n   * e.g. the root utility functions, and root configuration settings.\n   */\n  createContext(\n    props: EdenContextProps<TElysia, TSSRContext>,\n    config?: EdenQueryConfig<TElysia>,\n  ): EdenContextState<TElysia, TSSRContext>\n\n  /**\n   * Creates a proxy that can invoke tanstack-query helper functions.\n   */\n  createUtils(\n    props: EdenContextProps<TElysia, TSSRContext>,\n    config?: EdenQueryConfig<TElysia>,\n  ): EdenTreatySvelteQueryUtils<TElysia, TSSRContext>\n\n  /**\n   * Create utilities and provide them via context.\n   */\n  setContext(\n    props: EdenContextProps<TElysia, TSSRContext>,\n    config?: EdenQueryConfig<TElysia>,\n  ): EdenContextState<TElysia, TSSRContext>\n\n  /**\n   * Wraps the `create-queries` svelte-query hook in a type-safe proxy.\n   */\n  createQueries: EdenTreatySvelteQueryCreateQueries<TElysia>\n\n  /**\n   * Create a raw, untyped-client.\n   */\n  createClient: EdenCreateClient<TElysia>\n\n  /**\n   * Convenience method for creating and configuring a client with a single HTTPLink.\n   */\n  createHttpClient: (options?: HTTPLinkOptions<TElysia>) => EdenClient<TElysia>\n\n  /**\n   * Convenience method for creating and configuring a client with a single HttpBatchLink.\n   */\n  createHttpBatchClient: (options?: HttpBatchLinkOptions<TElysia>) => EdenClient<TElysia>\n}\n\n/**\n * RPC proxy derived from {@link AnyElysia._routes} that connects svelte-query with an Elysia.js API.\n */\nexport type EdenTreatySvelteQueryHooks<T extends AnyElysia> = T extends {\n  _routes: infer TSchema extends Record<string, any>\n}\n  ? EdenTreatySvelteQueryHooksProxy<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 EdenTreatySvelteQueryHooksProxy<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = ExtractEdenTreatyRouteParams<TSchema>,\n> = EdenTreatySvelteQueryPathHooks<TSchema, TPath, TRouteParams> &\n  EdenTreatySvelteQueryHooksPathParameterHook<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 svelte-query hooks.\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 EdenTreatySvelteQueryPathHooks<\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    ? EdenTreatySvelteQueryRouteLeaf<TSchema[K], K, TPath>\n    : EdenTreatySvelteQueryHooksProxy<TSchema[K], [...TPath, K]>\n}\n\n/**\n * This intersects the object created by {@link EdenTreatyPathHooks}\n * (for regular path parameters) to handle 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 */\nexport type EdenTreatySvelteQueryHooksPathParameterHook<\n  TSchema extends Record<string, any>,\n  TPath extends any[] = [],\n  TRouteParams = {},\n> = {} extends TRouteParams\n  ? {}\n  : (\n      params: StoreOrVal<ExtractEdenTreatyRouteParamsInput<TRouteParams>>,\n    ) => EdenTreatySvelteQueryHooksProxy<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 objects with svelte-query hooks related to the HTTP method.\n *\n * For example, the object would contain hooks for queries if {@link TMethod} was \"get\".\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 * @template TPath The current path segments up to this point (excluding dynamic path parameters).\n */\nexport type EdenTreatySvelteQueryRouteLeaf<\n  TRoute extends RouteSchema,\n  TMethod,\n  TPath extends any[] = [],\n> = TMethod extends HttpQueryMethod\n  ? EdenTreatySvelteQueryLeaf<TRoute, TPath>\n  : TMethod extends HttpMutationMethod\n    ? EdenTreatySvelteQueryMutationLeaf<TRoute, TPath>\n    : TMethod extends HttpSubscriptionMethod\n      ? EdenTreatySvelteQuerySubscriptionLeaf<TRoute, TPath>\n      : EdenTreatySvelteQueryUnknownLeaf<TRoute, TPath>\n\n/**\n * svelte-query hooks for \"queries\". e.g. routes with a \"GET\" endpoint.\n */\nexport type EdenTreatySvelteQueryLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TInput extends InferRouteOptions<TRoute> = InferRouteOptions<TRoute>,\n> = {\n  createQuery: EdenCreateQuery<TRoute, TPath>\n} & (InfiniteCursorKey extends keyof (TInput['params'] & TInput['query'])\n  ? EdenTreatySvelteQueryInfiniteQueryLeaf<TRoute, TPath>\n  : {})\n\n/**\n * svelte-query hooks for \"infinite-queries\".\n * e.g. routes with a \"GET\" endpoint that also expects \"cursor\" as a query parameter.\n */\nexport type EdenTreatySvelteQueryInfiniteQueryLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n> = {\n  createInfiniteQuery: EdenCreateInfiniteQuery<TRoute, TPath>\n}\n\n/**\n * svelte-query hooks for \"mutations\". e.g. Basically routes with any HTTP methods other than \"GET.\"\n */\nexport type EdenTreatySvelteQueryMutationLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n> = {\n  createMutation: EdenCreateMutation<TRoute, TPath>\n}\n\n/**\n * @todo: svelte-query hooks for \"subscriptions\". e.g. Basically routes that support \"CONNECT\" or \"SUBSCRIBE\" requests.\n *\n * @see https://github.com/trpc/trpc/blob/52a57eaa9c12394778abf5f0e6b52ec6f46288ed/packages/react-query/src/shared/hooks/createHooksInternal.tsx#L347\n * @see https://tkdodo.eu/blog/using-web-sockets-with-react-query\n */\nexport type EdenTreatySvelteQuerySubscriptionLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n  TInput = InferRouteOptions<TRoute>,\n> = {\n  options: Prettify<EdenRequestOptions & TInput>\n  queryKey: EdenQueryKey<TPath>\n}\n\n/**\n * svelte-query hooks for any unknown HTTP methods will just expose all known hooks for now.\n *\n * @todo Decide what hooks to expose...\n */\nexport type EdenTreatySvelteQueryUnknownLeaf<\n  TRoute extends RouteSchema,\n  TPath extends any[] = [],\n> = EdenTreatySvelteQueryLeaf<TRoute, TPath> &\n  EdenTreatySvelteQueryInfiniteQueryLeaf<TRoute, TPath> &\n  EdenTreatySvelteQueryMutationLeaf<TRoute, TPath> &\n  EdenTreatySvelteQuerySubscriptionLeaf<TRoute, TPath>\n\n/**\n * Main entrypoint for this library.\n *\n * @param config Default configuration for the root hooks.\n */\nexport function createEdenTreatySvelteQuery<TElysia extends AnyElysia, TSSRContext = unknown>(\n  config?: EdenQueryConfig<TElysia>,\n): EdenTreatySvelteQuery<TElysia, TSSRContext> {\n  /**\n   * Root hooks are invoked by leaf nodes in the proxy.\n   * Create the utility functions once at the beginning, and have all leaves use the same one.\n   */\n  const rootHooks = createEdenTreatyQueryRootHooks(config)\n\n  /**\n   * The actual proxy.\n   */\n  const edenTreatySvelteQueryProxy = createEdenTreatySvelteQueryProxy(rootHooks, config)\n\n  /**\n   * Wrapper around the proxy that will attempt to return properties found\n   * on the root hooks before accessing the proxy.\n   */\n  const edenTreatySvelteQuery = new Proxy(() => {}, {\n    get: (_target, path: string, _receiver): any => {\n      if (Object.prototype.hasOwnProperty.call(rootHooks, path)) {\n        return rootHooks[path as never]\n      }\n      return edenTreatySvelteQueryProxy[path as never]\n    },\n  })\n\n  return edenTreatySvelteQuery as any\n}\n\n/**\n * Creates the recursive proxy.\n *\n * @param config Root hooks that were created.\n *\n * @param rootHooks The original configuration for eden-treaty.\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 }, writable({ cursor: '456' }) ]\n */\nexport function createEdenTreatySvelteQueryProxy<T extends AnyElysia = AnyElysia>(\n  rootHooks: EdenTreatyQueryRootHooks<T>,\n  config?: EdenQueryConfig<T>,\n  paths: (string | symbol)[] = [],\n  pathParams: StoreOrVal<Record<string, any>>[] = [],\n) {\n  const edenTreatyQueryProxy = 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 createEdenTreatySvelteQueryProxy(rootHooks, config, nextPaths, pathParams)\n    },\n    apply: (_target, _thisArg, args) => {\n      /**\n       * @example ['nendoroid', 'createQuery']\n       */\n      const pathsCopy = [...paths]\n\n      /**\n       * @example 'createQuery'\n       */\n      const hook = pathsCopy.pop() ?? ''\n\n      /**\n       * Hook that returns path segment array.\n       *\n       * @internal\n       */\n      if (hook === routeDefinitionSymbol) {\n        return pathsCopy\n      }\n\n      /**\n       * Determine whether a path parameter can be found from the provided args.\n       *\n       * @example { param: { id: '123' }, key: 'id' }\n       *\n       * The `param` property is the actual argument that was passed,\n       * while the key is the string representing the placeholder.\n       */\n      const pathParam = getPathParam(args)\n\n      /**\n       * Determine if the property can be found on the root hooks.\n       * @example \"createQuery,\" \"createMutation,\" etc.\n       */\n      const isRootProperty = Object.prototype.hasOwnProperty.call(rootHooks, hook)\n\n      if (pathParam?.key != null && !isRootProperty) {\n        /**\n         * An array of objects representing path parameter replacements.\n         * @example [ writable({ id: 123 }) ]\n         */\n        const allPathParams = [...pathParams, pathParam.param]\n\n        /**\n         * Path parameter strings including the current path parameter as a placeholder.\n         *\n         * @example [ 'nendoroid', ':id' ]\n         */\n        const pathsWithParams = [...paths, `:${pathParam.key}`]\n\n        return createEdenTreatySvelteQueryProxy(rootHooks, config, pathsWithParams, allPathParams)\n      }\n\n      // Mutate the args to ensure that it is ordered correctly for its corresponding function call.\n      mutateArgs(hook, args, pathParams)\n\n      /**\n       * ```ts\n       * // The final hook that was invoked.\n       * const hook = \"createQuery\"\n       *\n       * // The array of path segments up to this point.\n       * // Note how \":id\" is included, this will be replaced by the `resolveRequest` function from eden.\n       * const pathsCopy = [\"nendoroid\", \":id\", \"createQuery\"]\n       *\n       * // Accummulated path parameters up to this point.\n       * const pathParams = [ writable({ id: 1895 }) ]\n       *\n       * // If the provided a search query and query options, args may look like this.\n       * const args = [ { location: \"jp\" }, { refetchOnUnmount: true } ]\n       *\n       * // The accummulated path parameters and search query are merged into one \"input\" object.\n       * const modifiedArgs = [\n       *   { query: { location: \"jp\" }, params: { id: 1895 } },\n       *   { refetchOnMount: false }\n       * ]\n       *\n       * // The full function call contains three arguments:\n       * // array of path segments, input, and query options.\n       *\n       * @remarks\n       * // For this example, the input has been converted to a Readable because one of the path\n       * // parameters was a Readable Svelte store.\n       *\n       * rootHooks.createQuery(\n       *   [\"nendoroid\", \":id\", \"name\"],\n       *   derived({ query: { location: \"jp\" }, params: { id: 1895 } }),\n       *   { refetchOnMount: false }\n       * )\n       * ```\n       */\n      const result = (rootHooks as any)[hook](pathsCopy, ...args)\n\n      return result\n    },\n  })\n\n  return edenTreatyQueryProxy\n}\n\nexport const routeDefinitionSymbol = Symbol('eden-treaty-svelte-query-route-definition')\n\n/**\n * Get a query key by providing the proxy at any level.\n */\nexport function getQueryKey<TSchema extends Record<string, any>>(\n  route: EdenTreatySvelteQueryHooksProxy<TSchema>,\n  input?: TSchema extends RouteSchema ? InferRouteOptions<TSchema> : any,\n  type?: EdenQueryType,\n): EdenQueryKey {\n  const paths = (route as any)[routeDefinitionSymbol]()\n  return internalGetQueryKey(paths, input, type ?? 'any')\n}\n\n/**\n * Get a mutation key by providing the proxy at any level.\n */\nexport function getMutationKey<TSchema extends RouteSchema>(\n  route: EdenTreatySvelteQueryHooksProxy<TSchema>,\n  options?: EdenQueryKeyOptions,\n): EdenMutationKey {\n  const paths = (route as any)[routeDefinitionSymbol]()\n  return internalGetMutationKey(paths, options)\n}\n\nexport * from './create-queries'\nexport * from './infer'\nexport * from './query-utils'\nexport * from './root-hooks'\n"],"mappings":";;;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BAAgB;AAK7C,cAAM,gBAAgB,CAAC,GAAG,YAAY,UAAU,KAAK;AAOrD,cAAM,kBAAkB,CAAC,GAAG,OAAO,IAAI,UAAU,GAAG,EAAE;AAEtD,eAAO,iCAAiC,WAAW,QAAQ,iBAAiB,aAAa;AAAA,MAC3F;AAGA,iBAAW,MAAM,MAAM,UAAU;AAqCjC,YAAM,SAAU,UAAkB,IAAI,EAAE,WAAW,GAAG,IAAI;AAE1D,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,IAAM,wBAAwB,OAAO,2CAA2C;AAKhF,SAASC,aACd,OACA,OACA,MACc;AACd,QAAM,QAAS,MAAc,qBAAqB,EAAE;AACpD,SAAO,YAAoB,OAAO,OAAO,QAAQ,KAAK;AACxD;AAKO,SAASC,gBACd,OACA,SACiB;AACjB,QAAM,QAAS,MAAc,qBAAqB,EAAE;AACpD,SAAO,eAAuB,OAAO,OAAO;AAC9C;","names":["getMutationKey","getQueryKey","observer","value","data","domain","url","AbortController","item","promise","defaultHeaders","query","headers","body","options","proxy","noop","noop","element","element","create_slot","attr","noop","subscribe","run","getPathParam","params","import_svelte_query","options","import_svelte_query","options","context","import_svelte_query","import_svelte_query","getPathParam","setContext","getContext","hook","__createQuery","__createQueries","__createInfiniteQuery","createMutation","getPathParam","getQueryKey","getMutationKey"]}