"enable aexpr";

System.register(['active-expression-rewriting', 'src/components/halo/lively-halo-item.js', 'src/client/vivide/scripts/saving.js'], function (_export, _context) {
  "use strict";

  var _getAndCallMember, _setMember, _setLocal, _getLocal, _getGlobal, _getMember, _traceMember, HaloItem, getName, writeFile;

  return {
    setters: [function (_activeExpressionRewriting) {
      _getAndCallMember = _activeExpressionRewriting.getAndCallMember;
      _setMember = _activeExpressionRewriting.setMember;
      _setLocal = _activeExpressionRewriting.setLocal;
      _getLocal = _activeExpressionRewriting.getLocal;
      _getGlobal = _activeExpressionRewriting.getGlobal;
      _getMember = _activeExpressionRewriting.getMember;
      _traceMember = _activeExpressionRewriting.traceMember;
    }, function (_srcComponentsHaloLivelyHaloItemJs) {
      HaloItem = _srcComponentsHaloLivelyHaloItemJs.default;
    }, function (_srcClientVivideScriptsSavingJs) {
      getName = _srcClientVivideScriptsSavingJs.getName;
      writeFile = _srcClientVivideScriptsSavingJs.writeFile;
    }],
    execute: function () {
      const __SystemJSRewritingHack = {};
      _recorder_._src_components_halo_lively_halo_vivide_save_application_item_js = _recorder_._src_components_halo_lively_halo_vivide_save_application_item_js || {};
      let _scope = {};
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'HaloItem', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'HaloItem', HaloItem) : void 0, HaloItem;
        },

        set(thisIsVererySecretVariableName) {
          let _scope2 = {};
          HaloItem = (self.__expressionAnalysisMode__ ? _getLocal(_scope2, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'HaloItem', HaloItem) : void 0, HaloItem;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'writeFile', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'writeFile', writeFile) : void 0, writeFile;
        },

        set(thisIsVererySecretVariableName) {
          let _scope3 = {};
          writeFile = (self.__expressionAnalysisMode__ ? _getLocal(_scope3, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'writeFile', writeFile) : void 0, writeFile;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'getName', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getName', getName) : void 0, getName;
        },

        set(thisIsVererySecretVariableName) {
          let _scope4 = {};
          getName = (self.__expressionAnalysisMode__ ? _getLocal(_scope4, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'getName', getName) : void 0, getName;
          return true;
        },

        enumerable: true,
        configurable: true
      });


      const basePath = "src/client/vivide/scripts/applications/";

      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'basePath', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'basePath', basePath) : void 0, basePath;
        },

        set(thisIsVererySecretVariableName) {
          let _scope5 = {};
          basePath = (self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName), true ? _setLocal(_scope, 'basePath', basePath) : void 0, basePath;
          return true;
        },

        enumerable: true,
        configurable: true
      });
      class LivelyHaloVivideSaveApplicationItem extends HaloItem {
        async onClick(evt) {
          let _scope6 = {};

          const saveTarget = _getMember((self.__expressionAnalysisMode__ ? _getGlobal('window') : void 0, window), 'that');
          const { name, description, url } = await (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'getName', getName) : void 0, getName)((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), "application");
          if ((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'name', name) : void 0, name) === (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined)) {
            return;
          }_setMember(this, 'storedViews', []);
          // set the name on the saveTarget
          /*
          We have to save a multitude of things:
          inputData
          scriptSteps
          And for applications:
          input targets
          output targets
          */
          const stringToSave = (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify((self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), (self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'name', name) : void 0, name), (self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'description', description) : void 0, description)))));
          _setMember(this, 'storedViews', []);
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'writeFile', writeFile) : void 0, writeFile)((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'url', url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'stringToSave', stringToSave) : void 0, stringToSave));
        }

        createJSON(saveTarget, name, description) {
          let _scope7 = {};

          _getAndCallMember(_getMember(this, 'storedViews'), 'push', [_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'id')]);
          _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'applicationName', (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'name', name) : void 0, name));
          _setMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'description', (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'description', description) : void 0, description));
          const script = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'myCurrentScript'), 'toJSON', []);
          const inputSources = _getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'inportSources'), 'filter', [i => {
            let _scope8 = {};
            return !_getAndCallMember(_getMember(this, 'storedViews'), 'includes', [_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'i', i) : void 0, i), 'id')]);
          }]), 'map', [v => {
            let _scope9 = {};

            return self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((self.__expressionAnalysisMode__ ? _getLocal(_scope9, 'v', v) : void 0, v), (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'name', name) : void 0, name));
          }]);
          const outputs = _getAndCallMember(_getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'outportTargets'), 'filter', [i => {
            let _scope10 = {};
            return !_getAndCallMember(_getMember(this, 'storedViews'), 'includes', [_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope10, 'i', i) : void 0, i), 'id')]);
          }]), 'map', [v => {
            let _scope11 = {};

            return self.__expressionAnalysisMode__ ? _traceMember(this, 'createJSON') : void 0, this.createJSON((self.__expressionAnalysisMode__ ? _getLocal(_scope11, 'v', v) : void 0, v), (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'name', name) : void 0, name));
          }]);
          const inputs = _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'input');
          const stringToSave = { description, script, outputs, inputSources, inputs, widget: _getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'widget'), 'tagName'), 'toLowerCase', []), id: _getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'saveTarget', saveTarget) : void 0, saveTarget), 'id') };
          return self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'stringToSave', stringToSave) : void 0, stringToSave;
        }
      }

      _export('default', LivelyHaloVivideSaveApplicationItem);

      if (self.__expressionAnalysisMode__) _traceMember(Object, 'defineProperty');
      Object.defineProperty(_getMember((self.__expressionAnalysisMode__ ? _getGlobal('_recorder_') : void 0, _recorder_), '_src_components_halo_lively_halo_vivide_save_application_item_js'), 'LivelyHaloVivideSaveApplicationItem', {
        get() {
          return self.__expressionAnalysisMode__ ? _getLocal(_scope, 'LivelyHaloVivideSaveApplicationItem', LivelyHaloVivideSaveApplicationItem) : void 0, LivelyHaloVivideSaveApplicationItem;
        },

        set(thisIsVererySecretVariableName) {
          let _scope12 = {};
          _export('default', LivelyHaloVivideSaveApplicationItem = (self.__expressionAnalysisMode__ ? _getLocal(_scope12, 'thisIsVererySecretVariableName', thisIsVererySecretVariableName) : void 0, thisIsVererySecretVariableName)), true ? _setLocal(_scope, 'LivelyHaloVivideSaveApplicationItem', LivelyHaloVivideSaveApplicationItem) : void 0, LivelyHaloVivideSaveApplicationItem;
          return true;
        },

        enumerable: true,
        configurable: true
      });
    }
  };
});