This commit is contained in:
tamat
2018-06-08 19:27:59 +02:00
parent 30e8374491
commit df18406070
2 changed files with 1304 additions and 183 deletions

File diff suppressed because it is too large Load Diff

109
build/litegraph.min.js vendored
View File

@@ -1,11 +1,11 @@
(function(r){function g(){l.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear()}function f(a){this._ctor(a)}function e(a,b,c){c=c||{};this.background_image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";
a&&a.constructor===String&&(a=document.querySelector(a));this.max_zoom=10;this.min_zoom=0.1;this.title_text_font="bold 14px Arial";this.inner_text_font="normal 12px Arial";this.default_link_color="#AAC";this.default_connection_color={input_off:"#AAB",input_on:"#7F7",output_off:"#AAB",output_on:"#7F7"};this.highquality_render=!0;this.editor_alpha=1;this.pause_rendering=!1;this.render_only_selected=this.clear_background=this.render_shadows=!0;this.live_mode=!1;this.allow_interaction=this.allow_dragnodes=
this.allow_dragcanvas=this.show_info=!0;this.drag_mode=!1;this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_area=!0;this.render_connections_shadows=!1;this.render_connection_arrows=this.render_curved_connections=this.render_connections_border=!0;this.connections_width=3;b&&b.attachCanvas(this);this.setCanvas(a);this.clear();c.skip_render||this.startRendering();this.autoresize=c.autoresize}function p(a,b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}
function q(a,b,c,n,h,d){return c<a&&c+h>a&&n<b&&n+d>b?!0:!1}function s(a,b){var c=a[0]+a[2],n=a[1]+a[3],h=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>h||c<b[0]||n<b[1]?!1:!0}function u(a,b){function c(a){var b=parseInt(h.style.top);h.style.top=(b+0.1*a.deltaY).toFixed()+"px";a.preventDefault();return!0}this.options=b=b||{};var n=this;b.parentMenu&&(b.parentMenu.constructor!==this.constructor?(console.error("parentMenu must be of class ContextMenu, ignoring it"),b.parentMenu=null):(this.parentMenu=b.parentMenu,
this.parentMenu.lock=!0,this.parentMenu.current_submenu=this));b.event&&b.event.constructor!==MouseEvent&&b.event.constructor!==CustomEvent&&(console.error("Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it."),b.event=null);var h=document.createElement("div");h.className="litegraph litecontextmenu litemenubar-panel";h.style.minWidth=100;h.style.minHeight=100;h.style.pointerEvents="none";setTimeout(function(){h.style.pointerEvents="auto"},100);h.addEventListener("mouseup",
function(a){a.preventDefault();return!0},!0);h.addEventListener("contextmenu",function(a){if(2!=a.button)return!1;a.preventDefault();return!1},!0);h.addEventListener("mousedown",function(a){if(2==a.button)return n.close(),a.preventDefault(),!0},!0);h.addEventListener("wheel",c,!0);h.addEventListener("mousewheel",c,!0);this.root=h;if(b.title){var d=document.createElement("div");d.className="litemenu-title";d.innerHTML=b.title;h.appendChild(d)}var d=0,k;for(k in a){var v=a.constructor==Array?a[k]:k;
null!=v&&v.constructor!==String&&(v=void 0===v.content?String(v):v.content);this.addItem(v,a[k],b);d++}h.addEventListener("mouseleave",function(a){n.lock||n.close(a)});k=document;b.event&&(k=b.event.target.ownerDocument);k||(k=document);k.body.appendChild(h);d=b.left||0;k=b.top||0;if(b.event){d=b.event.pageX-10;k=b.event.pageY-10;b.title&&(k-=20);b.parentMenu&&(d=b.parentMenu.root.getBoundingClientRect(),d=d.left+d.width);var v=document.body.getBoundingClientRect(),e=h.getBoundingClientRect();d>v.width-
e.width-10&&(d=v.width-e.width-10);k>v.height-e.height-10&&(k=v.height-e.height-10)}h.style.left=d+"px";h.style.top=k+"px"}var l=r.LiteGraph={NODE_TITLE_HEIGHT:16,NODE_SLOT_HEIGHT:15,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,CANVAS_GRID_SIZE:10,NODE_TITLE_COLOR:"#222",NODE_DEFAULT_COLOR:"#999",NODE_DEFAULT_BGCOLOR:"#444",NODE_DEFAULT_BOXCOLOR:"#AEF",NODE_DEFAULT_SHAPE:"box",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],node_images_path:"",VALID_SHAPES:["box",
a&&a.constructor===String&&(a=document.querySelector(a));this.max_zoom=10;this.min_zoom=0.1;this.zoom_modify_alpha=!1;this.title_text_font="bold 14px Arial";this.inner_text_font="normal 12px Arial";this.node_title_color=l.NODE_TITLE_COLOR;this.default_link_color="#AAC";this.default_connection_color={input_off:"#AAB",input_on:"#7F7",output_off:"#AAB",output_on:"#7F7"};this.highquality_render=!0;this.editor_alpha=1;this.pause_rendering=!1;this.render_only_selected=this.clear_background=this.render_shadows=
!0;this.live_mode=!1;this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=!1;this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=!0;this.render_connections_shadows=!1;this.render_connection_arrows=this.render_curved_connections=this.render_connections_border=!0;this.connections_width=3;b&&b.attachCanvas(this);this.setCanvas(a);this.clear();c.skip_render||this.startRendering();this.autoresize=c.autoresize}function p(a,
b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}function q(a,b,c,n,h,d){return c<a&&c+h>a&&n<b&&n+d>b?!0:!1}function s(a,b){var c=a[0]+a[2],n=a[1]+a[3],h=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>h||c<b[0]||n<b[1]?!1:!0}function u(a,b){function c(a){var b=parseInt(h.style.top);h.style.top=(b+0.1*a.deltaY).toFixed()+"px";a.preventDefault();return!0}this.options=b=b||{};var n=this;b.parentMenu&&(b.parentMenu.constructor!==this.constructor?(console.error("parentMenu must be of class ContextMenu, ignoring it"),
b.parentMenu=null):(this.parentMenu=b.parentMenu,this.parentMenu.lock=!0,this.parentMenu.current_submenu=this));b.event&&b.event.constructor!==MouseEvent&&b.event.constructor!==CustomEvent&&(console.error("Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it."),b.event=null);var h=document.createElement("div");h.className="litegraph litecontextmenu litemenubar-panel";h.style.minWidth=100;h.style.minHeight=100;h.style.pointerEvents="none";setTimeout(function(){h.style.pointerEvents=
"auto"},100);h.addEventListener("mouseup",function(a){a.preventDefault();return!0},!0);h.addEventListener("contextmenu",function(a){if(2!=a.button)return!1;a.preventDefault();return!1},!0);h.addEventListener("mousedown",function(a){if(2==a.button)return n.close(),a.preventDefault(),!0},!0);h.addEventListener("wheel",c,!0);h.addEventListener("mousewheel",c,!0);this.root=h;if(b.title){var d=document.createElement("div");d.className="litemenu-title";d.innerHTML=b.title;h.appendChild(d)}var d=0,k;for(k in a){var v=
a.constructor==Array?a[k]:k;null!=v&&v.constructor!==String&&(v=void 0===v.content?String(v):v.content);this.addItem(v,a[k],b);d++}h.addEventListener("mouseleave",function(a){n.lock||n.close(a)});k=document;b.event&&(k=b.event.target.ownerDocument);k||(k=document);k.body.appendChild(h);d=b.left||0;k=b.top||0;if(b.event){d=b.event.pageX-10;k=b.event.pageY-10;b.title&&(k-=20);b.parentMenu&&(d=b.parentMenu.root.getBoundingClientRect(),d=d.left+d.width);var v=document.body.getBoundingClientRect(),e=h.getBoundingClientRect();
d>v.width-e.width-10&&(d=v.width-e.width-10);k>v.height-e.height-10&&(k=v.height-e.height-10)}h.style.left=d+"px";h.style.top=k+"px"}var l=r.LiteGraph={NODE_TITLE_HEIGHT:16,NODE_SLOT_HEIGHT:15,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,CANVAS_GRID_SIZE:10,NODE_TITLE_COLOR:"#222",NODE_DEFAULT_COLOR:"#999",NODE_DEFAULT_BGCOLOR:"#444",NODE_DEFAULT_BOXCOLOR:"#AEF",NODE_DEFAULT_SHAPE:"box",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],node_images_path:"",VALID_SHAPES:["box",
"round"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,INPUT:1,OUTPUT:2,EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,proxy:null,debug:!1,throw_errors:!0,allow_scripts:!0,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype";b.type=a;l.debug&&console.log("Node registered: "+a);a.split("/");var c=b.name,n=a.lastIndexOf("/");b.category=a.substr(0,n);b.title||
(b.title=c);if(b.prototype)for(var h in f.prototype)b.prototype[h]||(b.prototype[h]=f.prototype[h]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "box":this._shape=l.BOX_SHAPE;break;case "round":this._shape=l.ROUND_SHAPE;break;case "circle":this._shape=l.CIRCLE_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[c]=b);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+
a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(h in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[h].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,c,n){for(var h=Array(b.length),d="",k=l.getParameterNames(b),v=0;v<k.length;++v)d+="this.addInput('"+k[v]+"',"+(c&&c[v]?"'"+c[v]+"'":"0")+");\n";c=Function(d+("this.addOutput('out',"+(n?"'"+n+"'":0)+");\n"));c.title=a.split("/").pop();c.desc="Generated from "+
@@ -109,53 +109,54 @@ b.height);this.bgcanvas==this.canvas?this.drawBackCanvas():a.drawImage(this.bgca
this.connecting_pos){a.lineWidth=this.connections_width;b=null;switch(this.connecting_output.type){case l.EVENT:b="#F85";break;default:b="#AFA"}this.renderLink(a,this.connecting_pos,[this.canvas_mouse[0],this.canvas_mouse[1]],null,!1,null,b);a.beginPath();this.connecting_output.type===l.EVENT?a.rect(this.connecting_pos[0]-6+0.5,this.connecting_pos[1]-5+0.5,14,10):a.arc(this.connecting_pos[0],this.connecting_pos[1],4,0,2*Math.PI);a.fill();a.fillStyle="#ffcc00";this._highlight_input&&(a.beginPath(),
a.arc(this._highlight_input[0],this._highlight_input[1],6,0,2*Math.PI),a.fill())}this.dragging_rectangle&&(a.strokeStyle="#FFF",a.strokeRect(this.dragging_rectangle[0],this.dragging_rectangle[1],this.dragging_rectangle[2],this.dragging_rectangle[3]));a.restore()}this.dirty_area&&a.restore();a.finish2D&&a.finish2D();this.dirty_canvas=!1}};e.prototype.renderInfo=function(a,b,c){b=b||0;c=c||0;a.save();a.translate(b,c);a.font="10px Arial";a.fillStyle="#888";this.graph?(a.fillText("T: "+this.graph.globaltime.toFixed(2)+
"s",5,13),a.fillText("I: "+this.graph.iteration,5,26),a.fillText("F: "+this.frame,5,39),a.fillText("FPS:"+this.fps.toFixed(2),5,52)):a.fillText("No graph selected",5,13);a.restore()};e.prototype.drawBackCanvas=function(){var a=this.bgcanvas;if(a.width!=this.canvas.width||a.height!=this.canvas.height)a.width=this.canvas.width,a.height=this.canvas.height;this.bgctx||(this.bgctx=this.bgcanvas.getContext("2d"));var b=this.bgctx;b.start&&b.start();this.clear_background&&b.clearRect(0,0,a.width,a.height);
this._graph_stack&&this._graph_stack.length&&(b.strokeStyle=this._graph_stack[this._graph_stack.length-1].bgcolor,b.lineWidth=10,b.strokeRect(1,1,a.width-2,a.height-2),b.lineWidth=1);b.restore();b.setTransform(1,0,0,1,0,0);if(this.graph){b.save();b.scale(this.scale,this.scale);b.translate(this.offset[0],this.offset[1]);if(this.background_image&&0.5<this.scale){b.globalAlpha=(1-0.5/this.scale)*this.editor_alpha;b.imageSmoothingEnabled=b.mozImageSmoothingEnabled=b.imageSmoothingEnabled=!1;if(!this._bg_img||
this._bg_img.name!=this.background_image){this._bg_img=new Image;this._bg_img.name=this.background_image;this._bg_img.src=this.background_image;var c=this;this._bg_img.onload=function(){c.draw(!0,!0)}}var d=null;null==this._pattern&&0<this._bg_img.width?(d=b.createPattern(this._bg_img,"repeat"),this._pattern_img=this._bg_img,this._pattern=d):d=this._pattern;d&&(b.fillStyle=d,b.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]),b.fillStyle="transparent");
b.globalAlpha=1;b.imageSmoothingEnabled=b.mozImageSmoothingEnabled=b.imageSmoothingEnabled=!0}if(this.onBackgroundRender)this.onBackgroundRender(a,b);this.render_canvas_area&&(b.strokeStyle="#235",b.strokeRect(0,0,a.width,a.height));this.render_connections_shadows?(b.shadowColor="#000",b.shadowOffsetX=0,b.shadowOffsetY=0,b.shadowBlur=6):b.shadowColor="rgba(0,0,0,0)";this.live_mode||this.drawConnections(b);b.shadowColor="rgba(0,0,0,0)";b.restore()}b.finish&&b.finish();this.dirty_bgcanvas=!1;this.dirty_canvas=
!0};var d=new Float32Array(2);e.prototype.drawNode=function(a,b){var c=a.color||l.NODE_DEFAULT_COLOR,e=!0;if(a.flags.skip_title_render||a.graph.isLive())e=!1;a.mouseOver&&(e=!0);a.selected||(this.render_shadows?(b.shadowColor="rgba(0,0,0,0.5)",b.shadowOffsetX=2,b.shadowOffsetY=2,b.shadowBlur=3):b.shadowColor="transparent");if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b)}else{var h=this.editor_alpha;b.globalAlpha=h;var f=a._shape||l.BOX_SHAPE;
d.set(a.size);a.flags.collapsed&&(d[0]=l.NODE_COLLAPSED_WIDTH,d[1]=0);a.flags.clip_area&&(b.save(),f==l.BOX_SHAPE?(b.beginPath(),b.rect(0,0,d[0],d[1])):f==l.ROUND_SHAPE?b.roundRect(0,0,d[0],d[1],10):f==l.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*d[0],0.5*d[1],0.5*d[0],0,2*Math.PI)),b.clip());this.drawNodeShape(a,b,d,c,a.bgcolor,!e,a.selected);b.shadowColor="transparent";b.textAlign="left";b.font=this.inner_text_font;e=0.6<this.scale;f=this.connecting_output;if(!a.flags.collapsed){if(a.inputs)for(var k=
0;k<a.inputs.length;k++){var m=a.inputs[k];b.globalAlpha=h;this.connecting_node&&l.isValidConnection(m.type&&f.type)&&(b.globalAlpha=0.4*h);b.fillStyle=null!=m.link?this.default_connection_color.input_on:this.default_connection_color.input_off;var g=a.getConnectionPos(!0,k);g[0]-=a.pos[0];g[1]-=a.pos[1];b.beginPath();m.type===l.EVENT?b.rect(g[0]-6+0.5,g[1]-5+0.5,14,10):b.arc(g[0],g[1],4,0,2*Math.PI);b.fill();e&&(m=null!=m.label?m.label:m.name)&&(b.fillStyle=c,b.fillText(m,g[0]+10,g[1]+5))}this.connecting_node&&
(b.globalAlpha=0.4*h);b.lineWidth=1;b.textAlign="right";b.strokeStyle="black";if(a.outputs)for(k=0;k<a.outputs.length;k++)if(m=a.outputs[k],g=a.getConnectionPos(!1,k),g[0]-=a.pos[0],g[1]-=a.pos[1],b.fillStyle=m.links&&m.links.length?this.default_connection_color.output_on:this.default_connection_color.output_off,b.beginPath(),m.type===l.EVENT?b.rect(g[0]-6+0.5,g[1]-5+0.5,14,10):b.arc(g[0],g[1],4,0,2*Math.PI),b.fill(),b.stroke(),e&&(m=null!=m.label?m.label:m.name))b.fillStyle=c,b.fillText(m,g[0]-10,
g[1]+5);b.textAlign="left";b.globalAlpha=1;if(a.onDrawForeground)a.onDrawForeground(b)}a.flags.clip_area&&b.restore();b.globalAlpha=1}};e.prototype.drawNodeShape=function(a,b,c,d,h,e,k){b.strokeStyle=d||l.NODE_DEFAULT_COLOR;b.fillStyle=h||l.NODE_DEFAULT_BGCOLOR;h=l.NODE_TITLE_HEIGHT;var f=a._shape||l.BOX_SHAPE;f==l.BOX_SHAPE?(b.beginPath(),b.rect(0,e?0:-h,c[0]+1,e?c[1]:c[1]+h),b.fill(),b.shadowColor="transparent",k&&(b.strokeStyle="#CCC",b.strokeRect(-0.5,e?-0.5:-h+-0.5,c[0]+2,e?c[1]+2:c[1]+h+2-1),
b.strokeStyle=d)):f==l.ROUND_SHAPE?(b.roundRect(0,e?0:-h,c[0],e?c[1]:c[1]+h,10),b.fill()):f==l.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0,2*Math.PI),b.fill());b.shadowColor="transparent";a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&&!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));if(a.onDrawBackground)a.onDrawBackground(b);e||(b.fillStyle=d||l.NODE_DEFAULT_COLOR,d=b.globalAlpha,b.globalAlpha=0.5*d,f==
l.BOX_SHAPE?(b.beginPath(),b.rect(0,-h,c[0]+1,h),b.fill()):f==l.ROUND_SHAPE&&(b.roundRect(0,-h,c[0],h,10,0),b.fill()),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),f==l.ROUND_SHAPE||f==l.CIRCLE_SHAPE?b.arc(0.5*h,-0.5*h,0.5*(h-6),0,2*Math.PI):b.rect(3,-h+3,h-6,h-6),b.fill(),b.globalAlpha=d,b.font=this.title_text_font,(a=a.getTitle())&&0.5<this.scale&&(b.fillStyle=l.NODE_TITLE_COLOR,b.fillText(a,16,13-h)))};e.prototype.drawNodeCollapsed=function(a,b,c,d){b.strokeStyle=c||l.NODE_DEFAULT_COLOR;
b.fillStyle=d||l.NODE_DEFAULT_BGCOLOR;c=l.NODE_COLLAPSED_RADIUS;d=a._shape||l.BOX_SHAPE;d==l.CIRCLE_SHAPE?(b.beginPath(),b.arc(0.5*a.size[0],0.5*a.size[1],c,0,2*Math.PI),b.fill(),b.shadowColor="rgba(0,0,0,0)",b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.arc(0.5*a.size[0],0.5*a.size[1],0.5*c,0,2*Math.PI)):d==l.ROUND_SHAPE?(b.beginPath(),b.roundRect(0.5*a.size[0]-c,0.5*a.size[1]-c,2*c,2*c,5),b.fill(),b.shadowColor="rgba(0,0,0,0)",b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,
b.beginPath(),b.roundRect(0.5*a.size[0]-0.5*c,0.5*a.size[1]-0.5*c,c,c,2)):(b.beginPath(),b.rect(0,0,a.size[0],2*c),b.fill(),b.shadowColor="rgba(0,0,0,0)",b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.rect(0.5*c,0.5*c,c,c));b.fill()};e.prototype.drawConnections=function(a){var b=l.getTime();a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;for(var c=0,d=this.graph._nodes.length;c<d;++c){var h=this.graph._nodes[c];
if(h.inputs&&h.inputs.length)for(var e=0;e<h.inputs.length;++e){var k=h.inputs[e];if(k&&null!=k.link&&(k=this.graph.links[k.link])){var f=this.graph.getNodeById(k.origin_id);if(null!=f){var m=k.origin_slot,g=null,g=-1==m?[f.pos[0]+10,f.pos[1]+10]:f.getConnectionPos(!1,m);this.renderLink(a,g,h.getConnectionPos(!0,e),k);k&&k._last_time&&1E3>b-k._last_time&&(f=2-0.002*(b-k._last_time),m="rgba(255,255,255, "+f.toFixed(2)+")",this.renderLink(a,g,h.getConnectionPos(!0,e),k,!0,f,m))}}}}a.globalAlpha=1};
e.prototype.renderLink=function(a,b,c,d,h,f,k){if(this.highquality_render){var m=p(b,c);this.render_connections_border&&0.6<this.scale&&(a.lineWidth=this.connections_width+4);!k&&d&&(k=e.link_type_colors[d.type]);k||(k=this.default_link_color);null!=d&&this.highlighted_links[d.id]&&(k="#FFF");a.beginPath();this.render_curved_connections?(a.moveTo(b[0],b[1]),a.bezierCurveTo(b[0]+0.25*m,b[1],c[0]-0.25*m,c[1],c[0],c[1])):(a.moveTo(b[0]+10,b[1]),a.lineTo(0.5*(b[0]+10+(c[0]-10)),b[1]),a.lineTo(0.5*(b[0]+
10+(c[0]-10)),c[1]),a.lineTo(c[0]-10,c[1]));this.render_connections_border&&0.6<this.scale&&!h&&(a.strokeStyle="rgba(0,0,0,0.5)",a.stroke());a.lineWidth=this.connections_width;a.fillStyle=a.strokeStyle=k;a.stroke();this.render_connection_arrows&&0.6<=this.scale&&this.render_connection_arrows&&0.6<this.scale&&(d=this.computeConnectionPoint(b,c,0.5),h=this.computeConnectionPoint(b,c,0.51),k=0,k=this.render_curved_connections?-Math.atan2(h[0]-d[0],h[1]-d[1]):c[1]>b[1]?0:Math.PI,a.save(),a.translate(d[0],
d[1]),a.rotate(k),a.beginPath(),a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(f)for(f=0;5>f;++f)d=(0.001*l.getTime()+0.2*f)%1,d=this.computeConnectionPoint(b,c,d),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};e.prototype.computeConnectionPoint=function(a,b,c){var d=p(a,b),h=[a[0]+0.25*d,a[1]],d=[b[0]-0.25*d,b[1]],e=(1-c)*(1-c)*(1-c),k=3*(1-c)*(1-c)*c,f=3*(1-c)*c*c;c*=c*c;return[e*a[0]+k*h[0]+f*d[0]+
c*b[0],e*a[1]+k*h[1]+f*d[1]+c*b[1]]};e.prototype.resize=function(a,b){if(!a&&!b){var c=this.canvas.parentNode;a=c.offsetWidth;b=c.offsetHeight}if(this.canvas.width!=a||this.canvas.height!=b)this.canvas.width=a,this.canvas.height=b,this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height,this.setDirty(!0,!0)};e.prototype.switchLiveMode=function(a){if(a){var b=this,c=this.live_mode?1.1:0.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=0.1);var d=setInterval(function(){b.editor_alpha*=
c;b.dirty_canvas=!0;b.dirty_bgcanvas=!0;1>c&&0.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1<c&&0.99<b.editor_alpha&&(clearInterval(d),b.editor_alpha=1)},1)}else this.live_mode=!this.live_mode,this.dirty_bgcanvas=this.dirty_canvas=!0};e.prototype.onNodeSelectionChange=function(a){};e.prototype.touchHandler=function(a){var b=a.changedTouches[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var d=
this.getCanvasWindow(),h=d.document.createEvent("MouseEvent");h.initMouseEvent(c,!0,!0,d,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null);b.target.dispatchEvent(h);a.preventDefault()};e.onMenuAdd=function(a,b,c,d){function h(a,b){var c=d.getFirstEvent(),k=l.createNode(a.value);k&&(k.pos=f.convertEventToCanvas(c),f.graph.add(k))}var f=e.active_canvas,k=f.getCanvasWindow();a=l.getNodeTypesCategories();b=[];for(var m in a)a[m]&&b.push({value:a[m],content:a[m],has_submenu:!0});var g=new l.ContextMenu(b,
{event:c,callback:function(a,b,c){a=l.getNodeTypesInCategory(a.value);b=[];for(var d in a)b.push({content:a[d].title,value:a[d].type});new l.ContextMenu(b,{event:c,callback:h,parentMenu:g},k);return!1},parentMenu:d},k);return!1};e.onMenuCollapseAll=function(){};e.onMenuNodeEdit=function(){};e.showMenuNodeOptionalInputs=function(a,b,c,d,h){function f(a,b,c){h&&(a.callback&&a.callback.call(k,h,a,b,c),a.value&&(h.addInput(a.value[0],a.value[1],a.value[2]),h.setDirtyCanvas(!0,!0)))}if(h){var k=this;a=
e.active_canvas.getCanvasWindow();b=h.optional_inputs;h.onGetInputs&&(b=h.onGetInputs());var m=[];if(b)for(var g in b){var p=b[g];if(p){var q=p[0];p[2]&&p[2].label&&(q=p[2].label);q={content:q,value:p};p[1]==l.ACTION&&(q.className="event");m.push(q)}else m.push(null)}this.onMenuNodeInputs&&(m=this.onMenuNodeInputs(m));if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,node:h},a),!1}};e.showMenuNodeOptionalOutputs=function(a,b,c,d,h){function f(a,b,c){if(h&&(a.callback&&a.callback.call(k,
h,a,b,c),a.value))if(c=a.value[1],!c||c.constructor!==Object&&c.constructor!==Array)h.addOutput(a.value[0],a.value[1],a.value[2]),h.setDirtyCanvas(!0,!0);else{a=[];for(var e in c)a.push({content:e,value:c[e]});new l.ContextMenu(a,{event:b,callback:f,parentMenu:d,node:h});return!1}}if(h){var k=this;a=e.active_canvas.getCanvasWindow();b=h.optional_outputs;h.onGetOutputs&&(b=h.onGetOutputs());var m=[];if(b)for(var g in b){var p=b[g];if(!p)m.push(null);else if(!h.flags||!h.flags.skip_repeated_outputs||
-1==h.findOutputSlot(p[0])){var q=p[0];p[2]&&p[2].label&&(q=p[2].label);q={content:q,value:p};p[1]==l.EVENT&&(q.className="event");m.push(q)}}this.onMenuNodeOutputs&&(m=this.onMenuNodeOutputs(m));if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,node:h},a),!1}};e.onShowMenuNodeProperties=function(a,b,c,d,h){function f(a,b,c,d){h&&(b=this.getBoundingClientRect(),k.showEditPropertyValue(h,a.value,{position:[b.left,b.top]}))}if(h&&h.properties){var k=e.active_canvas;b=k.getCanvasWindow();
var m=[],g;for(g in h.properties)a=void 0!==h.properties[g]?h.properties[g]:" ",a=e.decodeHTML(a),m.push({content:"<span class='property_name'>"+g+"</span><span class='property_value'>"+a+"</span>",value:g});if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,allow_html:!0,node:h},b),!1}};e.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};e.onResizeNode=function(a,b,c,d,h){h&&(h.size=h.computeSize(),h.setDirtyCanvas(!0,!0))};e.onShowTitleEditor=
function(a,b,c,d,h){function f(){h.title=m.value;k.parentNode.removeChild(k);h.setDirtyCanvas(!0,!0)}var k=document.createElement("div");k.className="graphdialog";k.innerHTML="<span class='name'>Title</span><input autofocus type='text' class='value'/><button>OK</button>";var m=k.querySelector("input");m&&(m.value=h.title,m.addEventListener("keydown",function(a){13==a.keyCode&&(f(),a.preventDefault(),a.stopPropagation())}));a=e.active_canvas.canvas;b=a.getBoundingClientRect();d=c=-20;b&&(c-=b.left,
d-=b.top);event?(k.style.left=event.pageX+c+"px",k.style.top=event.pageY+d+"px"):(k.style.left=0.5*a.width+c+"px",k.style.top=0.5*a.height+d+"px");k.querySelector("button").addEventListener("click",f);a.parentNode.appendChild(k)};e.prototype.showEditPropertyValue=function(a,b,c){function d(){h(p.value)}function h(c){"number"==typeof a.properties[b]&&(c=Number(c));a.properties[b]=c;if(a.onPropertyChanged)a.onPropertyChanged(b,c);l.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||
{};var e="string";null!==a.properties[b]&&(e=typeof a.properties[b]);var k=null;a.getPropertyInfo&&(k=a.getPropertyInfo(b));if(a.properties_info)for(var f=0;f<a.properties_info.length;++f)if(a.properties_info[f].name==b){k=a.properties_info[f];break}void 0!==k&&null!==k&&k.type&&(e=k.type);var m="";if("string"==e||"number"==e)m="<input autofocus type='text' class='value'/>";else if("enum"==e&&k.values){m="<select autofocus type='text' class='value'>";for(f in k.values)var g=k.values.constructor===
Array?k.values[f]:f,m=m+("<option value='"+g+"' "+(g==a.properties[b]?"selected":"")+">"+k.values[f]+"</option>");m+="</select>"}else"boolean"==e&&(m="<input autofocus type='checkbox' class='value' "+(a.properties[b]?"checked":"")+"/>");var l=this.createDialog("<span class='name'>"+b+"</span>"+m+"<button>OK</button>",c);if("enum"==e&&k.values){var p=l.querySelector("select");p.addEventListener("change",function(a){h(a.target.value)})}else if("boolean"==e)(p=l.querySelector("input"))&&p.addEventListener("click",
function(a){h(!!p.checked)});else if(p=l.querySelector("input"))p.value=void 0!==a.properties[b]?a.properties[b]:"",p.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())});l.querySelector("button").addEventListener("click",d)}};e.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;var d=this.canvas.getBoundingClientRect(),h=-20,e=-20;d&&(h-=d.left,e-=d.top);b.position?(h+=b.position[0],
e+=b.position[1]):b.event?(h+=b.event.pageX,e+=b.event.pageY):(h+=0.5*this.canvas.width,e+=0.5*this.canvas.height);c.style.left=h+"px";c.style.top=e+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};e.onMenuNodeCollapse=function(a,b,c,d,e){e.flags.collapsed=!e.flags.collapsed;e.setDirtyCanvas(!0,!0)};e.onMenuNodePin=function(a,b,c,d,e){e.pin()};e.onMenuNodeMode=function(a,b,c,d,e){new l.ContextMenu(["Always","On Event","On Trigger",
"Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode=l.ON_EVENT;break;case "On Trigger":e.mode=l.ON_TRIGGER;break;case "Never":e.mode=l.NEVER;break;default:e.mode=l.ALWAYS}},parentMenu:d,node:e});return!1};e.onMenuNodeColors=function(a,b,c,d,h){if(!h)throw"no node for color";b=[];for(var f in e.node_colors)a=e.node_colors[f],a={value:f,content:"<span style='display: block; color:"+a.color+"; background-color:"+a.bgcolor+"'>"+f+"</span>"},b.push(a);new l.ContextMenu(b,{event:c,
callback:function(a){h&&(a=e.node_colors[a.value])&&(h.color=a.color,h.bgcolor=a.bgcolor,h.setDirtyCanvas(!0))},parentMenu:d,node:h});return!1};e.onMenuNodeShapes=function(a,b,c,d,e){if(!e)throw"no node passed";new l.ContextMenu(l.VALID_SHAPES,{event:c,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))},parentMenu:d,node:e});return!1};e.onMenuNodeRemove=function(a,b,c,d,e){if(!e)throw"no node passed";!1!=e.removable&&(e.graph.remove(e),e.setDirtyCanvas(!0,!0))};e.onMenuNodeClone=function(a,
b,c,d,e){!1!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.add(a),e.setDirtyCanvas(!0,!0))};e.node_colors={red:{color:"#FAA",bgcolor:"#944"},green:{color:"#AFA",bgcolor:"#494"},blue:{color:"#AAF",bgcolor:"#449"},cyan:{color:"#AFF",bgcolor:"#499"},purple:{color:"#FAF",bgcolor:"#949"},yellow:{color:"#FFA",bgcolor:"#994"},black:{color:"#777",bgcolor:"#000"},white:{color:"#FFF",bgcolor:"#AAA"}};e.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():
(a=[{content:"Add Node",has_submenu:!0,callback:e.onMenuAdd}],this._graph_stack&&0<this._graph_stack.length&&(a=[{content:"Close subgraph",callback:this.closeSubgraph.bind(this)},null].concat(a)));if(this.getExtraMenuOptions){var b=this.getExtraMenuOptions(this,a);b&&(a=a.concat(b))}return a};e.prototype.getNodeMenuOptions=function(a){var b=null,b=a.getMenuOptions?a.getMenuOptions(this):[{content:"Inputs",has_submenu:!0,disabled:!0,callback:e.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,
disabled:!0,callback:e.showMenuNodeOptionalOutputs},null,{content:"Properties",has_submenu:!0,callback:e.onShowMenuNodeProperties},null,{content:"Title",callback:e.onShowTitleEditor},{content:"Mode",has_submenu:!0,callback:e.onMenuNodeMode},{content:"Resize",callback:e.onResizeNode},{content:"Collapse",callback:e.onMenuNodeCollapse},{content:"Pin",callback:e.onMenuNodePin},{content:"Colors",has_submenu:!0,callback:e.onMenuNodeColors},{content:"Shapes",has_submenu:!0,callback:e.onMenuNodeShapes},null];
if(a.getExtraMenuOptions){var c=a.getExtraMenuOptions(this);c&&(c.push(null),b=c.concat(b))}!1!==a.clonable&&b.push({content:"Clone",callback:e.onMenuNodeClone});!1!==a.removable&&b.push(null,{content:"Remove",callback:e.onMenuNodeRemove});a.onGetInputs&&(c=a.onGetInputs())&&c.length&&(b[0].disabled=!1);a.onGetOutputs&&(c=a.onGetOutputs())&&c.length&&(b[1].disabled=!1);if(a.graph&&a.graph.onGetNodeMenuOptions)a.graph.onGetNodeMenuOptions(b,a);return b};e.prototype.processContextMenu=function(a,b){var c=
this,d=e.active_canvas.getCanvasWindow(),f=null,m={event:b,callback:function(b,d,e){if(b)if("Remove Slot"==b.content){var k=b.slot;k.input?a.removeInput(k.slot):k.output&&a.removeOutput(k.slot)}else if("Rename Slot"==b.content){var k=b.slot,f=c.createDialog("<span class='name'>Name</span><input type='text'/><button>OK</button>",d),h=f.querySelector("input");f.querySelector("button").addEventListener("click",function(b){if(h.value){if(b=k.input?a.getInputInfo(k.slot):a.getOutputInfo(k.slot))b.label=
h.value;c.setDirty(!0)}f.close()})}},node:a},k=null;a&&(k=a.getSlotInPosition(b.canvasX,b.canvasY),e.active_node=a);k?(f=[],f.push(k.locked?"Cannot remove":{content:"Remove Slot",slot:k}),f.push({content:"Rename Slot",slot:k}),m.title=(k.input?k.input.type:k.output.type)||"*",k.input&&k.input.type==l.ACTION&&(m.title="Action"),k.output&&k.output.type==l.EVENT&&(m.title="Event")):f=a?this.getNodeMenuOptions(a):this.getCanvasMenuOptions();f&&new l.ContextMenu(f,m,d)};this.CanvasRenderingContext2D&&
(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e,f){void 0===e&&(e=5);void 0===f&&(f=e);this.beginPath();this.moveTo(a+e,b);this.lineTo(a+c-e,b);this.quadraticCurveTo(a+c,b,a+c,b+e);this.lineTo(a+c,b+d-f);this.quadraticCurveTo(a+c,b+d,a+c-f,b+d);this.lineTo(a+f,b+d);this.quadraticCurveTo(a,b+d,a,b+d-f);this.lineTo(a,b+e);this.quadraticCurveTo(a,b,a+e,b)});l.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};l.distance=p;l.colorToString=function(a){return"rgba("+
Math.round(255*a[0]).toFixed()+","+Math.round(255*a[1]).toFixed()+","+Math.round(255*a[2]).toFixed()+","+(4==a.length?a[3].toFixed(2):"1.0")+")"};l.isInsideRectangle=q;l.growBounding=function(a,b,c){b<a[0]?a[0]=b:b>a[2]&&(a[2]=b);c<a[1]?a[1]=c:c>a[3]&&(a[3]=c)};l.isInsideBounding=function(a,b){return a[0]<b[0][0]||a[1]<b[0][1]||a[0]>b[1][0]||a[1]>b[1][1]?!1:!0};l.overlapBounding=s;l.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,d,e,f=0;6>f;f+=2)d="0123456789ABCDEF".indexOf(a.charAt(f)),
e="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*d+e,c++;return b};l.num2hex=function(a){for(var b="#",c,d,e=0;3>e;e++)c=a[e]/16,d=a[e]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(d);return b};u.prototype.addItem=function(a,b,c){function d(a){var b=this.value;b&&b.has_submenu&&e.call(this,a)}function e(a){var b=this.value,d=!0;f.current_submenu&&f.current_submenu.close(a);if(c.callback){var k=c.callback.call(this,b,c,a,f,c.node);!0===k&&(d=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&
!0!==b.disabled&&(k=b.callback.call(this,b,c,a,f,c.node),!0===k&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new f.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:f,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,autoopen:c.autoopen});d=!1}d&&!f.lock&&f.close()}var f=this;c=c||{};var k=document.createElement("div");k.className="litemenu-entry submenu";var m=!1;if(null===b)k.classList.add("separator");
else{k.innerHTML=b&&b.title?b.title:a;if(k.value=b)b.disabled&&(m=!0,k.classList.add("disabled")),(b.submenu||b.has_submenu)&&k.classList.add("has_submenu");"function"==typeof b?(k.dataset.value=a,k.onclick_callback=b):k.dataset.value=b;b.className&&(k.className+=" "+b.className)}this.root.appendChild(k);m||k.addEventListener("click",e);c.autoopen&&k.addEventListener("mouseenter",d);return k};u.prototype.close=function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&
!b&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,void 0===a?this.parentMenu.close():a&&!u.isCursorOverElement(a,this.parentMenu.root)&&u.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0)};u.trigger=function(a,b,c,d){var e=document.createEvent("CustomEvent");e.initCustomEvent(b,!0,!0,c);e.srcElement=d;a.dispatchEvent?a.dispatchEvent(e):a.__events&&a.__events.dispatchEvent(e);return e};u.prototype.getTopMenu=function(){return this.options.parentMenu?
this.options.parentMenu.getTopMenu():this};u.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};u.isCursorOverElement=function(a,b){var c=a.pageX,d=a.pageY,e=b.getBoundingClientRect();return e?d>e.top&&d<e.top+e.height&&c>e.left&&c<e.left+e.width?!0:!1:!1};l.ContextMenu=u;l.closeAllContextMenus=function(a){a=a||window;a=a.document.querySelectorAll(".litecontextmenu");if(a.length){for(var b=[],c=0;c<a.length;c++)b.push(a[c]);
for(c in b)b[c].close?b[c].close():b[c].parentNode&&b[c].parentNode.removeChild(b[c])}};l.extendClass=function(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c]);if(b.prototype)for(c in b.prototype)b.prototype.hasOwnProperty(c)&&!a.prototype.hasOwnProperty(c)&&(b.prototype.__lookupGetter__(c)?a.prototype.__defineGetter__(c,b.prototype.__lookupGetter__(c)):a.prototype[c]=b.prototype[c],b.prototype.__lookupSetter__(c)&&a.prototype.__defineSetter__(c,b.prototype.__lookupSetter__(c)))};l.getParameterNames=
function(a){return(a+"").replace(/[/][/].*$/mg,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};Math.clamp=function(a,b,c){return b>a?b:c<a?c:a};"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this);"undefined"!=typeof exports&&(exports.LiteGraph=this.LiteGraph);
this._graph_stack&&this._graph_stack.length&&(b.strokeStyle=this._graph_stack[this._graph_stack.length-1].bgcolor,b.lineWidth=10,b.strokeRect(1,1,a.width-2,a.height-2),b.lineWidth=1);b.restore();b.setTransform(1,0,0,1,0,0);if(this.graph){b.save();b.scale(this.scale,this.scale);b.translate(this.offset[0],this.offset[1]);if(this.background_image&&0.5<this.scale){b.globalAlpha=this.zoom_modify_alpha?(1-0.5/this.scale)*this.editor_alpha:this.editor_alpha;b.imageSmoothingEnabled=b.mozImageSmoothingEnabled=
b.imageSmoothingEnabled=!1;if(!this._bg_img||this._bg_img.name!=this.background_image){this._bg_img=new Image;this._bg_img.name=this.background_image;this._bg_img.src=this.background_image;var c=this;this._bg_img.onload=function(){c.draw(!0,!0)}}var d=null;null==this._pattern&&0<this._bg_img.width?(d=b.createPattern(this._bg_img,"repeat"),this._pattern_img=this._bg_img,this._pattern=d):d=this._pattern;d&&(b.fillStyle=d,b.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]),
b.fillStyle="transparent");b.globalAlpha=1;b.imageSmoothingEnabled=b.mozImageSmoothingEnabled=b.imageSmoothingEnabled=!0}if(this.onBackgroundRender)this.onBackgroundRender(a,b);this.render_canvas_border&&(b.strokeStyle="#235",b.strokeRect(0,0,a.width,a.height));this.render_connections_shadows?(b.shadowColor="#000",b.shadowOffsetX=0,b.shadowOffsetY=0,b.shadowBlur=6):b.shadowColor="rgba(0,0,0,0)";this.live_mode||this.drawConnections(b);b.shadowColor="rgba(0,0,0,0)";b.restore()}b.finish&&b.finish();
this.dirty_bgcanvas=!1;this.dirty_canvas=!0};var d=new Float32Array(2);e.prototype.drawNode=function(a,b){var c=a.color||l.NODE_DEFAULT_COLOR,e=!0;if(a.flags.skip_title_render||a.graph.isLive())e=!1;a.mouseOver&&(e=!0);a.selected||(this.render_shadows?(b.shadowColor="rgba(0,0,0,0.5)",b.shadowOffsetX=2,b.shadowOffsetY=2,b.shadowBlur=3):b.shadowColor="transparent");if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b)}else{var h=this.editor_alpha;
b.globalAlpha=h;var f=a._shape||l.BOX_SHAPE;d.set(a.size);a.flags.collapsed&&(d[0]=l.NODE_COLLAPSED_WIDTH,d[1]=0);a.flags.clip_area&&(b.save(),f==l.BOX_SHAPE?(b.beginPath(),b.rect(0,0,d[0],d[1])):f==l.ROUND_SHAPE?b.roundRect(0,0,d[0],d[1],10):f==l.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*d[0],0.5*d[1],0.5*d[0],0,2*Math.PI)),b.clip());this.drawNodeShape(a,b,d,c,a.bgcolor,!e,a.selected);b.shadowColor="transparent";b.textAlign="left";b.font=this.inner_text_font;e=0.6<this.scale;f=this.connecting_output;
if(!a.flags.collapsed){if(a.inputs)for(var k=0;k<a.inputs.length;k++){var m=a.inputs[k];b.globalAlpha=h;this.connecting_node&&l.isValidConnection(m.type&&f.type)&&(b.globalAlpha=0.4*h);b.fillStyle=null!=m.link?this.default_connection_color.input_on:this.default_connection_color.input_off;var g=a.getConnectionPos(!0,k);g[0]-=a.pos[0];g[1]-=a.pos[1];b.beginPath();m.type===l.EVENT?b.rect(g[0]-6+0.5,g[1]-5+0.5,14,10):b.arc(g[0],g[1],4,0,2*Math.PI);b.fill();e&&(m=null!=m.label?m.label:m.name)&&(b.fillStyle=
c,b.fillText(m,g[0]+10,g[1]+5))}this.connecting_node&&(b.globalAlpha=0.4*h);b.lineWidth=1;b.textAlign="right";b.strokeStyle="black";if(a.outputs)for(k=0;k<a.outputs.length;k++)if(m=a.outputs[k],g=a.getConnectionPos(!1,k),g[0]-=a.pos[0],g[1]-=a.pos[1],b.fillStyle=m.links&&m.links.length?this.default_connection_color.output_on:this.default_connection_color.output_off,b.beginPath(),m.type===l.EVENT?b.rect(g[0]-6+0.5,g[1]-5+0.5,14,10):b.arc(g[0],g[1],4,0,2*Math.PI),b.fill(),b.stroke(),e&&(m=null!=m.label?
m.label:m.name))b.fillStyle=c,b.fillText(m,g[0]-10,g[1]+5);b.textAlign="left";b.globalAlpha=1;if(a.onDrawForeground)a.onDrawForeground(b)}a.flags.clip_area&&b.restore();b.globalAlpha=1}};e.prototype.drawNodeShape=function(a,b,c,d,h,e,k){b.strokeStyle=d||l.NODE_DEFAULT_COLOR;b.fillStyle=h||l.NODE_DEFAULT_BGCOLOR;h=l.NODE_TITLE_HEIGHT;var f=a._shape||l.BOX_SHAPE;f==l.BOX_SHAPE?(b.beginPath(),b.rect(0,e?0:-h,c[0]+1,e?c[1]:c[1]+h),b.fill(),b.shadowColor="transparent",k&&(b.strokeStyle="#CCC",b.strokeRect(-0.5,
e?-0.5:-h+-0.5,c[0]+2,e?c[1]+2:c[1]+h+2-1),b.strokeStyle=d)):f==l.ROUND_SHAPE?(b.roundRect(0,e?0:-h,c[0],e?c[1]:c[1]+h,10),b.fill()):f==l.CIRCLE_SHAPE&&(b.beginPath(),b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0,2*Math.PI),b.fill());b.shadowColor="transparent";a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&&!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));if(a.onDrawBackground)a.onDrawBackground(b);e||(b.fillStyle=d||l.NODE_DEFAULT_COLOR,
d=b.globalAlpha,b.globalAlpha=0.5*d,f==l.BOX_SHAPE?(b.beginPath(),b.rect(0,-h,c[0]+1,h),b.fill()):f==l.ROUND_SHAPE&&(b.roundRect(0,-h,c[0],h,10,0),b.fill()),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),f==l.ROUND_SHAPE||f==l.CIRCLE_SHAPE?b.arc(0.5*h,-0.5*h,0.5*(h-6),0,2*Math.PI):b.rect(3,-h+3,h-6,h-6),b.fill(),b.globalAlpha=d,b.font=this.title_text_font,(a=a.getTitle())&&0.5<this.scale&&(b.fillStyle=this.node_title_color,b.fillText(a,16,13-h)))};e.prototype.drawNodeCollapsed=function(a,
b,c,d){b.strokeStyle=c||l.NODE_DEFAULT_COLOR;b.fillStyle=d||l.NODE_DEFAULT_BGCOLOR;c=l.NODE_COLLAPSED_RADIUS;d=a._shape||l.BOX_SHAPE;d==l.CIRCLE_SHAPE?(b.beginPath(),b.arc(0.5*a.size[0],0.5*a.size[1],c,0,2*Math.PI),b.fill(),b.shadowColor="rgba(0,0,0,0)",b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.arc(0.5*a.size[0],0.5*a.size[1],0.5*c,0,2*Math.PI)):d==l.ROUND_SHAPE?(b.beginPath(),b.roundRect(0.5*a.size[0]-c,0.5*a.size[1]-c,2*c,2*c,5),b.fill(),b.shadowColor="rgba(0,0,0,0)",
b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.roundRect(0.5*a.size[0]-0.5*c,0.5*a.size[1]-0.5*c,c,c,2)):(b.beginPath(),b.rect(0,0,a.size[0],2*c),b.fill(),b.shadowColor="rgba(0,0,0,0)",b.stroke(),b.fillStyle=a.boxcolor||l.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.rect(0.5*c,0.5*c,c,c));b.fill()};e.prototype.drawConnections=function(a){var b=l.getTime();a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;for(var c=0,d=this.graph._nodes.length;c<
d;++c){var h=this.graph._nodes[c];if(h.inputs&&h.inputs.length)for(var e=0;e<h.inputs.length;++e){var k=h.inputs[e];if(k&&null!=k.link&&(k=this.graph.links[k.link])){var f=this.graph.getNodeById(k.origin_id);if(null!=f){var m=k.origin_slot,g=null,g=-1==m?[f.pos[0]+10,f.pos[1]+10]:f.getConnectionPos(!1,m);this.renderLink(a,g,h.getConnectionPos(!0,e),k);k&&k._last_time&&1E3>b-k._last_time&&(f=2-0.002*(b-k._last_time),m="rgba(255,255,255, "+f.toFixed(2)+")",this.renderLink(a,g,h.getConnectionPos(!0,
e),k,!0,f,m))}}}}a.globalAlpha=1};e.prototype.renderLink=function(a,b,c,d,h,f,k){if(this.highquality_render){var m=p(b,c);this.render_connections_border&&0.6<this.scale&&(a.lineWidth=this.connections_width+4);!k&&d&&(k=e.link_type_colors[d.type]);k||(k=this.default_link_color);null!=d&&this.highlighted_links[d.id]&&(k="#FFF");a.beginPath();this.render_curved_connections?(a.moveTo(b[0],b[1]),a.bezierCurveTo(b[0]+0.25*m,b[1],c[0]-0.25*m,c[1],c[0],c[1])):(a.moveTo(b[0]+10,b[1]),a.lineTo(0.5*(b[0]+10+
(c[0]-10)),b[1]),a.lineTo(0.5*(b[0]+10+(c[0]-10)),c[1]),a.lineTo(c[0]-10,c[1]));this.render_connections_border&&0.6<this.scale&&!h&&(a.strokeStyle="rgba(0,0,0,0.5)",a.stroke());a.lineWidth=this.connections_width;a.fillStyle=a.strokeStyle=k;a.stroke();this.render_connection_arrows&&0.6<=this.scale&&this.render_connection_arrows&&0.6<this.scale&&(d=this.computeConnectionPoint(b,c,0.5),h=this.computeConnectionPoint(b,c,0.51),k=0,k=this.render_curved_connections?-Math.atan2(h[0]-d[0],h[1]-d[1]):c[1]>
b[1]?0:Math.PI,a.save(),a.translate(d[0],d[1]),a.rotate(k),a.beginPath(),a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(f)for(f=0;5>f;++f)d=(0.001*l.getTime()+0.2*f)%1,d=this.computeConnectionPoint(b,c,d),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};e.prototype.computeConnectionPoint=function(a,b,c){var d=p(a,b),h=[a[0]+0.25*d,a[1]],d=[b[0]-0.25*d,b[1]],e=(1-c)*(1-c)*(1-c),k=3*(1-c)*(1-c)*c,f=3*
(1-c)*c*c;c*=c*c;return[e*a[0]+k*h[0]+f*d[0]+c*b[0],e*a[1]+k*h[1]+f*d[1]+c*b[1]]};e.prototype.resize=function(a,b){if(!a&&!b){var c=this.canvas.parentNode;a=c.offsetWidth;b=c.offsetHeight}if(this.canvas.width!=a||this.canvas.height!=b)this.canvas.width=a,this.canvas.height=b,this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height,this.setDirty(!0,!0)};e.prototype.switchLiveMode=function(a){if(a){var b=this,c=this.live_mode?1.1:0.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=
0.1);var d=setInterval(function(){b.editor_alpha*=c;b.dirty_canvas=!0;b.dirty_bgcanvas=!0;1>c&&0.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1<c&&0.99<b.editor_alpha&&(clearInterval(d),b.editor_alpha=1)},1)}else this.live_mode=!this.live_mode,this.dirty_bgcanvas=this.dirty_canvas=!0};e.prototype.onNodeSelectionChange=function(a){};e.prototype.touchHandler=function(a){var b=a.changedTouches[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";
break;case "touchend":c="mouseup";break;default:return}var d=this.getCanvasWindow(),h=d.document.createEvent("MouseEvent");h.initMouseEvent(c,!0,!0,d,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null);b.target.dispatchEvent(h);a.preventDefault()};e.onMenuAdd=function(a,b,c,d){function h(a,b){var c=d.getFirstEvent(),k=l.createNode(a.value);k&&(k.pos=f.convertEventToCanvas(c),f.graph.add(k))}var f=e.active_canvas,k=f.getCanvasWindow();a=l.getNodeTypesCategories();b=[];for(var m in a)a[m]&&
b.push({value:a[m],content:a[m],has_submenu:!0});var g=new l.ContextMenu(b,{event:c,callback:function(a,b,c){a=l.getNodeTypesInCategory(a.value);b=[];for(var d in a)b.push({content:a[d].title,value:a[d].type});new l.ContextMenu(b,{event:c,callback:h,parentMenu:g},k);return!1},parentMenu:d},k);return!1};e.onMenuCollapseAll=function(){};e.onMenuNodeEdit=function(){};e.showMenuNodeOptionalInputs=function(a,b,c,d,h){function f(a,b,c){h&&(a.callback&&a.callback.call(k,h,a,b,c),a.value&&(h.addInput(a.value[0],
a.value[1],a.value[2]),h.setDirtyCanvas(!0,!0)))}if(h){var k=this;a=e.active_canvas.getCanvasWindow();b=h.optional_inputs;h.onGetInputs&&(b=h.onGetInputs());var m=[];if(b)for(var g in b){var p=b[g];if(p){var q=p[0];p[2]&&p[2].label&&(q=p[2].label);q={content:q,value:p};p[1]==l.ACTION&&(q.className="event");m.push(q)}else m.push(null)}this.onMenuNodeInputs&&(m=this.onMenuNodeInputs(m));if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,node:h},a),!1}};e.showMenuNodeOptionalOutputs=
function(a,b,c,d,h){function f(a,b,c){if(h&&(a.callback&&a.callback.call(k,h,a,b,c),a.value))if(c=a.value[1],!c||c.constructor!==Object&&c.constructor!==Array)h.addOutput(a.value[0],a.value[1],a.value[2]),h.setDirtyCanvas(!0,!0);else{a=[];for(var e in c)a.push({content:e,value:c[e]});new l.ContextMenu(a,{event:b,callback:f,parentMenu:d,node:h});return!1}}if(h){var k=this;a=e.active_canvas.getCanvasWindow();b=h.optional_outputs;h.onGetOutputs&&(b=h.onGetOutputs());var m=[];if(b)for(var g in b){var p=
b[g];if(!p)m.push(null);else if(!h.flags||!h.flags.skip_repeated_outputs||-1==h.findOutputSlot(p[0])){var q=p[0];p[2]&&p[2].label&&(q=p[2].label);q={content:q,value:p};p[1]==l.EVENT&&(q.className="event");m.push(q)}}this.onMenuNodeOutputs&&(m=this.onMenuNodeOutputs(m));if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,node:h},a),!1}};e.onShowMenuNodeProperties=function(a,b,c,d,h){function f(a,b,c,d){h&&(b=this.getBoundingClientRect(),k.showEditPropertyValue(h,a.value,{position:[b.left,
b.top]}))}if(h&&h.properties){var k=e.active_canvas;b=k.getCanvasWindow();var m=[],g;for(g in h.properties)a=void 0!==h.properties[g]?h.properties[g]:" ",a=e.decodeHTML(a),m.push({content:"<span class='property_name'>"+g+"</span><span class='property_value'>"+a+"</span>",value:g});if(m.length)return new l.ContextMenu(m,{event:c,callback:f,parentMenu:d,allow_html:!0,node:h},b),!1}};e.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};e.onResizeNode=function(a,
b,c,d,h){h&&(h.size=h.computeSize(),h.setDirtyCanvas(!0,!0))};e.onShowTitleEditor=function(a,b,c,d,h){function f(){h.title=m.value;k.parentNode.removeChild(k);h.setDirtyCanvas(!0,!0)}var k=document.createElement("div");k.className="graphdialog";k.innerHTML="<span class='name'>Title</span><input autofocus type='text' class='value'/><button>OK</button>";var m=k.querySelector("input");m&&(m.value=h.title,m.addEventListener("keydown",function(a){13==a.keyCode&&(f(),a.preventDefault(),a.stopPropagation())}));
a=e.active_canvas.canvas;b=a.getBoundingClientRect();d=c=-20;b&&(c-=b.left,d-=b.top);event?(k.style.left=event.pageX+c+"px",k.style.top=event.pageY+d+"px"):(k.style.left=0.5*a.width+c+"px",k.style.top=0.5*a.height+d+"px");k.querySelector("button").addEventListener("click",f);a.parentNode.appendChild(k)};e.prototype.showEditPropertyValue=function(a,b,c){function d(){h(p.value)}function h(c){"number"==typeof a.properties[b]&&(c=Number(c));a.properties[b]=c;if(a.onPropertyChanged)a.onPropertyChanged(b,
c);l.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var e="string";null!==a.properties[b]&&(e=typeof a.properties[b]);var k=null;a.getPropertyInfo&&(k=a.getPropertyInfo(b));if(a.properties_info)for(var f=0;f<a.properties_info.length;++f)if(a.properties_info[f].name==b){k=a.properties_info[f];break}void 0!==k&&null!==k&&k.type&&(e=k.type);var m="";if("string"==e||"number"==e)m="<input autofocus type='text' class='value'/>";else if("enum"==e&&k.values){m="<select autofocus type='text' class='value'>";
for(f in k.values)var g=k.values.constructor===Array?k.values[f]:f,m=m+("<option value='"+g+"' "+(g==a.properties[b]?"selected":"")+">"+k.values[f]+"</option>");m+="</select>"}else"boolean"==e&&(m="<input autofocus type='checkbox' class='value' "+(a.properties[b]?"checked":"")+"/>");var l=this.createDialog("<span class='name'>"+b+"</span>"+m+"<button>OK</button>",c);if("enum"==e&&k.values){var p=l.querySelector("select");p.addEventListener("change",function(a){h(a.target.value)})}else if("boolean"==
e)(p=l.querySelector("input"))&&p.addEventListener("click",function(a){h(!!p.checked)});else if(p=l.querySelector("input"))p.value=void 0!==a.properties[b]?a.properties[b]:"",p.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())});l.querySelector("button").addEventListener("click",d)}};e.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;var d=this.canvas.getBoundingClientRect(),h=
-20,e=-20;d&&(h-=d.left,e-=d.top);b.position?(h+=b.position[0],e+=b.position[1]):b.event?(h+=b.event.pageX,e+=b.event.pageY):(h+=0.5*this.canvas.width,e+=0.5*this.canvas.height);c.style.left=h+"px";c.style.top=e+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};e.onMenuNodeCollapse=function(a,b,c,d,e){e.flags.collapsed=!e.flags.collapsed;e.setDirtyCanvas(!0,!0)};e.onMenuNodePin=function(a,b,c,d,e){e.pin()};e.onMenuNodeMode=
function(a,b,c,d,e){new l.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode=l.ON_EVENT;break;case "On Trigger":e.mode=l.ON_TRIGGER;break;case "Never":e.mode=l.NEVER;break;default:e.mode=l.ALWAYS}},parentMenu:d,node:e});return!1};e.onMenuNodeColors=function(a,b,c,d,h){if(!h)throw"no node for color";b=[];for(var f in e.node_colors)a=e.node_colors[f],a={value:f,content:"<span style='display: block; color:"+a.color+"; background-color:"+
a.bgcolor+"'>"+f+"</span>"},b.push(a);new l.ContextMenu(b,{event:c,callback:function(a){h&&(a=e.node_colors[a.value])&&(h.color=a.color,h.bgcolor=a.bgcolor,h.setDirtyCanvas(!0))},parentMenu:d,node:h});return!1};e.onMenuNodeShapes=function(a,b,c,d,e){if(!e)throw"no node passed";new l.ContextMenu(l.VALID_SHAPES,{event:c,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))},parentMenu:d,node:e});return!1};e.onMenuNodeRemove=function(a,b,c,d,e){if(!e)throw"no node passed";!1!=e.removable&&(e.graph.remove(e),
e.setDirtyCanvas(!0,!0))};e.onMenuNodeClone=function(a,b,c,d,e){!1!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.add(a),e.setDirtyCanvas(!0,!0))};e.node_colors={red:{color:"#FAA",bgcolor:"#944"},green:{color:"#AFA",bgcolor:"#494"},blue:{color:"#AAF",bgcolor:"#449"},cyan:{color:"#AFF",bgcolor:"#499"},purple:{color:"#FAF",bgcolor:"#949"},yellow:{color:"#FFA",bgcolor:"#994"},black:{color:"#777",bgcolor:"#000"},white:{color:"#FFF",bgcolor:"#AAA"}};e.prototype.getCanvasMenuOptions=
function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:e.onMenuAdd}],this._graph_stack&&0<this._graph_stack.length&&(a=[{content:"Close subgraph",callback:this.closeSubgraph.bind(this)},null].concat(a)));if(this.getExtraMenuOptions){var b=this.getExtraMenuOptions(this,a);b&&(a=a.concat(b))}return a};e.prototype.getNodeMenuOptions=function(a){var b=null,b=a.getMenuOptions?a.getMenuOptions(this):[{content:"Inputs",has_submenu:!0,disabled:!0,
callback:e.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,disabled:!0,callback:e.showMenuNodeOptionalOutputs},null,{content:"Properties",has_submenu:!0,callback:e.onShowMenuNodeProperties},null,{content:"Title",callback:e.onShowTitleEditor},{content:"Mode",has_submenu:!0,callback:e.onMenuNodeMode},{content:"Resize",callback:e.onResizeNode},{content:"Collapse",callback:e.onMenuNodeCollapse},{content:"Pin",callback:e.onMenuNodePin},{content:"Colors",has_submenu:!0,callback:e.onMenuNodeColors},
{content:"Shapes",has_submenu:!0,callback:e.onMenuNodeShapes},null];if(a.getExtraMenuOptions){var c=a.getExtraMenuOptions(this);c&&(c.push(null),b=c.concat(b))}!1!==a.clonable&&b.push({content:"Clone",callback:e.onMenuNodeClone});!1!==a.removable&&b.push(null,{content:"Remove",callback:e.onMenuNodeRemove});a.onGetInputs&&(c=a.onGetInputs())&&c.length&&(b[0].disabled=!1);a.onGetOutputs&&(c=a.onGetOutputs())&&c.length&&(b[1].disabled=!1);if(a.graph&&a.graph.onGetNodeMenuOptions)a.graph.onGetNodeMenuOptions(b,
a);return b};e.prototype.processContextMenu=function(a,b){var c=this,d=e.active_canvas.getCanvasWindow(),f=null,m={event:b,callback:function(b,d,e){if(b)if("Remove Slot"==b.content){var k=b.slot;k.input?a.removeInput(k.slot):k.output&&a.removeOutput(k.slot)}else if("Rename Slot"==b.content){var k=b.slot,f=c.createDialog("<span class='name'>Name</span><input type='text'/><button>OK</button>",d),h=f.querySelector("input");f.querySelector("button").addEventListener("click",function(b){if(h.value){if(b=
k.input?a.getInputInfo(k.slot):a.getOutputInfo(k.slot))b.label=h.value;c.setDirty(!0)}f.close()})}},node:a},k=null;a&&(k=a.getSlotInPosition(b.canvasX,b.canvasY),e.active_node=a);k?(f=[],f.push(k.locked?"Cannot remove":{content:"Remove Slot",slot:k}),f.push({content:"Rename Slot",slot:k}),m.title=(k.input?k.input.type:k.output.type)||"*",k.input&&k.input.type==l.ACTION&&(m.title="Action"),k.output&&k.output.type==l.EVENT&&(m.title="Event")):f=a?this.getNodeMenuOptions(a):this.getCanvasMenuOptions();
f&&new l.ContextMenu(f,m,d)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e,f){void 0===e&&(e=5);void 0===f&&(f=e);this.beginPath();this.moveTo(a+e,b);this.lineTo(a+c-e,b);this.quadraticCurveTo(a+c,b,a+c,b+e);this.lineTo(a+c,b+d-f);this.quadraticCurveTo(a+c,b+d,a+c-f,b+d);this.lineTo(a+f,b+d);this.quadraticCurveTo(a,b+d,a,b+d-f);this.lineTo(a,b+e);this.quadraticCurveTo(a,b,a+e,b)});l.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;
return!0};l.distance=p;l.colorToString=function(a){return"rgba("+Math.round(255*a[0]).toFixed()+","+Math.round(255*a[1]).toFixed()+","+Math.round(255*a[2]).toFixed()+","+(4==a.length?a[3].toFixed(2):"1.0")+")"};l.isInsideRectangle=q;l.growBounding=function(a,b,c){b<a[0]?a[0]=b:b>a[2]&&(a[2]=b);c<a[1]?a[1]=c:c>a[3]&&(a[3]=c)};l.isInsideBounding=function(a,b){return a[0]<b[0][0]||a[1]<b[0][1]||a[0]>b[1][0]||a[1]>b[1][1]?!1:!0};l.overlapBounding=s;l.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));
a=a.toUpperCase();for(var b=Array(3),c=0,d,e,f=0;6>f;f+=2)d="0123456789ABCDEF".indexOf(a.charAt(f)),e="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*d+e,c++;return b};l.num2hex=function(a){for(var b="#",c,d,e=0;3>e;e++)c=a[e]/16,d=a[e]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(d);return b};u.prototype.addItem=function(a,b,c){function d(a){var b=this.value;b&&b.has_submenu&&e.call(this,a)}function e(a){var b=this.value,d=!0;f.current_submenu&&f.current_submenu.close(a);if(c.callback){var k=
c.callback.call(this,b,c,a,f,c.node);!0===k&&(d=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(k=b.callback.call(this,b,c,a,f,c.node),!0===k&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new f.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:f,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,autoopen:c.autoopen});d=!1}d&&!f.lock&&f.close()}var f=this;c=c||{};var k=document.createElement("div");
k.className="litemenu-entry submenu";var m=!1;if(null===b)k.classList.add("separator");else{k.innerHTML=b&&b.title?b.title:a;if(k.value=b)b.disabled&&(m=!0,k.classList.add("disabled")),(b.submenu||b.has_submenu)&&k.classList.add("has_submenu");"function"==typeof b?(k.dataset.value=a,k.onclick_callback=b):k.dataset.value=b;b.className&&(k.className+=" "+b.className)}this.root.appendChild(k);m||k.addEventListener("click",e);c.autoopen&&k.addEventListener("mouseenter",d);return k};u.prototype.close=
function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&!b&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,void 0===a?this.parentMenu.close():a&&!u.isCursorOverElement(a,this.parentMenu.root)&&u.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0)};u.trigger=function(a,b,c,d){var e=document.createEvent("CustomEvent");e.initCustomEvent(b,!0,!0,c);e.srcElement=d;a.dispatchEvent?a.dispatchEvent(e):
a.__events&&a.__events.dispatchEvent(e);return e};u.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};u.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};u.isCursorOverElement=function(a,b){var c=a.pageX,d=a.pageY,e=b.getBoundingClientRect();return e?d>e.top&&d<e.top+e.height&&c>e.left&&c<e.left+e.width?!0:!1:!1};l.ContextMenu=u;l.closeAllContextMenus=function(a){a=a||
window;a=a.document.querySelectorAll(".litecontextmenu");if(a.length){for(var b=[],c=0;c<a.length;c++)b.push(a[c]);for(c in b)b[c].close?b[c].close():b[c].parentNode&&b[c].parentNode.removeChild(b[c])}};l.extendClass=function(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c]);if(b.prototype)for(c in b.prototype)b.prototype.hasOwnProperty(c)&&!a.prototype.hasOwnProperty(c)&&(b.prototype.__lookupGetter__(c)?a.prototype.__defineGetter__(c,b.prototype.__lookupGetter__(c)):a.prototype[c]=b.prototype[c],
b.prototype.__lookupSetter__(c)&&a.prototype.__defineSetter__(c,b.prototype.__lookupSetter__(c)))};l.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/mg,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};Math.clamp=function(a,b,c){return b>a?b:c<a?c:a};"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||
function(a){window.setTimeout(a,1E3/60)})})(this);"undefined"!=typeof exports&&(exports.LiteGraph=this.LiteGraph);
(function(r){function g(){this.addOutput("in ms","number");this.addOutput("in sec","number")}function f(){this.size=[120,60];this.subgraph=new LGraph;this.subgraph._subgraph_node=this;this.subgraph._is_subgraph=!0;this.subgraph.onGlobalInputAdded=this.onSubgraphNewGlobalInput.bind(this);this.subgraph.onGlobalInputRenamed=this.onSubgraphRenamedGlobalInput.bind(this);this.subgraph.onGlobalInputTypeChanged=this.onSubgraphTypeChangeGlobalInput.bind(this);this.subgraph.onGlobalOutputAdded=this.onSubgraphNewGlobalOutput.bind(this);
this.subgraph.onGlobalOutputRenamed=this.onSubgraphRenamedGlobalOutput.bind(this);this.subgraph.onGlobalOutputTypeChanged=this.onSubgraphTypeChangeGlobalOutput.bind(this);this.bgcolor="#663"}function e(){var a="input_"+(1E3*Math.random()).toFixed();this.addOutput(a,null);this.properties={name:a,type:null};var b=this;Object.defineProperty(this.properties,"name",{get:function(){return a},set:function(c){if(""!=c){var d=b.getOutputInfo(0);d.name!=c&&(d.name=c,b.graph&&b.graph.renameGlobalInput(a,c),
a=c)}},enumerable:!0});Object.defineProperty(this.properties,"type",{get:function(){return b.outputs[0].type},set:function(c){b.outputs[0].type=c;b.graph&&b.graph.changeGlobalInputType(a,b.outputs[0].type)},enumerable:!0})}function p(){var a="output_"+(1E3*Math.random()).toFixed();this.addInput(a,null);this._value=null;this.properties={name:a,type:null};var b=this;Object.defineProperty(this.properties,"name",{get:function(){return a},set:function(c){if(""!=c){var d=b.getInputInfo(0);d.name!=c&&(d.name=