text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const tslib_1 = require("tslib");
  const stream_1 = require("stream");
  const splitTaggedFilename_1 = tslib_1.__importDefault(require("./splitTaggedFilename"));
  class FilterResourceTag extends stream_1.Transform {
      constructor(resourceFilterTag) {
          super({ objectMode: true });
          this.resourceFilterTag = resourceFilterTag;
          this.files = new Map();
      }
      _transform(file, _, callback) {
          if (file.isDirectory()) {
              callback(undefined, file);
              return;
          }
          const { basename, tag } = splitTaggedFilename_1.default(file.basename);
          if (tag === this.resourceFilterTag ||
              (tag === undefined && !this.files.has(file.path))) {
              const newFile = file.clone({ contents: false });
              newFile.basename = basename;
              this.files.set(newFile.path, newFile);
          }
          callback();
      }
      _flush(callback) {
          for (const file of this.files.values()) {
              this.push(file);
          }
          this.files.clear();
          callback();
      }
  }
  function filterResourceTag(tagName) {
      return new FilterResourceTag(tagName);
  }
  exports.default = filterResourceTag;
  