replaced old roundRect function

This commit is contained in:
tamat
2021-08-16 16:45:36 +02:00
parent 0a21262238
commit 667b04f62a
8 changed files with 352 additions and 364 deletions

View File

@@ -169,18 +169,18 @@ b[d];a.save();a.translate(e.pos[0],e.pos[1]);this.drawNode(e,a);a.restore()}this
(this.connecting_node.horizontal?f.DOWN:f.RIGHT),f.CENTER);a.beginPath();this.connecting_output.type===f.EVENT||this.connecting_output.shape===f.BOX_SHAPE?a.rect(this.connecting_pos[0]-6+.5,this.connecting_pos[1]-5+.5,14,10):this.connecting_output.shape===f.ARROW_SHAPE?(a.moveTo(this.connecting_pos[0]+8,this.connecting_pos[1]+.5),a.lineTo(this.connecting_pos[0]-4,this.connecting_pos[1]+6+.5),a.lineTo(this.connecting_pos[0]-4,this.connecting_pos[1]-6+.5),a.closePath()):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(),this._highlight_input_slot.shape===f.ARROW_SHAPE?(a.moveTo(this._highlight_input[0]+8,this._highlight_input[1]+.5),a.lineTo(this._highlight_input[0]-4,this._highlight_input[1]+6+.5),a.lineTo(this._highlight_input[0]-4,this._highlight_input[1]-6+.5),a.closePath()):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]));if(this.over_link_center&&this.render_link_tooltip)this.drawLinkTooltip(a,this.over_link_center);else if(this.onDrawLinkTooltip)this.onDrawLinkTooltip(a,null);if(this.onDrawForeground)this.onDrawForeground(a,this.visible_rect);a.restore()}this._graph_stack&&this._graph_stack.length&&this.drawSubgraphPanel(a);if(this.onDrawOverlay)this.onDrawOverlay(a);c&&a.restore();a.finish2D&&a.finish2D()}};l.prototype.drawSubgraphPanel=
function(a){var b=this.graph,c=b._subgraph_node;if(c){var d=c.inputs?c.inputs.length:0,e=Math.floor(1.6*f.NODE_SLOT_HEIGHT);a.fillStyle="#111";a.globalAlpha=.8;a.beginPath();a.roundRect(10,10,300,(d+1)*e+50,8);a.fill();a.globalAlpha=1;a.fillStyle="#888";a.font="14px Arial";a.textAlign="left";a.fillText("Graph Inputs",20,34);if(this.drawButton(280,20,20,20,"X","#151515"))this.closeSubgraph();else{d=50;a.font="20px Arial";if(c.inputs)for(var g=0;g<c.inputs.length;++g){var h=c.inputs[g];if(!h.not_subgraph_input){if(this.drawButton(20,
function(a){var b=this.graph,c=b._subgraph_node;if(c){var d=c.inputs?c.inputs.length:0,e=Math.floor(1.6*f.NODE_SLOT_HEIGHT);a.fillStyle="#111";a.globalAlpha=.8;a.beginPath();a.roundRect(10,10,300,(d+1)*e+50,[8]);a.fill();a.globalAlpha=1;a.fillStyle="#888";a.font="14px Arial";a.textAlign="left";a.fillText("Graph Inputs",20,34);if(this.drawButton(280,20,20,20,"X","#151515"))this.closeSubgraph();else{d=50;a.font="20px Arial";if(c.inputs)for(var g=0;g<c.inputs.length;++g){var h=c.inputs[g];if(!h.not_subgraph_input){if(this.drawButton(20,
d+2,280,e-2)){var k=c.constructor.input_node_type||"graph/input";this.graph.beforeChange();var n=f.createNode(k);n?(b.add(n),this.block_click=!1,this.last_click_position=null,this.selectNodes([n]),this.node_dragged=n,this.dragging_canvas=!1,n.setProperty("name",h.name),n.setProperty("type",h.type),this.node_dragged.pos[0]=this.graph_mouse[0]-5,this.node_dragged.pos[1]=this.graph_mouse[1]-5,this.graph.afterChange()):console.error("graph input node not found:",k)}a.fillStyle="#9C9";a.beginPath();a.arc(284,
d+.5*e,5,0,2*Math.PI);a.fill();a.fillStyle="#AAA";a.fillText(h.name,50,d+.75*e);k=a.measureText(h.name);a.fillStyle="#777";a.fillText(h.type,50+k.width+10,d+.75*e);d+=e}}this.drawButton(20,d+2,280,e-2,"+","#151515","#222")&&this.showSubgraphPropertiesDialog(c)}}else console.warn("subgraph without subnode")};l.prototype.drawButton=function(a,b,c,d,e,g,h,k){var n=this.ctx;g=g||f.NODE_DEFAULT_COLOR;h=h||"#555";k=k||f.NODE_TEXT_COLOR;var u=this.mouse,t=f.isInsideRectangle(u[0],u[1],a,b,c,d);u=(u=this.last_click_position)&&
f.isInsideRectangle(u[0],u[1],a,b,c,d);n.fillStyle=t?h:g;u&&(n.fillStyle="#AAA");n.beginPath();n.roundRect(a,b,c,d,4);n.fill();null!=e&&e.constructor==String&&(n.fillStyle=k,n.textAlign="center",n.font=(.65*d|0)+"px Arial",n.fillText(e,a+.5*c,b+.75*d),n.textAlign="left");a=u&&!this.block_click;u&&this.blockClick();return a};l.prototype.isAreaClicked=function(a,b,c,d,e){var g=this.mouse;f.isInsideRectangle(g[0],g[1],a,b,c,d);b=(a=(g=this.last_click_position)&&f.isInsideRectangle(g[0],g[1],a,b,c,d))&&
!this.block_click;a&&e&&this.blockClick();return b};l.prototype.renderInfo=function(a,b,c){b=b||10;c=c||this.canvas.height-80;a.save();a.translate(b,c);a.font="10px Arial";a.fillStyle="#888";a.textAlign="left";this.graph?(a.fillText("T: "+this.graph.globaltime.toFixed(2)+"s",5,13),a.fillText("I: "+this.graph.iteration,5,26),a.fillText("N: "+this.graph._nodes.length+" ["+this.visible_nodes.length+"]",5,39),a.fillText("V: "+this.graph._version,5,52),a.fillText("FPS:"+this.fps.toFixed(2),5,65)):a.fillText("No graph selected",
5,13);a.restore()};l.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();var c=this.viewport||[0,0,b.canvas.width,b.canvas.height];this.clear_background&&b.clearRect(c[0],c[1],c[2],c[3]);if(this._graph_stack&&this._graph_stack.length){b.save();c=this.graph._subgraph_node;b.strokeStyle=c.bgcolor;
b.lineWidth=10;b.strokeRect(1,1,a.width-2,a.height-2);b.lineWidth=1;b.font="40px Arial";b.textAlign="center";b.fillStyle=c.bgcolor||"#AAA";for(var d="",e=1;e<this._graph_stack.length;++e)d+=this._graph_stack[e]._subgraph_node.getTitle()+" >> ";b.fillText(d+c.getTitle(),.5*a.width,40);b.restore()}c=!1;this.onRenderBackground&&(c=this.onRenderBackground(a,b));this.viewport||(b.restore(),b.setTransform(1,0,0,1,0,0));this.visible_links.length=0;if(this.graph){b.save();this.ds.toCanvasContext(b);if(this.background_image&&
.5<this.ds.scale&&!c){b.globalAlpha=this.zoom_modify_alpha?(1-.5/this.ds.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 g=this;this._bg_img.onload=function(){g.draw(!0,!0)}}c=null;null==this._pattern&&0<this._bg_img.width?(c=b.createPattern(this._bg_img,"repeat"),
this._pattern_img=this._bg_img,this._pattern=c):c=this._pattern;c&&(b.fillStyle=c,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}this.graph._groups.length&&!this.live_mode&&this.drawGroups(a,b);if(this.onDrawBackground)this.onDrawBackground(b,this.visible_area);this.onBackgroundRender&&(console.error("WARNING! onBackgroundRender deprecated, now is named onDrawBackground "),
f.isInsideRectangle(u[0],u[1],a,b,c,d);n.fillStyle=t?h:g;u&&(n.fillStyle="#AAA");n.beginPath();n.roundRect(a,b,c,d,[4]);n.fill();null!=e&&e.constructor==String&&(n.fillStyle=k,n.textAlign="center",n.font=(.65*d|0)+"px Arial",n.fillText(e,a+.5*c,b+.75*d),n.textAlign="left");a=u&&!this.block_click;u&&this.blockClick();return a};l.prototype.isAreaClicked=function(a,b,c,d,e){var g=this.mouse;f.isInsideRectangle(g[0],g[1],a,b,c,d);b=(a=(g=this.last_click_position)&&f.isInsideRectangle(g[0],g[1],a,b,c,
d))&&!this.block_click;a&&e&&this.blockClick();return b};l.prototype.renderInfo=function(a,b,c){b=b||10;c=c||this.canvas.height-80;a.save();a.translate(b,c);a.font="10px Arial";a.fillStyle="#888";a.textAlign="left";this.graph?(a.fillText("T: "+this.graph.globaltime.toFixed(2)+"s",5,13),a.fillText("I: "+this.graph.iteration,5,26),a.fillText("N: "+this.graph._nodes.length+" ["+this.visible_nodes.length+"]",5,39),a.fillText("V: "+this.graph._version,5,52),a.fillText("FPS:"+this.fps.toFixed(2),5,65)):
a.fillText("No graph selected",5,13);a.restore()};l.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();var c=this.viewport||[0,0,b.canvas.width,b.canvas.height];this.clear_background&&b.clearRect(c[0],c[1],c[2],c[3]);if(this._graph_stack&&this._graph_stack.length){b.save();c=this.graph._subgraph_node;
b.strokeStyle=c.bgcolor;b.lineWidth=10;b.strokeRect(1,1,a.width-2,a.height-2);b.lineWidth=1;b.font="40px Arial";b.textAlign="center";b.fillStyle=c.bgcolor||"#AAA";for(var d="",e=1;e<this._graph_stack.length;++e)d+=this._graph_stack[e]._subgraph_node.getTitle()+" >> ";b.fillText(d+c.getTitle(),.5*a.width,40);b.restore()}c=!1;this.onRenderBackground&&(c=this.onRenderBackground(a,b));this.viewport||(b.restore(),b.setTransform(1,0,0,1,0,0));this.visible_links.length=0;if(this.graph){b.save();this.ds.toCanvasContext(b);
if(this.background_image&&.5<this.ds.scale&&!c){b.globalAlpha=this.zoom_modify_alpha?(1-.5/this.ds.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 g=this;this._bg_img.onload=function(){g.draw(!0,!0)}}c=null;null==this._pattern&&0<this._bg_img.width?(c=b.createPattern(this._bg_img,
"repeat"),this._pattern_img=this._bg_img,this._pattern=c):c=this._pattern;c&&(b.fillStyle=c,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}this.graph._groups.length&&!this.live_mode&&this.drawGroups(a,b);if(this.onDrawBackground)this.onDrawBackground(b,this.visible_area);this.onBackgroundRender&&(console.error("WARNING! onBackgroundRender deprecated, now is named onDrawBackground "),
this.onBackgroundRender=null);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);l.prototype.drawNode=function(a,b){this.current_node=a;var c=a.color||a.constructor.color||
f.NODE_DEFAULT_COLOR,d=a.bgcolor||a.constructor.bgcolor||f.NODE_DEFAULT_BGCOLOR,e=.6>this.ds.scale;if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b,this,this.canvas)}else{var g=this.editor_alpha;b.globalAlpha=g;this.render_shadows&&!e?(b.shadowColor=f.DEFAULT_SHADOW_COLOR,b.shadowOffsetX=2*this.ds.scale,b.shadowOffsetY=2*this.ds.scale,b.shadowBlur=3*this.ds.scale):b.shadowColor="transparent";if(!a.flags.collapsed||!a.onDrawCollapsed||
1!=a.onDrawCollapsed(b,this)){var h=a._shape||f.BOX_SHAPE;D.set(a.size);var k=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var n=a.getTitle?a.getTitle():a.title;null!=n&&(a._collapsed_width=Math.min(a.size[0],b.measureText(n).width+2*f.NODE_TITLE_HEIGHT),D[0]=a._collapsed_width,D[1]=0)}a.clip_area&&(b.save(),b.beginPath(),h==f.BOX_SHAPE?b.rect(0,0,D[0],D[1]):h==f.ROUND_SHAPE?b.roundRect(0,0,D[0],D[1],10):h==f.CIRCLE_SHAPE&&b.arc(.5*D[0],.5*D[1],.5*D[0],0,2*Math.PI),b.clip());a.has_errors&&
1!=a.onDrawCollapsed(b,this)){var h=a._shape||f.BOX_SHAPE;D.set(a.size);var k=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var n=a.getTitle?a.getTitle():a.title;null!=n&&(a._collapsed_width=Math.min(a.size[0],b.measureText(n).width+2*f.NODE_TITLE_HEIGHT),D[0]=a._collapsed_width,D[1]=0)}a.clip_area&&(b.save(),b.beginPath(),h==f.BOX_SHAPE?b.rect(0,0,D[0],D[1]):h==f.ROUND_SHAPE?b.roundRect(0,0,D[0],D[1],[10]):h==f.CIRCLE_SHAPE&&b.arc(.5*D[0],.5*D[1],.5*D[0],0,2*Math.PI),b.clip());a.has_errors&&
(d="red");this.drawNodeShape(a,b,D,c,d,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=k?"center":"left";b.font=this.inner_text_font;d=!e;h=this.connecting_output;b.lineWidth=1;n=0;var u=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(c=0;c<a.inputs.length;c++){var t=a.inputs[c];b.globalAlpha=g;this.connecting_node&&!f.isValidConnection(t.type,h.type)&&(b.globalAlpha=.4*g);b.fillStyle=null!=t.link?t.color_on||
this.default_connection_color.input_on:t.color_off||this.default_connection_color.input_off;var m=a.getConnectionPos(!0,c,u);m[0]-=a.pos[0];m[1]-=a.pos[1];n<m[1]+.5*f.NODE_SLOT_HEIGHT&&(n=m[1]+.5*f.NODE_SLOT_HEIGHT);b.beginPath();t.type===f.EVENT||t.shape===f.BOX_SHAPE?k?b.rect(m[0]-5+.5,m[1]-8+.5,10,14):b.rect(m[0]-6+.5,m[1]-5+.5,14,10):t.shape===f.ARROW_SHAPE?(b.moveTo(m[0]+8,m[1]+.5),b.lineTo(m[0]-4,m[1]+6+.5),b.lineTo(m[0]-4,m[1]-6+.5),b.closePath()):e?b.rect(m[0]-4,m[1]-4,8,8):b.arc(m[0],m[1],
4,0,2*Math.PI);b.fill();if(d){var l=null!=t.label?t.label:t.name;l&&(b.fillStyle=f.NODE_TEXT_COLOR,k||t.dir==f.UP?b.fillText(l,m[0],m[1]-10):b.fillText(l,m[0]+10,m[1]+5))}}this.connecting_node&&(b.globalAlpha=.4*g);b.textAlign=k?"center":"right";b.strokeStyle="black";if(a.outputs)for(c=0;c<a.outputs.length;c++)if(t=a.outputs[c],m=a.getConnectionPos(!1,c,u),m[0]-=a.pos[0],m[1]-=a.pos[1],n<m[1]+.5*f.NODE_SLOT_HEIGHT&&(n=m[1]+.5*f.NODE_SLOT_HEIGHT),b.fillStyle=t.links&&t.links.length?t.color_on||this.default_connection_color.output_on:
@@ -188,96 +188,96 @@ t.color_off||this.default_connection_color.output_off,b.beginPath(),t.type===f.E
m[0]-10,m[1]+5);b.textAlign="left";b.globalAlpha=1;if(a.widgets){t=n;if(k||a.widgets_up)t=2;null!=a.widgets_start_y&&(t=a.widgets_start_y);this.drawNodeWidgets(a,t,b,this.node_widget&&this.node_widget[0]==a?this.node_widget[1]:null)}}else if(this.render_collapsed_slots){e=g=null;if(a.inputs)for(c=0;c<a.inputs.length;c++)if(t=a.inputs[c],null!=t.link){g=t;break}if(a.outputs)for(c=0;c<a.outputs.length;c++)t=a.outputs[c],t.links&&t.links.length&&(e=t);g&&(g=0,c=-.5*f.NODE_TITLE_HEIGHT,k&&(g=.5*a._collapsed_width,
c=-f.NODE_TITLE_HEIGHT),b.fillStyle="#686",b.beginPath(),t.type===f.EVENT||t.shape===f.BOX_SHAPE?b.rect(g-7+.5,c-4,14,8):t.shape===f.ARROW_SHAPE?(b.moveTo(g+8,c),b.lineTo(g+-4,c-4),b.lineTo(g+-4,c+4),b.closePath()):b.arc(g,c,4,0,2*Math.PI),b.fill());e&&(g=a._collapsed_width,c=-.5*f.NODE_TITLE_HEIGHT,k&&(g=.5*a._collapsed_width,c=0),b.fillStyle="#686",b.strokeStyle="black",b.beginPath(),t.type===f.EVENT||t.shape===f.BOX_SHAPE?b.rect(g-7+.5,c-4,14,8):t.shape===f.ARROW_SHAPE?(b.moveTo(g+6,c),b.lineTo(g-
6,c-4),b.lineTo(g-6,c+4),b.closePath()):b.arc(g,c,4,0,2*Math.PI),b.fill())}a.clip_area&&b.restore();b.globalAlpha=1}}};l.prototype.drawLinkTooltip=function(a,b){var c=b._pos;a.fillStyle="black";a.beginPath();a.arc(c[0],c[1],3,0,2*Math.PI);a.fill();if(null!=b.data&&(!this.onDrawLinkTooltip||1!=this.onDrawLinkTooltip(a,b,this))&&(b=b.data,b=b.constructor===Number?b.toFixed(2):b.constructor===String?'"'+b+'"':b.constructor===Boolean?String(b):b.toToolTip?b.toToolTip():"["+b.constructor.name+"]",null!=
b)){b=b.substr(0,30);a.font="14px Courier New";var d=a.measureText(b).width+20;a.shadowColor="black";a.shadowOffsetX=2;a.shadowOffsetY=2;a.shadowBlur=3;a.fillStyle="#454";a.beginPath();a.roundRect(c[0]-.5*d,c[1]-15-24,d,24,3,3);a.moveTo(c[0]-10,c[1]-15);a.lineTo(c[0]+10,c[1]-15);a.lineTo(c[0],c[1]-5);a.fill();a.shadowColor="transparent";a.textAlign="center";a.fillStyle="#CEC";a.fillText(b,c[0],c[1]-15-24*.3)}};var x=new Float32Array(4);l.prototype.drawNodeShape=function(a,b,c,d,e,g,h){b.strokeStyle=
d;b.fillStyle=e;e=f.NODE_TITLE_HEIGHT;var k=.5>this.ds.scale,n=a._shape||a.constructor.shape||f.ROUND_SHAPE,u=a.constructor.title_mode,t=!0;u==f.TRANSPARENT_TITLE?t=!1:u==f.AUTOHIDE_TITLE&&h&&(t=!0);x[0]=0;x[1]=t?-e:0;x[2]=c[0]+1;x[3]=t?c[1]+e:c[1];h=b.globalAlpha;b.beginPath();n==f.BOX_SHAPE||k?b.fillRect(x[0],x[1],x[2],x[3]):n==f.ROUND_SHAPE||n==f.CARD_SHAPE?b.roundRect(x[0],x[1],x[2],x[3],this.round_radius,n==f.CARD_SHAPE?0:this.round_radius):n==f.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0],0,
2*Math.PI);b.fill();a.flags.collapsed||(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,x[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(t||u==f.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,e,c,this.ds.scale,d);else if(u!=f.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){t=a.constructor.title_color||d;a.flags.collapsed&&(b.shadowColor=f.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var m=
l.gradients[t];m||(m=l.gradients[t]=b.createLinearGradient(0,0,400,0),m.addColorStop(0,t),m.addColorStop(1,"#000"));b.fillStyle=m}else b.fillStyle=t;b.beginPath();n==f.BOX_SHAPE||k?b.rect(0,-e,c[0]+1,e):(n==f.ROUND_SHAPE||n==f.CARD_SHAPE)&&b.roundRect(0,-e,c[0]+1,e,this.round_radius,a.flags.collapsed?this.round_radius:0);b.fill();b.shadowColor="transparent"}if(a.onDrawTitleBox)a.onDrawTitleBox(b,e,c,this.ds.scale);else n==f.ROUND_SHAPE||n==f.CIRCLE_SHAPE||n==f.CARD_SHAPE?(k&&(b.fillStyle="black",
b.beginPath(),b.arc(.5*e,-.5*e,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,k?b.fillRect(.5*e-5,-.5*e-5,10,10):(b.beginPath(),b.arc(.5*e,-.5*e,5,0,2*Math.PI),b.fill())):(k&&(b.fillStyle="black",b.fillRect(.5*(e-10)-1,-.5*(e+10)-1,12,12)),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(e-10),-.5*(e+10),10,10));b.globalAlpha=h;if(a.onDrawTitleText)a.onDrawTitleText(b,e,c,this.ds.scale,this.title_text_font,g);!k&&(b.font=this.title_text_font,h=String(a.getTitle()))&&
(b.fillStyle=g?f.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(h),b.fillText(h.substr(0,20),e,f.NODE_TITLE_TEXT_Y-e),b.textAlign="left"):(b.textAlign="left",b.fillText(h,e,f.NODE_TITLE_TEXT_Y-e)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(h=f.NODE_TITLE_HEIGHT,t=a.size[0]-h,m=f.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],t+2,-h+2,h-4,h-4),b.fillStyle=m?"#888":"#555",
n==f.BOX_SHAPE||k?b.fillRect(t+2,-h+2,h-4,h-4):(b.beginPath(),b.roundRect(t+2,-h+2,h-4,h-4,4),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(t+.2*h,.6*-h),b.lineTo(t+.8*h,.6*-h),b.lineTo(t+.5*h,.3*-h),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(g){if(a.onBounding)a.onBounding(x);u==f.TRANSPARENT_TITLE&&(x[1]-=e,x[3]+=e);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();n==f.BOX_SHAPE?b.rect(-6+x[0],-6+x[1],12+x[2],12+x[3]):n==f.ROUND_SHAPE||n==f.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+x[0],
-6+x[1],12+x[2],12+x[3],2*this.round_radius):n==f.CARD_SHAPE?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],2*this.round_radius,2):n==f.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0]+6,0,2*Math.PI);b.strokeStyle=f.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=d;b.globalAlpha=1}};var I=new Float32Array(4),B=new Float32Array(4),L=new Float32Array(2),M=new Float32Array(2);l.prototype.drawConnections=function(a){var b=f.getTime(),c=this.visible_area;I[0]=c[0]-20;I[1]=c[1]-20;I[2]=c[2]+40;I[3]=c[3]+40;a.lineWidth=
this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;c=this.graph._nodes;for(var d=0,e=c.length;d<e;++d){var g=c[d];if(g.inputs&&g.inputs.length)for(var h=0;h<g.inputs.length;++h){var k=g.inputs[h];if(k&&null!=k.link&&(k=this.graph.links[k.link])){var n=this.graph.getNodeById(k.origin_id);if(null!=n){var u=k.origin_slot;var t=-1==u?[n.pos[0]+10,n.pos[1]+10]:n.getConnectionPos(!1,u,L);var m=g.getConnectionPos(!0,h,M);B[0]=t[0];B[1]=t[1];B[2]=m[0]-t[0];B[3]=
m[1]-t[1];0>B[2]&&(B[0]+=B[2],B[2]=Math.abs(B[2]));0>B[3]&&(B[1]+=B[3],B[3]=Math.abs(B[3]));if(H(B,I)){var l=n.outputs[u];u=g.inputs[h];if(l&&u&&(n=l.dir||(n.horizontal?f.DOWN:f.RIGHT),u=u.dir||(g.horizontal?f.UP:f.LEFT),this.renderLink(a,t,m,k,!1,0,null,n,u),k&&k._last_time&&1E3>b-k._last_time)){l=2-.002*(b-k._last_time);var v=a.globalAlpha;a.globalAlpha=v*l;this.renderLink(a,t,m,k,!0,l,"white",n,u);a.globalAlpha=v}}}}}}a.globalAlpha=1};l.prototype.renderLink=function(a,b,c,d,e,g,h,k,n,u){d&&this.visible_links.push(d);
!h&&d&&(h=d.color||l.link_type_colors[d.type]);h||(h=this.default_link_color);null!=d&&this.highlighted_links[d.id]&&(h="#FFF");k=k||f.RIGHT;n=n||f.LEFT;var t=J(b,c);this.render_connections_border&&.6<this.ds.scale&&(a.lineWidth=this.connections_width+4);a.lineJoin="round";u=u||1;1<u&&(a.lineWidth=.5);a.beginPath();for(var m=0;m<u;m+=1){var r=5*(m-.5*(u-1));if(this.links_render_mode==f.SPLINE_LINK){a.moveTo(b[0],b[1]+r);var v=0,q=0,p=0,A=0;switch(k){case f.LEFT:v=-.25*t;break;case f.RIGHT:v=.25*t;
break;case f.UP:q=-.25*t;break;case f.DOWN:q=.25*t}switch(n){case f.LEFT:p=-.25*t;break;case f.RIGHT:p=.25*t;break;case f.UP:A=-.25*t;break;case f.DOWN:A=.25*t}a.bezierCurveTo(b[0]+v,b[1]+q+r,c[0]+p,c[1]+A+r,c[0],c[1]+r)}else if(this.links_render_mode==f.LINEAR_LINK){a.moveTo(b[0],b[1]+r);A=p=q=v=0;switch(k){case f.LEFT:v=-1;break;case f.RIGHT:v=1;break;case f.UP:q=-1;break;case f.DOWN:q=1}switch(n){case f.LEFT:p=-1;break;case f.RIGHT:p=1;break;case f.UP:A=-1;break;case f.DOWN:A=1}a.lineTo(b[0]+15*
v,b[1]+15*q+r);a.lineTo(c[0]+15*p,c[1]+15*A+r);a.lineTo(c[0],c[1]+r)}else if(this.links_render_mode==f.STRAIGHT_LINK)a.moveTo(b[0],b[1]),r=b[0],v=b[1],q=c[0],p=c[1],k==f.RIGHT?r+=10:v+=10,n==f.LEFT?q-=10:p-=10,a.lineTo(r,v),a.lineTo(.5*(r+q),v),a.lineTo(.5*(r+q),p),a.lineTo(q,p),a.lineTo(c[0],c[1]);else return}this.render_connections_border&&.6<this.ds.scale&&!e&&(a.strokeStyle="rgba(0,0,0,0.5)",a.stroke());a.lineWidth=this.connections_width;a.fillStyle=a.strokeStyle=h;a.stroke();e=this.computeConnectionPoint(b,
c,.5,k,n);d&&d._pos&&(d._pos[0]=e[0],d._pos[1]=e[1]);.6<=this.ds.scale&&this.highquality_render&&n!=f.CENTER&&(this.render_connection_arrows&&(m=this.computeConnectionPoint(b,c,.25,k,n),t=this.computeConnectionPoint(b,c,.26,k,n),d=this.computeConnectionPoint(b,c,.75,k,n),u=this.computeConnectionPoint(b,c,.76,k,n),this.render_curved_connections?(t=-Math.atan2(t[0]-m[0],t[1]-m[1]),u=-Math.atan2(u[0]-d[0],u[1]-d[1])):u=t=c[1]>b[1]?0:Math.PI,a.save(),a.translate(m[0],m[1]),a.rotate(t),a.beginPath(),a.moveTo(-5,
-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(d[0],d[1]),a.rotate(u),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill());if(g)for(a.fillStyle=h,m=0;5>m;++m)g=(.001*f.getTime()+.2*m)%1,e=this.computeConnectionPoint(b,c,g,k,n),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill()};l.prototype.computeConnectionPoint=function(a,b,c,d,e){d=d||f.RIGHT;e=e||f.LEFT;var g=J(a,b),h=[a[0],a[1]],k=
[b[0],b[1]];switch(d){case f.LEFT:h[0]+=-.25*g;break;case f.RIGHT:h[0]+=.25*g;break;case f.UP:h[1]+=-.25*g;break;case f.DOWN:h[1]+=.25*g}switch(e){case f.LEFT:k[0]+=-.25*g;break;case f.RIGHT:k[0]+=.25*g;break;case f.UP:k[1]+=-.25*g;break;case f.DOWN:k[1]+=.25*g}d=(1-c)*(1-c)*(1-c);e=3*(1-c)*(1-c)*c;g=3*(1-c)*c*c;c*=c*c;return[d*a[0]+e*h[0]+g*k[0]+c*b[0],d*a[1]+e*h[1]+g*k[1]+c*b[1]]};l.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=.25;a.textAlign="center";a.strokeStyle=
"white";a.globalAlpha=.75;for(var b=this.visible_nodes,c=0;c<b.length;++c){var d=b[c];a.fillStyle="black";a.fillRect(d.pos[0]-f.NODE_TITLE_HEIGHT,d.pos[1]-f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT);0==d.order&&a.strokeRect(d.pos[0]-f.NODE_TITLE_HEIGHT+.5,d.pos[1]-f.NODE_TITLE_HEIGHT+.5,f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT);a.fillStyle="#FFF";a.fillText(d.order,d.pos[0]+-.5*f.NODE_TITLE_HEIGHT,d.pos[1]-6)}a.globalAlpha=1};l.prototype.drawNodeWidgets=function(a,b,c,d){if(!a.widgets||
!a.widgets.length)return 0;var e=a.size[0],g=a.widgets;b+=2;var h=f.NODE_WIDGET_HEIGHT,k=.5<this.ds.scale;c.save();c.globalAlpha=this.editor_alpha;for(var n=f.WIDGET_OUTLINE_COLOR,l=f.WIDGET_BGCOLOR,t=f.WIDGET_TEXT_COLOR,m=f.WIDGET_SECONDARY_TEXT_COLOR,r=0;r<g.length;++r){var v=g[r],q=b;v.y&&(q=v.y);v.last_y=q;c.strokeStyle=n;c.fillStyle="#222";c.textAlign="left";v.disabled&&(c.globalAlpha*=.5);var p=v.width||e;switch(v.type){case "button":v.clicked&&(c.fillStyle="#AAA",v.clicked=!1,this.dirty_canvas=
!0);c.fillRect(15,q,p-30,h);k&&!v.disabled&&c.strokeRect(15,q,p-30,h);k&&(c.textAlign="center",c.fillStyle=t,c.fillText(v.name,.5*p,q+.7*h));break;case "toggle":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,.5*h):c.rect(15,b,p-30,h);c.fill();k&&!v.disabled&&c.stroke();c.fillStyle=v.value?"#89A":"#333";c.beginPath();c.arc(p-30,q+.5*h,.36*h,0,2*Math.PI);c.fill();k&&(c.fillStyle=m,null!=v.name&&c.fillText(v.name,30,q+.7*h),c.fillStyle=v.value?t:m,c.textAlign=
"right",c.fillText(v.value?v.options.on||"true":v.options.off||"false",p-40,q+.7*h));break;case "slider":c.fillStyle=l;c.fillRect(15,q,p-30,h);var A=v.options.max-v.options.min,F=(v.value-v.options.min)/A;c.fillStyle=d==v?"#89A":"#678";c.fillRect(15,q,F*(p-30),h);k&&!v.disabled&&c.strokeRect(15,q,p-30,h);v.marker&&(A=(v.marker-v.options.min)/A,c.fillStyle="#AA9",c.fillRect(15+A*(p-30),q,2,h));k&&(c.textAlign="center",c.fillStyle=t,c.fillText(v.name+" "+Number(v.value).toFixed(3),.5*p,q+.7*h));break;
case "number":case "combo":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,.5*h):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.fillStyle=t,v.disabled||(c.beginPath(),c.moveTo(31,b+5),c.lineTo(21,b+.5*h),c.lineTo(31,b+h-5),c.fill(),c.beginPath(),c.moveTo(p-15-16,b+5),c.lineTo(p-15-6,b+.5*h),c.lineTo(p-15-16,b+h-5),c.fill()),c.fillStyle=m,c.fillText(v.name,35,q+.7*h),c.fillStyle=t,c.textAlign="right","number"==v.type?c.fillText(Number(v.value).toFixed(void 0!==
v.options.precision?v.options.precision:3),p-30-20,q+.7*h):(A=v.value,v.options.values&&(F=v.options.values,F.constructor===Function&&(F=F()),F&&F.constructor!==Array&&(A=F[v.value])),c.fillText(A,p-30-20,q+.7*h)));break;case "string":case "text":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,.5*h):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.save(),c.beginPath(),c.rect(15,b,p-30,h),c.clip(),c.fillStyle=m,null!=v.name&&c.fillText(v.name,30,q+
.7*h),c.fillStyle=t,c.textAlign="right",c.fillText(String(v.value).substr(0,30),p-30,q+.7*h),c.restore());break;default:v.draw&&v.draw(c,a,p,q,h)}b+=(v.computeSize?v.computeSize(p)[1]:h)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};l.prototype.processNodeWidgets=function(a,b,c,d){function e(d,e){d.value=e;d.options&&d.options.property&&void 0!==a.properties[d.options.property]&&a.setProperty(d.options.property,e);d.callback&&d.callback(d.value,n,a,b,c)}if(!a.widgets||!a.widgets.length)return null;
for(var g=b[0]-a.pos[0],h=b[1]-a.pos[1],k=a.size[0],n=this,l=this.getCanvasWindow(),t=0;t<a.widgets.length;++t){var m=a.widgets[t];if(m&&!m.disabled){var p=m.computeSize?m.computeSize(k)[1]:f.NODE_WIDGET_HEIGHT,q=m.width||k;if(m==d||!(6>g||g>q-12||h<m.last_y||h>m.last_y+p||void 0===m.last_y)){d=m.value;switch(m.type){case "button":"mousedown"===c.type&&(m.callback&&setTimeout(function(){m.callback(m,n,a,b,c)},20),this.dirty_canvas=m.clicked=!0);break;case "slider":l=Math.clamp((g-15)/(q-30),0,1);
m.value=m.options.min+(m.options.max-m.options.min)*l;m.callback&&setTimeout(function(){e(m,m.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=m.value;if("mousemove"==c.type&&"number"==m.type)m.value+=.1*c.deltaX*(m.options.step||1),null!=m.options.min&&m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max);else if("mousedown"==c.type){var r=m.options.values;r&&r.constructor===Function&&(r=m.options.values(m,a));var w=
null;"number"!=m.type&&(w=r.constructor===Array?r:Object.keys(r));g=40>g?-1:g>q-40?1:0;if("number"==m.type)m.value+=.1*g*(m.options.step||1),null!=m.options.min&&m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max);else if(g)l=-1,this.last_mouseclick=0,l=r.constructor===Object?w.indexOf(String(m.value))+g:w.indexOf(m.value)+g,l>=w.length&&(l=w.length-1),0>l&&(l=0),m.value=r.constructor===Array?r[l]:l;else{var A=r!=w?Object.values(r):r;
new f.ContextMenu(A,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){r!=w&&(a=A.indexOf(a));this.value=a;e(this,a);n.dirty_canvas=!0;return!1}.bind(m)},l)}}else"mouseup"==c.type&&"number"==m.type&&(g=40>g?-1:g>q-40?1:0,200>c.click_time&&0==g&&this.prompt("Value",m.value,function(a){this.value=Number(a);e(this,this.value)}.bind(m),c));d!=m.value&&setTimeout(function(){e(this,this.value)}.bind(m),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(m.value=
!m.value,setTimeout(function(){e(m,m.value)},20));break;case "string":case "text":"mousedown"==c.type&&this.prompt("Value",m.value,function(a){this.value=a;e(this,a)}.bind(m),c,m.options?m.options.multiline:!1);break;default:m.mouse&&(this.dirty_canvas=m.mouse(c,[g,h],a))}if(d!=m.value){if(a.onWidgetChanged)a.onWidgetChanged(m.name,m.value,d,m);a.graph._version++}return m}}}return null};l.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;
for(var c=0;c<a.length;++c){var d=a[c];if(H(this.visible_area,d._bounding)){b.fillStyle=d.color||"#335";b.strokeStyle=d.color||"#335";var e=d._pos,g=d._size;b.globalAlpha=.25*this.editor_alpha;b.beginPath();b.rect(e[0]+.5,e[1]+.5,g[0],g[1]);b.fill();b.globalAlpha=this.editor_alpha;b.stroke();b.beginPath();b.moveTo(e[0]+g[0],e[1]+g[1]);b.lineTo(e[0]+g[0]-10,e[1]+g[1]);b.lineTo(e[0]+g[0],e[1]+g[1]-10);b.fill();g=d.font_size||f.DEFAULT_GROUP_FONT_SIZE;b.font=g+"px Arial";b.fillText(d.title,e[0]+4,e[1]+
g)}}b.restore()}};l.prototype.adjustNodesSize=function(){for(var a=this.graph._nodes,b=0;b<a.length;++b)a[b].size=a[b].computeSize();this.setDirty(!0,!0)};l.prototype.resize=function(a,b){a||b||(b=this.canvas.parentNode,a=b.offsetWidth,b=b.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)};l.prototype.switchLiveMode=function(a){if(a){var b=this,c=this.live_mode?
1.1:.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=.1);var d=setInterval(function(){b.editor_alpha*=c;b.dirty_canvas=!0;b.dirty_bgcanvas=!0;1>c&&.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1<c&&.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};l.prototype.onNodeSelectionChange=function(a){};l.prototype.touchHandler=function(a){var b=a.changedTouches[0];switch(a.type){case "touchstart":var c=
"mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var d=this.getCanvasWindow(),e=d.document.createEvent("MouseEvent");e.initMouseEvent(c,!0,!0,d,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null);b.target.dispatchEvent(e);a.preventDefault()};l.onGroupAdd=function(a,b,c){a=l.active_canvas;a.getCanvasWindow();b=new f.LGraphGroup;b.pos=a.convertEventToCanvasOffset(c);a.graph.add(b)};l.onMenuAdd=function(a,b,c,d,e){function g(a,b){var d=
[];f.getNodeTypesCategories(h.filter||n.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var c=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===d.findIndex(function(a){return a.value===c})&&d.push({value:c,content:b,has_submenu:!0,callback:function(a,b,c,d){g(a.value,d)}})}});f.getNodeTypesInCategory(a.slice(0,-1),h.filter||n.filter).map(function(a){a.skip_list||d.push({value:a.type,content:a.title,has_submenu:!1,
callback:function(a,b,c,d){b=d.getFirstEvent();h.graph.beforeChange();if(a=f.createNode(a.value))a.pos=h.convertEventToCanvasOffset(b),h.graph.add(a);e&&e(a);h.graph.afterChange()}})});new f.ContextMenu(d,{event:c,parentMenu:b},k)}var h=l.active_canvas,k=h.getCanvasWindow(),n=h.graph;if(n)return g("",d),!1};l.onMenuCollapseAll=function(){};l.onMenuNodeEdit=function(){};l.showMenuNodeOptionalInputs=function(a,b,c,d,e){if(e){var g=this;a=l.active_canvas.getCanvasWindow();b=e.optional_inputs;e.onGetInputs&&
(b=e.onGetInputs());var h=[];if(b)for(var k=0;k<b.length;k++){var n=b[k];if(n){var u=n[0];n[2]&&n[2].label&&(u=n[2].label);u={content:u,value:n};n[1]==f.ACTION&&(u.className="event");h.push(u)}else h.push(null)}this.onMenuNodeInputs&&(h=this.onMenuNodeInputs(h));if(h.length)return new f.ContextMenu(h,{event:c,callback:function(a,b,c){e&&(a.callback&&a.callback.call(g,e,a,b,c),a.value&&(e.graph.beforeChange(),e.addInput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,!0),e.graph.afterChange()))},
parentMenu:d,node:e},a),!1;console.log("no input entries")}};l.showMenuNodeOptionalOutputs=function(a,b,c,d,e){function g(a,b,c){if(e&&(a.callback&&a.callback.call(h,e,a,b,c),a.value))if(c=a.value[1],!c||c.constructor!==Object&&c.constructor!==Array)e.graph.beforeChange(),e.addOutput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,!0),e.graph.afterChange();else{a=[];for(var k in c)a.push({content:k,value:c[k]});new f.ContextMenu(a,{event:b,callback:g,parentMenu:d,node:e});return!1}}if(e){var h=
this;a=l.active_canvas.getCanvasWindow();b=e.optional_outputs;e.onGetOutputs&&(b=e.onGetOutputs());var k=[];if(b)for(var n=0;n<b.length;n++){var u=b[n];if(!u)k.push(null);else if(!e.flags||!e.flags.skip_repeated_outputs||-1==e.findOutputSlot(u[0])){var t=u[0];u[2]&&u[2].label&&(t=u[2].label);t={content:t,value:u};u[1]==f.EVENT&&(t.className="event");k.push(t)}}this.onMenuNodeOutputs&&(k=this.onMenuNodeOutputs(k));if(k.length)return new f.ContextMenu(k,{event:c,callback:g,parentMenu:d,node:e},a),!1}};
l.onShowMenuNodeProperties=function(a,b,c,d,e){if(e&&e.properties){var g=l.active_canvas;b=g.getCanvasWindow();var h=[],k;for(k in e.properties){a=void 0!==e.properties[k]?e.properties[k]:" ";"object"==typeof a&&(a=JSON.stringify(a));var n=e.getPropertyInfo(k);if("enum"==n.type||"combo"==n.type)a=l.getPropertyPrintableValue(a,n.values);a=l.decodeHTML(a);h.push({content:"<span class='property_name'>"+(n.label?n.label:k)+"</span><span class='property_value'>"+a+"</span>",value:k})}if(h.length)return new f.ContextMenu(h,
{event:c,callback:function(a,b,c,d){e&&(b=this.getBoundingClientRect(),g.showEditPropertyValue(e,a.value,{position:[b.left,b.top]}))},parentMenu:d,allow_html:!0,node:e},b),!1}};l.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};l.onResizeNode=function(a,b,c,d,e){if(e){e.size=e.computeSize();if(e.onResize)e.onResize(e.size);e.setDirtyCanvas(!0,!0)}};l.prototype.showLinkMenu=function(a,b){var c=this;console.log(a);var d=new f.ContextMenu(["Add Node",null,
"Delete"],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,g,h){switch(b){case "Add Node":l.onMenuAdd(null,null,h,d,function(b){console.log("node autoconnect");var d=c.graph.getNodeById(a.origin_id),e=c.graph.getNodeById(a.target_id);b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&d.outputs[a.origin_slot].type==b.inputs[0].type&&b.outputs[0].type==e.inputs[0].type&&(d.connect(a.origin_slot,b,0),b.connect(0,e,a.target_slot),b.pos[0]-=.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});
return!1};l.onShowPropertyEditor=function(a,b,c,d,e){function g(){var b=n.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);e[h]=b;f.parentNode&&f.parentNode.removeChild(f);e.setDirtyCanvas(!0,!0)}var h=a.property||"title";b=e[h];var f=document.createElement("div");f.className="graphdialog";f.innerHTML="<span class='name'></span><input autofocus type='text' class='value'/><button>OK</button>";f.querySelector(".name").innerText=h;var n=f.querySelector(".value");n&&(n.value=b,n.addEventListener("blur",
function(a){this.focus()}),n.addEventListener("keydown",function(a){if(13==a.keyCode||"textarea"==a.target.localName)g(),a.preventDefault(),a.stopPropagation()}));b=l.active_canvas.canvas;c=b.getBoundingClientRect();var u=d=-20;c&&(d-=c.left,u-=c.top);event?(f.style.left=event.clientX+d+"px",f.style.top=event.clientY+u+"px"):(f.style.left=.5*b.width+d+"px",f.style.top=.5*b.height+u+"px");f.querySelector("button").addEventListener("click",g);b.parentNode.appendChild(f)};l.prototype.prompt=function(a,
b,c,d,e){var g=this;a=a||"";var h=!1,f=document.createElement("div");f.className="graphdialog rounded";f.innerHTML=e?"<span class='name'></span> <textarea autofocus class='value'></textarea><button class='rounded'>OK</button>":"<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>";f.close=function(){g.prompt_box=null;f.parentNode&&f.parentNode.removeChild(f)};1<this.ds.scale&&(f.style.transform="scale("+this.ds.scale+")");f.addEventListener("mouseleave",
function(a){h||f.close()});g.prompt_box&&g.prompt_box.close();g.prompt_box=f;f.querySelector(".name").innerText=a;var n=f.querySelector(".value");n.value=b;n.addEventListener("keydown",function(a){h=!0;if(27==a.keyCode)f.close();else if(13==a.keyCode&&"textarea"!=a.target.localName)c&&c(this.value),f.close();else return;a.preventDefault();a.stopPropagation()});f.querySelector("button").addEventListener("click",function(a){c&&c(n.value);g.setDirty(!0);f.close()});a=l.active_canvas.canvas;b=a.getBoundingClientRect();
var u=e=-20;b&&(e-=b.left,u-=b.top);d?(f.style.left=d.clientX+e+"px",f.style.top=d.clientY+u+"px"):(f.style.left=.5*a.width+e+"px",f.style.top=.5*a.height+u+"px");a.parentNode.appendChild(f);setTimeout(function(){n.focus()},10);return f};l.search_limit=-1;l.prototype.showSearchBox=function(a){function b(b){if(b)if(e.onSearchBoxSelection)e.onSearchBoxSelection(b,a,g);else{var c=f.searchbox_extras[b.toLowerCase()];c&&(b=c.type);g.graph.beforeChange();if(b=f.createNode(b))b.pos=g.convertEventToCanvasOffset(a),
g.graph.add(b);if(c&&c.data){if(c.data.properties)for(var d in c.data.properties)b.addProperty(d,c.data.properties[d]);if(c.data.inputs)for(d in b.inputs=[],c.data.inputs)b.addOutput(c.data.inputs[d][0],c.data.inputs[d][1]);if(c.data.outputs)for(d in b.outputs=[],c.data.outputs)b.addOutput(c.data.outputs[d][0],c.data.outputs[d][1]);c.data.title&&(b.title=c.data.title);c.data.json&&b.configure(c.data.json);g.graph.afterChange()}}n.close()}function c(a){var b=p;p&&p.classList.remove("selected");p?(p=
a?p.nextSibling:p.previousSibling)||(p=b):p=a?t.childNodes[0]:t.childNodes[t.childNodes.length];p&&(p.classList.add("selected"),p.scrollIntoView({block:"end",behavior:"smooth"}))}function d(){function a(a,c){var d=document.createElement("div");m||(m=a);d.innerText=a;d.dataset.type=escape(a);d.className="litegraph lite-search-item";c&&(d.className+=" "+c);d.addEventListener("click",function(a){b(unescape(this.dataset.type))});t.appendChild(d)}q=null;var c=r.value;m=null;t.innerHTML="";if(c)if(e.onSearchBox){var d=
e.onSearchBox(t,c,g);if(d)for(var h=0;h<d.length;++h)a(d[h])}else{d=function(a){var b=f.registered_node_types[a];return n&&b.filter!=n?!1:-1!==a.toLowerCase().indexOf(c)};var k=0;c=c.toLowerCase();var n=g.filter||g.graph.filter;for(h in f.searchbox_extras){var p=f.searchbox_extras[h];if(-1!==p.desc.toLowerCase().indexOf(c)){var u=f.registered_node_types[p.type];if(!u||u.filter==n)if(a(p.desc,"searchbox_extra"),-1!==l.search_limit&&k++>l.search_limit)break}}p=null;if(Array.prototype.filter)p=Object.keys(f.registered_node_types).filter(d);
else for(h in p=[],f.registered_node_types)d(h)&&p.push(h);for(h=0;h<p.length&&!(a(p[h]),-1!==l.search_limit&&k++>l.search_limit);h++);}}var e=this,g=l.active_canvas,h=g.canvas,k=h.ownerDocument||document,n=document.createElement("div");n.className="litegraph litesearchbox graphdialog rounded";n.innerHTML="<span class='name'>Search</span> <input autofocus type='text' class='value rounded'/><div class='helper'></div>";n.close=function(){e.search_box=null;k.body.focus();k.body.style.overflow="";setTimeout(function(){e.canvas.focus()},
20);n.parentNode&&n.parentNode.removeChild(n)};var u=null;1<this.ds.scale&&(n.style.transform="scale("+this.ds.scale+")");n.addEventListener("mouseenter",function(a){u&&(clearTimeout(u),u=null)});n.addEventListener("mouseleave",function(a){u=setTimeout(function(){n.close()},500)});e.search_box&&e.search_box.close();e.search_box=n;var t=n.querySelector(".helper"),m=null,q=null,p=null,r=n.querySelector("input");r&&(r.addEventListener("blur",function(a){this.focus()}),r.addEventListener("keydown",function(a){if(38==
a.keyCode)c(!1);else if(40==a.keyCode)c(!0);else if(27==a.keyCode)n.close();else if(13==a.keyCode)p?b(p.innerHTML):m?b(m):n.close();else{q&&clearInterval(q);q=setTimeout(d,10);return}a.preventDefault();a.stopPropagation();a.stopImmediatePropagation();return!0}));k.fullscreenElement?k.fullscreenElement.appendChild(n):(k.body.appendChild(n),k.body.style.overflow="hidden");h=h.getBoundingClientRect();var w=(a?a.clientY:h.top+.5*h.height)-20;n.style.left=(a?a.clientX:h.left+.5*h.width)-80+"px";n.style.top=
w+"px";a.layerY>h.height-200&&(t.style.maxHeight=h.height-a.layerY-20+"px");r.focus();return n};l.prototype.showEditPropertyValue=function(a,b,c){function d(){e(m.value)}function e(d){g&&g.values&&g.values.constructor===Object&&void 0!=g.values[d]&&(d=g.values[d]);"number"==typeof a.properties[b]&&(d=Number(d));if("array"==h||"object"==h)d=JSON.parse(d);a.properties[b]=d;a.graph&&a.graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,d);if(c.onclose)c.onclose();p.close();a.setDirtyCanvas(!0,
!0)}if(a&&void 0!==a.properties[b]){c=c||{};var g=a.getPropertyInfo(b),h=g.type,f="";if("string"==h||"number"==h||"array"==h||"object"==h)f="<input autofocus type='text' class='value'/>";else if("enum"!=h&&"combo"!=h||!g.values)if("boolean"==h)f="<input autofocus type='checkbox' class='value' "+(a.properties[b]?"checked":"")+"/>";else{console.warn("unknown type: "+h);return}else{f="<select autofocus type='text' class='value'>";for(var n in g.values){var l=n;g.values.constructor===Array&&(l=g.values[n]);
f+="<option value='"+l+"' "+(l==a.properties[b]?"selected":"")+">"+g.values[n]+"</option>"}f+="</select>"}var p=this.createDialog("<span class='name'>"+(g.label?g.label:b)+"</span>"+f+"<button>OK</button>",c);if("enum"!=h&&"combo"!=h||!g.values)if("boolean"==h)(m=p.querySelector("input"))&&m.addEventListener("click",function(a){e(!!m.checked)});else{if(m=p.querySelector("input"))m.addEventListener("blur",function(a){this.focus()}),l=void 0!==a.properties[b]?a.properties[b]:"","string"!==h&&(l=JSON.stringify(l)),
m.value=l,m.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())})}else{var m=p.querySelector("select");m.addEventListener("change",function(a){e(a.target.value)})}p.querySelector("button").addEventListener("click",d);return p}};l.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;a=this.canvas.getBoundingClientRect();var d=-20,e=-20;a&&(d-=a.left,e-=a.top);b.position?(d+=b.position[0],
e+=b.position[1]):b.event?(d+=b.event.clientX,e+=b.event.clientY):(d+=.5*this.canvas.width,e+=.5*this.canvas.height);c.style.left=d+"px";c.style.top=e+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};l.prototype.createPanel=function(a,b){b=b||{};var c=b.window||window,d=document.createElement("div");d.className="litegraph dialog";d.innerHTML="<div class='dialog-header'><span class='dialog-title'></span></div><div class='dialog-content'></div><div class='dialog-footer'></div>";
d.header=d.querySelector(".dialog-header");b.width&&(d.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(d.style.height=b.height+(b.height.constructor===Number?"px":""));b.closable&&(b=document.createElement("span"),b.innerHTML="&#10005;",b.classList.add("close"),b.addEventListener("click",function(){d.close()}),d.header.appendChild(b));d.title_element=d.querySelector(".dialog-title");d.title_element.innerText=a;d.content=d.querySelector(".dialog-content");d.footer=d.querySelector(".dialog-footer");
d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};d.clear=function(){this.content.innerHTML=""};d.addHTML=function(a,b,c){var e=document.createElement("div");b&&(e.className=b);e.innerHTML=a;c?d.footer.appendChild(e):d.content.appendChild(e);return e};d.addButton=function(a,b,c){var e=document.createElement("button");e.innerText=a;e.options=c;e.classList.add("btn");e.addEventListener("click",b);d.footer.appendChild(e);return e};d.addSeparator=function(){var a=document.createElement("div");
a.className="separator";d.content.appendChild(a)};d.addWidget=function(a,b,h,k,n){function e(a,b){console.log("change",a,b);k.callback&&k.callback(a,b);n&&n(a,b)}k=k||{};var g=String(h);a=a.toLowerCase();"number"==a&&(g=h.toFixed(3));var m=document.createElement("div");m.className="property";m.innerHTML="<span class='property_name'></span><span class='property_value'></span>";m.querySelector(".property_name").innerText=k.label||b;var p=m.querySelector(".property_value");p.innerText=g;m.dataset.property=
b;m.dataset.type=k.type||a;m.options=k;m.value=h;if("boolean"==a)m.classList.add("boolean"),h&&m.classList.add("bool-on"),m.addEventListener("click",function(){var a=this.dataset.property;this.value=!this.value;this.classList.toggle("bool-on");this.querySelector(".property_value").innerText=this.value?"true":"false";e(a,this.value)});else if("string"==a||"number"==a)p.setAttribute("contenteditable",!0),p.addEventListener("keydown",function(a){"Enter"==a.code&&(a.preventDefault(),this.blur())}),p.addEventListener("blur",
function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));e(b,a)});else if("enum"==a||"combo"==a)g=l.getPropertyPrintableValue(h,k.values),p.innerText=g,p.addEventListener("click",function(a){var b=this.parentNode.dataset.property,d=this;new f.ContextMenu(k.values||[],{event:a,className:"dark",callback:function(a,c,g){d.innerText=a;e(b,a);return!1}},c)});d.content.appendChild(m);return m};return d};l.getPropertyPrintableValue=function(a,
b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",d;for(d in b)if(b[d]==a){c=d;break}return String(a)+" ("+c+")"}};l.prototype.showShowNodePanel=function(a){window.SELECTED_NODE=a;var b=document.querySelector("#node-panel");b&&b.close();var c=this.getCanvasWindow();b=this.createPanel(a.title||"",{closable:!0,window:c});b.id="node-panel";b.node=a;b.classList.add("settings");var d=this;(function(){b.content.innerHTML="";b.addHTML("<span class='node_type'>"+a.type+
"</span><span class='node_desc'>"+(a.constructor.desc||"")+"</span><span class='separator'></span>");b.addHTML("<h3>Properties</h3>");for(var c in a.properties){var g=a.properties[c],f=a.getPropertyInfo(c);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(c,b)||b.addWidget(f.widget||f.type,c,g,f,function(b,c){d.graph.beforeChange(a);a.setProperty(b,c);d.graph.afterChange();d.dirty_canvas=!0})}b.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(b);b.addButton("Delete",function(){a.block_delete||
(a.graph.remove(a),b.close())}).classList.add("delete")})();this.canvas.parentNode.appendChild(b)};l.prototype.showSubgraphPropertiesDialog=function(a){function b(){d.clear();if(a.inputs)for(var c=0;c<a.inputs.length;++c){var g=a.inputs[c];if(!g.not_subgraph_input){var f=d.addHTML("<button>&#10005;</button> <span class='bullet_icon'></span><span class='name'></span><span class='type'></span>","subgraph_property");f.dataset.name=g.name;f.dataset.slot=c;f.querySelector(".name").innerText=g.name;f.querySelector(".type").innerText=
g.type;f.querySelector("button").addEventListener("click",function(c){a.removeInput(Number(this.parentNode.dataset.slot));b()})}}}console.log("showing subgraph properties dialog");var c=this.canvas.parentNode.querySelector(".subgraph_dialog");c&&c.close();var d=this.createPanel("Subgraph Inputs",{closable:!0,width:500});d.node=a;d.classList.add("subgraph_dialog");d.addHTML(" + <span class='label'>Name</span><input class='name'/><span class='label'>Type</span><input class='type'></input><button>+</button>",
"subgraph_property extra",!0).querySelector("button").addEventListener("click",function(c){c=this.parentNode;var d=c.querySelector(".name").value,e=c.querySelector(".type").value;d&&-1==a.findInputSlot(d)&&(a.addInput(d,e),c.querySelector(".name").value="",c.querySelector(".type").value="",b())});b();this.canvas.parentNode.appendChild(d);return d};l.prototype.checkPanels=function(){if(this.canvas)for(var a=this.canvas.parentNode.querySelectorAll(".litegraph.dialog"),b=0;b<a.length;++b){var c=a[b];
c.node&&(c.node.graph&&c.graph==this.graph||c.close())}};l.onMenuNodeCollapse=function(a,b,c,d,e){e.graph.beforeChange(e);e.collapse();e.graph.afterChange(e)};l.onMenuNodePin=function(a,b,c,d,e){e.pin()};l.onMenuNodeMode=function(a,b,c,d,e){new f.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode=f.ON_EVENT;break;case "On Trigger":e.mode=f.ON_TRIGGER;break;case "Never":e.mode=f.NEVER;break;default:e.mode=f.ALWAYS}},parentMenu:d,
node:e});return!1};l.onMenuNodeColors=function(a,b,c,d,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"<span style='display: block; padding-left: 4px;'>No color</span>"});for(var g in l.node_colors)a=l.node_colors[g],a={value:g,content:"<span style='display: block; color: #999; padding-left: 4px; border-left: 8px solid "+a.color+"; background-color:"+a.bgcolor+"'>"+g+"</span>"},b.push(a);new f.ContextMenu(b,{event:c,callback:function(a){e&&((a=a.value?l.node_colors[a.value]:null)?
e.constructor===f.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:d,node:e});return!1};l.onMenuNodeShapes=function(a,b,c,d,e){if(!e)throw"no node passed";new f.ContextMenu(f.VALID_SHAPES,{event:c,callback:function(a){e&&(e.graph.beforeChange(e),e.shape=a,e.graph.afterChange(e),e.setDirtyCanvas(!0))},parentMenu:d,node:e});return!1};l.onMenuNodeRemove=function(a,b,c,d,e){if(!e)throw"no node passed";!1!==e.removable&&
(a=e.graph,a.beforeChange(),a.remove(e),a.afterChange(),e.setDirtyCanvas(!0,!0))};l.onMenuNodeToSubgraph=function(a,b,c,d,e){a=e.graph;if(b=l.active_canvas)c=Object.values(b.selected_nodes||{}),c.length||(c=[e]),d=f.createNode("graph/subgraph"),d.pos=e.pos.concat(),a.add(d),d.buildFromNodes(c),b.deselectAllNodes(),e.setDirtyCanvas(!0,!0)};l.onMenuNodeClone=function(a,b,c,d,e){0!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.beforeChange(),e.graph.add(a),e.graph.afterChange(),e.setDirtyCanvas(!0,
!0))};l.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",
groupcolor:"#444"}};l.prototype.getCanvasMenuOptions=function(){if(this.getMenuOptions)var a=this.getMenuOptions();else a=[{content:"Add Node",has_submenu:!0,callback:l.onMenuAdd},{content:"Add Group",callback:l.onGroupAdd}],this._graph_stack&&0<this._graph_stack.length&&a.push(null,{content:"Close subgraph",callback:this.closeSubgraph.bind(this)});if(this.getExtraMenuOptions){var b=this.getExtraMenuOptions(this,a);b&&(a=a.concat(b))}return a};l.prototype.getNodeMenuOptions=function(a){var b=null;
b=a.getMenuOptions?a.getMenuOptions(this):[{content:"Inputs",has_submenu:!0,disabled:!0,callback:l.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,disabled:!0,callback:l.showMenuNodeOptionalOutputs},null,{content:"Properties",has_submenu:!0,callback:l.onShowMenuNodeProperties},null,{content:"Title",callback:l.onShowPropertyEditor},{content:"Mode",has_submenu:!0,callback:l.onMenuNodeMode},{content:"Resize",callback:function(){if(a.resizable)return l.onResizeNode}},{content:"Collapse",
callback:l.onMenuNodeCollapse},{content:"Pin",callback:l.onMenuNodePin},{content:"Colors",has_submenu:!0,callback:l.onMenuNodeColors},{content:"Shapes",has_submenu:!0,callback:l.onMenuNodeShapes},null];if(a.onGetInputs){var c=a.onGetInputs();c&&c.length&&(b[0].disabled=!1)}a.onGetOutputs&&(c=a.onGetOutputs())&&c.length&&(b[1].disabled=!1);a.getExtraMenuOptions&&(c=a.getExtraMenuOptions(this,b))&&(c.push(null),b=c.concat(b));!1!==a.clonable&&b.push({content:"Clone",callback:l.onMenuNodeClone});b.push(null,
{content:"Remove",disabled:!(!1!==a.removable&&!a.block_delete),callback:l.onMenuNodeRemove});if(a.graph&&a.graph.onGetNodeMenuOptions)a.graph.onGetNodeMenuOptions(b,a);return b};l.prototype.getGroupMenuOptions=function(a){return[{content:"Title",callback:l.onShowPropertyEditor},{content:"Color",has_submenu:!0,callback:l.onMenuNodeColors},{content:"Font size",property:"font_size",type:"Number",callback:l.onShowPropertyEditor},null,{content:"Remove",callback:l.onMenuNodeRemove}]};l.prototype.processContextMenu=
function(a,b){var c=this,d=l.active_canvas.getCanvasWindow(),e=null,g={event:b,callback:function(b,d,e){if(b)if("Remove Slot"==b.content)b=b.slot,b.input?a.removeInput(b.slot):b.output&&a.removeOutput(b.slot);else if("Disconnect Links"==b.content)b=b.slot,b.output?a.disconnectOutput(b.slot):b.input&&a.disconnectInput(b.slot);else if("Rename Slot"==b.content){b=b.slot;var g=b.input?a.getInputInfo(b.slot):a.getOutputInfo(b.slot),f=c.createDialog("<span class='name'>Name</span><input autofocus type='text'/><button>OK</button>",
d),h=f.querySelector("input");h&&g&&(h.value=g.label||"");f.querySelector("button").addEventListener("click",function(a){h.value&&(g&&(g.label=h.value),c.setDirty(!0));f.close()})}},extra:a};a&&(g.title=a.type);var h=null;a&&(h=a.getSlotInPosition(b.canvasX,b.canvasY),l.active_node=a);h?(e=[],a.getSlotMenuOptions?e=a.getSlotMenuOptions(h):(h&&h.output&&h.output.links&&h.output.links.length&&e.push({content:"Disconnect Links",slot:h}),b=h.input||h.output,e.push(b.locked?"Cannot remove":{content:"Remove Slot",
slot:h}),e.push(b.nameLocked?"Cannot rename":{content:"Rename Slot",slot:h})),g.title=(h.input?h.input.type:h.output.type)||"*",h.input&&h.input.type==f.ACTION&&(g.title="Action"),h.output&&h.output.type==f.EVENT&&(g.title="Event")):a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(h=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:h,options:this.getGroupMenuOptions(h)}}));e&&new f.ContextMenu(e,g,d)};"undefined"!=
typeof window&&window.CanvasRenderingContext2D&&!window.CanvasRenderingContext2D.prototype.roundRect&&(window.CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e,g){var f,k;if(0===e)this.rect(a,b,c,d);else{void 0===g&&(g=e);if(null!=e&&e.constructor===Array)if(1==e.length)var n=f=k=g=e[0];else if(2==e.length)n=g=e[0],f=k=e[1];else if(4==e.length)n=e[0],f=e[1],k=e[2],g=e[3];else return;else n=e||0,f=e||0,k=g||0,g=g||0;this.moveTo(a+n,b);this.lineTo(a+c-f,b);this.quadraticCurveTo(a+c,b,
a+c,b+f);this.lineTo(a+c,b+d-g);this.quadraticCurveTo(a+c,b+d,a+c-g,b+d);this.lineTo(a+g,b+d);this.quadraticCurveTo(a,b+d,a,b+d-k);this.lineTo(a,b+k);this.quadraticCurveTo(a,b,a+n,b)}});f.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};f.distance=J;f.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")+")"};f.isInsideRectangle=C;f.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)};f.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};f.overlapBounding=H;f.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,d,e,g=0;6>g;g+=2)d="0123456789ABCDEF".indexOf(a.charAt(g)),e="0123456789ABCDEF".indexOf(a.charAt(g+1)),b[c]=16*d+e,c++;return b};f.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};E.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;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,g,c.node);!0===e&&(d=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(e=b.callback.call(this,b,c,a,g,c.extra),!0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";
new g.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:g,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!g.lock&&g.close()}var g=this;c=c||{};var f=document.createElement("div");f.className="litemenu-entry submenu";var k=!1;if(null===b)f.classList.add("separator");else{f.innerHTML=b&&b.title?b.title:a;if(f.value=b)b.disabled&&(k=!0,f.classList.add("disabled")),(b.submenu||b.has_submenu)&&
f.classList.add("has_submenu");"function"==typeof b?(f.dataset.value=a,f.onclick_callback=b):f.dataset.value=b;b.className&&(f.className+=" "+b.className)}this.root.appendChild(f);k||f.addEventListener("click",e);c.autoopen&&f.addEventListener("mouseenter",d);return f};E.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&&!E.isCursorOverElement(a,
this.parentMenu.root)&&E.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};E.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};E.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};E.prototype.getFirstEvent=
function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};E.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&a<b.top+b.height&&c>b.left&&c<b.left+b.width?!0:!1:!1};f.ContextMenu=E;f.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=0;c<b.length;c++)b[c].close?b[c].close():b[c].parentNode&&
b[c].parentNode.removeChild(b[c])}};f.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)))};G.sampleCurve=function(a,b){if(b){for(var c=0;c<b.length-1;++c){var d=
b[c],e=b[c+1];if(!(e[0]<a)){b=e[0]-d[0];if(1E-5>Math.abs(b))return d[1];a=(a-d[0])/b;return d[1]*(1-a)+e[1]*a}}return 0}};G.prototype.draw=function(a,b,c,d,e,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;e=e||"#666";a.save();a.translate(this.margin,this.margin);d&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333",a.strokeRect(0,0,g,b));a.strokeStyle=e;f&&(a.globalAlpha=.5);a.beginPath();for(d=0;d<c.length;++d)e=
c[d],a.lineTo(e[0]*g,(1-e[1])*b);a.stroke();a.globalAlpha=1;if(!f)for(d=0;d<c.length;++d)e=c[d],a.fillStyle=this.selected==d?"#FFF":this.nearest==d?"#DDD":"#AAA",a.beginPath(),a.arc(e[0]*g,(1-e[1])*b,2,0,2*Math.PI),a.fill();a.restore()}};G.prototype.onMouseDown=function(a,b){var c=this.points;if(c&&!(0>a[1])){var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,f=a[0]-this.margin;a=a[1]-this.margin;this.selected=this.getCloserPoint([f,a],30/b.ds.scale);-1==this.selected&&(b=[f/d,1-a/e],c.push(b),
c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0);if(-1!=this.selected)return!0}};G.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var d=this.selected;if(!(0>d)){var e=(a[0]-this.margin)/(this.size[0]-2*this.margin),f=(a[1]-this.margin)/(this.size[1]-2*this.margin);this._nearest=this.getCloserPoint([a[0]-this.margin,a[1]-this.margin],30/b.ds.scale);if(b=c[d]){var h=0==d||d==c.length-1;!h&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+
10)?(c.splice(d,1),this.selected=-1):(b[0]=h?0==d?0:1:Math.clamp(e,0,1),b[1]=1-Math.clamp(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};G.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};G.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,f=c.length,h=[0,0],k=1E6,l=-1,p=0;p<f;++p){var q=c[p];h[0]=q[0]*d;h[1]=(1-q[1])*e;q=vec2.distance(a,h);
q>k||q>b||(l=p,k=q)}return l};f.CurveEditor=G;f.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").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);
b)){b=b.substr(0,30);a.font="14px Courier New";var d=a.measureText(b).width+20;a.shadowColor="black";a.shadowOffsetX=2;a.shadowOffsetY=2;a.shadowBlur=3;a.fillStyle="#454";a.beginPath();a.roundRect(c[0]-.5*d,c[1]-15-24,d,24,[3]);a.moveTo(c[0]-10,c[1]-15);a.lineTo(c[0]+10,c[1]-15);a.lineTo(c[0],c[1]-5);a.fill();a.shadowColor="transparent";a.textAlign="center";a.fillStyle="#CEC";a.fillText(b,c[0],c[1]-15-24*.3)}};var x=new Float32Array(4);l.prototype.drawNodeShape=function(a,b,c,d,e,g,h){b.strokeStyle=
d;b.fillStyle=e;e=f.NODE_TITLE_HEIGHT;var k=.5>this.ds.scale,n=a._shape||a.constructor.shape||f.ROUND_SHAPE,u=a.constructor.title_mode,t=!0;u==f.TRANSPARENT_TITLE?t=!1:u==f.AUTOHIDE_TITLE&&h&&(t=!0);x[0]=0;x[1]=t?-e:0;x[2]=c[0]+1;x[3]=t?c[1]+e:c[1];h=b.globalAlpha;b.beginPath();n==f.BOX_SHAPE||k?b.fillRect(x[0],x[1],x[2],x[3]):n==f.ROUND_SHAPE||n==f.CARD_SHAPE?b.roundRect(x[0],x[1],x[2],x[3],n==f.CARD_SHAPE?[this.round_radius,this.round_radius,0,0]:[this.round_radius]):n==f.CIRCLE_SHAPE&&b.arc(.5*
c[0],.5*c[1],.5*c[0],0,2*Math.PI);b.fill();a.flags.collapsed||(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,x[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(t||u==f.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,e,c,this.ds.scale,d);else if(u!=f.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){t=a.constructor.title_color||d;a.flags.collapsed&&(b.shadowColor=f.DEFAULT_SHADOW_COLOR);
if(this.use_gradients){var m=l.gradients[t];m||(m=l.gradients[t]=b.createLinearGradient(0,0,400,0),m.addColorStop(0,t),m.addColorStop(1,"#000"));b.fillStyle=m}else b.fillStyle=t;b.beginPath();n==f.BOX_SHAPE||k?b.rect(0,-e,c[0]+1,e):(n==f.ROUND_SHAPE||n==f.CARD_SHAPE)&&b.roundRect(0,-e,c[0]+1,e,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}if(a.onDrawTitleBox)a.onDrawTitleBox(b,e,c,this.ds.scale);else n==f.ROUND_SHAPE||n==f.CIRCLE_SHAPE||
n==f.CARD_SHAPE?(k&&(b.fillStyle="black",b.beginPath(),b.arc(.5*e,-.5*e,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,k?b.fillRect(.5*e-5,-.5*e-5,10,10):(b.beginPath(),b.arc(.5*e,-.5*e,5,0,2*Math.PI),b.fill())):(k&&(b.fillStyle="black",b.fillRect(.5*(e-10)-1,-.5*(e+10)-1,12,12)),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(e-10),-.5*(e+10),10,10));b.globalAlpha=h;if(a.onDrawTitleText)a.onDrawTitleText(b,e,c,this.ds.scale,this.title_text_font,g);!k&&(b.font=
this.title_text_font,h=String(a.getTitle()))&&(b.fillStyle=g?f.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(h),b.fillText(h.substr(0,20),e,f.NODE_TITLE_TEXT_Y-e),b.textAlign="left"):(b.textAlign="left",b.fillText(h,e,f.NODE_TITLE_TEXT_Y-e)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(h=f.NODE_TITLE_HEIGHT,t=a.size[0]-h,m=f.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],
t+2,-h+2,h-4,h-4),b.fillStyle=m?"#888":"#555",n==f.BOX_SHAPE||k?b.fillRect(t+2,-h+2,h-4,h-4):(b.beginPath(),b.roundRect(t+2,-h+2,h-4,h-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(t+.2*h,.6*-h),b.lineTo(t+.8*h,.6*-h),b.lineTo(t+.5*h,.3*-h),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(g){if(a.onBounding)a.onBounding(x);u==f.TRANSPARENT_TITLE&&(x[1]-=e,x[3]+=e);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();n==f.BOX_SHAPE?b.rect(-6+x[0],-6+x[1],12+x[2],12+x[3]):n==f.ROUND_SHAPE||n==f.CARD_SHAPE&&
a.flags.collapsed?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius]):n==f.CARD_SHAPE?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius,2,2*this.round_radius,2]):n==f.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0]+6,0,2*Math.PI);b.strokeStyle=f.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=d;b.globalAlpha=1}};var I=new Float32Array(4),B=new Float32Array(4),L=new Float32Array(2),M=new Float32Array(2);l.prototype.drawConnections=function(a){var b=f.getTime(),c=this.visible_area;
I[0]=c[0]-20;I[1]=c[1]-20;I[2]=c[2]+40;I[3]=c[3]+40;a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;c=this.graph._nodes;for(var d=0,e=c.length;d<e;++d){var g=c[d];if(g.inputs&&g.inputs.length)for(var h=0;h<g.inputs.length;++h){var k=g.inputs[h];if(k&&null!=k.link&&(k=this.graph.links[k.link])){var n=this.graph.getNodeById(k.origin_id);if(null!=n){var u=k.origin_slot;var t=-1==u?[n.pos[0]+10,n.pos[1]+10]:n.getConnectionPos(!1,u,L);var m=g.getConnectionPos(!0,
h,M);B[0]=t[0];B[1]=t[1];B[2]=m[0]-t[0];B[3]=m[1]-t[1];0>B[2]&&(B[0]+=B[2],B[2]=Math.abs(B[2]));0>B[3]&&(B[1]+=B[3],B[3]=Math.abs(B[3]));if(H(B,I)){var l=n.outputs[u];u=g.inputs[h];if(l&&u&&(n=l.dir||(n.horizontal?f.DOWN:f.RIGHT),u=u.dir||(g.horizontal?f.UP:f.LEFT),this.renderLink(a,t,m,k,!1,0,null,n,u),k&&k._last_time&&1E3>b-k._last_time)){l=2-.002*(b-k._last_time);var v=a.globalAlpha;a.globalAlpha=v*l;this.renderLink(a,t,m,k,!0,l,"white",n,u);a.globalAlpha=v}}}}}}a.globalAlpha=1};l.prototype.renderLink=
function(a,b,c,d,e,g,h,k,n,u){d&&this.visible_links.push(d);!h&&d&&(h=d.color||l.link_type_colors[d.type]);h||(h=this.default_link_color);null!=d&&this.highlighted_links[d.id]&&(h="#FFF");k=k||f.RIGHT;n=n||f.LEFT;var t=J(b,c);this.render_connections_border&&.6<this.ds.scale&&(a.lineWidth=this.connections_width+4);a.lineJoin="round";u=u||1;1<u&&(a.lineWidth=.5);a.beginPath();for(var m=0;m<u;m+=1){var r=5*(m-.5*(u-1));if(this.links_render_mode==f.SPLINE_LINK){a.moveTo(b[0],b[1]+r);var v=0,q=0,p=0,A=
0;switch(k){case f.LEFT:v=-.25*t;break;case f.RIGHT:v=.25*t;break;case f.UP:q=-.25*t;break;case f.DOWN:q=.25*t}switch(n){case f.LEFT:p=-.25*t;break;case f.RIGHT:p=.25*t;break;case f.UP:A=-.25*t;break;case f.DOWN:A=.25*t}a.bezierCurveTo(b[0]+v,b[1]+q+r,c[0]+p,c[1]+A+r,c[0],c[1]+r)}else if(this.links_render_mode==f.LINEAR_LINK){a.moveTo(b[0],b[1]+r);A=p=q=v=0;switch(k){case f.LEFT:v=-1;break;case f.RIGHT:v=1;break;case f.UP:q=-1;break;case f.DOWN:q=1}switch(n){case f.LEFT:p=-1;break;case f.RIGHT:p=
1;break;case f.UP:A=-1;break;case f.DOWN:A=1}a.lineTo(b[0]+15*v,b[1]+15*q+r);a.lineTo(c[0]+15*p,c[1]+15*A+r);a.lineTo(c[0],c[1]+r)}else if(this.links_render_mode==f.STRAIGHT_LINK)a.moveTo(b[0],b[1]),r=b[0],v=b[1],q=c[0],p=c[1],k==f.RIGHT?r+=10:v+=10,n==f.LEFT?q-=10:p-=10,a.lineTo(r,v),a.lineTo(.5*(r+q),v),a.lineTo(.5*(r+q),p),a.lineTo(q,p),a.lineTo(c[0],c[1]);else return}this.render_connections_border&&.6<this.ds.scale&&!e&&(a.strokeStyle="rgba(0,0,0,0.5)",a.stroke());a.lineWidth=this.connections_width;
a.fillStyle=a.strokeStyle=h;a.stroke();e=this.computeConnectionPoint(b,c,.5,k,n);d&&d._pos&&(d._pos[0]=e[0],d._pos[1]=e[1]);.6<=this.ds.scale&&this.highquality_render&&n!=f.CENTER&&(this.render_connection_arrows&&(m=this.computeConnectionPoint(b,c,.25,k,n),t=this.computeConnectionPoint(b,c,.26,k,n),d=this.computeConnectionPoint(b,c,.75,k,n),u=this.computeConnectionPoint(b,c,.76,k,n),this.render_curved_connections?(t=-Math.atan2(t[0]-m[0],t[1]-m[1]),u=-Math.atan2(u[0]-d[0],u[1]-d[1])):u=t=c[1]>b[1]?
0:Math.PI,a.save(),a.translate(m[0],m[1]),a.rotate(t),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(d[0],d[1]),a.rotate(u),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill());if(g)for(a.fillStyle=h,m=0;5>m;++m)g=(.001*f.getTime()+.2*m)%1,e=this.computeConnectionPoint(b,c,g,k,n),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill()};l.prototype.computeConnectionPoint=
function(a,b,c,d,e){d=d||f.RIGHT;e=e||f.LEFT;var g=J(a,b),h=[a[0],a[1]],k=[b[0],b[1]];switch(d){case f.LEFT:h[0]+=-.25*g;break;case f.RIGHT:h[0]+=.25*g;break;case f.UP:h[1]+=-.25*g;break;case f.DOWN:h[1]+=.25*g}switch(e){case f.LEFT:k[0]+=-.25*g;break;case f.RIGHT:k[0]+=.25*g;break;case f.UP:k[1]+=-.25*g;break;case f.DOWN:k[1]+=.25*g}d=(1-c)*(1-c)*(1-c);e=3*(1-c)*(1-c)*c;g=3*(1-c)*c*c;c*=c*c;return[d*a[0]+e*h[0]+g*k[0]+c*b[0],d*a[1]+e*h[1]+g*k[1]+c*b[1]]};l.prototype.drawExecutionOrder=function(a){a.shadowColor=
"transparent";a.globalAlpha=.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=.75;for(var b=this.visible_nodes,c=0;c<b.length;++c){var d=b[c];a.fillStyle="black";a.fillRect(d.pos[0]-f.NODE_TITLE_HEIGHT,d.pos[1]-f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT);0==d.order&&a.strokeRect(d.pos[0]-f.NODE_TITLE_HEIGHT+.5,d.pos[1]-f.NODE_TITLE_HEIGHT+.5,f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT);a.fillStyle="#FFF";a.fillText(d.order,d.pos[0]+-.5*f.NODE_TITLE_HEIGHT,d.pos[1]-6)}a.globalAlpha=
1};l.prototype.drawNodeWidgets=function(a,b,c,d){if(!a.widgets||!a.widgets.length)return 0;var e=a.size[0],g=a.widgets;b+=2;var h=f.NODE_WIDGET_HEIGHT,k=.5<this.ds.scale;c.save();c.globalAlpha=this.editor_alpha;for(var n=f.WIDGET_OUTLINE_COLOR,l=f.WIDGET_BGCOLOR,t=f.WIDGET_TEXT_COLOR,m=f.WIDGET_SECONDARY_TEXT_COLOR,r=0;r<g.length;++r){var v=g[r],q=b;v.y&&(q=v.y);v.last_y=q;c.strokeStyle=n;c.fillStyle="#222";c.textAlign="left";v.disabled&&(c.globalAlpha*=.5);var p=v.width||e;switch(v.type){case "button":v.clicked&&
(c.fillStyle="#AAA",v.clicked=!1,this.dirty_canvas=!0);c.fillRect(15,q,p-30,h);k&&!v.disabled&&c.strokeRect(15,q,p-30,h);k&&(c.textAlign="center",c.fillStyle=t,c.fillText(v.name,.5*p,q+.7*h));break;case "toggle":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,[.5*h]):c.rect(15,b,p-30,h);c.fill();k&&!v.disabled&&c.stroke();c.fillStyle=v.value?"#89A":"#333";c.beginPath();c.arc(p-30,q+.5*h,.36*h,0,2*Math.PI);c.fill();k&&(c.fillStyle=m,null!=v.name&&c.fillText(v.name,
30,q+.7*h),c.fillStyle=v.value?t:m,c.textAlign="right",c.fillText(v.value?v.options.on||"true":v.options.off||"false",p-40,q+.7*h));break;case "slider":c.fillStyle=l;c.fillRect(15,q,p-30,h);var A=v.options.max-v.options.min,F=(v.value-v.options.min)/A;c.fillStyle=d==v?"#89A":"#678";c.fillRect(15,q,F*(p-30),h);k&&!v.disabled&&c.strokeRect(15,q,p-30,h);v.marker&&(A=(v.marker-v.options.min)/A,c.fillStyle="#AA9",c.fillRect(15+A*(p-30),q,2,h));k&&(c.textAlign="center",c.fillStyle=t,c.fillText(v.name+" "+
Number(v.value).toFixed(3),.5*p,q+.7*h));break;case "number":case "combo":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,[.5*h]):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.fillStyle=t,v.disabled||(c.beginPath(),c.moveTo(31,b+5),c.lineTo(21,b+.5*h),c.lineTo(31,b+h-5),c.fill(),c.beginPath(),c.moveTo(p-15-16,b+5),c.lineTo(p-15-6,b+.5*h),c.lineTo(p-15-16,b+h-5),c.fill()),c.fillStyle=m,c.fillText(v.name,35,q+.7*h),c.fillStyle=t,c.textAlign="right",
"number"==v.type?c.fillText(Number(v.value).toFixed(void 0!==v.options.precision?v.options.precision:3),p-30-20,q+.7*h):(A=v.value,v.options.values&&(F=v.options.values,F.constructor===Function&&(F=F()),F&&F.constructor!==Array&&(A=F[v.value])),c.fillText(A,p-30-20,q+.7*h)));break;case "string":case "text":c.textAlign="left";c.strokeStyle=n;c.fillStyle=l;c.beginPath();k?c.roundRect(15,b,p-30,h,[.5*h]):c.rect(15,b,p-30,h);c.fill();k&&(v.disabled||c.stroke(),c.save(),c.beginPath(),c.rect(15,b,p-30,
h),c.clip(),c.fillStyle=m,null!=v.name&&c.fillText(v.name,30,q+.7*h),c.fillStyle=t,c.textAlign="right",c.fillText(String(v.value).substr(0,30),p-30,q+.7*h),c.restore());break;default:v.draw&&v.draw(c,a,p,q,h)}b+=(v.computeSize?v.computeSize(p)[1]:h)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};l.prototype.processNodeWidgets=function(a,b,c,d){function e(d,e){d.value=e;d.options&&d.options.property&&void 0!==a.properties[d.options.property]&&a.setProperty(d.options.property,e);
d.callback&&d.callback(d.value,n,a,b,c)}if(!a.widgets||!a.widgets.length)return null;for(var g=b[0]-a.pos[0],h=b[1]-a.pos[1],k=a.size[0],n=this,l=this.getCanvasWindow(),t=0;t<a.widgets.length;++t){var m=a.widgets[t];if(m&&!m.disabled){var p=m.computeSize?m.computeSize(k)[1]:f.NODE_WIDGET_HEIGHT,q=m.width||k;if(m==d||!(6>g||g>q-12||h<m.last_y||h>m.last_y+p||void 0===m.last_y)){d=m.value;switch(m.type){case "button":"mousedown"===c.type&&(m.callback&&setTimeout(function(){m.callback(m,n,a,b,c)},20),
this.dirty_canvas=m.clicked=!0);break;case "slider":l=Math.clamp((g-15)/(q-30),0,1);m.value=m.options.min+(m.options.max-m.options.min)*l;m.callback&&setTimeout(function(){e(m,m.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=m.value;if("mousemove"==c.type&&"number"==m.type)m.value+=.1*c.deltaX*(m.options.step||1),null!=m.options.min&&m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max);else if("mousedown"==c.type){var r=
m.options.values;r&&r.constructor===Function&&(r=m.options.values(m,a));var w=null;"number"!=m.type&&(w=r.constructor===Array?r:Object.keys(r));g=40>g?-1:g>q-40?1:0;if("number"==m.type)m.value+=.1*g*(m.options.step||1),null!=m.options.min&&m.value<m.options.min&&(m.value=m.options.min),null!=m.options.max&&m.value>m.options.max&&(m.value=m.options.max);else if(g)l=-1,this.last_mouseclick=0,l=r.constructor===Object?w.indexOf(String(m.value))+g:w.indexOf(m.value)+g,l>=w.length&&(l=w.length-1),0>l&&
(l=0),m.value=r.constructor===Array?r[l]:l;else{var A=r!=w?Object.values(r):r;new f.ContextMenu(A,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){r!=w&&(a=A.indexOf(a));this.value=a;e(this,a);n.dirty_canvas=!0;return!1}.bind(m)},l)}}else"mouseup"==c.type&&"number"==m.type&&(g=40>g?-1:g>q-40?1:0,200>c.click_time&&0==g&&this.prompt("Value",m.value,function(a){this.value=Number(a);e(this,this.value)}.bind(m),c));d!=m.value&&setTimeout(function(){e(this,this.value)}.bind(m),
20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(m.value=!m.value,setTimeout(function(){e(m,m.value)},20));break;case "string":case "text":"mousedown"==c.type&&this.prompt("Value",m.value,function(a){this.value=a;e(this,a)}.bind(m),c,m.options?m.options.multiline:!1);break;default:m.mouse&&(this.dirty_canvas=m.mouse(c,[g,h],a))}if(d!=m.value){if(a.onWidgetChanged)a.onWidgetChanged(m.name,m.value,d,m);a.graph._version++}return m}}}return null};l.prototype.drawGroups=function(a,b){if(this.graph){a=
this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;for(var c=0;c<a.length;++c){var d=a[c];if(H(this.visible_area,d._bounding)){b.fillStyle=d.color||"#335";b.strokeStyle=d.color||"#335";var e=d._pos,g=d._size;b.globalAlpha=.25*this.editor_alpha;b.beginPath();b.rect(e[0]+.5,e[1]+.5,g[0],g[1]);b.fill();b.globalAlpha=this.editor_alpha;b.stroke();b.beginPath();b.moveTo(e[0]+g[0],e[1]+g[1]);b.lineTo(e[0]+g[0]-10,e[1]+g[1]);b.lineTo(e[0]+g[0],e[1]+g[1]-10);b.fill();g=d.font_size||f.DEFAULT_GROUP_FONT_SIZE;
b.font=g+"px Arial";b.fillText(d.title,e[0]+4,e[1]+g)}}b.restore()}};l.prototype.adjustNodesSize=function(){for(var a=this.graph._nodes,b=0;b<a.length;++b)a[b].size=a[b].computeSize();this.setDirty(!0,!0)};l.prototype.resize=function(a,b){a||b||(b=this.canvas.parentNode,a=b.offsetWidth,b=b.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)};l.prototype.switchLiveMode=
function(a){if(a){var b=this,c=this.live_mode?1.1:.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=.1);var d=setInterval(function(){b.editor_alpha*=c;b.dirty_canvas=!0;b.dirty_bgcanvas=!0;1>c&&.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1<c&&.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};l.prototype.onNodeSelectionChange=function(a){};l.prototype.touchHandler=function(a){var b=a.changedTouches[0];
switch(a.type){case "touchstart":var c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var d=this.getCanvasWindow(),e=d.document.createEvent("MouseEvent");e.initMouseEvent(c,!0,!0,d,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null);b.target.dispatchEvent(e);a.preventDefault()};l.onGroupAdd=function(a,b,c){a=l.active_canvas;a.getCanvasWindow();b=new f.LGraphGroup;b.pos=a.convertEventToCanvasOffset(c);a.graph.add(b)};l.onMenuAdd=function(a,
b,c,d,e){function g(a,b){var d=[];f.getNodeTypesCategories(h.filter||n.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var c=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===d.findIndex(function(a){return a.value===c})&&d.push({value:c,content:b,has_submenu:!0,callback:function(a,b,c,d){g(a.value,d)}})}});f.getNodeTypesInCategory(a.slice(0,-1),h.filter||n.filter).map(function(a){a.skip_list||d.push({value:a.type,
content:a.title,has_submenu:!1,callback:function(a,b,c,d){b=d.getFirstEvent();h.graph.beforeChange();if(a=f.createNode(a.value))a.pos=h.convertEventToCanvasOffset(b),h.graph.add(a);e&&e(a);h.graph.afterChange()}})});new f.ContextMenu(d,{event:c,parentMenu:b},k)}var h=l.active_canvas,k=h.getCanvasWindow(),n=h.graph;if(n)return g("",d),!1};l.onMenuCollapseAll=function(){};l.onMenuNodeEdit=function(){};l.showMenuNodeOptionalInputs=function(a,b,c,d,e){if(e){var g=this;a=l.active_canvas.getCanvasWindow();
b=e.optional_inputs;e.onGetInputs&&(b=e.onGetInputs());var h=[];if(b)for(var k=0;k<b.length;k++){var n=b[k];if(n){var u=n[0];n[2]&&n[2].label&&(u=n[2].label);u={content:u,value:n};n[1]==f.ACTION&&(u.className="event");h.push(u)}else h.push(null)}this.onMenuNodeInputs&&(h=this.onMenuNodeInputs(h));if(h.length)return new f.ContextMenu(h,{event:c,callback:function(a,b,c){e&&(a.callback&&a.callback.call(g,e,a,b,c),a.value&&(e.graph.beforeChange(),e.addInput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,
!0),e.graph.afterChange()))},parentMenu:d,node:e},a),!1;console.log("no input entries")}};l.showMenuNodeOptionalOutputs=function(a,b,c,d,e){function g(a,b,c){if(e&&(a.callback&&a.callback.call(h,e,a,b,c),a.value))if(c=a.value[1],!c||c.constructor!==Object&&c.constructor!==Array)e.graph.beforeChange(),e.addOutput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,!0),e.graph.afterChange();else{a=[];for(var k in c)a.push({content:k,value:c[k]});new f.ContextMenu(a,{event:b,callback:g,parentMenu:d,
node:e});return!1}}if(e){var h=this;a=l.active_canvas.getCanvasWindow();b=e.optional_outputs;e.onGetOutputs&&(b=e.onGetOutputs());var k=[];if(b)for(var n=0;n<b.length;n++){var u=b[n];if(!u)k.push(null);else if(!e.flags||!e.flags.skip_repeated_outputs||-1==e.findOutputSlot(u[0])){var t=u[0];u[2]&&u[2].label&&(t=u[2].label);t={content:t,value:u};u[1]==f.EVENT&&(t.className="event");k.push(t)}}this.onMenuNodeOutputs&&(k=this.onMenuNodeOutputs(k));if(k.length)return new f.ContextMenu(k,{event:c,callback:g,
parentMenu:d,node:e},a),!1}};l.onShowMenuNodeProperties=function(a,b,c,d,e){if(e&&e.properties){var g=l.active_canvas;b=g.getCanvasWindow();var h=[],k;for(k in e.properties){a=void 0!==e.properties[k]?e.properties[k]:" ";"object"==typeof a&&(a=JSON.stringify(a));var n=e.getPropertyInfo(k);if("enum"==n.type||"combo"==n.type)a=l.getPropertyPrintableValue(a,n.values);a=l.decodeHTML(a);h.push({content:"<span class='property_name'>"+(n.label?n.label:k)+"</span><span class='property_value'>"+a+"</span>",
value:k})}if(h.length)return new f.ContextMenu(h,{event:c,callback:function(a,b,c,d){e&&(b=this.getBoundingClientRect(),g.showEditPropertyValue(e,a.value,{position:[b.left,b.top]}))},parentMenu:d,allow_html:!0,node:e},b),!1}};l.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};l.onResizeNode=function(a,b,c,d,e){if(e){e.size=e.computeSize();if(e.onResize)e.onResize(e.size);e.setDirtyCanvas(!0,!0)}};l.prototype.showLinkMenu=function(a,b){var c=this;console.log(a);
var d=new f.ContextMenu(["Add Node",null,"Delete"],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,g,h){switch(b){case "Add Node":l.onMenuAdd(null,null,h,d,function(b){console.log("node autoconnect");var d=c.graph.getNodeById(a.origin_id),e=c.graph.getNodeById(a.target_id);b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&d.outputs[a.origin_slot].type==b.inputs[0].type&&b.outputs[0].type==e.inputs[0].type&&(d.connect(a.origin_slot,b,0),b.connect(0,e,a.target_slot),
b.pos[0]-=.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});return!1};l.onShowPropertyEditor=function(a,b,c,d,e){function g(){var b=n.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);e[h]=b;f.parentNode&&f.parentNode.removeChild(f);e.setDirtyCanvas(!0,!0)}var h=a.property||"title";b=e[h];var f=document.createElement("div");f.className="graphdialog";f.innerHTML="<span class='name'></span><input autofocus type='text' class='value'/><button>OK</button>";f.querySelector(".name").innerText=
h;var n=f.querySelector(".value");n&&(n.value=b,n.addEventListener("blur",function(a){this.focus()}),n.addEventListener("keydown",function(a){if(13==a.keyCode||"textarea"==a.target.localName)g(),a.preventDefault(),a.stopPropagation()}));b=l.active_canvas.canvas;c=b.getBoundingClientRect();var u=d=-20;c&&(d-=c.left,u-=c.top);event?(f.style.left=event.clientX+d+"px",f.style.top=event.clientY+u+"px"):(f.style.left=.5*b.width+d+"px",f.style.top=.5*b.height+u+"px");f.querySelector("button").addEventListener("click",
g);b.parentNode.appendChild(f)};l.prototype.prompt=function(a,b,c,d,e){var g=this;a=a||"";var h=!1,f=document.createElement("div");f.className="graphdialog rounded";f.innerHTML=e?"<span class='name'></span> <textarea autofocus class='value'></textarea><button class='rounded'>OK</button>":"<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>";f.close=function(){g.prompt_box=null;f.parentNode&&f.parentNode.removeChild(f)};1<this.ds.scale&&(f.style.transform=
"scale("+this.ds.scale+")");f.addEventListener("mouseleave",function(a){h||f.close()});g.prompt_box&&g.prompt_box.close();g.prompt_box=f;f.querySelector(".name").innerText=a;var n=f.querySelector(".value");n.value=b;n.addEventListener("keydown",function(a){h=!0;if(27==a.keyCode)f.close();else if(13==a.keyCode&&"textarea"!=a.target.localName)c&&c(this.value),f.close();else return;a.preventDefault();a.stopPropagation()});f.querySelector("button").addEventListener("click",function(a){c&&c(n.value);g.setDirty(!0);
f.close()});a=l.active_canvas.canvas;b=a.getBoundingClientRect();var u=e=-20;b&&(e-=b.left,u-=b.top);d?(f.style.left=d.clientX+e+"px",f.style.top=d.clientY+u+"px"):(f.style.left=.5*a.width+e+"px",f.style.top=.5*a.height+u+"px");a.parentNode.appendChild(f);setTimeout(function(){n.focus()},10);return f};l.search_limit=-1;l.prototype.showSearchBox=function(a){function b(b){if(b)if(e.onSearchBoxSelection)e.onSearchBoxSelection(b,a,g);else{var c=f.searchbox_extras[b.toLowerCase()];c&&(b=c.type);g.graph.beforeChange();
if(b=f.createNode(b))b.pos=g.convertEventToCanvasOffset(a),g.graph.add(b);if(c&&c.data){if(c.data.properties)for(var d in c.data.properties)b.addProperty(d,c.data.properties[d]);if(c.data.inputs)for(d in b.inputs=[],c.data.inputs)b.addOutput(c.data.inputs[d][0],c.data.inputs[d][1]);if(c.data.outputs)for(d in b.outputs=[],c.data.outputs)b.addOutput(c.data.outputs[d][0],c.data.outputs[d][1]);c.data.title&&(b.title=c.data.title);c.data.json&&b.configure(c.data.json);g.graph.afterChange()}}n.close()}
function c(a){var b=p;p&&p.classList.remove("selected");p?(p=a?p.nextSibling:p.previousSibling)||(p=b):p=a?t.childNodes[0]:t.childNodes[t.childNodes.length];p&&(p.classList.add("selected"),p.scrollIntoView({block:"end",behavior:"smooth"}))}function d(){function a(a,c){var d=document.createElement("div");m||(m=a);d.innerText=a;d.dataset.type=escape(a);d.className="litegraph lite-search-item";c&&(d.className+=" "+c);d.addEventListener("click",function(a){b(unescape(this.dataset.type))});t.appendChild(d)}
q=null;var c=r.value;m=null;t.innerHTML="";if(c)if(e.onSearchBox){var d=e.onSearchBox(t,c,g);if(d)for(var h=0;h<d.length;++h)a(d[h])}else{d=function(a){var b=f.registered_node_types[a];return n&&b.filter!=n?!1:-1!==a.toLowerCase().indexOf(c)};var k=0;c=c.toLowerCase();var n=g.filter||g.graph.filter;for(h in f.searchbox_extras){var p=f.searchbox_extras[h];if(-1!==p.desc.toLowerCase().indexOf(c)){var u=f.registered_node_types[p.type];if(!u||u.filter==n)if(a(p.desc,"searchbox_extra"),-1!==l.search_limit&&
k++>l.search_limit)break}}p=null;if(Array.prototype.filter)p=Object.keys(f.registered_node_types).filter(d);else for(h in p=[],f.registered_node_types)d(h)&&p.push(h);for(h=0;h<p.length&&!(a(p[h]),-1!==l.search_limit&&k++>l.search_limit);h++);}}var e=this,g=l.active_canvas,h=g.canvas,k=h.ownerDocument||document,n=document.createElement("div");n.className="litegraph litesearchbox graphdialog rounded";n.innerHTML="<span class='name'>Search</span> <input autofocus type='text' class='value rounded'/><div class='helper'></div>";
n.close=function(){e.search_box=null;k.body.focus();k.body.style.overflow="";setTimeout(function(){e.canvas.focus()},20);n.parentNode&&n.parentNode.removeChild(n)};var u=null;1<this.ds.scale&&(n.style.transform="scale("+this.ds.scale+")");n.addEventListener("mouseenter",function(a){u&&(clearTimeout(u),u=null)});n.addEventListener("mouseleave",function(a){u=setTimeout(function(){n.close()},500)});e.search_box&&e.search_box.close();e.search_box=n;var t=n.querySelector(".helper"),m=null,q=null,p=null,
r=n.querySelector("input");r&&(r.addEventListener("blur",function(a){this.focus()}),r.addEventListener("keydown",function(a){if(38==a.keyCode)c(!1);else if(40==a.keyCode)c(!0);else if(27==a.keyCode)n.close();else if(13==a.keyCode)p?b(p.innerHTML):m?b(m):n.close();else{q&&clearInterval(q);q=setTimeout(d,10);return}a.preventDefault();a.stopPropagation();a.stopImmediatePropagation();return!0}));k.fullscreenElement?k.fullscreenElement.appendChild(n):(k.body.appendChild(n),k.body.style.overflow="hidden");
h=h.getBoundingClientRect();var w=(a?a.clientY:h.top+.5*h.height)-20;n.style.left=(a?a.clientX:h.left+.5*h.width)-80+"px";n.style.top=w+"px";a.layerY>h.height-200&&(t.style.maxHeight=h.height-a.layerY-20+"px");r.focus();return n};l.prototype.showEditPropertyValue=function(a,b,c){function d(){e(m.value)}function e(d){g&&g.values&&g.values.constructor===Object&&void 0!=g.values[d]&&(d=g.values[d]);"number"==typeof a.properties[b]&&(d=Number(d));if("array"==h||"object"==h)d=JSON.parse(d);a.properties[b]=
d;a.graph&&a.graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,d);if(c.onclose)c.onclose();p.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var g=a.getPropertyInfo(b),h=g.type,f="";if("string"==h||"number"==h||"array"==h||"object"==h)f="<input autofocus type='text' class='value'/>";else if("enum"!=h&&"combo"!=h||!g.values)if("boolean"==h)f="<input autofocus type='checkbox' class='value' "+(a.properties[b]?"checked":"")+"/>";else{console.warn("unknown type: "+h);
return}else{f="<select autofocus type='text' class='value'>";for(var n in g.values){var l=n;g.values.constructor===Array&&(l=g.values[n]);f+="<option value='"+l+"' "+(l==a.properties[b]?"selected":"")+">"+g.values[n]+"</option>"}f+="</select>"}var p=this.createDialog("<span class='name'>"+(g.label?g.label:b)+"</span>"+f+"<button>OK</button>",c);if("enum"!=h&&"combo"!=h||!g.values)if("boolean"==h)(m=p.querySelector("input"))&&m.addEventListener("click",function(a){e(!!m.checked)});else{if(m=p.querySelector("input"))m.addEventListener("blur",
function(a){this.focus()}),l=void 0!==a.properties[b]?a.properties[b]:"","string"!==h&&(l=JSON.stringify(l)),m.value=l,m.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())})}else{var m=p.querySelector("select");m.addEventListener("change",function(a){e(a.target.value)})}p.querySelector("button").addEventListener("click",d);return p}};l.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=
a;a=this.canvas.getBoundingClientRect();var d=-20,e=-20;a&&(d-=a.left,e-=a.top);b.position?(d+=b.position[0],e+=b.position[1]):b.event?(d+=b.event.clientX,e+=b.event.clientY):(d+=.5*this.canvas.width,e+=.5*this.canvas.height);c.style.left=d+"px";c.style.top=e+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};l.prototype.createPanel=function(a,b){b=b||{};var c=b.window||window,d=document.createElement("div");d.className="litegraph dialog";
d.innerHTML="<div class='dialog-header'><span class='dialog-title'></span></div><div class='dialog-content'></div><div class='dialog-footer'></div>";d.header=d.querySelector(".dialog-header");b.width&&(d.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(d.style.height=b.height+(b.height.constructor===Number?"px":""));b.closable&&(b=document.createElement("span"),b.innerHTML="&#10005;",b.classList.add("close"),b.addEventListener("click",function(){d.close()}),d.header.appendChild(b));
d.title_element=d.querySelector(".dialog-title");d.title_element.innerText=a;d.content=d.querySelector(".dialog-content");d.footer=d.querySelector(".dialog-footer");d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};d.clear=function(){this.content.innerHTML=""};d.addHTML=function(a,b,c){var e=document.createElement("div");b&&(e.className=b);e.innerHTML=a;c?d.footer.appendChild(e):d.content.appendChild(e);return e};d.addButton=function(a,b,c){var e=document.createElement("button");
e.innerText=a;e.options=c;e.classList.add("btn");e.addEventListener("click",b);d.footer.appendChild(e);return e};d.addSeparator=function(){var a=document.createElement("div");a.className="separator";d.content.appendChild(a)};d.addWidget=function(a,b,h,k,n){function e(a,b){console.log("change",a,b);k.callback&&k.callback(a,b);n&&n(a,b)}k=k||{};var g=String(h);a=a.toLowerCase();"number"==a&&(g=h.toFixed(3));var m=document.createElement("div");m.className="property";m.innerHTML="<span class='property_name'></span><span class='property_value'></span>";
m.querySelector(".property_name").innerText=k.label||b;var p=m.querySelector(".property_value");p.innerText=g;m.dataset.property=b;m.dataset.type=k.type||a;m.options=k;m.value=h;if("boolean"==a)m.classList.add("boolean"),h&&m.classList.add("bool-on"),m.addEventListener("click",function(){var a=this.dataset.property;this.value=!this.value;this.classList.toggle("bool-on");this.querySelector(".property_value").innerText=this.value?"true":"false";e(a,this.value)});else if("string"==a||"number"==a)p.setAttribute("contenteditable",
!0),p.addEventListener("keydown",function(a){"Enter"==a.code&&(a.preventDefault(),this.blur())}),p.addEventListener("blur",function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));e(b,a)});else if("enum"==a||"combo"==a)g=l.getPropertyPrintableValue(h,k.values),p.innerText=g,p.addEventListener("click",function(a){var b=this.parentNode.dataset.property,d=this;new f.ContextMenu(k.values||[],{event:a,className:"dark",callback:function(a,
c,g){d.innerText=a;e(b,a);return!1}},c)});d.content.appendChild(m);return m};return d};l.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",d;for(d in b)if(b[d]==a){c=d;break}return String(a)+" ("+c+")"}};l.prototype.showShowNodePanel=function(a){window.SELECTED_NODE=a;var b=document.querySelector("#node-panel");b&&b.close();var c=this.getCanvasWindow();b=this.createPanel(a.title||"",{closable:!0,window:c});b.id="node-panel";b.node=
a;b.classList.add("settings");var d=this;(function(){b.content.innerHTML="";b.addHTML("<span class='node_type'>"+a.type+"</span><span class='node_desc'>"+(a.constructor.desc||"")+"</span><span class='separator'></span>");b.addHTML("<h3>Properties</h3>");for(var c in a.properties){var g=a.properties[c],f=a.getPropertyInfo(c);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(c,b)||b.addWidget(f.widget||f.type,c,g,f,function(b,c){d.graph.beforeChange(a);a.setProperty(b,c);d.graph.afterChange();d.dirty_canvas=
!0})}b.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(b);b.addButton("Delete",function(){a.block_delete||(a.graph.remove(a),b.close())}).classList.add("delete")})();this.canvas.parentNode.appendChild(b)};l.prototype.showSubgraphPropertiesDialog=function(a){function b(){d.clear();if(a.inputs)for(var c=0;c<a.inputs.length;++c){var g=a.inputs[c];if(!g.not_subgraph_input){var f=d.addHTML("<button>&#10005;</button> <span class='bullet_icon'></span><span class='name'></span><span class='type'></span>",
"subgraph_property");f.dataset.name=g.name;f.dataset.slot=c;f.querySelector(".name").innerText=g.name;f.querySelector(".type").innerText=g.type;f.querySelector("button").addEventListener("click",function(c){a.removeInput(Number(this.parentNode.dataset.slot));b()})}}}console.log("showing subgraph properties dialog");var c=this.canvas.parentNode.querySelector(".subgraph_dialog");c&&c.close();var d=this.createPanel("Subgraph Inputs",{closable:!0,width:500});d.node=a;d.classList.add("subgraph_dialog");
d.addHTML(" + <span class='label'>Name</span><input class='name'/><span class='label'>Type</span><input class='type'></input><button>+</button>","subgraph_property extra",!0).querySelector("button").addEventListener("click",function(c){c=this.parentNode;var d=c.querySelector(".name").value,e=c.querySelector(".type").value;d&&-1==a.findInputSlot(d)&&(a.addInput(d,e),c.querySelector(".name").value="",c.querySelector(".type").value="",b())});b();this.canvas.parentNode.appendChild(d);return d};l.prototype.checkPanels=
function(){if(this.canvas)for(var a=this.canvas.parentNode.querySelectorAll(".litegraph.dialog"),b=0;b<a.length;++b){var c=a[b];c.node&&(c.node.graph&&c.graph==this.graph||c.close())}};l.onMenuNodeCollapse=function(a,b,c,d,e){e.graph.beforeChange(e);e.collapse();e.graph.afterChange(e)};l.onMenuNodePin=function(a,b,c,d,e){e.pin()};l.onMenuNodeMode=function(a,b,c,d,e){new f.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(e)switch(a){case "On Event":e.mode=f.ON_EVENT;
break;case "On Trigger":e.mode=f.ON_TRIGGER;break;case "Never":e.mode=f.NEVER;break;default:e.mode=f.ALWAYS}},parentMenu:d,node:e});return!1};l.onMenuNodeColors=function(a,b,c,d,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"<span style='display: block; padding-left: 4px;'>No color</span>"});for(var g in l.node_colors)a=l.node_colors[g],a={value:g,content:"<span style='display: block; color: #999; padding-left: 4px; border-left: 8px solid "+a.color+"; background-color:"+a.bgcolor+
"'>"+g+"</span>"},b.push(a);new f.ContextMenu(b,{event:c,callback:function(a){e&&((a=a.value?l.node_colors[a.value]:null)?e.constructor===f.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:d,node:e});return!1};l.onMenuNodeShapes=function(a,b,c,d,e){if(!e)throw"no node passed";new f.ContextMenu(f.VALID_SHAPES,{event:c,callback:function(a){e&&(e.graph.beforeChange(e),e.shape=a,e.graph.afterChange(e),e.setDirtyCanvas(!0))},
parentMenu:d,node:e});return!1};l.onMenuNodeRemove=function(a,b,c,d,e){if(!e)throw"no node passed";!1!==e.removable&&(a=e.graph,a.beforeChange(),a.remove(e),a.afterChange(),e.setDirtyCanvas(!0,!0))};l.onMenuNodeToSubgraph=function(a,b,c,d,e){a=e.graph;if(b=l.active_canvas)c=Object.values(b.selected_nodes||{}),c.length||(c=[e]),d=f.createNode("graph/subgraph"),d.pos=e.pos.concat(),a.add(d),d.buildFromNodes(c),b.deselectAllNodes(),e.setDirtyCanvas(!0,!0)};l.onMenuNodeClone=function(a,b,c,d,e){0!=e.clonable&&
(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.beforeChange(),e.graph.add(a),e.graph.afterChange(),e.setDirtyCanvas(!0,!0))};l.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",
bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};l.prototype.getCanvasMenuOptions=function(){if(this.getMenuOptions)var a=this.getMenuOptions();else a=[{content:"Add Node",has_submenu:!0,callback:l.onMenuAdd},{content:"Add Group",callback:l.onGroupAdd}],this._graph_stack&&0<this._graph_stack.length&&a.push(null,{content:"Close subgraph",callback:this.closeSubgraph.bind(this)});if(this.getExtraMenuOptions){var b=
this.getExtraMenuOptions(this,a);b&&(a=a.concat(b))}return a};l.prototype.getNodeMenuOptions=function(a){var b=null;b=a.getMenuOptions?a.getMenuOptions(this):[{content:"Inputs",has_submenu:!0,disabled:!0,callback:l.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,disabled:!0,callback:l.showMenuNodeOptionalOutputs},null,{content:"Properties",has_submenu:!0,callback:l.onShowMenuNodeProperties},null,{content:"Title",callback:l.onShowPropertyEditor},{content:"Mode",has_submenu:!0,callback:l.onMenuNodeMode},
{content:"Resize",callback:function(){if(a.resizable)return l.onResizeNode}},{content:"Collapse",callback:l.onMenuNodeCollapse},{content:"Pin",callback:l.onMenuNodePin},{content:"Colors",has_submenu:!0,callback:l.onMenuNodeColors},{content:"Shapes",has_submenu:!0,callback:l.onMenuNodeShapes},null];if(a.onGetInputs){var c=a.onGetInputs();c&&c.length&&(b[0].disabled=!1)}a.onGetOutputs&&(c=a.onGetOutputs())&&c.length&&(b[1].disabled=!1);a.getExtraMenuOptions&&(c=a.getExtraMenuOptions(this,b))&&(c.push(null),
b=c.concat(b));!1!==a.clonable&&b.push({content:"Clone",callback:l.onMenuNodeClone});b.push(null,{content:"Remove",disabled:!(!1!==a.removable&&!a.block_delete),callback:l.onMenuNodeRemove});if(a.graph&&a.graph.onGetNodeMenuOptions)a.graph.onGetNodeMenuOptions(b,a);return b};l.prototype.getGroupMenuOptions=function(a){return[{content:"Title",callback:l.onShowPropertyEditor},{content:"Color",has_submenu:!0,callback:l.onMenuNodeColors},{content:"Font size",property:"font_size",type:"Number",callback:l.onShowPropertyEditor},
null,{content:"Remove",callback:l.onMenuNodeRemove}]};l.prototype.processContextMenu=function(a,b){var c=this,d=l.active_canvas.getCanvasWindow(),e=null,g={event:b,callback:function(b,d,e){if(b)if("Remove Slot"==b.content)b=b.slot,b.input?a.removeInput(b.slot):b.output&&a.removeOutput(b.slot);else if("Disconnect Links"==b.content)b=b.slot,b.output?a.disconnectOutput(b.slot):b.input&&a.disconnectInput(b.slot);else if("Rename Slot"==b.content){b=b.slot;var g=b.input?a.getInputInfo(b.slot):a.getOutputInfo(b.slot),
f=c.createDialog("<span class='name'>Name</span><input autofocus type='text'/><button>OK</button>",d),h=f.querySelector("input");h&&g&&(h.value=g.label||"");f.querySelector("button").addEventListener("click",function(a){h.value&&(g&&(g.label=h.value),c.setDirty(!0));f.close()})}},extra:a};a&&(g.title=a.type);var h=null;a&&(h=a.getSlotInPosition(b.canvasX,b.canvasY),l.active_node=a);h?(e=[],a.getSlotMenuOptions?e=a.getSlotMenuOptions(h):(h&&h.output&&h.output.links&&h.output.links.length&&e.push({content:"Disconnect Links",
slot:h}),b=h.input||h.output,e.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:h}),e.push(b.nameLocked?"Cannot rename":{content:"Rename Slot",slot:h})),g.title=(h.input?h.input.type:h.output.type)||"*",h.input&&h.input.type==f.ACTION&&(g.title="Action"),h.output&&h.output.type==f.EVENT&&(g.title="Event")):a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(h=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",
extra:h,options:this.getGroupMenuOptions(h)}}));e&&new f.ContextMenu(e,g,d)};"undefined"!=typeof window&&window.CanvasRenderingContext2D&&!window.CanvasRenderingContext2D.prototype.roundRect&&(window.CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e,g){var f,k;if(0===e)this.rect(a,b,c,d);else{void 0===g&&(g=e);if(null!=e&&e.constructor===Array)if(1==e.length)var n=f=k=g=e[0];else if(2==e.length)n=g=e[0],f=k=e[1];else if(4==e.length)n=e[0],f=e[1],k=e[2],g=e[3];else return;else n=e||0,
f=e||0,k=g||0,g=g||0;this.moveTo(a+n,b);this.lineTo(a+c-f,b);this.quadraticCurveTo(a+c,b,a+c,b+f);this.lineTo(a+c,b+d-g);this.quadraticCurveTo(a+c,b+d,a+c-g,b+d);this.lineTo(a+g,b+d);this.quadraticCurveTo(a,b+d,a,b+d-k);this.lineTo(a,b+k);this.quadraticCurveTo(a,b,a+n,b)}});f.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};f.distance=J;f.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")+")"};f.isInsideRectangle=C;f.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)};f.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};f.overlapBounding=H;f.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,d,e,g=0;6>g;g+=2)d="0123456789ABCDEF".indexOf(a.charAt(g)),e="0123456789ABCDEF".indexOf(a.charAt(g+1)),b[c]=16*d+e,c++;return b};
f.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};E.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;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,g,c.node);!0===e&&(d=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(e=b.callback.call(this,b,c,a,g,c.extra),
!0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new g.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:g,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!g.lock&&g.close()}var g=this;c=c||{};var f=document.createElement("div");f.className="litemenu-entry submenu";var k=!1;if(null===b)f.classList.add("separator");else{f.innerHTML=b&&b.title?b.title:
a;if(f.value=b)b.disabled&&(k=!0,f.classList.add("disabled")),(b.submenu||b.has_submenu)&&f.classList.add("has_submenu");"function"==typeof b?(f.dataset.value=a,f.onclick_callback=b):f.dataset.value=b;b.className&&(f.className+=" "+b.className)}this.root.appendChild(f);k||f.addEventListener("click",e);c.autoopen&&f.addEventListener("mouseenter",d);return f};E.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&&!E.isCursorOverElement(a,this.parentMenu.root)&&E.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};E.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};E.prototype.getTopMenu=
function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};E.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};E.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&a<b.top+b.height&&c>b.left&&c<b.left+b.width?!0:!1:!1};f.ContextMenu=E;f.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=0;c<b.length;c++)b[c].close?b[c].close():b[c].parentNode&&b[c].parentNode.removeChild(b[c])}};f.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)))};G.sampleCurve=function(a,b){if(b){for(var c=0;c<b.length-1;++c){var d=b[c],e=b[c+1];if(!(e[0]<a)){b=e[0]-d[0];if(1E-5>Math.abs(b))return d[1];a=(a-d[0])/b;return d[1]*(1-a)+e[1]*a}}return 0}};G.prototype.draw=function(a,b,c,d,e,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;e=e||"#666";a.save();a.translate(this.margin,this.margin);d&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333",
a.strokeRect(0,0,g,b));a.strokeStyle=e;f&&(a.globalAlpha=.5);a.beginPath();for(d=0;d<c.length;++d)e=c[d],a.lineTo(e[0]*g,(1-e[1])*b);a.stroke();a.globalAlpha=1;if(!f)for(d=0;d<c.length;++d)e=c[d],a.fillStyle=this.selected==d?"#FFF":this.nearest==d?"#DDD":"#AAA",a.beginPath(),a.arc(e[0]*g,(1-e[1])*b,2,0,2*Math.PI),a.fill();a.restore()}};G.prototype.onMouseDown=function(a,b){var c=this.points;if(c&&!(0>a[1])){var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,f=a[0]-this.margin;a=a[1]-this.margin;
this.selected=this.getCloserPoint([f,a],30/b.ds.scale);-1==this.selected&&(b=[f/d,1-a/e],c.push(b),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0);if(-1!=this.selected)return!0}};G.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var d=this.selected;if(!(0>d)){var e=(a[0]-this.margin)/(this.size[0]-2*this.margin),f=(a[1]-this.margin)/(this.size[1]-2*this.margin);this._nearest=this.getCloserPoint([a[0]-this.margin,a[1]-this.margin],30/b.ds.scale);
if(b=c[d]){var h=0==d||d==c.length-1;!h&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(d,1),this.selected=-1):(b[0]=h?0==d?0:1:Math.clamp(e,0,1),b[1]=1-Math.clamp(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};G.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};G.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,
f=c.length,h=[0,0],k=1E6,l=-1,p=0;p<f;++p){var q=c[p];h[0]=q[0]*d;h[1]=(1-q[1])*e;q=vec2.distance(a,h);q>k||q>b||(l=p,k=q)}return l};f.CurveEditor=G;f.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").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);