{"version":3,"file":"network-utils.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CACpC,SAA2B,EAC3B,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,IAAI;IAElB,IAAI,SAAS,GAAU,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAElD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEtE,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3B,MAAM,CAAC,gCAAgC;YACzC,CAAC;YAED,sCAAsC;YACtC,MAAM,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAEnD,oBAAoB;YACpB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,MAAM,SAAS,CAAC;AAClB,CAAC;AA3BD,4CA2BC","sourcesContent":["/**\n * Executes a network operation with retry logic for transient failures.\n *\n * @param operation - The async operation to execute.\n * @param maxRetries - Maximum number of retry attempts.\n * @param baseDelayMs - Base delay between retries in milliseconds.\n * @returns Promise that resolves with the operation result.\n */\nexport async function executeWithRetry<T>(\n  operation: () => Promise<T>,\n  maxRetries = 3,\n  baseDelayMs = 1000,\n): Promise<T> {\n  let lastError: Error = new Error('Unknown error');\n\n  for (let attempt = 0; attempt <= maxRetries; attempt++) {\n    try {\n      return await operation();\n    } catch (error) {\n      lastError = error instanceof Error ? error : new Error(String(error));\n\n      if (attempt === maxRetries) {\n        break; // Exit loop after final attempt\n      }\n\n      // Calculate exponential backoff delay\n      const delayMs = baseDelayMs * Math.pow(2, attempt);\n\n      // Wait before retry\n      await new Promise((resolve) => setTimeout(resolve, delayMs));\n    }\n  }\n\n  // This will only be reached if all attempts failed\n  throw lastError;\n}\n"]}