import { c as o } from "../../../../../../../_virtual/cancellation.js";
function c() {
  return new Promise((e) => {
    typeof setImmediate > "u" ? setTimeout(e, 0) : setImmediate(e);
  });
}
let t = 0, l = 10;
function u() {
  return t = performance.now(), new o.CancellationTokenSource();
}
const i = Symbol("OperationCancelled");
function f(e) {
  return e === i;
}
async function m(e) {
  if (e === o.CancellationToken.None)
    return;
  const n = performance.now();
  if (n - t >= l && (t = n, await c(), t = performance.now()), e.isCancellationRequested)
    throw i;
}
class p {
  constructor() {
    this.promise = new Promise((n, a) => {
      this.resolve = (r) => (n(r), this), this.reject = (r) => (a(r), this);
    });
  }
}
export {
  p as Deferred,
  i as OperationCancelled,
  c as delayNextTick,
  m as interruptAndCheck,
  f as isOperationCancelled,
  u as startCancelableOperation
};
