#pragma once

#include <QGeoCoordinate>
#include <QObject>

#include <memory>

class TileData;

class NemoInterface : public QObject {
  Q_OBJECT
  class Impl;
  using PImpl = std::unique_ptr<Impl>;

public:
  enum class STATUS {
    NOT_CONNECTED = 0,
    HEARTBEAT_DETECTED = 1,
    WEBSOCKET_DETECTED = 2,
    TIMEOUT = -1,
    INVALID_HEARTBEAT = -2
  };

  explicit NemoInterface(QObject *parent = nullptr);
  ~NemoInterface() override;

  Q_PROPERTY(int status READ status NOTIFY statusChanged)
  Q_PROPERTY(QString statusString READ statusString NOTIFY statusChanged)
  Q_PROPERTY(QVector<int> progress READ progress NOTIFY progressChanged)
  Q_PROPERTY(QString editorQml READ editorQml CONSTANT)
  Q_PROPERTY(bool running READ running NOTIFY runningChanged)

  Q_INVOKABLE void start();
  Q_INVOKABLE void stop();
  Q_INVOKABLE void publishTileData();
  Q_INVOKABLE void requestProgress();

  void setTileData(const TileData &tileData);
  bool hasTileData(const TileData &tileData) const;
  void setAutoPublish(bool ap);
  void setHoldProgress(bool hp);

  int status() const;
  STATUS statusEnum() const;
  QString statusString() const;
  QVector<int> progress() const;
  QString editorQml();
  bool running();

signals:
  void statusChanged();
  void progressChanged();
  void runningChanged();

private:
  PImpl pImpl;
};
