"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getManifest = getManifest;
exports.default = void 0;

var _settings = _interopRequireDefault(require("../models/settings"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function getManifest(_x, _x2) {
  return _getManifest.apply(this, arguments);
}

function _getManifest() {
  _getManifest = _asyncToGenerator(function* (req, res) {
    const iconsDirectory = 'favicon/';
    const scope = process.kresus.urlPrefix;
    let userId = req.user.id; // Eslint does not like camel_case keys in the JSON

    /* eslint-disable */

    res.status(200).contentType('application/manifest+json').json({
      name: 'Kresus',
      short_name: 'Kresus',
      description: 'Your personal finances manager',
      lang: yield _settings.default.getLocale(userId),
      start_url: scope,
      scope,
      display: 'fullscreen',
      theme_color: '#303641',
      icons: [{
        src: `${iconsDirectory}favicon-16x16.png`,
        sizes: '16x16',
        type: 'image/png',
        density: 0.75
      }, {
        src: `${iconsDirectory}favicon-32x32.png`,
        sizes: '32x32',
        type: 'image/png',
        density: 0.75
      }, {
        src: `${iconsDirectory}favicon-48x48.png`,
        sizes: '48x48',
        type: 'image/png',
        density: 1
      }, {
        src: `${iconsDirectory}favicon-96x96.png`,
        sizes: '96x96',
        type: 'image/png',
        density: 2
      }, {
        src: `${iconsDirectory}favicon-144x144.png`,
        sizes: '144x144',
        type: 'image/png',
        density: 3
      }, {
        src: `${iconsDirectory}favicon-192x192.png`,
        sizes: '192x192',
        type: 'image/png',
        density: 4
      }]
    });
    /* eslint-enable */
  });
  return _getManifest.apply(this, arguments);
}

var _default = {
  manifest: {
    get: getManifest
  }
};
exports.default = _default;