import * as tracing_1 from "../../../../Tracing"
const fileName_1 =
  "(@effect-ts/system): _src/Collections/Immutable/Chunk/api/splitWhere.ts"
import { concreteId } from "../definition"
import { splitAt_ } from "./splitAt"
/**
 * Splits this chunk on the first element that matches this predicate.
 */

export function splitWhere_(self, f) {
  const iterator = self.arrayLikeIterator()
  let next
  let cont = true
  let i = 0

  while (cont && (next = iterator.next()) && !next.done) {
    const array = next.value
    const len = array.length
    let j = 0

    while (cont && j < len) {
      const a = array[j]

      if (f(a)) {
        cont = false
      } else {
        i++
        j++
      }
    }
  }

  return splitAt_(self, i)
}
/**
 * Splits this chunk on the first element that matches this predicate.
 *
 * @dataFirst splitWhere_
 */

export function splitWhere(f) {
  return (self) => splitWhere_(self, f)
}
//# sourceMappingURL=splitWhere.js.map
