const fileName_1 = "(@effect/core) _src/io/Ref/operations/_internal/RefInternal.ts";
import * as tsplus_module_1 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Maybe/getOrElse";
import { RefSym } from "@effect/core/io/Ref/definition";
export const RefInternal = {
  /**
   * Internal Discriminator
   */
  get [RefSym]() {
    return RefSym;
  },

  /**
   * Atomically writes the specified value to the `Ref`, returning the value
   * immediately before modification.
   */
  getAndSet(a, __tsplusTrace) {
    return this.modify(v => tsplus_module_1.make(v, a), fileName_1 + ":17:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified function, returning the
   * value immediately before modification.
   */
  getAndUpdate(f, __tsplusTrace) {
    return this.modify(v => tsplus_module_1.make(v, f(v)), fileName_1 + ":25:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified partial function,
   * returning the value immediately before modification. If the function is
   * undefined on the current value it doesn't change it.
   */
  getAndUpdateSome(pf, __tsplusTrace) {
    return this.modify(v => tsplus_module_1.make(v, tsplus_module_2.getOrElse_(pf(v), () => v)), fileName_1 + ":34:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified partial function, which
   * computes a return value for the modification if the function is defined on
   * the current value otherwise it returns a default value. This is a more
   * powerful version of `updateSome`.
   */
  modifySome(fallback, pf, __tsplusTrace) {
    return this.modify(v => tsplus_module_2.getOrElse_(pf(v), () => tsplus_module_1.make(fallback, v)), fileName_1 + ":49:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified function.
   */
  update(f, __tsplusTrace) {
    return this.modify(v => tsplus_module_1.make(undefined, f(v)), fileName_1 + ":56:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified function and returns the
   * updated value.
   */
  updateAndGet(f, __tsplusTrace) {
    return this.modify(v => {
      const result = f(v);
      return tsplus_module_1.make(result, result);
    }, fileName_1 + ":64:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified partial function. If the
   * function is undefined on the current value it doesn't change it.
   */
  updateSome(pf, __tsplusTrace) {
    return this.modify(v => tsplus_module_1.make(undefined, tsplus_module_2.getOrElse_(pf(v), () => v)), fileName_1 + ":76:23");
  },

  /**
   * Atomically modifies the `Ref` with the specified partial function. If the
   * function is undefined on the current value it returns the old value without
   * changing it.
   */
  updateSomeAndGet(pf, __tsplusTrace) {
    return this.modify(v => {
      const result = tsplus_module_2.getOrElse_(pf(v), () => v);
      return tsplus_module_1.make(result, result);
    }, fileName_1 + ":85:23");
  }

};
//# sourceMappingURL=RefInternal.mjs.map