System.register(["src/external/lodash/lodash.js", "src/client/fileindex.js"], function (_export, _context) {
  "use strict";

  var _, FileIndex, SearchRoots, __SystemJSRewritingHack;
  _export("default", void 0);
  return {
    setters: [function (_srcExternalLodashLodashJs) {
      _ = _srcExternalLodashLodashJs.default;
    }, function (_srcClientFileindexJs) {
      FileIndex = _srcClientFileindexJs.default;
    }],
    execute: function () {
      __SystemJSRewritingHack = {};
      _recorder_._src_client_search_roots_js = _recorder_._src_client_search_roots_js || {};
      /*MD # Search Root Management MD*/
      Object.defineProperty(_recorder_._src_client_search_roots_js, "_", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return _;
        },
        set(thisIsVererySecretVariableName) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          _ = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      Object.defineProperty(_recorder_._src_client_search_roots_js, "FileIndex", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return FileIndex;
        },
        set(thisIsVererySecretVariableName) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          FileIndex = thisIsVererySecretVariableName;
          return true;
        },
        enumerable: true,
        configurable: true
      });
      _export("default", SearchRoots = class SearchRoots {
        static getSearchRoots() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return lively.preferences.get("ExtraSearchRoots");
        }
        static setSearchRoots(roots) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return lively.preferences.set("ExtraSearchRoots", roots);
        }

        /*
         * add url to local file index rember to search there  
         */
        static addSearchRoot(url) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          var roots = this.getSearchRoots();
          roots = _.uniq(roots.concat([url]));
          this.setSearchRoots(roots);
          return this.updateSearchRoot(url);
        }
        static updateSearchRoot(url) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return FileIndex.current().addDirectory(url);
        }
        static removeSearchRoot(url, cleanIndex = true) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          var roots = this.getSearchRoots();
          roots = roots.filter(ea => ea != url);
          this.setSearchRoots(roots);
          if (cleanIndex) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
            FileIndex.current().removeDirectory(url);
          }
        }
        static isSearchRoot(url) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return this.getSearchRoots().find(ea => ea == url);
        }
        static async updateAllSearchRoots() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          for (var ea of this.getSearchRoots()) {
            globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
            await this.updateSearchRoot(ea);
          }
        }
      });
      Object.defineProperty(_recorder_._src_client_search_roots_js, "SearchRoots", {
        get() {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          return SearchRoots;
        },
        set(thisIsVererySecretVariableName) {
          globalThis.systemActivity["https://lively-kernel.org/lively4/lively4-ansgar/src/client/search-roots.js"]++;
          _export("default", SearchRoots = thisIsVererySecretVariableName);
          return true;
        },
        enumerable: true,
        configurable: true
      });
    }
  };
});