You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
9 lines
54 KiB
9 lines
54 KiB
var gcs=function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=3)}([function(e,t,n){(function(B,H){
|
|
/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
|
* @version v4.2.4+314e4831
|
|
*/
|
|
e.exports=function(){"use strict";function u(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=0,t=void 0,o=void 0,s=function(e,t){p[r]=e,p[r+1]=t,2===(r+=2)&&(o?o(f):y())},e="undefined"!=typeof window?window:void 0,i=e||{},a=i.MutationObserver||i.WebKitMutationObserver,c="undefined"==typeof self&&void 0!==B&&"[object process]"==={}.toString.call(B),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var e=setTimeout;return function(){return e(f,1)}}var p=new Array(1e3);function f(){for(var e=0;e<r;e+=2){var t=p[e],n=p[e+1];t(n),p[e]=void 0,p[e+1]=void 0}r=0}var m,h,v,g,y=void 0;function w(e,t){var n=this,r=new this.constructor(P);void 0===r[_]&&G(r);var o=n._state;if(o){var i=arguments[o-1];s(function(){return L(o,r,i,n._result)})}else U(n,r,e,t);return r}function b(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(P);return F(t,e),t}y=c?function(){return B.nextTick(f)}:a?(h=0,v=new a(f),g=document.createTextNode(""),v.observe(g,{characterData:!0}),function(){g.data=h=++h%2}):l?((m=new MessageChannel).port1.onmessage=f,function(){return m.port2.postMessage(0)}):void 0===e?function(){try{var e=Function("return this")().require("vertx");return void 0===(t=e.runOnLoop||e.runOnContext)?d():function(){t(f)}}catch(e){return d()}}():d();var _=Math.random().toString(36).substring(2);function P(){}var D=void 0,S=1,k=2,I={error:null};function E(e){try{return e.then}catch(e){return I.error=e,I}}function C(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}function T(e,t,n){var r,o,i,a;t.constructor===e.constructor&&n===w&&t.constructor.resolve===b?(i=e,(a=t)._state===S?x(i,a._result):a._state===k?M(i,a._result):U(a,void 0,function(e){return F(i,e)},function(e){return M(i,e)})):n===I?(M(e,I.error),I.error=null):void 0===n?x(e,t):u(n)?(r=t,o=n,s(function(t){var n=!1,e=C(o,r,function(e){n||(n=!0,r!==e?F(t,e):x(t,e))},function(e){n||(n=!0,M(t,e))},t._label);!n&&e&&(n=!0,M(t,e))},e)):x(e,t)}function F(e,t){var n,r;e===t?M(e,new TypeError("You cannot resolve a promise with itself")):(r=typeof(n=t),null===n||"object"!==r&&"function"!==r?x(e,t):T(e,t,E(t)))}function O(e){e._onerror&&e._onerror(e._result),A(e)}function x(e,t){e._state===D&&(e._result=t,e._state=S,0!==e._subscribers.length&&s(A,e))}function M(e,t){e._state===D&&(e._state=k,e._result=t,s(O,e))}function U(e,t,n,r){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+S]=n,o[i+k]=r,0===i&&e._state&&s(A,e)}function A(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r=void 0,o=void 0,i=e._result,a=0;a<t.length;a+=3)r=t[a],o=t[a+n],r?L(n,r,o,i):o(i);e._subscribers.length=0}}function L(e,t,n,r){var o=u(n),i=void 0,a=void 0,s=void 0,c=void 0;if(o){if((i=function(e,t){try{return e(t)}catch(e){return I.error=e,I}}(n,r))===I?(c=!0,a=i.error,i.error=null):s=!0,t===i)return void M(t,new TypeError("A promises callback cannot return that same promise."))}else i=r,s=!0;t._state!==D||(o&&s?F(t,i):c?M(t,a):e===S?x(t,i):e===k&&M(t,i))}var N=0;function G(e){e[_]=N++,e._state=void 0,e._result=void 0,e._subscribers=[]}var j=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(P),this.promise[_]||G(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&x(this.promise,this._result))):M(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;this._state===D&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===b){var o=E(t);if(o===w&&t._state!==D)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===R){var i=new n(P);T(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},e.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===D&&(this._remaining--,e===k?M(r,n):this._result[t]=n),0===this._remaining&&x(r,this._result)},e.prototype._willSettleAt=function(e,t){var n=this;U(e,void 0,function(e){return n._settledAt(S,t,e)},function(e){return n._settledAt(k,t,e)})},e}(),R=function(){function t(e){this[_]=N++,this._result=this._state=void 0,this._subscribers=[],P!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(t,e){try{e(function(e){F(t,e)},function(e){M(t,e)})}catch(e){M(t,e)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var n=this.constructor;return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})})},t}();return R.prototype.then=w,R.all=function(e){return new j(this,e).promise},R.race=function(o){var i=this;return n(o)?new i(function(e,t){for(var n=o.length,r=0;r<n;r++)i.resolve(o[r]).then(e,t)}):new i(function(e,t){return t(new TypeError("You must pass an array to race."))})},R.resolve=b,R.reject=function(e){var t=new this(P);return M(t,e),t},R._setScheduler=function(e){o=e},R._setAsap=function(e){s=e},R._asap=s,R.polyfill=function(){var e=void 0;if(void 0!==H)e=H;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=R},R.Promise=R}()}).call(this,n(5),n(6))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),l=n(2),r=function(){function e(e,t,n,r){if(e instanceof l.Diagram&&(e=[e]),this._managedDiagrams=e,this._currentDiagramFile={name:null,id:null,path:null},this._isAutoSaving=!0,n?this._clientId=n:n=null,t){var o=t.trim().charAt(0);t&&"{"===o&&(this._defaultModel=t),this._iconsRelativeDirectory="{"===o||r?r||"../goCloudStorageIcons/":t}else this._defaultModel=null;var i=document.createElement("div");function a(e){e.addModelChangedListener(function(e){e.isTransactionFinished&&c.isAutoSaving&&""!==e.oldValue&&c.currentDiagramFile.name&&c.save()})}i.className="goCustomFilepicker",i.style.visibility="hidden",document.getElementsByTagName("body")[0].appendChild(i),this._ui=i,this._deferredPromise={promise:this.makeDeferredPromise()};var s=this.managedDiagrams,c=this;if(s instanceof l.Diagram)a(s);else for(var u=0;u<s.length;u++)a(s[u])}return Object.defineProperty(e.prototype,"managedDiagrams",{get:function(){return this._managedDiagrams},set:function(e){this._managedDiagrams=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultModel",{get:function(){return this._defaultModel},set:function(e){this._defaultModel=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iconsRelativeDirectory",{get:function(){return this._iconsRelativeDirectory},set:function(e){this._iconsRelativeDirectory=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientId",{get:function(){return this._clientId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentDiagramFile",{get:function(){return this._currentDiagramFile},set:function(e){this._currentDiagramFile=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAutoSaving",{get:function(){return this._isAutoSaving},set:function(e){this._isAutoSaving=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"serviceName",{get:function(){return this._serviceName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ui",{get:function(){return this._ui},enumerable:!0,configurable:!0}),e.prototype.authorize=function(e){return void 0===e&&(e=!1),new s.Promise(function(e,t){t("authorize not implemented")})},e.prototype.makeDeferredPromise=function(){var n,r,e=new s.Promise(function(e,t){n=e,r=t});return e.resolve=n,e.reject=r,e},e.prototype.getUserInfo=function(){return new s.Promise(function(e,t){t("getUserInfo not implemented")})},e.prototype.hideUI=function(e){void 0===e&&(e=!1);if(this.ui.style.visibility="hidden",e){var t=document.getElementById("actionButton").innerHTML;this._deferredPromise.promise.resolve(t+" canceled by user"),this._deferredPromise.promise=this.makeDeferredPromise()}},e.prototype.checkFileExists=function(e){return new s.Promise(function(e,t){t("checkFileExists not implemented")})},e.prototype.getFile=function(e){return new s.Promise(function(e,t){throw Error("getFile not implemented")})},e.prototype.showUI=function(e){return new s.Promise(function(e,t){throw Error("showUI not implemented")})},e.prototype.create=function(r,o){void 0===o&&(o=!1);var i=this;function a(e){i.defaultModel?e.model=l.Model.fromJson(JSON.parse(i.defaultModel)):e.model=new l.GraphLinksModel}return new s.Promise(function(n,e){if(o&&i.promptUserToSaveBeforeNew().then(function(e){if(e)i.saveWithUI().then(function(e){if(i.currentDiagramFile={name:null,id:null,path:null},i.managedDiagrams instanceof l.Diagram)a(i.managedDiagrams);else for(var t=0;t<i.managedDiagrams.length;t++)a(i.managedDiagrams[t]);i.isAutoSaving?n(r?i.save(r):i.saveWithUI()):n("New diagram created.")});else{if(i.currentDiagramFile={name:null,id:null,path:null},i.managedDiagrams instanceof l.Diagram)a(i.managedDiagrams);else for(var t=0;t<i.managedDiagrams.length;t++)a(i.managedDiagrams[t]);i.isAutoSaving?n(r?i.save(r):i.saveWithUI()):n("New diagram created.")}}),!o){if(i.currentDiagramFile={name:null,id:null,path:null},i.managedDiagrams instanceof l.Diagram)a(i.managedDiagrams);else for(var t=0;t<i.managedDiagrams.length;t++)a(i.managedDiagrams[t]);i.isAutoSaving?n(r?i.save(r):i.saveWithUI()):n("New diagram created.")}})},e.prototype.promptUserToSaveBeforeNew=function(){return new s.Promise(function(e,t){var n=document.getElementById("gcs-save-before-new");n&&document.body.removeChild(n);var r=document.createElement("div");r.id="gcs-save-before-new";var o=document.createElement("p");o.innerText="Save current diagram(s) before creating a new file?";var i=document.createElement("button");i.innerText="Yes";var a=document.createElement("button");a.innerText="No",i.onclick=function(){document.body.removeChild(r),e(!0)},a.onclick=function(){document.body.removeChild(r),e(!1)},a.style.float="right",r.style["font-family"]="Arial, Helvetica, sans-serif",r.style.width="400px",r.style.top="25%",r.style.left="40%",r.style.position="absolute",r.style.border="1px solid black",r.style.padding="10px",r.style["box-shadow"]="10px 10px 5px #888888",r.style.background="white",r.style["z-index"]="100",r.appendChild(o),r.appendChild(i),r.appendChild(a),document.body.appendChild(r)})},e.prototype.makeSaveFile=function(){var e="{\n";if(0!==this.managedDiagrams.length){for(var t=0;t<this.managedDiagrams.length;t++){var n=this.managedDiagrams[t],r=n.div.id;n.model.toJson();e+='"'+r+'": '+n.model.toJson(),t+1!==this.managedDiagrams.length&&(e+=",\n")}return e+="\n}"}},e.prototype.loadFromFileContents=function(e){var t=JSON.parse(e);for(var n in t){var r=t[n],o=document.getElementById(n),i=l.Diagram.fromDiv(o);if(!i)throw Error("No Diagram on page is associated with a div with id "+n);i.model=l.Model.fromJson(JSON.stringify(r))}},e.prototype.saveWithUI=function(){return new s.Promise(function(e,t){t("saveWithUI not implemented")})},e.prototype.save=function(e){return new s.Promise(function(e,t){t("save not implemented")})},e.prototype.load=function(e){return new s.Promise(function(e,t){t("load not implemented")})},e.prototype.loadWithUI=function(){return new s.Promise(function(e,t){t("loadWithUI not implemented")})},e.prototype.remove=function(e){return new s.Promise(function(e,t){t("remove not implemented")})},e.prototype.removeWithUI=function(){return new s.Promise(function(e,t){t("removeWithUI not implemented")})},e}();t.GoCloudStorage=r},function(e,t){e.exports=go},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),e.exports={GoLocalStorage:n(4).GoLocalStorage,GoDropBox:n(7).GoDropBox,GoGoogleDrive:n(8).GoGoogleDrive,GoOneDrive:n(9).GoOneDrive,GoNetCore:n(10).GoNetCore,GoCloudStorageManager:n(11).GoCloudStorageManager}},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),o=function(o){function S(e,t,n){var r=o.call(this,e,t,null,n)||this;return r._localStorage=window.localStorage,r.ui.id="goLocalStorageCustomFilepicker",r._serviceName="Local Storage",r._className="GoLocalStorage",r}return i(S,o),Object.defineProperty(S.prototype,"localStorage",{get:function(){return this._localStorage},enumerable:!0,configurable:!0}),S.prototype.authorize=function(e){void 0===e&&(e=!1);var n=this;return new s.Promise(function(t,e){try{n.localStorage.setItem("item","item"),n.localStorage.removeItem("item"),t(!0)}catch(e){t(!1)}})},S.prototype.showUI=function(e,t){var n=this,r=n.ui,o="qwe45qw34";t||(t=0);var i=S._MIN_FILES_IN_UI+t;r.innerHTML="<img class='icons' src='"+n.iconsRelativeDirectory+"localStorage.png'></img>";var a=e+" Diagram File";r.innerHTML+="<strong>"+a+"</strong><hr></hr>",r.style.visibility="visible";var s=document.createElement("div");s.id="fileOptions";var c=[],u=0,l=!1;if(0!==n.localStorage.length){for(var d in n.localStorage)if(c.length<i){u++;var p=n.localStorage.getItem(d);if(p&&(-1!==p.indexOf("GraphLinksModel")||-1!==p.indexOf("TreeModel"))){var f={key:d,model:p};c.push(f)}u===n.localStorage.length&&(l=!0)}}else l=!0;if(0!==c.length)for(var m=0;m<c.length;m++){var h=(f=c[m].key).replace(/ /g,o);s.innerHTML+="Save"!==e?"<div class='fileOption'><input id="+h+" type='radio' name='localStorageFile' /><label id ="+h+"-label for='"+h+"'>"+f+"</label></div>":"<div class='fileOption'><label id ="+h+"-label for='"+h+"'>"+f+"</label></div>"}if(!l){var v=t+50;s.innerHTML+="<p>There may be more diagram files not shown. <a id='localStorageLoadMoreFiles'>Click here</a> to try loading more.</p>",document.getElementById("localStorageLoadMoreFiles").onclick=function(){n.showUI(e,v)}}if(r.appendChild(s),n.currentDiagramFile.id){var g=n.currentDiagramFile.id.replace(/ /g,o),y=document.getElementById(g+"-label");y&&(y.style.fontStyle="italic")}if("Save"===e){var w=document.createElement("div");w.id="userInputDiv",w.innerHTML+='<span>Save Diagram As </span><input id="userInput" placeholder="Enter filename"></input>',r.appendChild(w)}var b=document.createElement("div");b.id="submitDiv";var _=document.createElement("button");_.textContent=e,_.id="actionButton",_.onclick=function(){n.processUIResult(e)},b.appendChild(_),r.appendChild(b);var P=document.createElement("div"),D=document.createElement("button");return D.id="cancelButton",D.textContent="Cancel",D.onclick=function(){n.hideUI(!0)},P.appendChild(D),r.appendChild(P),n._deferredPromise.promise},S.prototype.processUIResult=function(e){var t=function(){for(var e=document.getElementsByName("localStorageFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id.replace(/qwe45qw34/g," "));return t||null}();switch(e){case"Save":var n=document.getElementById("userInput").value;n&&(n+=".diagram",this.save(n));break;case"Load":this.load(t);break;case"Delete":this.remove(t)}this.hideUI()},S.prototype.getFile=function(r){return-1===r.indexOf(".diagram")&&(r+=".diagram"),new s.Promise(function(e,t){var n=window.localStorage.getItem(r)?window.localStorage.getItem(r):null;e({name:r,content:n,path:r,id:r})})},S.prototype.checkFileExists=function(n){return-1===n.indexOf(".diagram")&&(n+=".diagram"),new s.Promise(function(e,t){e(!!window.localStorage.getItem(n))})},S.prototype.saveWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Save"))})},S.prototype.save=function(i){var a=this;return new s.Promise(function(e,t){if(i){-1===i.indexOf(".diagram")&&(i+=".diagram");var n=a.makeSaveFile();a.localStorage.setItem(i,n);var r={name:i,id:i,path:i};e(a.currentDiagramFile=r),a._deferredPromise.promise.resolve(r),a._deferredPromise.promise=a.makeDeferredPromise()}else if(a.currentDiagramFile.path){var o=a.currentDiagramFile.path;r={name:o,path:o,id:o},n=a.makeSaveFile();a.localStorage.setItem(o,n),e(o)}else e(a.saveWithUI())})},S.prototype.loadWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Load"))}).catch(function(e){throw Error(e)})},S.prototype.load=function(o){var i=this;return new s.Promise(function(e,t){if(!o)throw Error("Cannot load file from local storage with path "+o);var n=i.localStorage.getItem(o);if(!n)throw Error("Cannot load file from local storage with path "+o);i.loadFromFileContents(n);var r={name:o,id:o,path:o};e(i.currentDiagramFile=r),i._deferredPromise.promise.resolve(r),i._deferredPromise.promise=i.makeDeferredPromise()}).catch(function(e){throw Error(e)})},S.prototype.removeWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Delete"))})},S.prototype.remove=function(r){var o=this;return new s.Promise(function(e,t){if(!r)throw Error("Cannot delete file from local storage with path "+r);var n={name:r,path:r,id:r};o.currentDiagramFile&&r===o.currentDiagramFile.name&&(o.currentDiagramFile={name:null,path:null,id:null}),o.localStorage.removeItem(r),e(n),o._deferredPromise.promise.resolve(n),o._deferredPromise.promise=o.makeDeferredPromise()})},S._MIN_FILES_IN_UI=100,S}(n(1).GoCloudStorage);t.GoLocalStorage=o},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var c,u=[],l=!1,d=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&f())}function f(){if(!l){var e=s(p);l=!0;for(var t=u.length;t;){for(c=u,u=[];++d<t;)c&&c[d].run();d=-1,t=u.length}c=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new m(e,t)),1!==u.length||l||s(f)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=function(a){function e(e,t,n,r){var o=a.call(this,e,n,t,r)||this;if(window.Dropbox){var i=window.Dropbox;o._dropbox=new i({clientId:t})}return o.menuPath="",o.ui.id="goDropBoxCustomFilepicker",o._serviceName="Dropbox",o._className="GoDropBox",o._options={success:function(e){alert("Here's the file link: "+e[0].link)},cancel:function(){},linkType:"direct",multiselect:!1,extensions:[".pdf",".doc",".docx",".diagram"],folderselect:!1},o}return o(e,a),Object.defineProperty(e.prototype,"dropbox",{get:function(){return this._dropbox},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"menuPath",{get:function(){return this._menuPath},set:function(e){this._menuPath=e},enumerable:!0,configurable:!0}),e.prototype.authorize=function(r){void 0===r&&(r=!1);var o=this;return new s.Promise(function(e,t){if(r){o.maybeSaveAppState();var n=o.dropbox.getAuthenticationUrl(window.location.href);window.location.href=n,e(!1)}else if(!o.dropbox.getAccessToken())if(o.getAccessTokenFromUrl())o.dropbox.setAccessToken(o.getAccessTokenFromUrl()),e(!0);else{o.maybeSaveAppState();n=o.dropbox.getAuthenticationUrl(window.location.href);window.location.href=n,e(!1)}o.maybeLoadAppState(),e(!0)})},e.prototype.getAccessTokenFromUrl=function(){var e=window.location.hash.substring(window.location.hash.indexOf("=")+1,window.location.hash.indexOf("&"));return e||null},e.prototype.maybeSaveAppState=function(){try{var e=this.makeSaveFile();window.localStorage.setItem("gdb-"+this.clientId,e)}catch(e){throw new Error("Local storage not supported; diagrams model data will not be preserved during Dropboc authentication.")}},e.prototype.maybeLoadAppState=function(){try{var e=window.localStorage.getItem("gdb-"+this.clientId);this.loadFromFileContents(e),localStorage.removeItem("gdb-"+this.clientId)}catch(e){}},e.prototype.signOut=function(){var e=this.dropbox;this.maybeSaveAppState(),e.setAccessToken(null),e.authTokenRevoke()},e.prototype.getUserInfo=function(){var n=this;return new s.Promise(function(t,e){n.dropbox.getAccessToken()||-1!==window.location.hash.indexOf("access_token")?n.dropbox.getAccessToken()||1!==window.location.hash.indexOf("access_token")||n.authorize(!1):n.authorize(!0),n.dropbox.usersGetCurrentAccount(null).then(function(e){t(e)}).catch(function(e){400===e.status&&n.authorize(!0)})})},e.prototype.showUI=function(){var t=this,n=t.ui;n.innerHTML="",n.style.visibility="visible",n.innerHTML="<img class='icons' src='"+t.iconsRelativeDirectory+"dropBox.png'></img><strong>Save Diagram As</strong><hr></hr>";var e=document.createElement("div");e.id="userInputDiv",e.innerHTML+='<input id="gdb-userInput" placeholder="Enter filename"></input>',n.appendChild(e);var r=document.createElement("div");r.id="submitDiv";var o=document.createElement("button");o.id="actionButton",o.textContent="Save",o.onclick=function(){var e=document.getElementById("gdb-userInput").value;""!==e&&void 0!==e&&null!=e&&(n.style.visibility="hidden",t.saveWithUI(e))},r.appendChild(o),n.appendChild(r);var i=document.createElement("div");i.id="cancelDiv";var a=document.createElement("button");return a.id="cancelButton",a.textContent="Cancel",a.onclick=function(){t.hideUI(!0)},i.appendChild(a),n.appendChild(i),t._deferredPromise.promise},e.prototype.hideUI=function(e){this.menuPath="",a.prototype.hideUI.call(this,e)},e.prototype.processUIResult=function(e){var t=this;var n=function(){for(var e=document.getElementsByName("dropBoxFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].getAttribute("data"));return t}();switch(e){case"Save":if(t.menuPath||""===t.menuPath){var r=document.getElementById("userInput").value;r?(-1===r.indexOf(".diagram")&&(r+=".diagram"),t.save(t.menuPath+"/"+r)):console.log("Proposed file name is not valid")}break;case"Load":t.load(n);break;case"Delete":t.remove(n)}t.hideUI()},e.prototype.checkFileExists=function(n){var r=this;return-1===n.indexOf(".diagram")&&(n+=".diagram"),new s.Promise(function(t,e){r.dropbox.filesGetMetadata({path:n}).then(function(e){e&&t(!0)}).catch(function(e){t(!1)})})},e.prototype.getFile=function(e){return-1===e.indexOf(".diagram")&&(e+=".diagram"),this.dropbox.filesGetMetadata({path:e}).then(function(e){if(e)return e}).catch(function(e){return null})},e.prototype.saveWithUI=function(n){var u=this;return void 0===n||null==n?new s.Promise(function(e,t){e(u.showUI())}):(n.length<8?n+=".diagram":".diagram"!==n.substring(n.length-8,n.length)&&(n+=".diagram"),new s.Promise(function(c,e){u._options.success=function(e){u.dropbox.filesListFolder({path:"",recursive:!0}).then(function(e){for(var t=e.entries,n=new Date(-84e5),r=null,o=0;o<t.length;o++){var i=t[o],a=new Date(i.server_modified);null!=a&&void 0!==a&&a instanceof Date&&n<a&&(a=n,r=i)}var s={name:r.name,path:r.path_lower,id:r.id};u.currentDiagramFile=s,c(s),u._deferredPromise.promise.resolve(s),u._deferredPromise.promise=u.makeDeferredPromise()})};var t="data:text/html,"+encodeURIComponent(u.makeSaveFile());window.Dropbox.save(t,n,u._options)}))},e.prototype.save=function(t){var r=this;return new s.Promise(function(n,e){t?r.dropbox.filesUpload({contents:r.makeSaveFile(),path:t,autorename:!0,mode:{".tag":"add"},mute:!1}).then(function(e){var t={name:e.name,id:e.id,path:e.path_lower};r.currentDiagramFile=t,n(t),r._deferredPromise.promise.resolve(t),r._deferredPromise.promise=r.makeDeferredPromise()}).catch(function(e){400===e.status&&r.authorize(!0)}):r.currentDiagramFile.path?(t=r.currentDiagramFile.path,r.dropbox.filesUpload({contents:r.makeSaveFile(),path:t,autorename:!1,mode:{".tag":"overwrite"},mute:!0}).then(function(e){var t={name:e.name,id:e.id,path:e.path_lower};n(t)}).catch(function(e){400===e.status&&r.authorize(!0)})):n(r.saveWithUI())})},e.prototype.loadWithUI=function(){var n=this;return n._options.success=function(e){var t=e[0];n.dropbox.filesGetMetadata({path:t.id}).then(function(e){var t=e.path_display;n.load(t)})},window.Dropbox.choose(n._options),n._deferredPromise.promise},e.prototype.load=function(o){var i=this;return new s.Promise(function(r,e){if(!o)throw Error("Cannot load file from Dropbox with path "+o);i.dropbox.filesGetTemporaryLink({path:o}).then(function(t){var e=t.link;i.currentDiagramFile.name=t.metadata.name,i.currentDiagramFile.id=t.metadata.id,i.currentDiagramFile.path=o;var n=new XMLHttpRequest;n.open("GET",e,!0),n.setRequestHeader("Authorization","Bearer "+i.dropbox.getAccessToken()),n.onload=function(){if(4!==n.readyState||200!==n.status)throw Error("Cannot load file from Dropbox with path "+o);i.loadFromFileContents(n.response);var e={name:t.metadata.name,id:t.metadata.id,path:t.metadata.path_lower};r(e),i._deferredPromise.promise.resolve(e),i._deferredPromise.promise=i.makeDeferredPromise()},n.send()}).catch(function(e){400===e.status&&i.authorize(!0)})})},e.prototype.removeWithUI=function(){var n=this;return n._options.success=function(e){var t=e[0];n.dropbox.filesGetMetadata({path:t.id}).then(function(e){var t=e.path_display;n.remove(t)})},window.Dropbox.choose(n._options),n._deferredPromise.promise},e.prototype.remove=function(t){var r=this;return new s.Promise(function(n,e){if(!t)throw Error("Cannot delete file from Dropbox with path "+t);r.dropbox.filesDelete({path:t}).then(function(e){r.currentDiagramFile&&r.currentDiagramFile.id===e.id&&(r.currentDiagramFile={name:null,path:null,id:null});var t={name:e.name,id:e.id,path:e.path_lower};n(t),r._deferredPromise.promise.resolve(t),r._deferredPromise.promise=r.makeDeferredPromise()}).catch(function(e){400===e.status&&r.authorize(!0)})})},e}(n(1).GoCloudStorage);t.GoDropBox=i},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),a=function(a){function e(e,t,n,r,o){var i=a.call(this,e,r,t,o)||this;return i._scope="https://www.googleapis.com/auth/drive",i._pickerApiKey=n,i._oauthToken=null,i._gapiClient=null,i._gapiPicker=null,i.ui.id="goGoogleDriveSavePrompt",i._serviceName="Google Drive",i._className="GoGoogleDrive",i}return o(e,a),Object.defineProperty(e.prototype,"pickerApiKey",{get:function(){return this._pickerApiKey},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scope",{get:function(){return this._scope},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gapiClient",{get:function(){return this._gapiClient},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gapiPicker",{get:function(){return this._gapiPicker},enumerable:!0,configurable:!0}),e.prototype.authorize=function(e){void 0===e&&(e=!1);var n=this,r=null;if(window.gapi){if(r=window.gapi,e){var t=document.location.href;document.location.href="https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue="+t}return new i.Promise(function(t,e){r.load("client:auth",function(){r.auth.authorize({client_id:n.clientId,scope:n.scope,immediate:!1},function(e){e&&!e.error&&(n._oauthToken=e.access_token),n._gapiClient=r.client,window.google&&(n._gapiPicker=window.google.picker),t(!0)})}),r.load("picker",{})})}},e.prototype.createPicker=function(t){var e=this;if(e._oauthToken){var n=e.clientId.substring(0,this.clientId.indexOf("-")),r=new e.gapiPicker.View(e.gapiPicker.ViewId.DOCS);r.setMimeTypes("application/json"),r.setQuery("*.diagram"),(new e.gapiPicker.PickerBuilder).enableFeature(e.gapiPicker.Feature.NAV_HIDDEN).enableFeature(e.gapiPicker.Feature.MULTISELECT_ENABLED).setAppId(n).setOrigin(window.location.protocol+"//"+window.location.host).setOAuthToken(e._oauthToken).addView(r).setDeveloperKey(e.pickerApiKey).setCallback(function(e){t(e)}).build().setVisible(!0)}},e.prototype.getUserInfo=function(){var e=this;return new i.Promise(function(t,n){e.gapiClient.request({path:"/drive/v3/about",method:"GET",params:{fields:"user"},callback:function(e){e?t(e.user):n(e)}})})},e.prototype.getFile=function(e){var r=this;return new i.Promise(function(t,n){r.gapiClient.request({path:"/drive/v3/files/"+e,method:"GET",callback:function(e){e.error?n(e.error):t(e)}})})},e.prototype.checkFileExists=function(n){var r=this;return new i.Promise(function(t,e){r.gapiClient.request({path:"/drive/v3/files/"+n,method:"GET",callback:function(e){t(!!e)}})})},e.prototype.showUI=function(){var e=this,t=e.ui;t.innerHTML="",t.style.visibility="visible",t.innerHTML="<img class='icons' src='"+e.iconsRelativeDirectory+"googleDrive.jpg'></img><strong>Save Diagram As</strong><hr></hr>";var n=document.createElement("div");n.id="userInputDiv",n.innerHTML+='<input id="userInput" placeholder="Enter filename"></input>',t.appendChild(n);var r=document.createElement("div");r.id="submitDiv";var o=document.createElement("button");o.id="actionButton",o.textContent="Save",o.onclick=function(){e.saveWithUI()},r.appendChild(o),t.appendChild(r);var i=document.createElement("div");i.id="cancelDiv";var a=document.createElement("button");return a.id="cancelButton",a.textContent="Cancel",a.onclick=function(){e.hideUI(!0)},i.appendChild(a),t.appendChild(i),e._deferredPromise.promise},e.prototype.saveWithUI=function(){var r=this,o=r.ui;return new i.Promise(function(e,t){if("hidden"===o.style.visibility)e(r.showUI());else{var n=document.getElementById("userInput").value;r.save(n),e(r.hideUI())}})},e.prototype.save=function(l){var d=this;return new i.Promise(function(u,e){if(l){-1===l.indexOf(".diagram")&&(l+=".diagram");d.gapiClient.request({path:"/drive/v3/files",method:"GET",params:{q:'trashed=false and name contains ".diagram" and mimeType = "application/json"'},callback:function(e){var t=e.files;if(t)for(var n=0;n<t.length;n++)t[n].name===l&&(!0,t[n]);var r="-------314159265358979323846",o="\r\n--"+r+"\r\n",i="application/json",a={name:l,mimeType:i},s=d.makeSaveFile(),c=o+"Content-Type: application/json\r\n\r\n"+JSON.stringify(a)+o+"Content-Type: "+i+"\r\n\r\n"+s+"\r\n---------314159265358979323846--";d.gapiClient.request({path:"/upload/drive/v3/files",method:"POST",params:{uploadType:"multipart"},headers:{"Content-Type":'multipart/related; boundary="'+r+'"'},body:c}).execute(function(e){var t={name:e.name,id:e.id,path:e.name};d.currentDiagramFile=t,u(t),d._deferredPromise.promise.resolve(t),d._deferredPromise.promise=d.makeDeferredPromise()})}})}else if(d.currentDiagramFile.path){var t=d.currentDiagramFile.id,n=d.makeSaveFile();d.gapiClient.request({path:"/upload/drive/v3/files/"+t,method:"PATCH",params:{uploadType:"media"},body:n,callback:function(e){if(e.error)401===e.error.code&&d.authorize(!0);else{var t={name:e.name,id:e.id,path:e.name};u(t)}}})}else u(d.saveWithUI())})},e.prototype.loadWithUI=function(){var o=this;return new i.Promise(function(r,e){o.createPicker(function(e){if("picked"===e.action){var n=e.docs[0];o.gapiClient.request({path:"/drive/v3/files/"+n.id+"?alt=media",method:"GET",callback:function(e){if(-1!==n.name.indexOf(".diagram")){var t={name:n.name,path:n.name,id:n.id};r(o.load(n.id)),o.currentDiagramFile=t}}})}})})},e.prototype.load=function(e){var o=this;return new i.Promise(function(r,t){o.getFile(e).then(function(n){o.gapiClient.request({path:"/drive/v3/files/"+n.id+"?alt=media",method:"GET",callback:function(e){if(e&&-1!==n.name.indexOf(".diagram")){o.loadFromFileContents(JSON.stringify(e));var t={name:n.name,path:n.name,id:n.id};o.currentDiagramFile=t,r(t)}}})}).catch(function(e){t(e.message)})})},e.prototype.removeWithUI=function(){var r=this;return new i.Promise(function(n,e){r.createPicker(function(e){if("picked"===e.action){var t=e.docs[0];n(r.remove(t.id))}})})},e.prototype.remove=function(r){var o=this;return new i.Promise(function(t,n){o.getFile(r).then(function(e){o.gapiClient.request({path:"drive/v3/files/"+r,method:"DELETE",callback:function(){o.currentDiagramFile&&r===o.currentDiagramFile.id&&(o.currentDiagramFile={name:null,path:null,id:null}),e.path=e.name,t(e)}})}).catch(function(e){n(e.message)})})},e}(n(1).GoCloudStorage);t.GoGoogleDrive=a},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var l=n(0),i=function(i){function e(e,t,n,r){var o=i.call(this,e,n,t,r)||this;return o._oauthToken=null,o.ui.id="goOneDriveSavePrompt",window.OneDrive&&(o._oneDriveFilepicker=window.OneDrive),o.authorize(!1),o._serviceName="Microsoft OneDrive",o._className="GoOneDrive",o}return o(e,i),Object.defineProperty(e.prototype,"oauthToken",{get:function(){return this._oauthToken},set:function(e){this._oauthToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"oneDriveFilepicker",{get:function(){return this._oneDriveFilepicker},enumerable:!0,configurable:!0}),e.prototype.authorize=function(o){var i=this;return new l.Promise(function(e,t){if(o||-1===window.location.hash.indexOf("access_token")){if(o){var n="https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id="+i.clientId+"&scope=files.readwrite.all&response_type=token&redirect_uri="+window.location.href;window.location.href=n,e(!0)}}else{var r=window.location.hash.substring(window.location.hash.indexOf("=")+1,window.location.hash.indexOf("&"));i.oauthToken=r,e(!0)}})},e.prototype.getUserInfo=function(){var r=this;return new l.Promise(function(e,t){var n=new XMLHttpRequest;r.oauthToken?(n.open("GET","https://graph.microsoft.com/v1.0/me"),n.setRequestHeader("Authorization","Bearer "+r.oauthToken),n.onreadystatechange=function(){4===n.readyState&&200===n.status?e(JSON.parse(n.response)):401===n.status&&(r.authorize(!0),t(n.response))},n.send()):-1===window.location.hash.indexOf("access_token")?(t("No acessToken in current uri"),r.authorize(!0)):(t("oauthToken not set"),r.authorize(!1))})},e.prototype.checkFileExists=function(e){var i=this;return-1===e.indexOf(".diagram")&&(e+=".diagram"),new l.Promise(function(n,r){var o=new XMLHttpRequest;o.open("GET","https://graph.microsoft.com/v1.0"+e,!0),o.setRequestHeader("Authorization","Bearer "+i.oauthToken),o.onreadystatechange=function(){var e,t;4===o.readyState&&(200===o.status?e=!0:401===o.status?i.authorize(!0):404===o.status?e=!1:t=o.response,n(e),t&&r(t))},o.send()})},e.prototype.getFile=function(o,i){var a=this;return-1===o.indexOf(".diagram")&&(o+=".diagram"),new l.Promise(function(t,n){var r=new XMLHttpRequest;r.open("GET","https://graph.microsoft.com/v1.0"+o,!0);var e=i||a.oauthToken;r.setRequestHeader("Authorization","Bearer "+e),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status){var e=JSON.parse(r.response);t(e)}else 401===r.status?a.authorize(!0):n(r.response)},r.send()})},e.prototype.showUI=function(){var e=this,t=e.ui;t.innerHTML="",t.style.visibility="visible",t.innerHTML="<img class='icons' src='"+e.iconsRelativeDirectory+"oneDrive.png'></img><strong>Save Diagram As</strong><hr></hr>";var n=document.createElement("div");n.id="userInputDiv",n.innerHTML+='<input id="userInput" placeholder="Enter filename"></input>',t.appendChild(n);var r=document.createElement("div");r.id="submitDiv";var o=document.createElement("button");o.id="actionButton",o.textContent="Save",o.onclick=function(){e.saveWithUI()},r.appendChild(o),t.appendChild(r);var i=document.createElement("div");i.id="cancelDiv";var a=document.createElement("button");return a.id="cancelButton",a.textContent="Cancel",a.onclick=function(){e.hideUI(!0)},i.appendChild(a),t.appendChild(i),e._deferredPromise.promise},e.prototype.saveWithUI=function(){var o=this,i=o.ui;return new l.Promise(function(e,t){if("hidden"===i.style.visibility)e(o.showUI());else{var r=document.getElementById("userInput").value;r&&-1===r.indexOf(".diagram")&&(r+=".diagram");var n={clientId:o.clientId,action:"query",openInNewWindow:!0,success:function(e){var t=e.value[0],n=e.accessToken;o.currentDiagramFile={id:null,name:r,token:n,parentReference:{driveId:t.parentReference.driveId,id:t.id},path:"placeholder"},o.hideUI(),o.save()}};r&&""!==r&&void 0!==r?o.oneDriveFilepicker.save(n):t("Cannot save file to OneDrive with save name "+r)}})},e.prototype.save=function(c){var u=this;return new l.Promise(function(n,r){if(c){var o=new XMLHttpRequest;-1===c.indexOf(".diagram")&&(c+=".diagram");var e=u.makeSaveFile();o.open("PUT","https://graph.microsoft.com/v1.0"+c+":/content",!0),o.setRequestHeader("Authorization","Bearer "+u.oauthToken),o.setRequestHeader("Content-Type","application/json"),o.onreadystatechange=function(){if(4===o.readyState)if(200<=o.status&&o.status<300){var e=JSON.parse(o.response),t={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name,parentReference:e.parentReference};n(t)}else{if(401!==o.status)throw Error(o.response);u.authorize(!0)}},o.send(e)}else if(u.currentDiagramFile.path){var i=u.currentDiagramFile.token,t=u.generateGraphUrl(u.currentDiagramFile,!0,!0),a=(e=u.makeSaveFile(),i?u.currentDiagramFile.token:u.oauthToken),s=new XMLHttpRequest;s.open("PUT",t,!0),s.setRequestHeader("Authorization","Bearer "+a),s.onload=function(){if(4!==s.readyState||200!==s.status&&201!==s.status)r(s.response);else{var e=JSON.parse(s.response),t={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name,token:i,parentReference:e.parentReference};u.currentDiagramFile=t,n(t),u._deferredPromise.promise.resolve(t),u._deferredPromise.promise=u.makeDeferredPromise()}},s.send(e)}else n(u.saveWithUI())})},e.prototype.loadWithUI=function(){var i=this;return new l.Promise(function(o,e){var t={clientId:i.clientId,action:"share",multiSelect:!1,advanced:{filter:".diagram"},success:function(e){var t=e.value[0],n=e.accessToken,r=t.parentReference.path+"/"+t.name;o(i.load(r,n))}};i.oneDriveFilepicker.open(t)})},e.prototype.load=function(n,o){var i=this;return new l.Promise(function(r,e){if(n){var t=o||i.oauthToken;i.getFile(n,t).then(function(t){var e=t["@microsoft.graph.downloadUrl"],n=new XMLHttpRequest;n.open("GET",e,!0),n.onreadystatechange=function(){if(4===n.readyState&&200===n.status){i.loadFromFileContents(n.response);var e={name:t.name,id:t.id,path:t.parentReference.path+"/"+t.name,token:o,parentReference:{id:t.parentReference.id,driveId:t.parentReference.driveId}};i.currentDiagramFile=e,r(e)}},n.send()})}else e("Cannot load file from OneDrive with path "+n)})},e.prototype.removeWithUI=function(){var i=this;return new l.Promise(function(o,e){var t={clientId:i.clientId,action:"share",openInNewWindow:!0,success:function(e){if(e){var t=e.value[0],n=e.accessToken,r=t.parentReference.path+"/"+t.name;o(new l.Promise(function(e,t){e(i.remove(r,n))}))}}};i.oneDriveFilepicker.open(t)})},e.prototype.remove=function(i,e){var a=this,s=e||a.oauthToken;return new l.Promise(function(r,o){a.getFile(i,s).then(function(e){var t={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name},n=new XMLHttpRequest;n.open("DELETE","https://graph.microsoft.com/v1.0"+i,!0),n.setRequestHeader("Authorization","Bearer"+s),n.onload=function(){4===n.readyState&&204===n.status?(a.currentDiagramFile&&i===a.currentDiagramFile.path&&(a.currentDiagramFile={id:null,path:null,name:null}),r(t)):401===n.status?a.authorize(!0):o(n.response)},n.send()}).catch(function(e){throw Error(e)})})},e.prototype.generateGraphUrl=function(e,t,n){var r="https://graph.microsoft.com/v1.0/";return r+=t?"drives/"+e.parentReference.driveId+"/items/"+e.parentReference.id+"/children/"+e.name:"drives/"+e.parentReference.driveId+"/items/"+e.id,n&&(r+="/content"),r},e}(n(1).GoCloudStorage);t.GoOneDrive=i},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),i=function(i){function t(e,t,n,r){var o=i.call(this,e,n)||this;return o._rootEndpoint=t,o.ui.id="goNetCoreCustomFilepicker",o._serviceName="Microsoft ASP .NET Core Web API",o._className="GoNetCore",o}return o(t,i),Object.defineProperty(t.prototype,"rootEndpoint",{get:function(){return this._rootEndpoint},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){void 0===e&&(e=!1);return new s.Promise(function(e,t){e(!0)})},t.prototype.showUI=function(m,h){var v=this,g=v.ui;h||(h=0);var y=t._MIN_FILES_IN_UI+h;g.innerHTML="";var e=m+" Diagram File";g.innerHTML+="<strong>"+e+"</strong><hr></hr>",document.getElementsByTagName("body")[0].appendChild(g),g.style.visibility="visible";var w=document.createElement("div");w.id="fileOptions";var b=[],_=0,P=!1;return v.getFiles().then(function(e){if(0!==e.length)for(var t in e){var n=e[t];if(b.length<y){_++;var r=n.file;if(r&&-1!==r.indexOf("GraphLinksModel")){var o={name:n.name,id:n.id};b.push(o)}_===e.length&&(P=!0)}}else P=!0;if(0!==b.length)for(t=0;t<b.length;t++){var i=(n=b[t]).name,a=n.id;w.innerHTML+="Save"!==m?"<div class='fileOption'><input id="+a+" type='radio' name='localStorageFile' /><label id ="+a+"-label for='"+i+"'>"+i+"</label></div>":"<div class='fileOption'><label id ="+a+"-label for='"+a+"'>"+i+"</label></div>"}if(!P){var s=h+50;w.innerHTML+="<p>There may be more diagram files not shown. <a id='netCoreLoadMoreFiles'>Click here</a> to try loading more.</p>",document.getElementById("netCoreLoadMoreFiles").onclick=function(){v.showUI(m,s)}}if(g.appendChild(w),v.currentDiagramFile.id){var c=document.getElementById(v.currentDiagramFile.id+"-label");c&&(c.style.fontStyle="italic")}if("Save"===m){var u=document.createElement("div");u.id="userInputDiv",u.innerHTML+='<span>Save Diagram As </span><input id="userInput" placeholder="Enter filename"></input>',g.appendChild(u)}var l=document.createElement("div");l.id="submitDiv";var d=document.createElement("button");d.textContent=m,d.id="actionButton",d.onclick=function(){v.processUIResult(m)},l.appendChild(d),g.appendChild(l);var p=document.createElement("div"),f=document.createElement("button");f.id="cancelButton",f.textContent="Cancel",f.onclick=function(){v.hideUI(!0)},p.appendChild(f),g.appendChild(p)}),v._deferredPromise.promise},t.prototype.processUIResult=function(e){var t=function(){for(var e=document.getElementsByName("localStorageFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id.replace(/qwe45qw34/g," "));return t||null}();switch(e){case"Save":var n=document.getElementById("userInput").value;n&&(n+=".diagram",this.save(n));break;case"Load":this.load(t);break;case"Delete":this.remove(t)}this.hideUI()},t.prototype.getFile=function(r){var o=this.rootEndpoint+r;return new s.Promise(function(e,t){if(r){var n=new XMLHttpRequest;n.open("GET",o,!0),n.onreadystatechange=function(){4===n.readyState&&200<=n.status&&n.status<300&&e(JSON.parse(n.response))},n.send()}else t("Cannot get diagram file from ASP .NET Core Web API with id "+r)})},t.prototype.getFiles=function(){var r=this;return new s.Promise(function(e,t){var n=new XMLHttpRequest;n.open("GET",r.rootEndpoint,!0),n.onreadystatechange=function(){4===n.readyState&&(200<=n.status&&n.status<300?e(JSON.parse(n.response)):t(n.response))},n.send()})},t.prototype.checkFileExists=function(e){var r=this.rootEndpoint+e;return new s.Promise(function(e,t){var n=new XMLHttpRequest;n.open("GET",r,!0),n.onreadystatechange=function(){4===n.readyState&&(200<=n.status&&n.status<300?e(!0):e(!1))},n.send()})},t.prototype.saveWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Save"))})},t.prototype.save=function(e){var a=this;return new s.Promise(function(r,o){if(a.currentDiagramFile.id&&!e){var i=new XMLHttpRequest;a.getFile(a.currentDiagramFile.id).then(function(e){var t={id:a.currentDiagramFile.id,name:a.currentDiagramFile.name,file:a.makeSaveFile()},n={id:t.id,name:t.name,path:t.name};i.open("PUT",a.rootEndpoint+a.currentDiagramFile.id,!0),i.setRequestHeader("Content-Type","application/json; charset=utf-8"),i.onreadystatechange=function(){4===i.readyState&&(200<i.status&&i.status<300?r(n):o(i.responseText))},i.send(JSON.stringify(t))})}else{var t=new XMLHttpRequest,n={name:null!==e?e:"New diagram",file:a.makeSaveFile()};t.open("POST",a.rootEndpoint,!0),t.setRequestHeader("Content-Type","application/json; charset=utf-8"),t.onreadystatechange=function(){if(4===t.readyState)if(200<t.status&&t.status<300){var e={id:JSON.parse(t.response).id,name:n.name,path:n.name};a.currentDiagramFile=e,r(e),a._deferredPromise.promise.resolve(e),a._deferredPromise.promise=a.makeDeferredPromise()}else o(t.responseText)},t.send(JSON.stringify(n))}})},t.prototype.loadWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Load"))}).catch(function(e){throw Error(e)})},t.prototype.load=function(e){var i=this;return new s.Promise(function(n,r){if(!e)throw Error("Cannot load file from .NET Core Web API with path "+e);var o=new XMLHttpRequest;o.open("GET",i.rootEndpoint+e,!0),o.onreadystatechange=function(){if(4===o.readyState)if(200<=o.status&&o.status<300){var e=JSON.parse(o.response);i.loadFromFileContents(e.file);var t={id:e.id,path:e.name,name:e.name};i.currentDiagramFile=t,n(t),i._deferredPromise.promise.resolve(t),i._deferredPromise.promise=i.makeDeferredPromise()}else r(o.responseText)},o.send()}).catch(function(e){throw Error(e)})},t.prototype.removeWithUI=function(){var n=this;return new s.Promise(function(e,t){e(n.showUI("Delete"))})},t.prototype.remove=function(i){var a=this;return new s.Promise(function(r,o){if(!i)throw Error("Cannot delete file from local storage with id "+i);a.getFile(i).then(function(e){var t={name:e.name,path:e.name,id:i};a.currentDiagramFile&&e.name===a.currentDiagramFile.name&&(a.currentDiagramFile={name:null,path:null,id:null});var n=new XMLHttpRequest;n.open("DELETE",a.rootEndpoint+i,!0),n.onreadystatechange=function(){4===n.readyState&&(200<=n.status&&n.status<300?(r(t),a._deferredPromise.promise.resolve(t),a._deferredPromise.promise=a.makeDeferredPromise()):o(n.responseText))},n.send()})})},t._MIN_FILES_IN_UI=100,t}(n(1).GoCloudStorage);t.GoNetCore=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),a=n(2),c=n(1),r=function(){function e(e,t){if(e instanceof Array){for(var n=new a.Set,r=0;r<e.length;r++){if(!(e[r]instanceof c.GoCloudStorage))throw new Error("Cannot create GoCloudStorageManager; provided 'storages' parameter elements are not all of type GoCloudStorage");n.add(e[r])}e=n}if(!(e instanceof a.Set&&e))throw Error("Cannot create GoCloudStorageManager with provided 'storages' parameter");var o=this;o._storages=e,o._currentStorage=e.first();var i=document.createElement("div");i.id="goCloudStorageManagerMenu",o._menu=i,o._deferredPromise={promise:c.GoCloudStorage.prototype.makeDeferredPromise()},o._iconsRelativeDirectory=t||"../goCloudStorageIcons/",t&&o._storages.iterator.each(function(e){e.iconsRelativeDirectory=t}),-1!==window.location.href.indexOf("account_id=dbid")&&e.iterator.each(function(e){"GoDropBox"===e.className&&(o._currentStorage=e,o.currentStorage.authorize())}),document.getElementsByTagName("body")[0].appendChild(o.menu)}return Object.defineProperty(e.prototype,"storages",{get:function(){return this._storages},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iconsRelativeDirectory",{get:function(){return this._iconsRelativeDirectory},set:function(e){this._iconsRelativeDirectory=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"menu",{get:function(){return this._menu},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentStorage",{get:function(){return this._currentStorage},set:function(e){this._currentStorage=e},enumerable:!0,configurable:!0}),e.prototype.create=function(n){void 0===n&&(n=!1);var r=this;return new s.Promise(function(e,t){e(r.handleAction("Create",n))})},e.prototype.load=function(){var n=this;return new s.Promise(function(e,t){e(n.handleAction("Load"))})},e.prototype.remove=function(){var n=this;return new s.Promise(function(e,t){e(n.handleAction("Remove"))})},e.prototype.save=function(n){void 0===n&&(n=!0);var r=this;return new s.Promise(function(e,t){e(n?r.handleAction("SaveAs"):r.handleAction("Save"))})},e.prototype.showMessage=function(e,t){t||(t=2);var n=document.createElement("div");n.id="goCloudStorageManagerMessageBox",n.innerHTML="<p>"+e+"</p>",document.body.appendChild(n),setTimeout(function(){n.style.opacity="0",setTimeout(function(){n.parentNode.removeChild(n)},1e3)},1e3*t)},e.prototype.getStorageIconPath=function(e){if(null==this.iconsRelativeDirectory||void 0===this.iconsRelativeDirectory)return null;var t=this.iconsRelativeDirectory;switch(e){case"GoGoogleDrive":t+="googleDrive.jpg";break;case"GoOneDrive":t+="oneDrive.png";break;case"GoLocalStorage":t+="localStorage.png";break;case"GoDropBox":t+="dropBox.png"}return t},e.prototype.selectStorageService=function(){var u=this,l=this.storages;return new s.Promise(function(r,e){var t=u.menu;t.innerHTML="<strong>Select Storage Service</strong><hr></hr>";var n=document.createElement("p");n.id="gcsmSelectedStorage",n.innerHTML=u.currentStorage.serviceName,t.appendChild(n),t.onchange=function(){for(var e=document.getElementsByName("storageSelection"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id);var r="";l.iterator.each(function(e){e.className===t&&(r=e.serviceName)}),document.getElementById("gcsmSelectedStorage").innerHTML=r},u.menu.style.visibility="visible";var o=document.createElement("div");o.id="storageOptions",l.iterator.each(function(e){var t=e.className,n=u.getStorageIconPath(t),r="";e.className===u.currentStorage.className&&(r="checked"),o.innerHTML+="<label><input id="+t+" type='radio' name='storageSelection' "+r+" /><img class='storageLogo' src="+n+" >"}),t.appendChild(o);t.innerHTML+="<p class='description'>This will be where you save / load diagram model data to / from. You will need to grant GoCloudStorage permission to access your files on the selected storage service.</p>";var i=document.createElement("div"),a=document.createElement("button");a.id="actionButton",a.textContent="Select",a.onclick=function(){for(var e=document.getElementsByName("storageSelection"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id);u.storages.each(function(e){e.className===t&&(u.currentStorage=e)}),u.currentStorageNeedsAuth()&&u.currentStorage.authorize().then(function(e){}),r(u.currentStorage),u.hideMenu()},i.appendChild(a),t.appendChild(i);var s=document.createElement("div"),c=document.createElement("button");c.id="cancelButton",c.textContent="Cancel",c.onclick=function(){u.hideMenu()},s.appendChild(c),t.appendChild(s)})},e.prototype.hideMenu=function(){this.menu.style.visibility="hidden"},e.prototype.currentStorageNeedsAuth=function(){var e=this.currentStorage.className;return"GoGoogleDrive"===e||"GoDropBox"===e},e.prototype.handleAction=function(r,o){void 0===o&&(o=!1);var i=this,a=i.currentStorage;return new s.Promise(function(e,t){function n(){switch(r){case"Load":e(a.loadWithUI());break;case"SaveAs":e(a.saveWithUI());break;case"Save":e(a.save());break;case"Remove":e(a.removeWithUI());break;case"Create":e(a.create(null,o))}i.hideMenu()}i.currentStorageNeedsAuth()?a.authorize().then(function(){n()}):n()})},e}();t.GoCloudStorageManager=r}]); |