import * as tsplus_module_1 from "@tsplus/stdlib/exceptions";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/die";
import * as tsplus_module_3 from "@tsplus/stdlib/collections/Chunk/get";
import * as tsplus_module_4 from "@tsplus/stdlib/data/Maybe/toUndefined";
import * as tsplus_module_5 from "@effect/core/stm/TRef/operations/get";
import { concreteTArray } from "@effect/core/stm/TArray/operations/_internal/InternalTArray";
/**
 * Extracts value from ref in array.
 *
 * @tsplus index ets/TArray
 * @tsplus fluent ets/TArray get
 */

export function get_(self, index) {
  void 0;

  if (!Number.isInteger(index) || index < 0 || index >= self.chunk.length) {
    return tsplus_module_2.die(() => new tsplus_module_1.IndexOutOfBounds(index, 0, self.chunk.length));
  }

  return tsplus_module_5.get(tsplus_module_4.toUndefined(tsplus_module_3.get_(self.chunk, index)));
}
/**
 * Extracts value from ref in array.
 *
 * @tsplus static ets/TArray/Aspects get
 */

export const get = index => self => get_(self, index);
//# sourceMappingURL=get.mjs.map