Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rete

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rete - npm Package Compare versions

Comparing version 1.4.9 to 1.4.10

6

build/rete.min.js
/*!
* rete v1.4.9
* (c) 2022 Vitaliy Stoliarov
* rete v1.4.10
* (c) 2023 Vitaliy Stoliarov
* Released under the MIT license.
*/
var runtime=function(i){"use strict";var u,t=Object.prototype,c=t.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",r=e.toStringTag||"@@toStringTag";function s(t,e,n,r){var o=e&&e.prototype instanceof a?e:a,i=Object.create(o.prototype),s=new N(r||[]);return i._invoke=function(i,s,a){var u=l;return function(t,e){if(u===f)throw new Error("Generator is already running");if(u===p){if("throw"===t)throw e;return R()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=O(n,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===l)throw u=p,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=f;var o=h(i,s,a);if("normal"===o.type){if(u=a.done?p:d,o.arg===v)continue;return{value:o.arg,done:a.done}}"throw"===o.type&&(u=p,a.method="throw",a.arg=o.arg)}}}(t,n,s),i}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=s;var l="suspendedStart",d="suspendedYield",f="executing",p="completed",v={};function a(){}function y(){}function m(){}var g={};g[o]=function(){return this};var k=Object.getPrototypeOf,w=k&&k(k(P([])));w&&w!==t&&c.call(w,o)&&(g=w);var b=m.prototype=a.prototype=Object.create(g);function x(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function E(u){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=h(u[t],u,n);if("throw"!==i.type){var s=i.arg,a=s.value;return a&&"object"==typeof a&&c.call(a,"__await")?Promise.resolve(a.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(a).then(function(t){s.value=t,r(s)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function O(t,e){var n=t.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=u,O(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var r=h(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,v;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u),e.delegate=null,v):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(c.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t};return r.next=r}}return{next:R}}function R(){return{value:u,done:!0}}return y.prototype=b.constructor=m,m.constructor=y,m[r]=y.displayName="GeneratorFunction",i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(b),t},i.awrap=function(t){return{__await:t}},x(E.prototype),E.prototype[n]=function(){return this},i.AsyncIterator=E,i.async=function(t,e,n,r){var o=new E(s(t,e,n,r));return i.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},x(b),b[r]="Generator",b[o]=function(){return this},b.toString=function(){return"[object Generator]"},i.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},i.values=P,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&c.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var s=c.call(o,"catchLoc"),a=c.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),v}},i}("object"==typeof module?module.exports:{});try{regeneratorRuntime=runtime}catch(t){Function("r","regeneratorRuntime = r")(runtime)}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).Rete={})}(this,function(t){"use strict";function u(t,e,n,r,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,o)}function f(a){return function(){var t=this,s=arguments;return new Promise(function(e,n){var r=a.apply(t,s);function o(t){u(r,e,n,o,i,"next",t)}function i(t){u(r,e,n,o,i,"throw",t)}o(void 0)})}}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(t){y(e,t,n[t])})}return e}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function k(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function w(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?k(t):e}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(t){p(this,i),y(this,"name",void 0),y(this,"data",{}),y(this,"engine",null),this.name=t}var s=function(){function i(t){p(this,i),y(this,"name",void 0),y(this,"id",void 0),y(this,"position",[0,0]),y(this,"inputs",new Map),y(this,"outputs",new Map),y(this,"controls",new Map),y(this,"data",{}),y(this,"meta",{}),this.name=t,this.id=i.incrementId()}return v(i,[{key:"_add",value:function(t,e,n){if(t.has(e.key))throw new Error("Item with key '".concat(e.key,"' already been added to the node"));if(null!==e[n])throw new Error("Item has already been added to some node");e[n]=this,t.set(e.key,e)}},{key:"addControl",value:function(t){return this._add(this.controls,t,"parent"),this}},{key:"removeControl",value:function(t){t.parent=null,this.controls.delete(t.key)}},{key:"addInput",value:function(t){return this._add(this.inputs,t,"node"),this}},{key:"removeInput",value:function(t){t.removeConnections(),t.node=null,this.inputs.delete(t.key)}},{key:"addOutput",value:function(t){return this._add(this.outputs,t,"node"),this}},{key:"removeOutput",value:function(t){t.removeConnections(),t.node=null,this.outputs.delete(t.key)}},{key:"setMeta",value:function(t){return this.meta=t,this}},{key:"getConnections",value:function(){return[].concat(b(this.inputs.values()),b(this.outputs.values())).reduce(function(t,e){return[].concat(b(t),b(e.connections))},[])}},{key:"update",value:function(){}},{key:"toJSON",value:function(){function t(t){return Array.from(t).reduce(function(t,e){var n=c(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{})}return{id:this.id,data:this.data,inputs:t(this.inputs),outputs:t(this.outputs),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"resetId",value:function(){this.latestId=0}},{key:"fromJSON",value:function(t){var e=new i(t.name),n=c(t.position,2),r=n[0],o=n[1];return e.id=t.id,e.data=t.data,e.position=[r,o],e.name=t.name,i.latestId=Math.max(e.id,i.latestId),e}}]),i}();y(s,"latestId",0);var e=function(t){function n(t){var e;return p(this,n),y(k(e=w(this,g(n).call(this,t))),"editor",null),y(k(e),"data",{}),e}var e,r;return m(n,i),v(n,[{key:"build",value:(r=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.builder(e);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createNode",value:(e=f(regeneratorRuntime.mark(function t(){var e,n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<r.length&&void 0!==r[0]?r[0]:{},(n=new s(this.name)).data=e,t.next=5,this.build(n);case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}},t,this)})),function(){return e.apply(this,arguments)})}]),n}(),h=function(){function n(t,e){p(this,n),y(this,"output",void 0),y(this,"input",void 0),y(this,"data",{}),this.output=t,this.input=e,this.data={},this.input.addConnection(this)}return v(n,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),n}(),l=function(){function e(t){if(p(this,e),y(this,"key",void 0),y(this,"data",{}),y(this,"parent",null),this.constructor===e)throw new TypeError("Can not construct abstract class");if(!t)throw new Error("The key parameter is missing in super() of Control ");this.key=t}return v(e,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");if(this.parent instanceof s)return this.parent;if(!this.parent.node)throw new Error("Control hasn't be added to Input or Node");return this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,e){this.getNode().data[t]=e}}]),e}(),d=function(){function e(t){p(this,e),y(this,"events",{}),y(this,"silent",!1),this.events=t instanceof e?t.events:t.handlers}return v(e,[{key:"on",value:function(t,e){var n=this;return(t instanceof Array?t:t.split(" ")).forEach(function(t){if(!n.events[t])throw new Error("The event ".concat(t," does not exist"));n.events[t].push(e)}),this}},{key:"trigger",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!(t in this.events))throw new Error("The event ".concat(t," cannot be triggered"));return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}},{key:"bind",value:function(t){if(this.events[t])throw new Error("The event ".concat(t," is already bound"));this.events[t]=[]}},{key:"exist",value:function(t){return Array.isArray(this.events[t])}}]),e}(),x=function(){function o(t,e,n,r){p(this,o),y(this,"node",null),y(this,"multipleConnections",void 0),y(this,"connections",[]),y(this,"key",void 0),y(this,"name",void 0),y(this,"socket",void 0),this.node=null,this.multipleConnections=r,this.connections=[],this.key=t,this.name=e,this.socket=n}return v(o,[{key:"removeConnection",value:function(t){this.connections.splice(this.connections.indexOf(t),1)}},{key:"removeConnections",value:function(){var e=this;this.connections.forEach(function(t){return e.removeConnection(t)})}}]),o}(),E=function(t){function i(t,e,n){var r,o=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return p(this,i),y(k(r=w(this,g(i).call(this,t,e,n,o))),"control",null),r}return m(i,x),v(i,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"addConnection",value:function(t){if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){(this.control=t).parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){if(!t.output.node)throw new Error("Node not added to Output");return{node:t.output.node.id,output:t.output.key,data:t.data}})}}}]),i}(),O=function(){function t(){p(this,t)}return v(t,null,[{key:"isValidData",value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,e){var n=t.split("@"),r=e.id.split("@"),o=[];return this.isValidData(e)||o.push("Data is not suitable"),t!==e.id&&o.push("IDs not equal"),n[0]!==r[0]&&o.push("Names don't match"),n[1]!==r[1]&&o.push("Versions don't match"),{success:Boolean(!o.length),msg:o.join(". ")}}}]),t}(),C=function(t){function r(t,e){var n;if(p(this,r),y(k(n=w(this,g(r).call(this,e))),"id",void 0),y(k(n),"plugins",void 0),y(k(n),"components",void 0),!O.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return n.id=t,n.plugins=new Map,n.components=new Map,n}return m(r,d),v(r,[{key:"use",value:function(t,e){if(t.name&&this.plugins.has(t.name))throw new Error("Plugin ".concat(t.name," already in use"));t.install(this,e||{}),this.plugins.set(t.name,e)}},{key:"register",value:function(t){if(this.components.has(t.name))throw new Error("Component ".concat(t.name," already registered"));this.components.set(t.name,t),this.trigger("componentregister",t)}},{key:"destroy",value:function(){this.trigger("destroy")}}]),r}();function S(t,e){return window.addEventListener(t,e),function(){window.removeEventListener(t,e)}}function N(t){p(this,N),y(this,"handlers",void 0),this.handlers=a({warn:[console.warn],error:[console.error],componentregister:[],destroy:[]},t)}var P=function(){function s(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(t,e,n){},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(t){},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(t){};p(this,s),this.onTranslate=e,this.onStart=n,this.onDrag=r,y(this,"pointerStart",void 0),y(this,"el",void 0),y(this,"destroy",void 0),this.pointerStart=null,this.el=t,this.el.style.touchAction="none",this.el.addEventListener("pointerdown",this.down.bind(this));var o=S("pointermove",this.move.bind(this)),i=S("pointerup",this.up.bind(this));this.destroy=function(){o(),i()}}return v(s,[{key:"down",value:function(t){"mouse"===t.pointerType&&0!==t.button||(t.stopPropagation(),this.pointerStart=[t.pageX,t.pageY],this.onStart(t))}},{key:"move",value:function(t){if(this.pointerStart){t.preventDefault();var e=[t.pageX,t.pageY],n=e[1],r=[e[0]-this.pointerStart[0],n-this.pointerStart[1]],o=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.onTranslate(r[0]/o,r[1]/o,t)}}},{key:"up",value:function(t){this.pointerStart&&(this.pointerStart=null,this.onDrag(t))}}]),s}(),R=function(){function a(t,e,n,r){p(this,a),y(this,"el",void 0),y(this,"intensity",void 0),y(this,"onzoom",void 0),y(this,"previous",null),y(this,"pointers",[]),y(this,"destroy",void 0),this.el=e,this.intensity=n,this.onzoom=r,t.addEventListener("wheel",this.wheel.bind(this)),t.addEventListener("pointerdown",this.down.bind(this)),t.addEventListener("dblclick",this.dblclick.bind(this));var o=S("pointermove",this.move.bind(this)),i=S("pointerup",this.end.bind(this)),s=S("pointercancel",this.end.bind(this));this.destroy=function(){o(),i(),s()}}return v(a,[{key:"wheel",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=t.deltaY<0?this.intensity:-this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"wheel")}},{key:"touches",value:function(){var t={touches:this.pointers},e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],s=o[1];return{cx:(n+i)/2,cy:(r+s)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-s,2))}}},{key:"down",value:function(t){this.pointers.push(t)}},{key:"move",value:function(e){if(this.pointers=this.pointers.map(function(t){return t.pointerId===e.pointerId?e:t}),this.translating){var t=this.el.getBoundingClientRect(),n=this.touches(),r=n.cx,o=n.cy,i=n.distance;if(null!==this.previous){var s=i/this.previous.distance-1,a=(t.left-r)*s,u=(t.top-o)*s;this.onzoom(s,a-(this.previous.cx-r),u-(this.previous.cy-o),"touch")}this.previous={cx:r,cy:o,distance:i}}}},{key:"end",value:function(e){this.previous=null,this.pointers=this.pointers.filter(function(t){return t.pointerId!==e.pointerId})}},{key:"dblclick",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=4*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"dblclick")}},{key:"translating",get:function(){return 2<=this.pointers.length}}]),a}(),I=function(t){function o(t,e){var n;p(this,o),y(k(n=w(this,g(o).call(this,e))),"el",void 0),y(k(n),"container",void 0),y(k(n),"transform",{k:1,x:0,y:0}),y(k(n),"mouse",{x:0,y:0}),y(k(n),"_startPosition",null),y(k(n),"_zoom",void 0),y(k(n),"_drag",void 0);var r=n.el=document.createElement("div");return n.container=t,r.style.transformOrigin="0 0",n._zoom=new R(t,r,.1,n.onZoom.bind(k(n))),n._drag=new P(t,n.onTranslate.bind(k(n)),n.onStart.bind(k(n))),e.on("destroy",function(){n._zoom.destroy(),n._drag.destroy()}),n.container.addEventListener("pointermove",n.pointermove.bind(k(n))),n.update(),n}return m(o,d),v(o,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate(".concat(t.x,"px, ").concat(t.y,"px) scale(").concat(t.k,")")}},{key:"pointermove",value:function(t){var e=t.clientX,n=t.clientY,r=this.el.getBoundingClientRect(),o=e-r.left,i=n-r.top,s=this.transform.k;this.mouse={x:o/s,y:i/s},this.trigger("mousemove",a({},this.mouse))}},{key:"onStart",value:function(){this._startPosition=a({},this.transform)}},{key:"onTranslate",value:function(t,e){this._zoom.translating||this._startPosition&&this.translate(this._startPosition.x+t,this._startPosition.y+e)}},{key:"onZoom",value:function(t,e,n,r){this.zoom(this.transform.k*(1+t),e,n,r),this.update()}},{key:"translate",value:function(t,e){var n={transform:this.transform,x:t,y:e};this.trigger("translate",n)&&(this.transform.x=n.x,this.transform.y=n.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length?arguments[3]:void 0,o=this.transform.k,i={transform:this.transform,zoom:t,source:r};if(this.trigger("zoom",i)){var s=(o-i.zoom)/(o-t||1);this.transform.k=i.zoom||1,this.transform.x+=e*s,this.transform.y+=n*s,this.update(),this.trigger("zoomed",{source:r})}}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),o}(),_=function(t){function i(t,e,n,r){var o;return p(this,i),y(k(o=w(this,g(i).call(this,r))),"connection",void 0),y(k(o),"inputNode",void 0),y(k(o),"outputNode",void 0),y(k(o),"el",void 0),o.connection=t,o.inputNode=e,o.outputNode=n,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.style.zIndex="-1",o.trigger("renderconnection",{el:o.el,connection:o.connection,points:o.getPoints()}),o}return m(i,d),v(i,[{key:"getPoints",value:function(){var t=this.connection,e=t.input,n=t.output;if(this.inputNode.hasSocket(e)&&this.outputNode.hasSocket(n)){var r=c(this.outputNode.getSocketPosition(n),2),o=r[0],i=r[1],s=c(this.inputNode.getSocketPosition(e),2);return[o,i,s[0],s[1]]}return[0,0,0,0]}},{key:"update",value:function(){this.trigger("updateconnection",{el:this.el,connection:this.connection,points:this.getPoints()})}}]),i}(),j=function(t){function o(t,e,n){var r;return p(this,o),(r=w(this,g(o).call(this,n))).trigger("rendercontrol",{el:t,control:e}),r}return m(o,d),o}(),L=function(t){function a(t,e,n,r,o){var i,s;return p(this,a),y(k(s=w(this,g(a).call(this,o))),"el",void 0),y(k(s),"type",void 0),y(k(s),"io",void 0),y(k(s),"node",void 0),s.el=t,s.type=e,s.io=n,s.node=r,s.trigger("rendersocket",(y(i={el:t},e,s.io),y(i,"socket",n.socket),i)),s}return m(a,d),v(a,[{key:"getPosition",value:function(t){var e=t.position,n=this.el;return[e[0]+n.offsetLeft+n.offsetWidth/2,e[1]+n.offsetTop+n.offsetHeight/2]}}]),a}(),D=function(t){function o(t,e,n){var r;return p(this,o),y(k(r=w(this,g(o).call(this,n))),"node",void 0),y(k(r),"component",void 0),y(k(r),"sockets",new Map),y(k(r),"controls",new Map),y(k(r),"el",void 0),y(k(r),"_startPosition",[]),y(k(r),"_drag",void 0),r.node=t,r.component=e,r.el=document.createElement("div"),r.el.style.position="absolute",r.el.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,node:r.node})}),r._drag=new P(r.el,r.onTranslate.bind(k(r)),r.onSelect.bind(k(r)),function(){r.trigger("nodedraged",t),r.trigger("nodedragged",t)}),r.trigger("rendernode",{el:r.el,node:t,component:e.data,bindSocket:r.bindSocket.bind(k(r)),bindControl:r.bindControl.bind(k(r))}),r.update(),r}return m(o,d),v(o,[{key:"clearSockets",value:function(){var e=this,n=[].concat(b(this.node.inputs.values()),b(this.node.outputs.values()));this.sockets.forEach(function(t){n.includes(t.io)||e.sockets.delete(t.io)})}},{key:"bindSocket",value:function(t,e,n){this.clearSockets(),this.sockets.set(n,new L(t,e,n,this.node,this))}},{key:"bindControl",value:function(t,e){this.controls.set(e,new j(t,e,this))}},{key:"hasSocket",value:function(t){return this.sockets.has(t)}},{key:"getSocketPosition",value:function(t){var e=this.sockets.get(t);if(!e)throw new Error("Socket not found for ".concat(t.name," with key ").concat(t.key));return e.getPosition(this.node)}},{key:"onSelect",value:function(t){var e={node:this.node,accumulate:t.ctrlKey,e:t};this.onStart(),this.trigger("multiselectnode",e),this.trigger("selectnode",e)}},{key:"onStart",value:function(){this._startPosition=b(this.node.position)}},{key:"onTranslate",value:function(t,e){this.trigger("translatenode",{node:this.node,dx:t,dy:e})}},{key:"onDrag",value:function(t,e){var n=this._startPosition[0]+t,r=this._startPosition[1]+e;this.translate(n,r)}},{key:"translate",value:function(t,e){var n=this.node,r={node:n,x:t,y:e};if(this.trigger("nodetranslate",r)){var o=c(n.position,2),i=[o[0],o[1]];n.position[0]=r.x,n.position[1]=r.y,this.update(),this.trigger("nodetranslated",{node:n,prev:i})}}},{key:"update",value:function(){var t=c(this.node.position,2),e=t[0],n=t[1];this.el.style.transform="translate(".concat(e,"px, ").concat(n,"px)")}},{key:"remove",value:function(){}},{key:"destroy",value:function(){this._drag.destroy()}}]),o}(),T=function(t){function o(t,e,n){var r;return p(this,o),y(k(r=w(this,g(o).call(this,n))),"container",void 0),y(k(r),"components",void 0),y(k(r),"nodes",new Map),y(k(r),"connections",new Map),y(k(r),"area",void 0),r.container=t,r.components=e,r.container.style.overflow="hidden",r.container.addEventListener("click",r.click.bind(k(r))),r.container.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,view:k(r)})}),n.on("destroy",S("resize",r.resize.bind(k(r)))),n.on("destroy",function(){return r.nodes.forEach(function(t){return t.destroy()})}),r.on("nodetranslated",r.updateConnections.bind(k(r))),r.on("rendersocket",function(t){var o=t.socket;Array.from(r.connections.entries()).filter(function(t){var e=c(t,1)[0],n=e.input,r=e.output;return[n.socket,r.socket].includes(o)}).forEach(function(t){var e=c(t,2),n=(e[0],e[1]);return requestAnimationFrame(function(){return n.update()})})}),r.area=new I(t,k(r)),r.container.appendChild(r.area.el),r}return m(o,d),v(o,[{key:"addNode",value:function(t){var e=this.components.get(t.name);if(!e)throw new Error("Component ".concat(t.name," not found"));var n=new D(t,e,this);this.nodes.set(t,n),this.area.appendChild(n.el)}},{key:"removeNode",value:function(t){var e=this.nodes.get(t);this.nodes.delete(t),e&&(this.area.removeChild(e.el),e.destroy())}},{key:"addConnection",value:function(t){if(!t.input.node||!t.output.node)throw new Error("Connection input or output not added to node");var e=this.nodes.get(t.input.node),n=this.nodes.get(t.output.node);if(!e||!n)throw new Error("View node not found for input or output");var r=new _(t,e,n,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){var e=this.connections.get(t);this.connections.delete(t),e&&this.area.removeChild(e.el)}},{key:"updateConnections",value:function(t){var n=this;t.node.getConnections().forEach(function(t){var e=n.connections.get(t);if(!e)throw new Error("Connection view not found");e.update()})}},{key:"resize",value:function(){var t=this.container;if(!t.parentElement)throw new Error("Container doesn't have parent element");var e=t.parentElement.clientWidth,n=t.parentElement.clientHeight;t.style.width=e+"px",t.style.height=n+"px"}},{key:"click",value:function(t){var e=this.container;e===t.target&&this.trigger("click",{e:t,container:e})}}]),o}(),A=function(){function t(){p(this,t),y(this,"list",[])}return v(t,[{key:"add",value:function(t){1<arguments.length&&void 0!==arguments[1]&&arguments[1]?this.contains(t)||this.list.push(t):this.list=[t]}},{key:"clear",value:function(){this.list=[]}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),z=function(t){function e(){return p(this,e),w(this,g(e).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],translatenode:[],nodetranslate:[],nodetranslated:[],nodedraged:[],nodedragged:[],selectnode:[],multiselectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],updateconnection:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[],clear:[]}))}return m(e,N),e}(),M=function(t){function n(t,e){var o;return p(this,n),y(k(o=w(this,g(n).call(this,t,new z))),"nodes",[]),y(k(o),"selected",new A),y(k(o),"view",void 0),o.view=new T(e,o.components,k(o)),o.on("destroy",S("keydown",function(t){return o.trigger("keydown",t)})),o.on("destroy",S("keyup",function(t){return o.trigger("keyup",t)})),o.on("selectnode",function(t){var e=t.node,n=t.accumulate;return o.selectNode(e,n)}),o.on("nodeselected",function(){return o.selected.each(function(t){var e=o.view.nodes.get(t);e&&e.onStart()})}),o.on("translatenode",function(t){var n=t.dx,r=t.dy;return o.selected.each(function(t){var e=o.view.nodes.get(t);e&&e.onDrag(n,r)})}),o}var e;return m(n,C),v(n,[{key:"addNode",value:function(t){this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var e=this;this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return e.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(this.trigger("connectioncreate",{output:t,input:e}))try{var r=t.connectTo(e);r.data=n,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,e),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var e=this.components.get(t);if(!e)throw"Component ".concat(t," not found");return e}},{key:"register",value:function(t){o(g(n.prototype),"register",this).call(this,t),t.editor=this}},{key:"clear",value:function(){var e=this;b(this.nodes).forEach(function(t){return e.removeNode(t)}),this.trigger("clear")}},{key:"toJSON",value:function(){var e={id:this.id,nodes:{}};return this.nodes.forEach(function(t){return e.nodes[t.id]=t.toJSON()}),this.trigger("export",e),e}},{key:"beforeImport",value:function(t){var e=O.validate(this.id,t);return e.success?(this.silent=!0,this.clear(),this.trigger("import",t),!0):(this.trigger("warn",e.msg),!1)}},{key:"afterImport",value:function(){return!(this.silent=!1)}},{key:"fromJSON",value:(e=f(regeneratorRuntime.mark(function t(o){var a,u=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.beforeImport(o)){t.next=2;break}return t.abrupt("return",!1);case 2:return a={},t.prev=3,t.next=6,Promise.all(Object.keys(o.nodes).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.nodes[e],r=u.getComponent(n.name),t.next=4,r.build(s.fromJSON(n));case 4:a[e]=t.sent,u.addNode(a[e]);case 6:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 6:Object.keys(o.nodes).forEach(function(t){var e=o.nodes[t],s=a[t];Object.keys(e.outputs).forEach(function(i){e.outputs[i].connections.forEach(function(t){var e=t.node,n=t.data,r=s.outputs.get(i),o=a[e].inputs.get(t.input);if(!r||!o)return u.trigger("error","IO not found for node ".concat(s.id));u.connect(r,o,n)})})}),t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(3),this.trigger("warn",t.t0),t.abrupt("return",!this.afterImport());case 13:return t.abrupt("return",this.afterImport());case 14:case"end":return t.stop()}},t,this,[[3,9]])})),function(t){return e.apply(this,arguments)})}]),n}(),Y=function(t){function o(t,e,n){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return p(this,o),w(this,g(o).call(this,t,e,n,r))}return m(o,x),v(o,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"connectTo",value:function(t){if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var e=new h(this,t);return this.connections.push(e),e}},{key:"connectedTo",value:function(e){return this.connections.some(function(t){return t.input===e})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){if(!t.input.node)throw new Error("Node not added to Input");return{node:t.input.node.id,input:t.input.key,data:t.data}})}}}]),o}(),J=function(){function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};p(this,n),y(this,"name",void 0),y(this,"data",void 0),y(this,"compatible",[]),this.name=t,this.data=e,this.compatible=[]}return v(n,[{key:"combineWith",value:function(t){this.compatible.push(t)}},{key:"compatibleWith",value:function(t){return this===t||this.compatible.includes(t)}}]),n}();var G=function(){function e(t){p(this,e),y(this,"nodes",void 0),this.nodes=t}return v(e,[{key:"extractInputNodes",value:function(r){var o=this;return Object.keys(r.inputs).reduce(function(t,e){var n=(r.inputs[e].connections||[]).reduce(function(t,e){return[].concat(b(t),[o.nodes[e.node]])},[]);return[].concat(b(t),b(n))},[])}},{key:"findSelf",value:function(t,e){var n=function(t,e){return t.filter(function(t){return-1!==e.indexOf(t)})}(t,e);if(n.length)return n[0];var r=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var u=s.value,c=[u].concat(b(t)),h=this.findSelf(c,this.extractInputNodes(u));if(h)return h}}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return null}},{key:"detect",value:function(){var e=this,t=Object.keys(this.nodes).map(function(t){return e.nodes[t]}),n=!0,r=!1,o=void 0;try{for(var i,s=t[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value,u=this.findSelf([a],this.extractInputNodes(a));if(u)return u}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}return null}}]),e}(),W=0,F=1,V=2,X=function(t){function e(){return p(this,e),w(this,g(e).call(this,{}))}return m(e,N),e}(),B=function(t){function n(t){var e;return p(this,n),y(k(e=w(this,g(n).call(this,t,new X))),"args",[]),y(k(e),"data",null),y(k(e),"state",W),y(k(e),"forwarded",new Set),y(k(e),"onAbort",function(){}),e}var e,r,o,i,s,a,u,c,h,l,d;return m(n,C),v(n,[{key:"clone",value:function(){var e=new n(this.id);return this.components.forEach(function(t){return e.register(t)}),e}},{key:"throwError",value:(d=f(regeneratorRuntime.mark(function t(e){var n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<r.length&&void 0!==r[1]?r[1]:null,t.next=3,this.abort();case 3:return this.trigger("error",{message:e,data:n}),this.processDone(),t.abrupt("return","error");case 6:case"end":return t.stop()}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"processStart",value:function(){return this.state===W?(this.state=F,!0):(this.state===V||console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==V;return this.state=W,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:(l=f(regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.state===F?(e.state=V,e.onAbort=t):e.state===V?(e.onAbort(),e.onAbort=t):t()}));case 1:case"end":return t.stop()}},t)})),function(){return l.apply(this,arguments)})},{key:"lock",value:(h=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.unlockPool=e.unlockPool||[],e.busy&&!e.outputData?e.unlockPool.push(t):t(),e.busy=!0}));case 1:case"end":return t.stop()}},t)})),function(t){return h.apply(this,arguments)})},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:(c=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s,a,u,c=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=0,o=Object.keys(e.inputs);case 2:if(r<o.length)return i=o[r],s=e.inputs[i],a=s.connections,t.next=8,Promise.all(a.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.data.nodes[e.node],t.next=3,c.processNode(n);case 3:if(r=t.sent){t.next=8;break}c.abort(),t.next=9;break;case 8:return t.abrupt("return",r[e.output]);case 9:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));t.next=13;break;case 8:u=t.sent,n[i]=u;case 10:r++,t.next=2;break;case 13:return t.abrupt("return",n);case 14:case"end":return t.stop()}},t)})),function(t){return c.apply(this,arguments)})},{key:"processWorker",value:(u=f(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractInputData(e);case 2:return n=t.sent,r=this.components.get(e.name),o={},t.prev=5,t.next=8,r.worker.apply(r,[e,n,o].concat(b(this.args)));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),this.abort(),this.trigger("warn",t.t0);case 14:return t.abrupt("return",o);case 15:case"end":return t.stop()}},t,this,[[5,10]])})),function(t){return u.apply(this,arguments)})},{key:"processNode",value:(a=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state!==V&&e){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,this.lock(e);case 4:if(e.outputData){t.next=8;break}return t.next=7,this.processWorker(e);case 7:e.outputData=t.sent;case 8:return this.unlock(e),t.abrupt("return",e.outputData);case 10:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"forwardProcess",value:(s=f(regeneratorRuntime.mark(function t(r){var o=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state===V)return t.abrupt("return",null);t.next=2;break;case 2:return t.next=4,Promise.all(Object.keys(r.outputs).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.outputs[e],t.next=3,Promise.all(n.connections.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.data.nodes[e.node],o.forwarded.has(n)){t.next=7;break}return o.forwarded.add(n),t.next=5,o.processNode(n);case 5:return t.next=7,o.forwardProcess(n);case 7:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"copy",value:function(e){return(e=Object.assign({},e)).nodes=Object.assign({},e.nodes),Object.keys(e.nodes).forEach(function(t){e.nodes[t]=Object.assign({},e.nodes[t])}),e}},{key:"validate",value:(i=f(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=O.validate(this.id,e),r=new G(e.nodes),n.success){t.next=6;break}return t.next=5,this.throwError(n.msg);case 5:return t.abrupt("return",t.sent);case 6:if(o=r.detect())return t.next=10,this.throwError("Recursion detected",o);t.next=11;break;case 10:return t.abrupt("return",t.sent);case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"processStartNode",value:(o=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:if(n=this.data.nodes[e]){t.next=7;break}return t.next=6,this.throwError("Node with such id not found");case 6:return t.abrupt("return",t.sent);case 7:return t.next=9,this.processNode(n);case 9:return t.next=11,this.forwardProcess(n);case 11:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"processUnreachable",value:(r=f(regeneratorRuntime.mark(function t(){var e,n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=this.data,t.t0=regeneratorRuntime.keys(e.nodes);case 2:if((t.t1=t.t0()).done){t.next=12;break}if(n=t.t1.value,void 0===(r=e.nodes[n]).outputData)return t.next=8,this.processNode(r);t.next=10;break;case 8:return t.next=10,this.forwardProcess(r);case 10:t.next=2;break;case 12:case"end":return t.stop()}},t,this)})),function(){return r.apply(this,arguments)})},{key:"process",value:(e=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=1<s.length&&void 0!==s[1]?s[1]:null,this.processStart()){t.next=3;break}return t.abrupt("return");case 3:if(this.validate(e)){t.next=5;break}return t.abrupt("return");case 5:for(this.data=this.copy(e),r=s.length,o=new Array(2<r?r-2:0),i=2;i<r;i++)o[i-2]=s[i];return this.args=o,this.forwarded=new Set,t.next=11,this.processStartNode(n);case 11:return t.next=13,this.processUnreachable();case 13:return t.abrupt("return",this.processDone()?"success":"aborted");case 14:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})}]),n}(),q={Engine:B,Recursion:G,Component:e,Control:l,Connection:h,Emitter:d,Input:E,IO:x,Node:s,NodeEditor:M,Output:Y,Socket:J};t.Component=e,t.Connection=h,t.Control=l,t.Emitter=d,t.Engine=B,t.IO=x,t.Input=E,t.Node=s,t.NodeEditor=M,t.Output=Y,t.Recursion=G,t.Socket=J,t.default=q,Object.defineProperty(t,"__esModule",{value:!0})});
var runtime=function(i){"use strict";var u,t=Object.prototype,c=t.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",r=e.toStringTag||"@@toStringTag";function s(t,e,n,r){var o=e&&e.prototype instanceof a?e:a,i=Object.create(o.prototype),s=new N(r||[]);return i._invoke=function(i,s,a){var u=l;return function(t,e){if(u===f)throw new Error("Generator is already running");if(u===p){if("throw"===t)throw e;return R()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=O(n,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===l)throw u=p,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=f;var o=h(i,s,a);if("normal"===o.type){if(u=a.done?p:d,o.arg===v)continue;return{value:o.arg,done:a.done}}"throw"===o.type&&(u=p,a.method="throw",a.arg=o.arg)}}}(t,n,s),i}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=s;var l="suspendedStart",d="suspendedYield",f="executing",p="completed",v={};function a(){}function y(){}function m(){}var g={};g[o]=function(){return this};var k=Object.getPrototypeOf,w=k&&k(k(P([])));w&&w!==t&&c.call(w,o)&&(g=w);var b=m.prototype=a.prototype=Object.create(g);function x(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function E(u){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=h(u[t],u,n);if("throw"!==i.type){var s=i.arg,a=s.value;return a&&"object"==typeof a&&c.call(a,"__await")?Promise.resolve(a.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(a).then(function(t){s.value=t,r(s)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function O(t,e){var n=t.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=u,O(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var r=h(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,v;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u),e.delegate=null,v):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(c.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t};return r.next=r}}return{next:R}}function R(){return{value:u,done:!0}}return y.prototype=b.constructor=m,m.constructor=y,m[r]=y.displayName="GeneratorFunction",i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(b),t},i.awrap=function(t){return{__await:t}},x(E.prototype),E.prototype[n]=function(){return this},i.AsyncIterator=E,i.async=function(t,e,n,r){var o=new E(s(t,e,n,r));return i.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},x(b),b[r]="Generator",b[o]=function(){return this},b.toString=function(){return"[object Generator]"},i.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},i.values=P,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&c.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var s=c.call(o,"catchLoc"),a=c.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),v}},i}("object"==typeof module?module.exports:{});try{regeneratorRuntime=runtime}catch(t){Function("r","regeneratorRuntime = r")(runtime)}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).Rete={})}(this,function(t){"use strict";function u(t,e,n,r,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,o)}function f(a){return function(){var t=this,s=arguments;return new Promise(function(e,n){var r=a.apply(t,s);function o(t){u(r,e,n,o,i,"next",t)}function i(t){u(r,e,n,o,i,"throw",t)}o(void 0)})}}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(t){y(e,t,n[t])})}return e}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function k(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function w(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?k(t):e}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function i(t){p(this,i),y(this,"name",void 0),y(this,"data",{}),y(this,"engine",null),this.name=t}var s=function(){function i(t){p(this,i),y(this,"name",void 0),y(this,"id",void 0),y(this,"position",[0,0]),y(this,"inputs",new Map),y(this,"outputs",new Map),y(this,"controls",new Map),y(this,"data",{}),y(this,"meta",{}),this.name=t,this.id=i.incrementId()}return v(i,[{key:"_add",value:function(t,e,n){if(t.has(e.key))throw new Error("Item with key '".concat(e.key,"' already been added to the node"));if(null!==e[n])throw new Error("Item has already been added to some node");e[n]=this,t.set(e.key,e)}},{key:"addControl",value:function(t){return this._add(this.controls,t,"parent"),this}},{key:"removeControl",value:function(t){t.parent=null,this.controls.delete(t.key)}},{key:"addInput",value:function(t){return this._add(this.inputs,t,"node"),this}},{key:"removeInput",value:function(t){t.removeConnections(),t.node=null,this.inputs.delete(t.key)}},{key:"addOutput",value:function(t){return this._add(this.outputs,t,"node"),this}},{key:"removeOutput",value:function(t){t.removeConnections(),t.node=null,this.outputs.delete(t.key)}},{key:"setMeta",value:function(t){return this.meta=t,this}},{key:"getConnections",value:function(){return[].concat(b(this.inputs.values()),b(this.outputs.values())).reduce(function(t,e){return[].concat(b(t),b(e.connections))},[])}},{key:"update",value:function(){}},{key:"toJSON",value:function(){function t(t){return Array.from(t).reduce(function(t,e){var n=c(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{})}return{id:this.id,data:this.data,inputs:t(this.inputs),outputs:t(this.outputs),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"resetId",value:function(){this.latestId=0}},{key:"fromJSON",value:function(t){var e=new i(t.name),n=c(t.position,2),r=n[0],o=n[1];return e.id=t.id,e.data=t.data,e.position=[r,o],e.name=t.name,i.latestId=Math.max(e.id,i.latestId),e}}]),i}();y(s,"latestId",0);var e=function(t){function n(t){var e;return p(this,n),y(k(e=w(this,g(n).call(this,t))),"editor",null),y(k(e),"data",{}),e}var e,r;return m(n,i),v(n,[{key:"build",value:(r=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.builder(e);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createNode",value:(e=f(regeneratorRuntime.mark(function t(){var e,n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<r.length&&void 0!==r[0]?r[0]:{},(n=new s(this.name)).data=e,t.next=5,this.build(n);case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}},t,this)})),function(){return e.apply(this,arguments)})}]),n}(),h=function(){function n(t,e){p(this,n),y(this,"output",void 0),y(this,"input",void 0),y(this,"data",{}),this.output=t,this.input=e,this.data={},this.input.addConnection(this)}return v(n,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),n}(),l=function(){function e(t){if(p(this,e),y(this,"key",void 0),y(this,"data",{}),y(this,"parent",null),this.constructor===e)throw new TypeError("Can not construct abstract class");if(!t)throw new Error("The key parameter is missing in super() of Control ");this.key=t}return v(e,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");if(this.parent instanceof s)return this.parent;if(!this.parent.node)throw new Error("Control hasn't be added to Input or Node");return this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,e){this.getNode().data[t]=e}}]),e}(),d=function(){function e(t){p(this,e),y(this,"events",{}),y(this,"silent",!1),this.events=t instanceof e?t.events:t.handlers}return v(e,[{key:"on",value:function(t,e){var n=this;return(t instanceof Array?t:t.split(" ")).forEach(function(t){if(!n.events[t])throw new Error("The event ".concat(t," does not exist"));n.events[t].push(e)}),this}},{key:"trigger",value:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!(t in this.events))throw new Error("The event ".concat(t," cannot be triggered"));return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}},{key:"bind",value:function(t){if(this.events[t])throw new Error("The event ".concat(t," is already bound"));this.events[t]=[]}},{key:"exist",value:function(t){return Array.isArray(this.events[t])}}]),e}(),x=function(){function o(t,e,n,r){p(this,o),y(this,"node",null),y(this,"multipleConnections",void 0),y(this,"connections",[]),y(this,"key",void 0),y(this,"name",void 0),y(this,"socket",void 0),this.node=null,this.multipleConnections=r,this.connections=[],this.key=t,this.name=e,this.socket=n}return v(o,[{key:"removeConnection",value:function(t){this.connections.splice(this.connections.indexOf(t),1)}},{key:"removeConnections",value:function(){var e=this;this.connections.forEach(function(t){return e.removeConnection(t)})}}]),o}(),E=function(t){function i(t,e,n){var r,o=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return p(this,i),y(k(r=w(this,g(i).call(this,t,e,n,o))),"control",null),r}return m(i,x),v(i,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"addConnection",value:function(t){if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){(this.control=t).parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){if(!t.output.node)throw new Error("Node not added to Output");return{node:t.output.node.id,output:t.output.key,data:t.data}})}}}]),i}(),O=function(){function t(){p(this,t)}return v(t,null,[{key:"isValidData",value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,e){var n=t.split("@"),r=e.id.split("@"),o=[];return this.isValidData(e)||o.push("Data is not suitable"),t!==e.id&&o.push("IDs not equal"),n[0]!==r[0]&&o.push("Names don't match"),n[1]!==r[1]&&o.push("Versions don't match"),{success:Boolean(!o.length),msg:o.join(". ")}}}]),t}(),C=function(t){function r(t,e){var n;if(p(this,r),y(k(n=w(this,g(r).call(this,e))),"id",void 0),y(k(n),"plugins",void 0),y(k(n),"components",void 0),!O.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return n.id=t,n.plugins=new Map,n.components=new Map,n}return m(r,d),v(r,[{key:"use",value:function(t,e){if(t.name&&this.plugins.has(t.name))throw new Error("Plugin ".concat(t.name," already in use"));t.install(this,e||{}),this.plugins.set(t.name,e)}},{key:"register",value:function(t){if(this.components.has(t.name))throw new Error("Component ".concat(t.name," already registered"));this.components.set(t.name,t),this.trigger("componentregister",t)}},{key:"destroy",value:function(){this.trigger("destroy")}}]),r}();function S(t,e){return window.addEventListener(t,e),function(){window.removeEventListener(t,e)}}function N(t){p(this,N),y(this,"handlers",void 0),this.handlers=a({warn:[console.warn],error:[console.error],componentregister:[],destroy:[]},t)}var P=function(){function s(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(t,e,n){},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(t){},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(t){};p(this,s),this.onTranslate=e,this.onStart=n,this.onDrag=r,y(this,"pointerStart",void 0),y(this,"el",void 0),y(this,"destroy",void 0),this.pointerStart=null,this.el=t,this.el.style.touchAction="none",this.el.addEventListener("pointerdown",this.down.bind(this));var o=S("pointermove",this.move.bind(this)),i=S("pointerup",this.up.bind(this));this.destroy=function(){o(),i()}}return v(s,[{key:"down",value:function(t){"mouse"===t.pointerType&&0!==t.button||(t.stopPropagation(),this.pointerStart=[t.pageX,t.pageY],this.onStart(t))}},{key:"move",value:function(t){if(this.pointerStart){t.preventDefault();var e=[t.pageX,t.pageY],n=e[1],r=[e[0]-this.pointerStart[0],n-this.pointerStart[1]],o=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.onTranslate(r[0]/o,r[1]/o,t)}}},{key:"up",value:function(t){this.pointerStart&&(this.pointerStart=null,this.onDrag(t))}}]),s}(),R=function(){function a(t,e,n,r){p(this,a),y(this,"el",void 0),y(this,"intensity",void 0),y(this,"onzoom",void 0),y(this,"previous",null),y(this,"pointers",[]),y(this,"destroy",void 0),this.el=e,this.intensity=n,this.onzoom=r,t.addEventListener("wheel",this.wheel.bind(this)),t.addEventListener("pointerdown",this.down.bind(this)),t.addEventListener("dblclick",this.dblclick.bind(this));var o=S("pointermove",this.move.bind(this)),i=S("pointerup",this.end.bind(this)),s=S("pointercancel",this.end.bind(this));this.destroy=function(){o(),i(),s()}}return v(a,[{key:"wheel",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=t.deltaY<0?this.intensity:-this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"wheel")}},{key:"touches",value:function(){var t={touches:this.pointers},e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],s=o[1];return{cx:(n+i)/2,cy:(r+s)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-s,2))}}},{key:"down",value:function(t){this.pointers.push(t)}},{key:"move",value:function(e){if(this.pointers=this.pointers.map(function(t){return t.pointerId===e.pointerId?e:t}),this.translating){var t=this.el.getBoundingClientRect(),n=this.touches(),r=n.cx,o=n.cy,i=n.distance;if(null!==this.previous){var s=i/this.previous.distance-1,a=(t.left-r)*s,u=(t.top-o)*s;this.onzoom(s,a-(this.previous.cx-r),u-(this.previous.cy-o),"touch")}this.previous={cx:r,cy:o,distance:i}}}},{key:"end",value:function(e){this.previous=null,this.pointers=this.pointers.filter(function(t){return t.pointerId!==e.pointerId})}},{key:"dblclick",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=4*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"dblclick")}},{key:"translating",get:function(){return 2<=this.pointers.length}}]),a}(),I=function(t){function o(t,e){var n;p(this,o),y(k(n=w(this,g(o).call(this,e))),"el",void 0),y(k(n),"container",void 0),y(k(n),"transform",{k:1,x:0,y:0}),y(k(n),"mouse",{x:0,y:0}),y(k(n),"_startPosition",null),y(k(n),"_zoom",void 0),y(k(n),"_drag",void 0);var r=n.el=document.createElement("div");return n.container=t,r.style.transformOrigin="0 0",n._zoom=new R(t,r,.1,n.onZoom.bind(k(n))),n._drag=new P(t,n.onTranslate.bind(k(n)),n.onStart.bind(k(n))),e.on("destroy",function(){n._zoom.destroy(),n._drag.destroy()}),n.container.addEventListener("pointermove",n.pointermove.bind(k(n))),n.update(),n}return m(o,d),v(o,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate(".concat(t.x,"px, ").concat(t.y,"px) scale(").concat(t.k,")")}},{key:"pointermove",value:function(t){var e=t.clientX,n=t.clientY,r=this.el.getBoundingClientRect(),o=e-r.left,i=n-r.top,s=this.transform.k;this.mouse={x:o/s,y:i/s},this.trigger("mousemove",a({},this.mouse))}},{key:"onStart",value:function(){this._startPosition=a({},this.transform)}},{key:"onTranslate",value:function(t,e){this._zoom.translating||this._startPosition&&this.translate(this._startPosition.x+t,this._startPosition.y+e)}},{key:"onZoom",value:function(t,e,n,r){this.zoom(this.transform.k*(1+t),e,n,r),this.update()}},{key:"translate",value:function(t,e){var n={transform:this.transform,x:t,y:e};this.trigger("translate",n)&&(this.transform.x=n.x,this.transform.y=n.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length?arguments[3]:void 0,o=this.transform.k,i={transform:this.transform,zoom:t,source:r};if(this.trigger("zoom",i)){var s=(o-i.zoom)/(o-t||1);this.transform.k=i.zoom||1,this.transform.x+=e*s,this.transform.y+=n*s,this.update(),this.trigger("zoomed",{source:r})}}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),o}(),_=function(t){function i(t,e,n,r){var o;return p(this,i),y(k(o=w(this,g(i).call(this,r))),"connection",void 0),y(k(o),"inputNode",void 0),y(k(o),"outputNode",void 0),y(k(o),"el",void 0),o.connection=t,o.inputNode=e,o.outputNode=n,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.style.zIndex="-1",o.trigger("renderconnection",{el:o.el,connection:o.connection,points:o.getPoints()}),o}return m(i,d),v(i,[{key:"getPoints",value:function(){var t=this.connection,e=t.input,n=t.output;if(this.inputNode.hasSocket(e)&&this.outputNode.hasSocket(n)){var r=c(this.outputNode.getSocketPosition(n),2),o=r[0],i=r[1],s=c(this.inputNode.getSocketPosition(e),2);return[o,i,s[0],s[1]]}return[0,0,0,0]}},{key:"update",value:function(){this.trigger("updateconnection",{el:this.el,connection:this.connection,points:this.getPoints()})}}]),i}(),j=function(t){function o(t,e,n){var r;return p(this,o),(r=w(this,g(o).call(this,n))).trigger("rendercontrol",{el:t,control:e}),r}return m(o,d),o}(),L=function(t){function a(t,e,n,r,o){var i,s;return p(this,a),y(k(s=w(this,g(a).call(this,o))),"el",void 0),y(k(s),"type",void 0),y(k(s),"io",void 0),y(k(s),"node",void 0),s.el=t,s.type=e,s.io=n,s.node=r,s.trigger("rendersocket",(y(i={el:t},e,s.io),y(i,"socket",n.socket),i)),s}return m(a,d),v(a,[{key:"getPosition",value:function(t){var e=t.position,n=this.el;return[e[0]+n.offsetLeft+n.offsetWidth/2,e[1]+n.offsetTop+n.offsetHeight/2]}}]),a}(),D=function(t){function o(t,e,n){var r;return p(this,o),y(k(r=w(this,g(o).call(this,n))),"node",void 0),y(k(r),"component",void 0),y(k(r),"sockets",new Map),y(k(r),"controls",new Map),y(k(r),"el",void 0),y(k(r),"_startPosition",[]),y(k(r),"_drag",void 0),r.node=t,r.component=e,r.el=document.createElement("div"),r.el.style.position="absolute",r.el.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,node:r.node})}),r._drag=new P(r.el,r.onTranslate.bind(k(r)),r.onSelect.bind(k(r)),function(){r.trigger("nodedraged",t),r.trigger("nodedragged",t)}),r.trigger("rendernode",{el:r.el,node:t,component:e.data,bindSocket:r.bindSocket.bind(k(r)),bindControl:r.bindControl.bind(k(r))}),r.update(),r}return m(o,d),v(o,[{key:"clearSockets",value:function(){var e=this,n=[].concat(b(this.node.inputs.values()),b(this.node.outputs.values()));this.sockets.forEach(function(t){n.includes(t.io)||e.sockets.delete(t.io)})}},{key:"bindSocket",value:function(t,e,n){this.clearSockets(),this.sockets.set(n,new L(t,e,n,this.node,this))}},{key:"bindControl",value:function(t,e){this.controls.set(e,new j(t,e,this))}},{key:"hasSocket",value:function(t){return this.sockets.has(t)}},{key:"getSocketPosition",value:function(t){var e=this.sockets.get(t);if(!e)throw new Error("Socket not found for ".concat(t.name," with key ").concat(t.key));return e.getPosition(this.node)}},{key:"onSelect",value:function(t){var e={node:this.node,accumulate:t.ctrlKey,e:t};this.onStart(),this.trigger("multiselectnode",e),this.trigger("selectnode",e)}},{key:"onStart",value:function(){this._startPosition=b(this.node.position)}},{key:"onTranslate",value:function(t,e){this.trigger("translatenode",{node:this.node,dx:t,dy:e})}},{key:"onDrag",value:function(t,e){var n=this._startPosition[0]+t,r=this._startPosition[1]+e;this.translate(n,r)}},{key:"translate",value:function(t,e){var n=this.node,r={node:n,x:t,y:e};if(this.trigger("nodetranslate",r)){var o=c(n.position,2),i=[o[0],o[1]];n.position[0]=r.x,n.position[1]=r.y,this.update(),this.trigger("nodetranslated",{node:n,prev:i})}}},{key:"update",value:function(){var t=c(this.node.position,2),e=t[0],n=t[1];this.el.style.transform="translate(".concat(e,"px, ").concat(n,"px)")}},{key:"remove",value:function(){}},{key:"destroy",value:function(){this._drag.destroy()}}]),o}(),T=function(t){function r(t,e,n){var o;return p(this,r),y(k(o=w(this,g(r).call(this,n))),"container",void 0),y(k(o),"components",void 0),y(k(o),"nodes",new Map),y(k(o),"connections",new Map),y(k(o),"area",void 0),o.container=t,o.components=e,o.container.style.overflow="hidden",o.container.addEventListener("click",o.click.bind(k(o))),o.container.addEventListener("contextmenu",function(t){return o.trigger("contextmenu",{e:t,view:k(o)})}),n.on("destroy",S("resize",o.resize.bind(k(o)))),n.on("destroy",function(){return o.nodes.forEach(function(t){return t.destroy()})}),o.on("nodetranslated",o.updateConnections.bind(k(o))),o.on("rendersocket",function(t){var n=t.input,r=t.output;Array.from(o.connections.entries()).filter(function(t){var e=c(t,1)[0];return e.input===n||e.output===r}).forEach(function(t){var e=c(t,2),n=(e[0],e[1]);return requestAnimationFrame(function(){return n.update()})})}),o.area=new I(t,k(o)),o.container.appendChild(o.area.el),o}return m(r,d),v(r,[{key:"addNode",value:function(t){var e=this.components.get(t.name);if(!e)throw new Error("Component ".concat(t.name," not found"));var n=new D(t,e,this);this.nodes.set(t,n),this.area.appendChild(n.el)}},{key:"removeNode",value:function(t){var e=this.nodes.get(t);this.nodes.delete(t),e&&(this.area.removeChild(e.el),e.destroy())}},{key:"addConnection",value:function(t){if(!t.input.node||!t.output.node)throw new Error("Connection input or output not added to node");var e=this.nodes.get(t.input.node),n=this.nodes.get(t.output.node);if(!e||!n)throw new Error("View node not found for input or output");var r=new _(t,e,n,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){var e=this.connections.get(t);this.connections.delete(t),e&&this.area.removeChild(e.el)}},{key:"updateConnections",value:function(t){var n=this;t.node.getConnections().forEach(function(t){var e=n.connections.get(t);if(!e)throw new Error("Connection view not found");e.update()})}},{key:"resize",value:function(){var t=this.container;if(!t.parentElement)throw new Error("Container doesn't have parent element");var e=t.parentElement.clientWidth,n=t.parentElement.clientHeight;t.style.width=e+"px",t.style.height=n+"px"}},{key:"click",value:function(t){var e=this.container;e===t.target&&this.trigger("click",{e:t,container:e})}}]),r}(),A=function(){function t(){p(this,t),y(this,"list",[])}return v(t,[{key:"add",value:function(t){1<arguments.length&&void 0!==arguments[1]&&arguments[1]?this.contains(t)||this.list.push(t):this.list=[t]}},{key:"clear",value:function(){this.list=[]}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),z=function(t){function e(){return p(this,e),w(this,g(e).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],translatenode:[],nodetranslate:[],nodetranslated:[],nodedraged:[],nodedragged:[],selectnode:[],multiselectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],updateconnection:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[],clear:[]}))}return m(e,N),e}(),M=function(t){function n(t,e){var o;return p(this,n),y(k(o=w(this,g(n).call(this,t,new z))),"nodes",[]),y(k(o),"selected",new A),y(k(o),"view",void 0),o.view=new T(e,o.components,k(o)),o.on("destroy",S("keydown",function(t){return o.trigger("keydown",t)})),o.on("destroy",S("keyup",function(t){return o.trigger("keyup",t)})),o.on("selectnode",function(t){var e=t.node,n=t.accumulate;return o.selectNode(e,n)}),o.on("nodeselected",function(){return o.selected.each(function(t){var e=o.view.nodes.get(t);e&&e.onStart()})}),o.on("translatenode",function(t){var n=t.dx,r=t.dy;return o.selected.each(function(t){var e=o.view.nodes.get(t);e&&e.onDrag(n,r)})}),o}var e;return m(n,C),v(n,[{key:"addNode",value:function(t){this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var e=this;this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return e.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(this.trigger("connectioncreate",{output:t,input:e}))try{var r=t.connectTo(e);r.data=n,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,e),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var e=this.components.get(t);if(!e)throw"Component ".concat(t," not found");return e}},{key:"register",value:function(t){o(g(n.prototype),"register",this).call(this,t),t.editor=this}},{key:"clear",value:function(){var e=this;b(this.nodes).forEach(function(t){return e.removeNode(t)}),this.trigger("clear")}},{key:"toJSON",value:function(){var e={id:this.id,nodes:{}};return this.nodes.forEach(function(t){return e.nodes[t.id]=t.toJSON()}),this.trigger("export",e),e}},{key:"beforeImport",value:function(t){var e=O.validate(this.id,t);return e.success?(this.silent=!0,this.clear(),this.trigger("import",t),!0):(this.trigger("warn",e.msg),!1)}},{key:"afterImport",value:function(){return!(this.silent=!1)}},{key:"fromJSON",value:(e=f(regeneratorRuntime.mark(function t(o){var a,u=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.beforeImport(o)){t.next=2;break}return t.abrupt("return",!1);case 2:return a={},t.prev=3,t.next=6,Promise.all(Object.keys(o.nodes).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.nodes[e],r=u.getComponent(n.name),t.next=4,r.build(s.fromJSON(n));case 4:a[e]=t.sent,u.addNode(a[e]);case 6:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 6:Object.keys(o.nodes).forEach(function(t){var e=o.nodes[t],s=a[t];Object.keys(e.outputs).forEach(function(i){e.outputs[i].connections.forEach(function(t){var e=t.node,n=t.data,r=s.outputs.get(i),o=a[e].inputs.get(t.input);if(!r||!o)return u.trigger("error","IO not found for node ".concat(s.id));u.connect(r,o,n)})})}),t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(3),this.trigger("warn",t.t0),t.abrupt("return",!this.afterImport());case 13:return t.abrupt("return",this.afterImport());case 14:case"end":return t.stop()}},t,this,[[3,9]])})),function(t){return e.apply(this,arguments)})}]),n}(),Y=function(t){function o(t,e,n){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return p(this,o),w(this,g(o).call(this,t,e,n,r))}return m(o,x),v(o,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"connectTo",value:function(t){if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var e=new h(this,t);return this.connections.push(e),e}},{key:"connectedTo",value:function(e){return this.connections.some(function(t){return t.input===e})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){if(!t.input.node)throw new Error("Node not added to Input");return{node:t.input.node.id,input:t.input.key,data:t.data}})}}}]),o}(),J=function(){function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};p(this,n),y(this,"name",void 0),y(this,"data",void 0),y(this,"compatible",[]),this.name=t,this.data=e,this.compatible=[]}return v(n,[{key:"combineWith",value:function(t){this.compatible.push(t)}},{key:"compatibleWith",value:function(t){return this===t||this.compatible.includes(t)}}]),n}();var G=function(){function e(t){p(this,e),y(this,"nodes",void 0),this.nodes=t}return v(e,[{key:"extractInputNodes",value:function(r){var o=this;return Object.keys(r.inputs).reduce(function(t,e){var n=(r.inputs[e].connections||[]).reduce(function(t,e){return[].concat(b(t),[o.nodes[e.node]])},[]);return[].concat(b(t),b(n))},[])}},{key:"findSelf",value:function(t,e){var n=function(t,e){return t.filter(function(t){return-1!==e.indexOf(t)})}(t,e);if(n.length)return n[0];var r=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var u=s.value,c=[u].concat(b(t)),h=this.findSelf(c,this.extractInputNodes(u));if(h)return h}}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return null}},{key:"detect",value:function(){var e=this,t=Object.keys(this.nodes).map(function(t){return e.nodes[t]}),n=!0,r=!1,o=void 0;try{for(var i,s=t[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value,u=this.findSelf([a],this.extractInputNodes(a));if(u)return u}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}return null}}]),e}(),W=0,F=1,V=2,X=function(t){function e(){return p(this,e),w(this,g(e).call(this,{}))}return m(e,N),e}(),B=function(t){function n(t){var e;return p(this,n),y(k(e=w(this,g(n).call(this,t,new X))),"args",[]),y(k(e),"data",null),y(k(e),"state",W),y(k(e),"forwarded",new Set),y(k(e),"onAbort",function(){}),e}var e,r,o,i,s,a,u,c,h,l,d;return m(n,C),v(n,[{key:"clone",value:function(){var e=new n(this.id);return this.components.forEach(function(t){return e.register(t)}),e}},{key:"throwError",value:(d=f(regeneratorRuntime.mark(function t(e){var n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<r.length&&void 0!==r[1]?r[1]:null,t.next=3,this.abort();case 3:return this.trigger("error",{message:e,data:n}),this.processDone(),t.abrupt("return","error");case 6:case"end":return t.stop()}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"processStart",value:function(){return this.state===W?(this.state=F,!0):(this.state===V||console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==V;return this.state=W,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:(l=f(regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.state===F?(e.state=V,e.onAbort=t):e.state===V?(e.onAbort(),e.onAbort=t):t()}));case 1:case"end":return t.stop()}},t)})),function(){return l.apply(this,arguments)})},{key:"lock",value:(h=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.unlockPool=e.unlockPool||[],e.busy&&!e.outputData?e.unlockPool.push(t):t(),e.busy=!0}));case 1:case"end":return t.stop()}},t)})),function(t){return h.apply(this,arguments)})},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:(c=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s,a,u,c=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=0,o=Object.keys(e.inputs);case 2:if(r<o.length)return i=o[r],s=e.inputs[i],a=s.connections,t.next=8,Promise.all(a.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.data.nodes[e.node],t.next=3,c.processNode(n);case 3:if(r=t.sent){t.next=8;break}c.abort(),t.next=9;break;case 8:return t.abrupt("return",r[e.output]);case 9:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));t.next=13;break;case 8:u=t.sent,n[i]=u;case 10:r++,t.next=2;break;case 13:return t.abrupt("return",n);case 14:case"end":return t.stop()}},t)})),function(t){return c.apply(this,arguments)})},{key:"processWorker",value:(u=f(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractInputData(e);case 2:return n=t.sent,r=this.components.get(e.name),o={},t.prev=5,t.next=8,r.worker.apply(r,[e,n,o].concat(b(this.args)));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),this.abort(),this.trigger("warn",t.t0);case 14:return t.abrupt("return",o);case 15:case"end":return t.stop()}},t,this,[[5,10]])})),function(t){return u.apply(this,arguments)})},{key:"processNode",value:(a=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state!==V&&e){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,this.lock(e);case 4:if(e.outputData){t.next=8;break}return t.next=7,this.processWorker(e);case 7:e.outputData=t.sent;case 8:return this.unlock(e),t.abrupt("return",e.outputData);case 10:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"forwardProcess",value:(s=f(regeneratorRuntime.mark(function t(r){var o=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state===V)return t.abrupt("return",null);t.next=2;break;case 2:return t.next=4,Promise.all(Object.keys(r.outputs).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.outputs[e],t.next=3,Promise.all(n.connections.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.data.nodes[e.node],o.forwarded.has(n)){t.next=7;break}return o.forwarded.add(n),t.next=5,o.processNode(n);case 5:return t.next=7,o.forwardProcess(n);case 7:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"copy",value:function(e){return(e=Object.assign({},e)).nodes=Object.assign({},e.nodes),Object.keys(e.nodes).forEach(function(t){e.nodes[t]=Object.assign({},e.nodes[t])}),e}},{key:"validate",value:(i=f(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=O.validate(this.id,e),r=new G(e.nodes),n.success){t.next=6;break}return t.next=5,this.throwError(n.msg);case 5:return t.abrupt("return",t.sent);case 6:if(o=r.detect())return t.next=10,this.throwError("Recursion detected",o);t.next=11;break;case 10:return t.abrupt("return",t.sent);case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"processStartNode",value:(o=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:if(n=this.data.nodes[e]){t.next=7;break}return t.next=6,this.throwError("Node with such id not found");case 6:return t.abrupt("return",t.sent);case 7:return t.next=9,this.processNode(n);case 9:return t.next=11,this.forwardProcess(n);case 11:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"processUnreachable",value:(r=f(regeneratorRuntime.mark(function t(){var e,n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=this.data,t.t0=regeneratorRuntime.keys(e.nodes);case 2:if((t.t1=t.t0()).done){t.next=12;break}if(n=t.t1.value,void 0===(r=e.nodes[n]).outputData)return t.next=8,this.processNode(r);t.next=10;break;case 8:return t.next=10,this.forwardProcess(r);case 10:t.next=2;break;case 12:case"end":return t.stop()}},t,this)})),function(){return r.apply(this,arguments)})},{key:"process",value:(e=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=1<s.length&&void 0!==s[1]?s[1]:null,this.processStart()){t.next=3;break}return t.abrupt("return");case 3:if(this.validate(e)){t.next=5;break}return t.abrupt("return");case 5:for(this.data=this.copy(e),r=s.length,o=new Array(2<r?r-2:0),i=2;i<r;i++)o[i-2]=s[i];return this.args=o,this.forwarded=new Set,t.next=11,this.processStartNode(n);case 11:return t.next=13,this.processUnreachable();case 13:return t.abrupt("return",this.processDone()?"success":"aborted");case 14:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})}]),n}(),q={Engine:B,Recursion:G,Component:e,Control:l,Connection:h,Emitter:d,Input:E,IO:x,Node:s,NodeEditor:M,Output:Y,Socket:J};t.Component=e,t.Connection=h,t.Control=l,t.Emitter=d,t.Engine=B,t.IO=x,t.Input=E,t.Node=s,t.NodeEditor=M,t.Output=Y,t.Recursion=G,t.Socket=J,t.default=q,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=rete.min.js.map
{
"name": "rete",
"version": "1.4.9",
"version": "1.4.10",
"description": "JavaScript framework",

@@ -5,0 +5,0 @@ "main": "build/rete.common.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc