
      }
    } else {
      lastModified = DateNow();
    }

    this[kState] = new FileState(StringPrototypeToWellFormed(`${fileName}`), lastModified);
  }

  get name() {
    if (!isFile(this))
      throw new ERR_INVALID_THIS('File');

    return this[kState].name;
  }

  get lastModified() {
    if (!isFile(this))
      throw new ERR_INVALID_THIS('File');

    return this[kState].lastModified;
  }

  [kInspect](depth, options) {
    if (depth < 0) {
      return this;
    }

    const opts = {
      ...options,
      depth: options.depth == null ? null : options.depth - 1,
    };

    return `File ${inspect({
      size: this.size,
      type: this.type,
      name: this[kState].name,
      lastModified: this[kState].lastModified,
    }, opts)}`;
  }

  [kClone]() {
    return {
      data: { ...super[kClone]().data, ...this[kState] },
      deserializeInfo: 'internal/file:TransferableFile',
    };
  }

  [kDeserialize](data) {
    super[kDeserialize](data);

    this[kState] = new FileState(data.name, data.lastModified);
  }
}

function TransferableFile(handle, length, type = '') {
  FunctionPrototypeApply(TransferableBlob, this, [handle, length, type]);
  ObjectSetPrototypeOf(this, File.prototype);
}

ObjectSetPrototypeOf(TransferableFile.prototype, File.prototype);
ObjectSetPrototypeOf(TransferableFile, File);

ObjectDefineProperties(File.prototype, {
  name: kEnumerableProperty,
  lastModified: kEnumerableProperty,
  [SymbolToStringTag]: {
    __proto__: null,
    configurable: true,
    value: 'File',
  },
});

module.exports = {
  File,
  TransferableFile,
};
