{"version":3,"sources":["iterable/operators/flat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,MAAM,OAAO,eAAyB,SAAQ,SAAkB;IAI9D,YAAY,MAAyB,EAAE,KAAa;QAClD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,6CAA6C;IACrC,CAAC,QAAQ,CAAC,MAAyB,EAAE,KAAa;QACxD,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;gBACzB,MAAM,IAAI,CAAC;aACZ;YACD,OAAO,SAAS,CAAC;SAClB;QACD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;YACzB,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;gBACpB,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE;oBACtD,MAAM,SAAS,CAAC;iBACjB;aACF;iBAAM;gBACL,MAAM,IAAI,CAAC;aACZ;SACF;IACH,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrE,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAI,QAAgB,QAAQ;IAC9C,OAAO,SAAS,uBAAuB,CAAC,MAAmB;QACzD,OAAO,IAAI,eAAe,CAAI,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC","file":"flat.js","sourcesContent":["import { IterableX } from '../iterablex';\nimport { isIterable } from '../../util/isiterable';\nimport { MonoTypeOperatorFunction } from '../../interfaces';\n\nexport class FlattenIterable<TSource> extends IterableX<TSource> {\n  private _source: Iterable<TSource>;\n  private _depth: number;\n\n  constructor(source: Iterable<TSource>, depth: number) {\n    super();\n    this._source = source;\n    this._depth = depth;\n  }\n\n  // eslint-disable-next-line consistent-return\n  private *_flatten(source: Iterable<TSource>, depth: number): Iterable<TSource> {\n    if (depth === 0) {\n      for (const item of source) {\n        yield item;\n      }\n      return undefined;\n    }\n    for (const item of source) {\n      if (isIterable(item)) {\n        for (const innerItem of this._flatten(item, depth - 1)) {\n          yield innerItem;\n        }\n      } else {\n        yield item;\n      }\n    }\n  }\n\n  [Symbol.iterator]() {\n    return this._flatten(this._source, this._depth)[Symbol.iterator]();\n  }\n}\n\n/**\n * Flattens the nested iterable by the given depth.\n *\n * @export\n * @template T The type of elements in the source sequence.\n * @param {number} [depth=Infinity] The depth to flatten the iterable sequence if specified, otherwise infinite.\n * @returns {MonoTypeOperatorFunction<T>} An operator that flattens the iterable sequence.\n */\nexport function flat<T>(depth: number = Infinity): MonoTypeOperatorFunction<T> {\n  return function flattenOperatorFunction(source: Iterable<T>): IterableX<T> {\n    return new FlattenIterable<T>(source, depth);\n  };\n}\n"]}