"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, _setLocal, _getLocal, _getGlobal, _getMember, _traceMember, HaloItem, getName, writeFile;

  return {
    setters: [function (_activeExpressionRewriting) {
      _getAndCallMember = _activeExpressionRewriting.getAndCallMember;
      _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_script_item_js = _recorder_._src_components_halo_lively_halo_vivide_save_script_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_script_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_script_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_script_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
      });
      class LivelyHaloVivideSaveScriptItem extends HaloItem {
        async onClick() {
          let _scope5 = {};

          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(_scope5, 'saveTarget', saveTarget) : void 0, saveTarget), "script");
          const content = (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(_scope5, 'saveTarget', saveTarget) : void 0, saveTarget), (self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'name', name) : void 0, name), (self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'description', description) : void 0, description)))));
          (self.__expressionAnalysisMode__ ? _getLocal(_scope, 'writeFile', writeFile) : void 0, writeFile)((self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'url', url) : void 0, url), (self.__expressionAnalysisMode__ ? _getLocal(_scope5, 'content', content) : void 0, content));
        }

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

          if ((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'name', name) : void 0, name) === (self.__expressionAnalysisMode__ ? _getGlobal('undefined') : void 0, undefined)) {
            return;
          } /*
            We have to save a multitude of things:
            inputData
            scriptStepson
            And for applications:
            input targets
            output targets
            */
          // We also want to save a description for scripts so we can suggest with more info
          // Additionally we want to safe the shape of the in and out object with types for later suggestion
          const script = _getAndCallMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), 'myCurrentScript'), 'toJSON', []);
          const stringToSave = {
            script,
            description,
            widget: _getAndCallMember(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), 'widget'), 'tagName'), 'toLowerCase', []),
            inputs: (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), 'input'))),
            inScheme: (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify(_getMember(_getMember((self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget), 'input'), 0), (_, value) => {
              let _scope7 = {};
              return typeof (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'value', value) : void 0, value) === "object" ? (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'value', value) : void 0, value) : typeof (self.__expressionAnalysisMode__ ? _getLocal(_scope7, 'value', value) : void 0, value);
            })),
            outScheme: (self.__expressionAnalysisMode__ ? _traceMember(JSON, 'stringify') : void 0, (self.__expressionAnalysisMode__ ? _getGlobal('JSON') : void 0, JSON).stringify(_getMember((self.__expressionAnalysisMode__ ? _traceMember(saveTarget, 'getDataToTransmit') : void 0, (self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'saveTarget', saveTarget) : void 0, saveTarget).getDataToTransmit()), 0), (_, value) => {
              let _scope8 = {};
              return typeof (self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'value', value) : void 0, value) === "object" ? (self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'value', value) : void 0, value) : typeof (self.__expressionAnalysisMode__ ? _getLocal(_scope8, 'value', value) : void 0, value);
            }))
          };
          return self.__expressionAnalysisMode__ ? _getLocal(_scope6, 'stringToSave', stringToSave) : void 0, stringToSave;
        }
      }

      _export('default', LivelyHaloVivideSaveScriptItem);

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

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

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