"use strict";

require("core-js/modules/es.promise");

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

var _api = require("subfirelib/api");

/*
const type = props.route.match.params.type;
const id = props.route.match.params.id;
const mode = props.route.match.params.mode;

const position = props.route.match.params.position;
const bookmarkId = props.route.match.params.bookmarkId;

types:
playlist - playlist
station - playlist
albumID3 - album
albumAction - album
artist - artist
artistAction - artist
album - directory
directoryAction - directory
directory - directory
folderShuffle - folder (fake the object)
playQueue - playQueue (fake the object)
bookmarks - bookmarks (fake the object)
podcasts - podcasts (fake the object)
song - song
*/
const matchers = {
  playlist: ({
    type,
    id
  }) => {
    console.warn('match?', _api.SubsonicCache.Playlists);
    return _api.SubsonicCache.Playlists.find(p => p.id === id);
  }
};
const loaders = {
  playlist: ({
    id
  }) => _api.Subsonic.getPlaylist(id)
}; // defaultResults presumes that the cache is enough.

const defaultResults = res => Promise.resolve(res);

exports.defaultResults = defaultResults;
console.warn('factory', matchers, loaders);
const LoaderFactory = {
  getLoader: (type, finalize, results = defaultResults) => {
    return {
      match: matchers[type],
      load: loaders[type],
      results,
      finalize
    };
  }
};
exports.LoaderFactory = LoaderFactory;
var _default = LoaderFactory;
exports.default = _default;