import { K as r } from "../shared-types-CIxCt9tj.js";
class i extends r {
  constructor() {
    super("Cannot update a completed AsyncDeliveredObject");
  }
  get userFacingSessionErrorMessage() {
    return "Closed stream had unexpected results delivered";
  }
}
class l {
  value;
  isComplete = !1;
  resolvePromise;
  promise;
  constructor(e) {
    this.value = e, this.promise = new Promise((t) => {
      this.resolvePromise = t;
    });
  }
  getCurrentValue() {
    return this.value;
  }
  isCompleted() {
    return this.isComplete;
  }
  update(e) {
    if (this.isComplete)
      throw new i();
    this.value = e;
  }
  complete(e) {
    this.isComplete || (e !== void 0 && (this.value = e), this.isComplete = !0, this.resolvePromise && this.resolvePromise(this.value));
  }
  getCompletionPromise() {
    return this.isComplete ? Promise.resolve(this.value) : this.promise;
  }
  async waitForCompletion() {
    return this.getCompletionPromise();
  }
}
export {
  l as AsyncDeliveredObject,
  i as CompletedObjectUpdateError
};
//# sourceMappingURL=index.js.map
