var _a, _b, _c;

import * as tsplus_module_1 from "@tsplus/stdlib/structure/Hash";
import * as tsplus_module_2 from "@tsplus/stdlib/structure/Equals";
import * as tsplus_module_3 from "@effect/core/io/Exit/operations/succeed";
import * as tsplus_module_4 from "@effect/core/io/Exit/operations/die";
import * as tsplus_module_5 from "@effect/core/io/Exit/operations/fail";
import * as tsplus_module_6 from "@effect/core/io/Exit/operations/interrupt";
export const isState = isState_1;
export const STMStateSym = /*#__PURE__*/Symbol.for("@effect/core/stm/STM/State");
export const State = {};
/**
 * @tsplus unify ets/STM/State
 */

export function unifyState(self) {
  return self;
}
export class Done {
  constructor(exit) {
    this.exit = exit;
    this._tag = "Done";
    this[_a] = STMStateSym;
  }

  [(_a = STMStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.combine(tsplus_module_1.hashString(this._tag), tsplus_module_1.hashUnknown(this.exit));
  }

  [tsplus_module_2.Equals.sym](that) {
    return isState_1(that) && this[tsplus_module_1.Hash.sym]() === that[tsplus_module_1.Hash.sym]();
  }

}
export class Interrupted {
  constructor() {
    this._tag = "Interrupted";
    this[_b] = STMStateSym;
  }

  [(_b = STMStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.hashString(this._tag);
  }

  [tsplus_module_2.Equals.sym](that) {
    return isState_1(that) && this[tsplus_module_1.Hash.sym]() === that[tsplus_module_1.Hash.sym]();
  }

}
export class Running {
  constructor() {
    this._tag = "Running";
    this[_c] = STMStateSym;
  }

  [(_c = STMStateSym, tsplus_module_1.Hash.sym)]() {
    return tsplus_module_1.hashString(this._tag);
  }

  [tsplus_module_2.Equals.sym](that) {
    return isState_1(that) && this[tsplus_module_1.Hash.sym]() === that[tsplus_module_1.Hash.sym]();
  }

}
/**
 * @tsplus static ets/STM/State/Ops isState
 */

function isState_1(u) {
  return typeof u === "object" && u != null && STMStateSym in u;
}
/**
 * @tsplus static ets/STM/State/Ops done
 */


export function done(exit) {
  switch (exit._tag) {
    case "Succeed":
      {
        return new Done(tsplus_module_3.succeed(exit.value));
      }

    case "Die":
      {
        return new Done(tsplus_module_4.die(exit.value));
      }

    case "Fail":
      {
        return new Done(tsplus_module_5.fail(exit.value));
      }

    case "Interrupt":
      {
        return new Done(tsplus_module_6.interrupt(exit.fiberId));
      }

    case "Retry":
      {
        throw new Error("Bug: done being called on TExit.Retry");
      }
  }
}
/**
 * @tsplus static ets/STM/State/Ops interrupted
 */

export const interrupted = /*#__PURE__*/new Interrupted();
/**
 * @tsplus static ets/STM/State/Ops running
 */

export const running = /*#__PURE__*/new Running();
/**
 * @tsplus fluent ets/STM/State isRunning
 */

export function isRunning(self) {
  return self._tag === "Running";
}
//# sourceMappingURL=State.mjs.map