/** Polling with a total deadline, shared by the two browser-compatible vi helpers. */
export declare const STORY_POLLING_CODE = "\n/** Polls without overlapping callbacks, retaining each helper's error semantics. */\nfunction pollValue(callback, options, until) {\n  const { interval = 50, timeout = 1000 } = typeof options === 'number' ? { timeout: options } : options\n  return new Promise((resolve, reject) => {\n    let stopped = false\n    let retryTimer\n    let lastError\n\n    /** Settles once and prevents abandoned callbacks from scheduling more work. */\n    function finish(success, value) {\n      if (stopped) return\n      stopped = true\n      clearTimeout(deadlineTimer)\n      clearTimeout(retryTimer)\n      if (success) resolve(value)\n      else reject(value)\n    }\n\n    // A separate timer bounds even a callback promise that never settles.\n    const deadlineTimer = setTimeout(() => {\n      finish(false, lastError || new Error(until ? 'Timed out in waitUntil!' : 'Timed out in waitFor!'))\n    }, timeout)\n\n    /** Retries only after the previous callback settled. */\n    function retry() {\n      if (!stopped) retryTimer = setTimeout(check, interval)\n    }\n\n    /** waitFor retries assertions; waitUntil treats any error as final. */\n    function onError(error) {\n      if (stopped) return\n      lastError = error\n      if (until) finish(false, error)\n      else retry()\n    }\n\n    /** Evaluates both synchronous callbacks and promises under the same deadline. */\n    function check() {\n      if (stopped) return\n      try {\n        Promise.resolve(callback()).then(value => {\n          if (until && !value) retry()\n          else finish(true, value)\n        }, onError)\n      }\n      catch (error) {\n        onError(error)\n      }\n    }\n\n    check()\n  })\n}\n\n/** Retries rejected assertions and returns the first successful value. */\nfunction waitForValue(callback, options = {}) {\n  return pollValue(callback, options, false)\n}\n\n/** Retries falsy values and rejects callback errors immediately. */\nfunction waitUntilValue(callback, options = {}) {\n  return pollValue(callback, options, true)\n}\n";
//# sourceMappingURL=polling.d.ts.map