{"version":3,"file":"url.cjs","names":["defaultDevServerHost","defaultInngestApiBaseUrl"],"sources":["../../src/helpers/url.ts"],"sourcesContent":["import { defaultDevServerHost, defaultInngestApiBaseUrl } from \"./consts.ts\";\nimport { devServerAvailable } from \"./devserver.ts\";\nimport type { Mode } from \"./env.ts\";\n\ninterface ResolveApiBaseUrlOpts {\n  /**\n   * An explicit API base URL to use. If provided, this will be returned\n   * directly without any further logic.\n   */\n  apiBaseUrl: string | undefined;\n\n  /**\n   * The current mode of the SDK, indicating whether it's running in dev or\n   * cloud mode and whether that was explicitly set or inferred.\n   */\n  mode: Mode;\n\n  /**\n   * The fetch implementation to use when checking for dev server availability.\n   * If not provided, defaults to globalThis.fetch.\n   */\n  fetch?: typeof fetch;\n}\n\n/**\n * Resolves the API base URL based on the provided configuration.\n *\n * The resolution logic follows this order of precedence:\n * 1. If an explicit `apiBaseUrl` is provided, use it directly\n * 2. If in dev mode AND that mode was inferred (not explicitly set), check if\n *    the dev server is available and use it if so\n * 3. Fall back to the production API URL\n *\n * This function is used by both `InngestApi` and `ConnectionCore` to ensure\n * consistent URL resolution logic across the SDK.\n */\nexport function resolveApiBaseUrl(opts: ResolveApiBaseUrlOpts): string {\n  if (opts.apiBaseUrl !== undefined) {\n    return opts.apiBaseUrl;\n  }\n\n  if (opts.mode === \"dev\") {\n    return defaultDevServerHost;\n  }\n\n  return defaultInngestApiBaseUrl;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,MAAqC;AACrE,KAAI,KAAK,eAAe,OACtB,QAAO,KAAK;AAGd,KAAI,KAAK,SAAS,MAChB,QAAOA;AAGT,QAAOC"}