From 610d4fdb71df844d85d77108d0e1a9708a00dc5e Mon Sep 17 00:00:00 2001
From: tamat
Date: Fri, 10 May 2019 19:50:01 +0200
Subject: [PATCH] build
---
build/litegraph.js | 88 +++++++-----
build/litegraph.min.js | 320 +++++++++++++++++++++--------------------
2 files changed, 215 insertions(+), 193 deletions(-)
diff --git a/build/litegraph.js b/build/litegraph.js
index a80c6d825..7a7941825 100644
--- a/build/litegraph.js
+++ b/build/litegraph.js
@@ -4309,6 +4309,7 @@ LGraphNode.prototype.executeAction = function(action)
this.pause_rendering = false;
this.clear_background = true;
+ this.read_only = false; //if set to true users cannot modify the graph
this.render_only_selected = true;
this.live_mode = false;
this.show_info = true;
@@ -4869,7 +4870,7 @@ LGraphNode.prototype.executeAction = function(action)
//when clicked on top of a node
//and it is not interactive
- if (node && this.allow_interaction && !skip_action) {
+ if (node && this.allow_interaction && !skip_action && !this.read_only) {
if (!this.live_mode && !node.flags.pinned) {
this.bringToFront(node);
} //if it wasn't selected?
@@ -5076,29 +5077,30 @@ LGraphNode.prototype.executeAction = function(action)
} //clicked outside of nodes
else {
//search for link connector
- for (var i = 0; i < this.visible_links.length; ++i) {
- var link = this.visible_links[i];
- var center = link._pos;
- if (
- !center ||
- e.canvasX < center[0] - 4 ||
- e.canvasX > center[0] + 4 ||
- e.canvasY < center[1] - 4 ||
- e.canvasY > center[1] + 4
- ) {
- continue;
- }
- //link clicked
- this.showLinkMenu(link, e);
- break;
- }
+ if(!this.read_only)
+ for (var i = 0; i < this.visible_links.length; ++i) {
+ var link = this.visible_links[i];
+ var center = link._pos;
+ if (
+ !center ||
+ e.canvasX < center[0] - 4 ||
+ e.canvasX > center[0] + 4 ||
+ e.canvasY < center[1] - 4 ||
+ e.canvasY > center[1] + 4
+ ) {
+ continue;
+ }
+ //link clicked
+ this.showLinkMenu(link, e);
+ break;
+ }
this.selected_group = this.graph.getGroupOnPos(
e.canvasX,
e.canvasY
);
this.selected_group_resizing = false;
- if (this.selected_group) {
+ if (this.selected_group && !this.read_only ) {
if (e.ctrlKey) {
this.dragging_rectangle = null;
}
@@ -5119,7 +5121,7 @@ LGraphNode.prototype.executeAction = function(action)
}
}
- if (is_double_click) {
+ if (is_double_click && !this.read_only ) {
this.showSearchBox(e);
}
@@ -5133,7 +5135,8 @@ LGraphNode.prototype.executeAction = function(action)
//middle button
} else if (e.which == 3) {
//right button
- this.processContextMenu(node, e);
+ if(!this.read_only)
+ this.processContextMenu(node, e);
}
//TODO
@@ -5210,7 +5213,7 @@ LGraphNode.prototype.executeAction = function(action)
this.dragging_rectangle[2] = e.canvasX - this.dragging_rectangle[0];
this.dragging_rectangle[3] = e.canvasY - this.dragging_rectangle[1];
this.dirty_canvas = true;
- } else if (this.selected_group) {
+ } else if (this.selected_group && !this.read_only) {
//moving/resizing a group
if (this.selected_group_resizing) {
this.selected_group.size = [
@@ -5231,7 +5234,7 @@ LGraphNode.prototype.executeAction = function(action)
this.ds.offset[1] += delta[1] / this.ds.scale;
this.dirty_canvas = true;
this.dirty_bgcanvas = true;
- } else if (this.allow_interaction) {
+ } else if (this.allow_interaction && !this.read_only) {
if (this.connecting_node) {
this.dirty_canvas = true;
}
@@ -16109,14 +16112,13 @@ if (typeof exports != "undefined") {
this.addInput("value", "number");
this.addOutput("Texture", "Texture");
this.help =
- "pixelcode must be vec3
\
- uvcode must be vec2, is optional
\
- uv: tex. coords
color: texture
colorB: textureB
time: scene time
value: input value
For multiline you must type: result = ...
";
+ "pixelcode must be vec3, uvcode must be vec2, is optional
\
+ uv: tex. coords
color: texture colorB: textureB
time: scene time value: input value
For multiline you must type: result = ...
";
this.properties = {
value: 1,
- uvcode: "",
pixelcode: "color + colorB * value",
+ uvcode: "",
precision: LGraphTexture.DEFAULT
};
@@ -16124,8 +16126,8 @@ if (typeof exports != "undefined") {
}
LGraphTextureOperation.widgets_info = {
- uvcode: { widget: "textarea", height: 100 },
- pixelcode: { widget: "textarea", height: 100 },
+ uvcode: { widget: "code" },
+ pixelcode: { widget: "code" },
precision: { widget: "combo", values: LGraphTexture.MODE_VALUES }
};
@@ -17156,14 +17158,13 @@ if (typeof exports != "undefined") {
this.addOutput("avg", "vec4");
this.addOutput("lum", "number");
this.properties = {
- use_previous_frame: true,
- mipmap_offset: 0,
- low_precision: false
+ use_previous_frame: true, //to avoid stalls
+ high_quality: false //to use as much pixels as possible
};
this._uniforms = {
u_texture: 0,
- u_mipmap_offset: this.properties.mipmap_offset
+ u_mipmap_offset: 0
};
this._luminance = new Float32Array(4);
}
@@ -17234,6 +17235,25 @@ if (typeof exports != "undefined") {
});
}
+ this._uniforms.u_mipmap_offset = 0;
+
+ if(this.properties.high_quality)
+ {
+ if( !this._temp_pot2_texture || this._temp_pot2_texture.type != type )
+ this._temp_pot2_texture = new GL.Texture(512, 512, {
+ type: type,
+ format: gl.RGBA,
+ minFilter: gl.LINEAR_MIPMAP_LINEAR,
+ magFilter: gl.LINEAR
+ });
+
+ tex.copyTo( this._temp_pot2_texture );
+ tex = this._temp_pot2_texture;
+ tex.bind(0);
+ gl.generateMipmap(GL_TEXTURE_2D);
+ this._uniforms.u_mipmap_offset = 9;
+ }
+
var shader = LGraphTextureAverage._shader;
var uniforms = this._uniforms;
uniforms.u_mipmap_offset = this.properties.mipmap_offset;
@@ -17273,8 +17293,8 @@ if (typeof exports != "undefined") {
void main() {\n\
vec4 color = vec4(0.0);\n\
//random average\n\
- for(int i = 0; i <= 4; ++i)\n\
- for(int j = 0; j <= 4; ++j)\n\
+ for(int i = 0; i < 4; ++i)\n\
+ for(int j = 0; j < 4; ++j)\n\
{\n\
color += texture2D(u_texture, vec2( u_samples_a[i][j], u_samples_b[i][j] ), u_mipmap_offset );\n\
color += texture2D(u_texture, vec2( 1.0 - u_samples_a[i][j], 1.0 - u_samples_b[i][j] ), u_mipmap_offset );\n\
diff --git a/build/litegraph.min.js b/build/litegraph.min.js
index 6a00aa870..d85bcad9c 100755
--- a/build/litegraph.min.js
+++ b/build/litegraph.min.js
@@ -1,34 +1,34 @@
(function(v){function e(a){c.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function h(a,b,d,u,k,c){this.id=a;this.type=b;this.origin_id=d;this.origin_slot=u;this.target_id=k;this.target_slot=c;this._data=null;this._pos=new Float32Array(2)}function r(a){this._ctor(a)}function m(a){this._ctor(a)}function s(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=0.1;this.onredraw=null;this.enabled=!0;this.last_mouse=
[0,0];this.element=null;this.visible_area=new Float32Array(4);a&&(this.element=a,b||this.bindEvents(a))}function f(a,b,d){d=d||{};this.background_image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";
-a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new s;this.zoom_modify_alpha=!0;this.title_text_font=""+c.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+c.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=c.NODE_TITLE_COLOR;this.default_link_color=c.LINK_COLOR;this.default_connection_color={input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1;this.render_only_selected=
-this.clear_background=!0;this.live_mode=!1;this.allow_searchbox=this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=this.allow_reconnect_links=!1;this.filter=this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=this.render_shadows=!0;this.render_connections_shadows=!1;this.render_connections_border=!0;this.render_connection_arrows=this.render_curved_connections=!1;this.render_collapsed_slots=!0;this.render_execution_order=
-!1;this.render_title_colored=!0;this.links_render_mode=c.SPLINE_LINK;this.canvas_mouse=[0,0];this.onDrawOverlay=this.onDrawForeground=this.onDrawBackground=this.onMouse=this.onSearchBoxSelection=this.onSearchBox=null;this.connections_width=3;this.round_radius=8;this.node_widget=this.current_node=null;this.last_mouse_position=[0,0];this.visible_area=this.ds.visible_area;this.visible_links=[];b&&b.attachCanvas(this);this.setCanvas(a);this.clear();d.skip_render||this.startRendering();this.autoresize=
-d.autoresize}function y(a,b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}function B(a,b,d,u,k,c){return da&&ub?!0:!1}function A(a,b){var d=a[0]+a[2],u=a[1]+a[3],k=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>k||de.width-f.width-10&&(c=e.width-f.width-10);g>e.height-f.height-10&&(g=e.height-f.height-10)}k.style.left=c+"px";k.style.top=g+"px";b.scale&&(k.style.transform="scale("+b.scale+")")}var c=v.LiteGraph={VERSION:0.4,CANVAS_GRID_SIZE:10,
-NODE_TITLE_HEIGHT:30,NODE_TITLE_TEXT_Y:20,NODE_SLOT_HEIGHT:20,NODE_WIDGET_HEIGHT:20,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,NODE_TITLE_COLOR:"#999",NODE_TEXT_SIZE:14,NODE_TEXT_COLOR:"#AAA",NODE_SUBTEXT_SIZE:12,NODE_DEFAULT_COLOR:"#333",NODE_DEFAULT_BGCOLOR:"#353535",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,LINK_COLOR:"#9A9",EVENT_LINK_COLOR:"#A86",CONNECTING_LINK_COLOR:"#AFA",MAX_NUMBER_OF_NODES:1E3,
-DEFAULT_POSITION:[100,100],VALID_SHAPES:["default","box","round","card"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,CARD_SHAPE:4,ARROW_SHAPE:5,INPUT:1,OUTPUT:2,EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,UP:1,DOWN:2,LEFT:3,RIGHT:4,CENTER:5,STRAIGHT_LINK:0,LINEAR_LINK:1,SPLINE_LINK:2,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,catch_exceptions:!0,throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},
-Nodes:{},searchbox_extras:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype";b.type=a;c.debug&&console.log("Node registered: "+a);a.split("/");var d=b.name,u=a.lastIndexOf("/");b.category=a.substr(0,u);b.title||(b.title=d);if(b.prototype)for(var k in r.prototype)b.prototype[k]||(b.prototype[k]=r.prototype[k]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=
-c.BOX_SHAPE;break;case "round":this._shape=c.ROUND_SHAPE;break;case "circle":this._shape=c.CIRCLE_SHAPE;break;case "card":this._shape=c.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});u=this.registered_node_types[a];this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[d]=b);if(c.onNodeTypeRegistered)c.onNodeTypeRegistered(a,b);if(u&&c.onNodeTypeReplaced)c.onNodeTypeReplaced(a,b,u);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+
-a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(k in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[k].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,d,u,k){for(var g=Array(b.length),e="",f=c.getParameterNames(b),p=0;pe&&(e=k.size[0]),f+=k.size[1]+a;b+=e+a}this.setDirtyCanvas(!0,!0)};e.prototype.getTime=function(){return this.globaltime};e.prototype.getFixedTime=function(){return this.fixedtime};e.prototype.getElapsedTime=function(){return this.elapsed_time};e.prototype.sendEventToAllNodes=function(a,b,d){d=d||c.ALWAYS;var u=this._nodes_in_order?this._nodes_in_order:this._nodes;if(u)for(var k=0,g=u.length;ka&&ub?!0:!1}function A(a,b){var d=a[0]+a[2],u=a[1]+a[3],k=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>k||de.width-f.width-10&&(c=e.width-f.width-10);g>e.height-f.height-10&&(g=e.height-f.height-10)}k.style.left=c+"px";k.style.top=g+"px";b.scale&&
+(k.style.transform="scale("+b.scale+")")}var c=v.LiteGraph={VERSION:0.4,CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:30,NODE_TITLE_TEXT_Y:20,NODE_SLOT_HEIGHT:20,NODE_WIDGET_HEIGHT:20,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,NODE_TITLE_COLOR:"#999",NODE_TEXT_SIZE:14,NODE_TEXT_COLOR:"#AAA",NODE_SUBTEXT_SIZE:12,NODE_DEFAULT_COLOR:"#333",NODE_DEFAULT_BGCOLOR:"#353535",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,
+LINK_COLOR:"#9A9",EVENT_LINK_COLOR:"#A86",CONNECTING_LINK_COLOR:"#AFA",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],VALID_SHAPES:["default","box","round","card"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,CARD_SHAPE:4,ARROW_SHAPE:5,INPUT:1,OUTPUT:2,EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,UP:1,DOWN:2,LEFT:3,RIGHT:4,CENTER:5,STRAIGHT_LINK:0,LINEAR_LINK:1,SPLINE_LINK:2,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,catch_exceptions:!0,
+throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},searchbox_extras:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype";b.type=a;c.debug&&console.log("Node registered: "+a);a.split("/");var d=b.name,u=a.lastIndexOf("/");b.category=a.substr(0,u);b.title||(b.title=d);if(b.prototype)for(var k in r.prototype)b.prototype[k]||(b.prototype[k]=r.prototype[k]);Object.defineProperty(b.prototype,
+"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=c.BOX_SHAPE;break;case "round":this._shape=c.ROUND_SHAPE;break;case "circle":this._shape=c.CIRCLE_SHAPE;break;case "card":this._shape=c.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});u=this.registered_node_types[a];this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[d]=b);if(c.onNodeTypeRegistered)c.onNodeTypeRegistered(a,b);if(u&&c.onNodeTypeReplaced)c.onNodeTypeReplaced(a,
+b,u);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(k in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[k].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,d,u,k){for(var g=Array(b.length),e="",f=c.getParameterNames(b),p=0;pe&&(e=k.size[0]),f+=k.size[1]+a;b+=e+a}this.setDirtyCanvas(!0,!0)};e.prototype.getTime=function(){return this.globaltime};e.prototype.getFixedTime=function(){return this.fixedtime};e.prototype.getElapsedTime=function(){return this.elapsed_time};e.prototype.sendEventToAllNodes=function(a,b,d){d=d||c.ALWAYS;var u=this._nodes_in_order?this._nodes_in_order:this._nodes;if(u)for(var k=0,g=u.length;k=c.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";null==a.id||-1==a.id?a.id=++this.last_node_id:this.last_node_idc.getTime()-this.last_mouseclick;this.canvas_mouse[0]=a.canvasX;this.canvas_mouse[1]=a.canvasY;this.canvas.focus();
-c.closeAllContextMenus(b);if(!this.onMouse||!0!=this.onMouse(a)){if(1==a.which){a.ctrlKey&&(this.dragging_rectangle=new Float32Array(4),this.dragging_rectangle[0]=a.canvasX,this.dragging_rectangle[1]=a.canvasY,this.dragging_rectangle[2]=1,this.dragging_rectangle[3]=1,g=!0);var e=!1;if(d&&this.allow_interaction&&!g){this.live_mode||d.flags.pinned||this.bringToFront(d);if(!this.connecting_node&&!d.flags.collapsed&&!this.live_mode)if(!g&&!1!==d.resizable&&B(a.canvasX,a.canvasY,d.pos[0]+d.size[0]-5,d.pos[1]+
-d.size[1]-5,10,10))this.resizing_node=d,this.canvas.style.cursor="se-resize",g=!0;else{if(d.outputs)for(var p=0,n=d.outputs.length;pe[0]+4||a.canvasYe[1]+4)){this.showLinkMenu(d,a);break}this.selected_group=this.graph.getGroupOnPos(a.canvasX,a.canvasY);this.selected_group_resizing=!1;this.selected_group&&(a.ctrlKey&&(this.dragging_rectangle=null),10>y([a.canvasX,a.canvasY],[this.selected_group.pos[0]+this.selected_group.size[0],this.selected_group.pos[1]+
-this.selected_group.size[1]])*this.ds.scale?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes());k&&this.showSearchBox(a);e=!0}!g&&e&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}else 2!=a.which&&3==a.which&&this.processContextMenu(d,a);this.last_mouse[0]=a.localX;this.last_mouse[1]=a.localY;this.last_mouseclick=c.getTime();this.last_mouse_dragging=!0;this.graph.change();(!b.document.activeElement||"input"!=b.document.activeElement.nodeName.toLowerCase()&&"textarea"!=b.document.activeElement.nodeName.toLowerCase())&&
-a.preventDefault();a.stopPropagation();if(this.onMouseDown)this.onMouseDown(a);return!1}}};f.prototype.processMouseMove=function(a){this.autoresize&&this.resize();if(this.graph){f.active_canvas=this;this.adjustMouseEvent(a);var b=[a.localX,a.localY],d=[b[0]-this.last_mouse[0],b[1]-this.last_mouse[1]];this.last_mouse=b;this.canvas_mouse[0]=a.canvasX;this.canvas_mouse[1]=a.canvasY;a.dragging=this.last_mouse_dragging;this.node_widget&&(this.processNodeWidgets(this.node_widget[0],this.canvas_mouse,a,
-this.node_widget[1]),this.dirty_canvas=!0);if(this.dragging_rectangle)this.dragging_rectangle[2]=a.canvasX-this.dragging_rectangle[0],this.dragging_rectangle[3]=a.canvasY-this.dragging_rectangle[1],this.dirty_canvas=!0;else if(this.selected_group)this.selected_group_resizing?this.selected_group.size=[a.canvasX-this.selected_group.pos[0],a.canvasY-this.selected_group.pos[1]]:(this.selected_group.move(d[0]/this.ds.scale,d[1]/this.ds.scale,a.ctrlKey),this.selected_group._nodes.length&&(this.dirty_canvas=
-!0)),this.dirty_bgcanvas=!0;else if(this.dragging_canvas)this.ds.offset[0]+=d[0]/this.ds.scale,this.ds.offset[1]+=d[1]/this.ds.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if(this.allow_interaction){this.connecting_node&&(this.dirty_canvas=!0);for(var g=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes),b=0,k=this.graph._nodes.length;bthis.dragging_rectangle[3]?this.dragging_rectangle[1]-k:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-g:this.dragging_rectangle[0];this.dragging_rectangle[1]=e;this.dragging_rectangle[2]=
-g;this.dragging_rectangle[3]=k;k=[];for(e=0;ea.click_time&&B(a.canvasX,a.canvasY,g.pos[0],g.pos[1]-c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT)&&g.collapse(),this.dirty_bgcanvas=this.dirty_canvas=!0,this.node_dragged.pos[0]=Math.round(this.node_dragged.pos[0]),this.node_dragged.pos[1]=Math.round(this.node_dragged.pos[1]),this.graph.config.align_to_grid&&this.node_dragged.alignToGrid(),this.node_dragged=null;else{g=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);!g&&300>a.click_time&&this.deselectAllNodes();
-this.dirty_canvas=!0;this.dragging_canvas=!1;if(this.node_over&&this.node_over.onMouseUp)this.node_over.onMouseUp(a,[a.canvasX-this.node_over.pos[0],a.canvasY-this.node_over.pos[1]],this);if(this.node_capturing_input&&this.node_capturing_input.onMouseUp)this.node_capturing_input.onMouseUp(a,[a.canvasX-this.node_capturing_input.pos[0],a.canvasY-this.node_capturing_input.pos[1]])}}else 2==a.which?(this.dirty_canvas=!0,this.dragging_canvas=!1):3==a.which&&(this.dirty_canvas=!0,this.dragging_canvas=!1);
-this.graph.change();a.stopPropagation();a.preventDefault();return!1}};f.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var d=this.ds.scale;0b&&(d*=1/1.1);this.ds.changeScale(d,[a.localX,a.localY]);this.graph.change();a.preventDefault();return!1}};f.prototype.isOverNodeBox=function(a,b,d){var g=c.NODE_TITLE_HEIGHT;return B(b,d,a.pos[0]+2,a.pos[1]+2-g,g-4,g-4)?!0:!1};f.prototype.isOverNodeInput=
-function(a,b,d,c){if(a.inputs)for(var g=0,e=a.inputs.length;gd-this.graph._last_trigger_time)&&this.drawBackCanvas();(this.dirty_canvas||a)&&this.drawFrontCanvas();this.fps=this.render_time?1/this.render_time:0;this.frame+=1}};f.prototype.drawFrontCanvas=function(){this.dirty_canvas=!1;this.ctx||(this.ctx=this.bgcanvas.getContext("2d"));var a=this.ctx;if(a){a.start2D&&a.start2D();var b=this.canvas;a.restore();a.setTransform(1,0,0,1,0,0);this.dirty_area&&(a.save(),
-a.beginPath(),a.rect(this.dirty_area[0],this.dirty_area[1],this.dirty_area[2],this.dirty_area[3]),a.clip());this.clear_background&&a.clearRect(0,0,b.width,b.height);this.bgcanvas==this.canvas?this.drawBackCanvas():a.drawImage(this.bgcanvas,0,0);if(this.onRender)this.onRender(b,a);this.show_info&&this.renderInfo(a);if(this.graph){a.save();this.ds.toCanvasContext(a);for(var b=this.computeVisibleNodes(null,this.visible_nodes),d=0;d> ";b.fillText(c+d.getTitle(),0.5*a.width,40);b.restore()}d=!1;this.onRenderBackground&&(d=this.onRenderBackground(a,b));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&&0.5this.ds.scale,l=a._shape||a.constructor.shape||c.ROUND_SHAPE,h=a.constructor.title_mode,m=!0;h==c.TRANSPARENT_TITLE?m=!1:h==c.AUTOHIDE_TITLE&&p&&(m=!0);n[0]=0;n[1]=m?-k:0;n[2]=d[0]+1;n[3]=m?d[1]+k:d[1];p=b.globalAlpha;b.beginPath();l==c.BOX_SHAPE||q?b.fillRect(n[0],n[1],n[2],n[3]):l==c.ROUND_SHAPE||l==c.CARD_SHAPE?
-b.roundRect(n[0],n[1],n[2],n[3],this.round_radius,l==c.CARD_SHAPE?0:this.round_radius):l==c.CIRCLE_SHAPE&&b.arc(0.5*d[0],0.5*d[1],0.5*d[0],0,2*Math.PI);b.fill();b.shadowColor="transparent";b.fillStyle="rgba(0,0,0,0.2)";b.fillRect(0,-1,n[2],2);b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas);if(m||h==c.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,k,d,this.ds.scale,g);else if(h!=c.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){m=
-a.constructor.title_color||g;a.flags.collapsed&&(b.shadowColor=c.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var t=f.gradients[m];t||(t=f.gradients[m]=b.createLinearGradient(0,0,400,0),t.addColorStop(0,m),t.addColorStop(1,"#000"));b.fillStyle=t}else b.fillStyle=m;b.beginPath();l==c.BOX_SHAPE||q?b.rect(0,-k,d[0]+1,k):l!=c.ROUND_SHAPE&&l!=c.CARD_SHAPE||b.roundRect(0,-k,d[0]+1,k,this.round_radius,a.flags.collapsed?this.round_radius:0);b.fill();b.shadowColor="transparent"}if(a.onDrawTitleBox)a.onDrawTitleBox(b,
-k,d,this.ds.scale);else l==c.ROUND_SHAPE||l==c.CIRCLE_SHAPE||l==c.CARD_SHAPE?(q&&(b.fillStyle="black",b.beginPath(),b.arc(0.5*k,-0.5*k,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||c.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.arc(0.5*k,-0.5*k,5,0,2*Math.PI),b.fill()):(q&&(b.fillStyle="black",b.fillRect(0.5*(k-10)-1,-0.5*(k+10)-1,12,12)),b.fillStyle=a.boxcolor||c.NODE_DEFAULT_BOXCOLOR,b.fillRect(0.5*(k-10),-0.5*(k+10),10,10));b.globalAlpha=p;if(a.onDrawTitleText)a.onDrawTitleText(b,k,d,this.ds.scale,
-this.title_text_font,e);!q&&(b.font=this.title_text_font,q=a.getTitle())&&(b.fillStyle=e?"white":a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="center",p=b.measureText(q),b.fillText(q,k+0.5*p.width,c.NODE_TITLE_TEXT_Y-k),b.textAlign="left"):(b.textAlign="left",b.fillText(q,k,c.NODE_TITLE_TEXT_Y-k)));if(a.onDrawTitle)a.onDrawTitle(b)}if(e){if(a.onBounding)a.onBounding(n);h==c.TRANSPARENT_TITLE&&(n[1]-=k,n[3]+=k);b.lineWidth=1;b.globalAlpha=0.8;b.beginPath();l==
-c.BOX_SHAPE?b.rect(-6+n[0],-6+n[1],12+n[2],12+n[3]):l==c.ROUND_SHAPE||l==c.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+n[0],-6+n[1],12+n[2],12+n[3],2*this.round_radius):l==c.CARD_SHAPE?b.roundRect(-6+n[0],-6+n[1],12+n[2],12+n[3],2*this.round_radius,2):l==c.CIRCLE_SHAPE&&b.arc(0.5*d[0],0.5*d[1],0.5*d[0]+6,0,2*Math.PI);b.strokeStyle="#FFF";b.stroke();b.strokeStyle=g;b.globalAlpha=1}};var l=new Float32Array(4),g=new Float32Array(4),q=new Float32Array(2),w=new Float32Array(2);f.prototype.drawConnections=
-function(a){var b=c.getTime(),d=this.visible_area;l[0]=d[0]-20;l[1]=d[1]-20;l[2]=d[2]+40;l[3]=d[3]+40;a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;for(var d=this.graph._nodes,e=0,k=d.length;eg[2]&&(g[0]+=g[2],g[2]=Math.abs(g[2]));0>g[3]&&(g[1]+=g[3],g[3]=Math.abs(g[3]));if(A(g,l)){var D=h.outputs[m],m=f.inputs[p];if(D&&m&&(h=D.dir||(h.horizontal?c.DOWN:c.RIGHT),m=m.dir||(f.horizontal?c.UP:c.LEFT),this.renderLink(a,r,t,n,!1,0,null,h,m),n&&n._last_time&&1E3>b-n._last_time)){var D=2-0.002*(b-n._last_time),E=a.globalAlpha;a.globalAlpha=E*D;this.renderLink(a,r,t,n,!0,
-D,"white",h,m);a.globalAlpha=E}}}}}}a.globalAlpha=1};f.prototype.renderLink=function(a,b,d,g,k,e,p,n,l,q){g&&this.visible_links.push(g);!p&&g&&(p=g.color||f.link_type_colors[g.type]);p||(p=this.default_link_color);null!=g&&this.highlighted_links[g.id]&&(p="#FFF");n=n||c.RIGHT;l=l||c.LEFT;var h=y(b,d);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(t[0],t[1]),a.rotate(D),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(q[0],q[1]),a.rotate(E),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(k[0],k[1],5,0,2*Math.PI),a.fill());if(e)for(a.fillStyle=p,t=0;5>t;++t)e=(0.001*c.getTime()+0.2*t)%1,k=this.computeConnectionPoint(b,d,e,n,l),a.beginPath(),a.arc(k[0],
-k[1],5,0,2*Math.PI),a.fill()};f.prototype.computeConnectionPoint=function(a,b,d,g,k){g=g||c.RIGHT;k=k||c.LEFT;var e=y(a,b),f=[a[0],a[1]],p=[b[0],b[1]];switch(g){case c.LEFT:f[0]+=-0.25*e;break;case c.RIGHT:f[0]+=0.25*e;break;case c.UP:f[1]+=-0.25*e;break;case c.DOWN:f[1]+=0.25*e}switch(k){case c.LEFT:p[0]+=-0.25*e;break;case c.RIGHT:p[0]+=0.25*e;break;case c.UP:p[1]+=-0.25*e;break;case c.DOWN:p[1]+=0.25*e}g=(1-d)*(1-d)*(1-d);k=3*(1-d)*(1-d)*d;e=3*(1-d)*d*d;d*=d*d;return[g*a[0]+k*f[0]+e*p[0]+d*b[0],
-g*a[1]+k*f[1]+e*p[1]+d*b[1]]};f.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=0.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=0.75;for(var b=this.visible_nodes,d=0;dt.last_y&&ft.options.max&&(t.value=t.options.max);else if("mousedown"==d.type)if((g=t.options.values)&&g.constructor===Function&&(g=t.options.values(t,
-a)),e=40>e?-1:e>p-40?1:0,"number"==t.type)t.value+=0.1*e*(t.options.step||1),null!=t.options.min&&t.valuet.options.max&&(t.value=t.options.max);else if(e)n=g.indexOf(t.value)+e,n>=g.length&&(n=0),0>n&&(n=g.length-1),t.value=g[n];else{new c.ContextMenu(g,{scale:Math.max(1,this.ds.scale),event:d,className:"dark",callback:D.bind(t)},n);var D=function(a,b,d){this.value=a;k(this,a);l.dirty_canvas=!0;return!1}}setTimeout(function(){k(this,
-this.value)}.bind(t),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==d.type&&(t.value=!t.value,t.callback&&setTimeout(function(){k(t,t.value)},20));break;case "string":case "text":"mousedown"==d.type&&this.prompt("Value",t.value,function(a){this.value=a;k(this,a)}.bind(t),d);break;default:t.mouse&&t.mouse(ctx,d,[e,f],a)}return t}}return null};f.prototype.drawGroups=function(a,b){if(this.graph){var d=this.graph._groups;b.save();b.globalAlpha=0.5*this.editor_alpha;for(var g=0;gd&&0.01>b.editor_alpha&&(clearInterval(c),1>d&&(b.live_mode=!0));1"+q+""+a+"",value:q});if(l.length)return new c.ContextMenu(l,{event:d,callback:e,parentMenu:g,
-allow_html:!0,node:k},b),!1}};f.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};f.onResizeNode=function(a,b,d,c,g){g&&(g.size=g.computeSize(),g.setDirtyCanvas(!0,!0))};f.prototype.showLinkMenu=function(a,b){var d=this;new c.ContextMenu(["Delete"],{event:b,callback:function(b){switch(b){case "Delete":d.graph.removeLink(a.id)}}});return!1};f.onShowPropertyEditor=function(a,b,d,c,g){function e(){var b=q.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&
-(b=Boolean(b));g[p]=b;l.parentNode&&l.parentNode.removeChild(l);g.setDirtyCanvas(!0,!0)}var p=a.property||"title";b=g[p];var l=document.createElement("div");l.className="graphdialog";l.innerHTML="";l.querySelector(".name").innerText=p;var q=l.querySelector("input");q&&(q.value=b,q.addEventListener("blur",function(a){this.focus()}),q.addEventListener("keydown",function(a){13==a.keyCode&&(e(),a.preventDefault(),
-a.stopPropagation())}));b=f.active_canvas.canvas;d=b.getBoundingClientRect();var n=c=-20;d&&(c-=d.left,n-=d.top);event?(l.style.left=event.clientX+c+"px",l.style.top=event.clientY+n+"px"):(l.style.left=0.5*b.width+c+"px",l.style.top=0.5*b.height+n+"px");l.querySelector("button").addEventListener("click",e);b.parentNode.appendChild(l)};f.prototype.prompt=function(a,b,d,c){var g=this;a=a||"";var e=!1,l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML=" ";
-l.close=function(){g.prompt_box=null;l.parentNode&&l.parentNode.removeChild(l)};1f.search_limit))break}if(Array.prototype.filter)for(m=Object.keys(c.registered_node_types).filter(function(a){return-1!==a.toLowerCase().indexOf(d)}),p=0;pf.search_limit);p++);else for(p in c.registered_node_types)if(-1!=p.indexOf(d)&&(a(p),-1!==f.search_limit&&l++>f.search_limit))break}}var e=this,l=document.createElement("div");l.className="litegraph litesearchbox graphdialog rounded";l.innerHTML="Search ";l.close=function(){e.search_box=null;document.body.focus();setTimeout(function(){e.canvas.focus()},20);l.parentNode&&
-l.parentNode.removeChild(l)};var p=null;1";else if("enum"==e&&l.values){p=""}else if("boolean"==
-e)p="";else{console.warn("unknown type: "+e);return}var n=this.createDialog(""+b+""+p+"",d);if("enum"==e&&l.values){var t=n.querySelector("select");t.addEventListener("change",function(a){g(a.target.value)})}else if("boolean"==e)(t=n.querySelector("input"))&&t.addEventListener("click",function(a){g(!!t.checked)});else if(t=n.querySelector("input"))t.addEventListener("blur",
-function(a){this.focus()}),t.value=void 0!==a.properties[b]?a.properties[b]:"",t.addEventListener("keydown",function(a){13==a.keyCode&&(c(),a.preventDefault(),a.stopPropagation())});n.querySelector("button").addEventListener("click",c)}};f.prototype.createDialog=function(a,b){b=b||{};var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;var c=this.canvas.getBoundingClientRect(),g=-20,e=-20;c&&(g-=c.left,e-=c.top);b.position?(g+=b.position[0],e+=b.position[1]):b.event?(g+=b.event.clientX,
-e+=b.event.clientY):(g+=0.5*this.canvas.width,e+=0.5*this.canvas.height);d.style.left=g+"px";d.style.top=e+"px";this.canvas.parentNode.appendChild(d);d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return d};f.onMenuNodeCollapse=function(a,b,d,c,g){g.collapse()};f.onMenuNodePin=function(a,b,d,c,g){g.pin()};f.onMenuNodeMode=function(a,b,d,g,e){new c.ContextMenu(["Always","On Event","On Trigger","Never"],{event:d,callback:function(a){if(e)switch(a){case "On Event":e.mode=c.ON_EVENT;
-break;case "On Trigger":e.mode=c.ON_TRIGGER;break;case "Never":e.mode=c.NEVER;break;default:e.mode=c.ALWAYS}},parentMenu:g,node:e});return!1};f.onMenuNodeColors=function(a,b,d,g,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var l in f.node_colors)a=f.node_colors[l],a={value:l,content:""+l+""},b.push(a);new c.ContextMenu(b,{event:d,callback:function(a){e&&((a=a.value?f.node_colors[a.value]:null)?e.constructor===c.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:g,node:e});return!1};f.onMenuNodeShapes=function(a,b,d,g,e){if(!e)throw"no node passed";new c.ContextMenu(c.VALID_SHAPES,{event:d,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))},parentMenu:g,node:e});return!1};
-f.onMenuNodeRemove=function(a,b,d,c,g){if(!g)throw"no node passed";!1!==g.removable&&(g.graph.remove(g),g.setDirtyCanvas(!0,!0))};f.onMenuNodeClone=function(a,b,d,c,g){!1!=g.clonable&&(a=g.clone())&&(a.pos=[g.pos[0]+5,g.pos[1]+5],g.graph.add(a),g.setDirtyCanvas(!0,!0))};f.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"}};f.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:f.onMenuAdd},{content:"Add Group",callback:f.onGroupAdd}],this._graph_stack&&
-0Name",c),l=e.querySelector("input");l&&t&&(l.value=t.label||"");e.querySelector("button").addEventListener("click",function(a){l.value&&(t&&(t.label=l.value),d.setDirty(!0));e.close()})}},extra:a},p=null;a&&(p=a.getSlotInPosition(b.canvasX,b.canvasY),f.active_node=a);if(p){e=[];
-p&&p.output&&p.output.links&&p.output.links.length&&e.push({content:"Disconnect Links",slot:p});var q=p.input||p.output;e.push(q.locked?"Cannot remove":{content:"Remove Slot",slot:p});e.push(q.nameLocked?"Cannot rename":{content:"Rename Slot",slot:p});l.title=(p.input?p.input.type:p.output.type)||"*";p.input&&p.input.type==c.ACTION&&(l.title="Action");p.output&&p.output.type==c.EVENT&&(l.title="Event")}else a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(p=this.graph.getGroupOnPos(b.canvasX,
-b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:p,options:this.getGroupMenuOptions(p)}}));e&&new c.ContextMenu(e,l,g)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,d,c,g,e){void 0===g&&(g=5);void 0===e&&(e=g);this.moveTo(a+g,b);this.lineTo(a+d-g,b);this.quadraticCurveTo(a+d,b,a+d,b+g);this.lineTo(a+d,b+c-e);this.quadraticCurveTo(a+d,b+c,a+d-e,b+c);this.lineTo(a+e,b+c);this.quadraticCurveTo(a,b+c,a,b+c-e);this.lineTo(a,
-b+g);this.quadraticCurveTo(a,b,a+g,b)});c.compareObjects=function(a,b){for(var d in a)if(a[d]!=b[d])return!1;return!0};c.distance=y;c.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")+")"};c.isInsideRectangle=B;c.growBounding=function(a,b,d){ba[2]&&(a[2]=b);da[3]&&(a[3]=d)};c.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};c.overlapBounding=A;c.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),d=0,c,g,e=0;6>e;e+=2)c="0123456789ABCDEF".indexOf(a.charAt(e)),g="0123456789ABCDEF".indexOf(a.charAt(e+1)),b[d]=16*c+g,d++;return b};c.num2hex=function(a){for(var b="#",d,c,g=0;3>g;g++)d=a[g]/16,c=a[g]%16,b+="0123456789ABCDEF".charAt(d)+"0123456789ABCDEF".charAt(c);return b};z.prototype.addItem=function(a,b,d){function c(a){var b=this.value;b&&b.has_submenu&&
-g.call(this,a)}function g(a){var b=this.value,c=!0;e.current_submenu&&e.current_submenu.close(a);if(d.callback){var t=d.callback.call(this,b,d,a,e,d.node);!0===t&&(c=!1)}if(b&&(b.callback&&!d.ignore_item_callbacks&&!0!==b.disabled&&(t=b.callback.call(this,b,d,a,e,d.extra),!0===t&&(c=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new e.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:e,ignore_item_callbacks:b.submenu.ignore_item_callbacks,
-title:b.submenu.title,extra:b.submenu.extra,autoopen:d.autoopen});c=!1}c&&!e.lock&&e.close()}var e=this;d=d||{};var l=document.createElement("div");l.className="litemenu-entry submenu";var f=!1;if(null===b)l.classList.add("separator");else{l.innerHTML=b&&b.title?b.title:a;if(l.value=b)b.disabled&&(f=!0,l.classList.add("disabled")),(b.submenu||b.has_submenu)&&l.classList.add("has_submenu");"function"==typeof b?(l.dataset.value=a,l.onclick_callback=b):l.dataset.value=b;b.className&&(l.className+=" "+
-b.className)}this.root.appendChild(l);f||l.addEventListener("click",g);d.autoopen&&l.addEventListener("mouseenter",c);return l};z.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&&!z.isCursorOverElement(a,this.parentMenu.root)&&z.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&
-clearTimeout(this.root.closing_timer)};z.trigger=function(a,b,d,c){var g=document.createEvent("CustomEvent");g.initCustomEvent(b,!0,!0,d);g.srcElement=c;a.dispatchEvent?a.dispatchEvent(g):a.__events&&a.__events.dispatchEvent(g);return g};z.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};z.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};z.isCursorOverElement=function(a,
-b){var d=a.clientX,c=a.clientY,g=b.getBoundingClientRect();return g?c>g.top&&cg.left&&d
-a?b:de[0]+4||a.canvasYe[1]+4)){this.showLinkMenu(d,a);break}this.selected_group=this.graph.getGroupOnPos(a.canvasX,a.canvasY);this.selected_group_resizing=!1;this.selected_group&&!this.read_only&&(a.ctrlKey&&(this.dragging_rectangle=null),10>y([a.canvasX,a.canvasY],[this.selected_group.pos[0]+
+this.selected_group.size[0],this.selected_group.pos[1]+this.selected_group.size[1]])*this.ds.scale?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes());k&&!this.read_only&&this.showSearchBox(a);e=!0}!g&&e&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}else 2!=a.which&&3==a.which&&(this.read_only||this.processContextMenu(d,a));this.last_mouse[0]=a.localX;this.last_mouse[1]=a.localY;this.last_mouseclick=c.getTime();this.last_mouse_dragging=!0;this.graph.change();(!b.document.activeElement||
+"input"!=b.document.activeElement.nodeName.toLowerCase()&&"textarea"!=b.document.activeElement.nodeName.toLowerCase())&&a.preventDefault();a.stopPropagation();if(this.onMouseDown)this.onMouseDown(a);return!1}}};f.prototype.processMouseMove=function(a){this.autoresize&&this.resize();if(this.graph){f.active_canvas=this;this.adjustMouseEvent(a);var b=[a.localX,a.localY],d=[b[0]-this.last_mouse[0],b[1]-this.last_mouse[1]];this.last_mouse=b;this.canvas_mouse[0]=a.canvasX;this.canvas_mouse[1]=a.canvasY;
+a.dragging=this.last_mouse_dragging;this.node_widget&&(this.processNodeWidgets(this.node_widget[0],this.canvas_mouse,a,this.node_widget[1]),this.dirty_canvas=!0);if(this.dragging_rectangle)this.dragging_rectangle[2]=a.canvasX-this.dragging_rectangle[0],this.dragging_rectangle[3]=a.canvasY-this.dragging_rectangle[1],this.dirty_canvas=!0;else if(this.selected_group&&!this.read_only)this.selected_group_resizing?this.selected_group.size=[a.canvasX-this.selected_group.pos[0],a.canvasY-this.selected_group.pos[1]]:
+(this.selected_group.move(d[0]/this.ds.scale,d[1]/this.ds.scale,a.ctrlKey),this.selected_group._nodes.length&&(this.dirty_canvas=!0)),this.dirty_bgcanvas=!0;else if(this.dragging_canvas)this.ds.offset[0]+=d[0]/this.ds.scale,this.ds.offset[1]+=d[1]/this.ds.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if(this.allow_interaction&&!this.read_only){this.connecting_node&&(this.dirty_canvas=!0);for(var g=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes),b=0,k=this.graph._nodes.length;b<
+k;++b)if(this.graph._nodes[b].mouseOver&&g!=this.graph._nodes[b]){this.graph._nodes[b].mouseOver=!1;if(this.node_over&&this.node_over.onMouseLeave)this.node_over.onMouseLeave(a);this.node_over=null;this.dirty_canvas=!0}if(g){if(!g.mouseOver&&(g.mouseOver=!0,this.node_over=g,this.dirty_canvas=!0,g.onMouseEnter))g.onMouseEnter(a);if(g.onMouseMove)g.onMouseMove(a,[a.canvasX-g.pos[0],a.canvasY-g.pos[1]],this);if(this.connecting_node&&(k=this._highlight_input||[0,0],!this.isOverNodeBox(g,a.canvasX,a.canvasY))){var e=
+this.isOverNodeInput(g,a.canvasX,a.canvasY,k);-1!=e&&g.inputs[e]?c.isValidConnection(this.connecting_output.type,g.inputs[e].type)&&(this._highlight_input=k):this._highlight_input=null}this.canvas&&(B(a.canvasX,a.canvasY,g.pos[0]+g.size[0]-5,g.pos[1]+g.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="crosshair")}else this.canvas&&(this.canvas.style.cursor="");if(this.node_capturing_input&&this.node_capturing_input!=g&&this.node_capturing_input.onMouseMove)this.node_capturing_input.onMouseMove(a);
+if(this.node_dragged&&!this.live_mode){for(b in this.selected_nodes)g=this.selected_nodes[b],g.pos[0]+=d[0]/this.ds.scale,g.pos[1]+=d[1]/this.ds.scale;this.dirty_bgcanvas=this.dirty_canvas=!0}this.resizing_node&&!this.live_mode&&(this.resizing_node.size[0]=a.canvasX-this.resizing_node.pos[0],this.resizing_node.size[1]=a.canvasY-this.resizing_node.pos[1],d=Math.max(this.resizing_node.inputs?this.resizing_node.inputs.length:0,this.resizing_node.outputs?this.resizing_node.outputs.length:0)*c.NODE_SLOT_HEIGHT+
+(this.resizing_node.widgets?this.resizing_node.widgets.length:0)*(c.NODE_WIDGET_HEIGHT+4)+4,this.resizing_node.size[1]this.dragging_rectangle[3]?this.dragging_rectangle[1]-k:this.dragging_rectangle[1];this.dragging_rectangle[0]=
+0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-g:this.dragging_rectangle[0];this.dragging_rectangle[1]=e;this.dragging_rectangle[2]=g;this.dragging_rectangle[3]=k;k=[];for(e=0;ea.click_time&&B(a.canvasX,a.canvasY,g.pos[0],g.pos[1]-c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT)&&g.collapse(),this.dirty_bgcanvas=this.dirty_canvas=!0,this.node_dragged.pos[0]=Math.round(this.node_dragged.pos[0]),this.node_dragged.pos[1]=Math.round(this.node_dragged.pos[1]),this.graph.config.align_to_grid&&
+this.node_dragged.alignToGrid(),this.node_dragged=null;else{g=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);!g&&300>a.click_time&&this.deselectAllNodes();this.dirty_canvas=!0;this.dragging_canvas=!1;if(this.node_over&&this.node_over.onMouseUp)this.node_over.onMouseUp(a,[a.canvasX-this.node_over.pos[0],a.canvasY-this.node_over.pos[1]],this);if(this.node_capturing_input&&this.node_capturing_input.onMouseUp)this.node_capturing_input.onMouseUp(a,[a.canvasX-this.node_capturing_input.pos[0],
+a.canvasY-this.node_capturing_input.pos[1]])}}else 2==a.which?(this.dirty_canvas=!0,this.dragging_canvas=!1):3==a.which&&(this.dirty_canvas=!0,this.dragging_canvas=!1);this.graph.change();a.stopPropagation();a.preventDefault();return!1}};f.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var d=this.ds.scale;0b&&(d*=1/1.1);this.ds.changeScale(d,[a.localX,a.localY]);this.graph.change();
+a.preventDefault();return!1}};f.prototype.isOverNodeBox=function(a,b,d){var g=c.NODE_TITLE_HEIGHT;return B(b,d,a.pos[0]+2,a.pos[1]+2-g,g-4,g-4)?!0:!1};f.prototype.isOverNodeInput=function(a,b,d,c){if(a.inputs)for(var g=0,e=a.inputs.length;gd-this.graph._last_trigger_time)&&this.drawBackCanvas();(this.dirty_canvas||a)&&this.drawFrontCanvas();this.fps=this.render_time?1/this.render_time:
+0;this.frame+=1}};f.prototype.drawFrontCanvas=function(){this.dirty_canvas=!1;this.ctx||(this.ctx=this.bgcanvas.getContext("2d"));var a=this.ctx;if(a){a.start2D&&a.start2D();var b=this.canvas;a.restore();a.setTransform(1,0,0,1,0,0);this.dirty_area&&(a.save(),a.beginPath(),a.rect(this.dirty_area[0],this.dirty_area[1],this.dirty_area[2],this.dirty_area[3]),a.clip());this.clear_background&&a.clearRect(0,0,b.width,b.height);this.bgcanvas==this.canvas?this.drawBackCanvas():a.drawImage(this.bgcanvas,0,
+0);if(this.onRender)this.onRender(b,a);this.show_info&&this.renderInfo(a);if(this.graph){a.save();this.ds.toCanvasContext(a);for(var b=this.computeVisibleNodes(null,this.visible_nodes),d=0;d> ";b.fillText(c+d.getTitle(),0.5*a.width,40);b.restore()}d=!1;this.onRenderBackground&&(d=this.onRenderBackground(a,b));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&&0.5this.ds.scale,l=a._shape||a.constructor.shape||c.ROUND_SHAPE,h=a.constructor.title_mode,m=!0;h==c.TRANSPARENT_TITLE?m=!1:h==c.AUTOHIDE_TITLE&&p&&(m=!0);n[0]=0;n[1]=m?-k:0;n[2]=d[0]+1;n[3]=m?d[1]+k:d[1];p=b.globalAlpha;b.beginPath();l==c.BOX_SHAPE||q?b.fillRect(n[0],n[1],n[2],n[3]):l==c.ROUND_SHAPE||l==c.CARD_SHAPE?b.roundRect(n[0],n[1],n[2],n[3],this.round_radius,l==c.CARD_SHAPE?0:this.round_radius):l==c.CIRCLE_SHAPE&&b.arc(0.5*d[0],0.5*d[1],0.5*d[0],0,2*Math.PI);b.fill();b.shadowColor="transparent";
+b.fillStyle="rgba(0,0,0,0.2)";b.fillRect(0,-1,n[2],2);b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas);if(m||h==c.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,k,d,this.ds.scale,g);else if(h!=c.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){m=a.constructor.title_color||g;a.flags.collapsed&&(b.shadowColor=c.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var t=f.gradients[m];t||(t=f.gradients[m]=b.createLinearGradient(0,0,
+400,0),t.addColorStop(0,m),t.addColorStop(1,"#000"));b.fillStyle=t}else b.fillStyle=m;b.beginPath();l==c.BOX_SHAPE||q?b.rect(0,-k,d[0]+1,k):l!=c.ROUND_SHAPE&&l!=c.CARD_SHAPE||b.roundRect(0,-k,d[0]+1,k,this.round_radius,a.flags.collapsed?this.round_radius:0);b.fill();b.shadowColor="transparent"}if(a.onDrawTitleBox)a.onDrawTitleBox(b,k,d,this.ds.scale);else l==c.ROUND_SHAPE||l==c.CIRCLE_SHAPE||l==c.CARD_SHAPE?(q&&(b.fillStyle="black",b.beginPath(),b.arc(0.5*k,-0.5*k,6,0,2*Math.PI),b.fill()),b.fillStyle=
+a.boxcolor||c.NODE_DEFAULT_BOXCOLOR,b.beginPath(),b.arc(0.5*k,-0.5*k,5,0,2*Math.PI),b.fill()):(q&&(b.fillStyle="black",b.fillRect(0.5*(k-10)-1,-0.5*(k+10)-1,12,12)),b.fillStyle=a.boxcolor||c.NODE_DEFAULT_BOXCOLOR,b.fillRect(0.5*(k-10),-0.5*(k+10),10,10));b.globalAlpha=p;if(a.onDrawTitleText)a.onDrawTitleText(b,k,d,this.ds.scale,this.title_text_font,e);!q&&(b.font=this.title_text_font,q=a.getTitle())&&(b.fillStyle=e?"white":a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign=
+"center",p=b.measureText(q),b.fillText(q,k+0.5*p.width,c.NODE_TITLE_TEXT_Y-k),b.textAlign="left"):(b.textAlign="left",b.fillText(q,k,c.NODE_TITLE_TEXT_Y-k)));if(a.onDrawTitle)a.onDrawTitle(b)}if(e){if(a.onBounding)a.onBounding(n);h==c.TRANSPARENT_TITLE&&(n[1]-=k,n[3]+=k);b.lineWidth=1;b.globalAlpha=0.8;b.beginPath();l==c.BOX_SHAPE?b.rect(-6+n[0],-6+n[1],12+n[2],12+n[3]):l==c.ROUND_SHAPE||l==c.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+n[0],-6+n[1],12+n[2],12+n[3],2*this.round_radius):l==c.CARD_SHAPE?
+b.roundRect(-6+n[0],-6+n[1],12+n[2],12+n[3],2*this.round_radius,2):l==c.CIRCLE_SHAPE&&b.arc(0.5*d[0],0.5*d[1],0.5*d[0]+6,0,2*Math.PI);b.strokeStyle="#FFF";b.stroke();b.strokeStyle=g;b.globalAlpha=1}};var l=new Float32Array(4),g=new Float32Array(4),q=new Float32Array(2),w=new Float32Array(2);f.prototype.drawConnections=function(a){var b=c.getTime(),d=this.visible_area;l[0]=d[0]-20;l[1]=d[1]-20;l[2]=d[2]+40;l[3]=d[3]+40;a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=
+this.editor_alpha;for(var d=this.graph._nodes,e=0,k=d.length;eg[2]&&(g[0]+=g[2],g[2]=Math.abs(g[2]));0>g[3]&&(g[1]+=g[3],g[3]=Math.abs(g[3]));
+if(A(g,l)){var D=h.outputs[m],m=f.inputs[p];if(D&&m&&(h=D.dir||(h.horizontal?c.DOWN:c.RIGHT),m=m.dir||(f.horizontal?c.UP:c.LEFT),this.renderLink(a,r,t,n,!1,0,null,h,m),n&&n._last_time&&1E3>b-n._last_time)){var D=2-0.002*(b-n._last_time),E=a.globalAlpha;a.globalAlpha=E*D;this.renderLink(a,r,t,n,!0,D,"white",h,m);a.globalAlpha=E}}}}}}a.globalAlpha=1};f.prototype.renderLink=function(a,b,d,g,k,e,p,n,l,q){g&&this.visible_links.push(g);!p&&g&&(p=g.color||f.link_type_colors[g.type]);p||(p=this.default_link_color);
+null!=g&&this.highlighted_links[g.id]&&(p="#FFF");n=n||c.RIGHT;l=l||c.LEFT;var h=y(b,d);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(t[0],t[1]),a.rotate(D),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(q[0],
+q[1]),a.rotate(E),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(k[0],k[1],5,0,2*Math.PI),a.fill());if(e)for(a.fillStyle=p,t=0;5>t;++t)e=(0.001*c.getTime()+0.2*t)%1,k=this.computeConnectionPoint(b,d,e,n,l),a.beginPath(),a.arc(k[0],k[1],5,0,2*Math.PI),a.fill()};f.prototype.computeConnectionPoint=function(a,b,d,g,k){g=g||c.RIGHT;k=k||c.LEFT;var e=y(a,b),f=[a[0],a[1]],p=[b[0],b[1]];switch(g){case c.LEFT:f[0]+=-0.25*e;break;case c.RIGHT:f[0]+=0.25*
+e;break;case c.UP:f[1]+=-0.25*e;break;case c.DOWN:f[1]+=0.25*e}switch(k){case c.LEFT:p[0]+=-0.25*e;break;case c.RIGHT:p[0]+=0.25*e;break;case c.UP:p[1]+=-0.25*e;break;case c.DOWN:p[1]+=0.25*e}g=(1-d)*(1-d)*(1-d);k=3*(1-d)*(1-d)*d;e=3*(1-d)*d*d;d*=d*d;return[g*a[0]+k*f[0]+e*p[0]+d*b[0],g*a[1]+k*f[1]+e*p[1]+d*b[1]]};f.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=0.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=0.75;for(var b=this.visible_nodes,d=0;d<
+b.length;++d){var g=b[d];a.fillStyle="black";a.fillRect(g.pos[0]-c.NODE_TITLE_HEIGHT,g.pos[1]-c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT);0==g.order&&a.strokeRect(g.pos[0]-c.NODE_TITLE_HEIGHT+0.5,g.pos[1]-c.NODE_TITLE_HEIGHT+0.5,c.NODE_TITLE_HEIGHT,c.NODE_TITLE_HEIGHT);a.fillStyle="#FFF";a.fillText(g.order,g.pos[0]+-0.5*c.NODE_TITLE_HEIGHT,g.pos[1]-6)}a.globalAlpha=1};f.prototype.drawNodeWidgets=function(a,b,d,g){if(!a.widgets||!a.widgets.length)return 0;var k=a.size[0],e=a.widgets;
+b+=2;var f=c.NODE_WIDGET_HEIGHT,p=0.5t.last_y&&ft.options.max&&(t.value=t.options.max);else if("mousedown"==d.type)if((g=t.options.values)&&g.constructor===Function&&(g=t.options.values(t,a)),e=40>e?-1:e>p-40?1:0,"number"==t.type)t.value+=0.1*e*(t.options.step||1),null!=t.options.min&&t.valuet.options.max&&(t.value=t.options.max);else if(e)n=
+g.indexOf(t.value)+e,n>=g.length&&(n=0),0>n&&(n=g.length-1),t.value=g[n];else{new c.ContextMenu(g,{scale:Math.max(1,this.ds.scale),event:d,className:"dark",callback:D.bind(t)},n);var D=function(a,b,d){this.value=a;k(this,a);l.dirty_canvas=!0;return!1}}setTimeout(function(){k(this,this.value)}.bind(t),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==d.type&&(t.value=!t.value,t.callback&&setTimeout(function(){k(t,t.value)},20));break;case "string":case "text":"mousedown"==d.type&&this.prompt("Value",
+t.value,function(a){this.value=a;k(this,a)}.bind(t),d);break;default:t.mouse&&t.mouse(ctx,d,[e,f],a)}return t}}return null};f.prototype.drawGroups=function(a,b){if(this.graph){var d=this.graph._groups;b.save();b.globalAlpha=0.5*this.editor_alpha;for(var g=0;gd&&0.01>b.editor_alpha&&(clearInterval(c),1>d&&(b.live_mode=!0));1"+q+""+a+"",value:q});if(l.length)return new c.ContextMenu(l,{event:d,callback:e,parentMenu:g,allow_html:!0,node:k},b),!1}};f.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};f.onResizeNode=function(a,b,d,c,g){g&&(g.size=g.computeSize(),
+g.setDirtyCanvas(!0,!0))};f.prototype.showLinkMenu=function(a,b){var d=this;new c.ContextMenu(["Delete"],{event:b,callback:function(b){switch(b){case "Delete":d.graph.removeLink(a.id)}}});return!1};f.onShowPropertyEditor=function(a,b,d,c,g){function e(){var b=q.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=Boolean(b));g[p]=b;l.parentNode&&l.parentNode.removeChild(l);g.setDirtyCanvas(!0,!0)}var p=a.property||"title";b=g[p];var l=document.createElement("div");l.className="graphdialog";l.innerHTML=
+"";l.querySelector(".name").innerText=p;var q=l.querySelector("input");q&&(q.value=b,q.addEventListener("blur",function(a){this.focus()}),q.addEventListener("keydown",function(a){13==a.keyCode&&(e(),a.preventDefault(),a.stopPropagation())}));b=f.active_canvas.canvas;d=b.getBoundingClientRect();var n=c=-20;d&&(c-=d.left,n-=d.top);event?(l.style.left=event.clientX+c+"px",l.style.top=event.clientY+n+"px"):(l.style.left=
+0.5*b.width+c+"px",l.style.top=0.5*b.height+n+"px");l.querySelector("button").addEventListener("click",e);b.parentNode.appendChild(l)};f.prototype.prompt=function(a,b,d,c){var g=this;a=a||"";var e=!1,l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML=" ";l.close=function(){g.prompt_box=null;l.parentNode&&l.parentNode.removeChild(l)};1f.search_limit))break}if(Array.prototype.filter)for(m=Object.keys(c.registered_node_types).filter(function(a){return-1!==a.toLowerCase().indexOf(d)}),p=0;pf.search_limit);p++);else for(p in c.registered_node_types)if(-1!=
+p.indexOf(d)&&(a(p),-1!==f.search_limit&&l++>f.search_limit))break}}var e=this,l=document.createElement("div");l.className="litegraph litesearchbox graphdialog rounded";l.innerHTML="Search ";l.close=function(){e.search_box=null;document.body.focus();setTimeout(function(){e.canvas.focus()},20);l.parentNode&&l.parentNode.removeChild(l)};var p=null;1";else if("enum"==e&&l.values){p=""}else if("boolean"==e)p="";else{console.warn("unknown type: "+e);return}var n=this.createDialog(""+b+""+p+"",d);if("enum"==e&&l.values){var t=n.querySelector("select");t.addEventListener("change",function(a){g(a.target.value)})}else if("boolean"==e)(t=n.querySelector("input"))&&t.addEventListener("click",function(a){g(!!t.checked)});else if(t=n.querySelector("input"))t.addEventListener("blur",function(a){this.focus()}),t.value=void 0!==a.properties[b]?a.properties[b]:"",t.addEventListener("keydown",
+function(a){13==a.keyCode&&(c(),a.preventDefault(),a.stopPropagation())});n.querySelector("button").addEventListener("click",c)}};f.prototype.createDialog=function(a,b){b=b||{};var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;var c=this.canvas.getBoundingClientRect(),g=-20,e=-20;c&&(g-=c.left,e-=c.top);b.position?(g+=b.position[0],e+=b.position[1]):b.event?(g+=b.event.clientX,e+=b.event.clientY):(g+=0.5*this.canvas.width,e+=0.5*this.canvas.height);d.style.left=g+"px";d.style.top=
+e+"px";this.canvas.parentNode.appendChild(d);d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return d};f.onMenuNodeCollapse=function(a,b,d,c,g){g.collapse()};f.onMenuNodePin=function(a,b,d,c,g){g.pin()};f.onMenuNodeMode=function(a,b,d,g,e){new c.ContextMenu(["Always","On Event","On Trigger","Never"],{event:d,callback:function(a){if(e)switch(a){case "On Event":e.mode=c.ON_EVENT;break;case "On Trigger":e.mode=c.ON_TRIGGER;break;case "Never":e.mode=c.NEVER;break;default:e.mode=
+c.ALWAYS}},parentMenu:g,node:e});return!1};f.onMenuNodeColors=function(a,b,d,g,e){if(!e)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var l in f.node_colors)a=f.node_colors[l],a={value:l,content:""+l+""},b.push(a);new c.ContextMenu(b,{event:d,callback:function(a){e&&((a=a.value?f.node_colors[a.value]:
+null)?e.constructor===c.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor):(delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:g,node:e});return!1};f.onMenuNodeShapes=function(a,b,d,g,e){if(!e)throw"no node passed";new c.ContextMenu(c.VALID_SHAPES,{event:d,callback:function(a){e&&(e.shape=a,e.setDirtyCanvas(!0))},parentMenu:g,node:e});return!1};f.onMenuNodeRemove=function(a,b,d,c,g){if(!g)throw"no node passed";!1!==g.removable&&(g.graph.remove(g),g.setDirtyCanvas(!0,
+!0))};f.onMenuNodeClone=function(a,b,d,c,g){!1!=g.clonable&&(a=g.clone())&&(a.pos=[g.pos[0]+5,g.pos[1]+5],g.graph.add(a),g.setDirtyCanvas(!0,!0))};f.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"}};f.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:f.onMenuAdd},{content:"Add Group",callback:f.onGroupAdd}],this._graph_stack&&0Name",c),l=e.querySelector("input");l&&t&&(l.value=t.label||"");e.querySelector("button").addEventListener("click",function(a){l.value&&(t&&(t.label=l.value),d.setDirty(!0));e.close()})}},extra:a},p=null;a&&(p=a.getSlotInPosition(b.canvasX,b.canvasY),f.active_node=a);if(p){e=[];p&&p.output&&p.output.links&&p.output.links.length&&e.push({content:"Disconnect Links",slot:p});var q=p.input||p.output;e.push(q.locked?
+"Cannot remove":{content:"Remove Slot",slot:p});e.push(q.nameLocked?"Cannot rename":{content:"Rename Slot",slot:p});l.title=(p.input?p.input.type:p.output.type)||"*";p.input&&p.input.type==c.ACTION&&(l.title="Action");p.output&&p.output.type==c.EVENT&&(l.title="Event")}else a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(p=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:p,options:this.getGroupMenuOptions(p)}}));
+e&&new c.ContextMenu(e,l,g)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,d,c,g,e){void 0===g&&(g=5);void 0===e&&(e=g);this.moveTo(a+g,b);this.lineTo(a+d-g,b);this.quadraticCurveTo(a+d,b,a+d,b+g);this.lineTo(a+d,b+c-e);this.quadraticCurveTo(a+d,b+c,a+d-e,b+c);this.lineTo(a+e,b+c);this.quadraticCurveTo(a,b+c,a,b+c-e);this.lineTo(a,b+g);this.quadraticCurveTo(a,b,a+g,b)});c.compareObjects=function(a,b){for(var d in a)if(a[d]!=b[d])return!1;return!0};c.distance=
+y;c.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")+")"};c.isInsideRectangle=B;c.growBounding=function(a,b,d){ba[2]&&(a[2]=b);da[3]&&(a[3]=d)};c.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};c.overlapBounding=A;c.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();
+for(var b=Array(3),d=0,c,g,e=0;6>e;e+=2)c="0123456789ABCDEF".indexOf(a.charAt(e)),g="0123456789ABCDEF".indexOf(a.charAt(e+1)),b[d]=16*c+g,d++;return b};c.num2hex=function(a){for(var b="#",d,c,g=0;3>g;g++)d=a[g]/16,c=a[g]%16,b+="0123456789ABCDEF".charAt(d)+"0123456789ABCDEF".charAt(c);return b};z.prototype.addItem=function(a,b,d){function c(a){var b=this.value;b&&b.has_submenu&&g.call(this,a)}function g(a){var b=this.value,c=!0;e.current_submenu&&e.current_submenu.close(a);if(d.callback){var t=d.callback.call(this,
+b,d,a,e,d.node);!0===t&&(c=!1)}if(b&&(b.callback&&!d.ignore_item_callbacks&&!0!==b.disabled&&(t=b.callback.call(this,b,d,a,e,d.extra),!0===t&&(c=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new e.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:e,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:d.autoopen});c=!1}c&&!e.lock&&e.close()}var e=this;d=d||{};var l=document.createElement("div");
+l.className="litemenu-entry submenu";var f=!1;if(null===b)l.classList.add("separator");else{l.innerHTML=b&&b.title?b.title:a;if(l.value=b)b.disabled&&(f=!0,l.classList.add("disabled")),(b.submenu||b.has_submenu)&&l.classList.add("has_submenu");"function"==typeof b?(l.dataset.value=a,l.onclick_callback=b):l.dataset.value=b;b.className&&(l.className+=" "+b.className)}this.root.appendChild(l);f||l.addEventListener("click",g);d.autoopen&&l.addEventListener("mouseenter",c);return l};z.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&&!z.isCursorOverElement(a,this.parentMenu.root)&&z.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};z.trigger=function(a,b,d,c){var g=document.createEvent("CustomEvent");g.initCustomEvent(b,
+!0,!0,d);g.srcElement=c;a.dispatchEvent?a.dispatchEvent(g):a.__events&&a.__events.dispatchEvent(g);return g};z.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};z.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};z.isCursorOverElement=function(a,b){var d=a.clientX,c=a.clientY,g=b.getBoundingClientRect();return g?c>g.top&&cg.left&&da?b:dpixelcode must be vec3
\t\t\tFor multiline you must type: result = ...
";this.properties={value:1,uvcode:"",pixelcode:"color + colorB * value",
-precision:h.DEFAULT};this.has_error=!1};s.widgets_info={uvcode:{widget:"textarea",height:100},pixelcode:{widget:"textarea",height:100},precision:{widget:"combo",values:h.MODE_VALUES}};s.title="Operation";s.desc="Texture shader operation";s.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]};s.prototype.onPropertyChanged=function(){this.has_error=!1};s.prototype.onDrawBackground=
-function(a){this.flags.collapsed||20>=this.size[1]||!this.properties.show||!this._tex||this._tex.gl!=a||(a.save(),a.drawImage(this._tex,0,0,this.size[0],this.size[1]),a.restore())};s.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===h.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var c=512,d=512;a?(c=a.width,d=a.height):b&&(c=b.width,d=b.height);var e=h.getTextureType(this.properties.precision,
-a);this._tex=a||this._tex?h.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(c,d,{type:e,format:gl.RGBA,filter:gl.LINEAR});e="";this.properties.uvcode&&(e="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&&(e=this.properties.uvcode));var g="";this.properties.pixelcode&&(g="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(g=this.properties.pixelcode));var f=this._shader;if(!(this.has_error||f&&this._shader_code==
-e+"|"+g)){var k=h.replaceCode(s.pixel_shader,{UV_CODE:e,PIXEL_CODE:g});try{f=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,k),this.boxcolor="#00FF00"}catch(q){console.log("Error compiling shader: ",q,k);this.boxcolor="#FF0000";this.has_error=!0;return}this._shader=f;this._shader_code=e+"|"+g}var l=this.getInputData(2);null!=l?this.properties.value=l:l=parseFloat(this.properties.value);var m=this.graph.getTime();this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);
-a&&a.bind(0);b&&b.bind(1);var e=Mesh.getScreenQuad();f.uniforms({u_texture:0,u_textureB:1,value:l,texSize:[c,d],time:m}).draw(e)});this.setOutputData(0,this._tex)}}};s.pixel_shader="precision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform sampler2D u_textureB;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform float time;\n\t\t\tuniform float value;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 uv = v_coord;\n\t\t\t\t{{UV_CODE}};\n\t\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\t\tvec3 color = color4.rgb;\n\t\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\t\tvec3 colorB = color4B.rgb;\n\t\t\t\tvec3 result = color;\n\t\t\t\tfloat alpha = 1.0;\n\t\t\t\t{{PIXEL_CODE}};\n\t\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t\t}\n\t\t\t";
+this.addInput("TextureB","Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="For multiline you must type: result = ...
";this.properties={value:1,pixelcode:"color + colorB * value",uvcode:"",precision:h.DEFAULT};
+this.has_error=!1};s.widgets_info={uvcode:{widget:"code"},pixelcode:{widget:"code"},precision:{widget:"combo",values:h.MODE_VALUES}};s.title="Operation";s.desc="Texture shader operation";s.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]};s.prototype.onPropertyChanged=function(){this.has_error=!1};s.prototype.onDrawBackground=function(a){this.flags.collapsed||20>=this.size[1]||
+!this.properties.show||!this._tex||this._tex.gl!=a||(a.save(),a.drawImage(this._tex,0,0,this.size[0],this.size[1]),a.restore())};s.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===h.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var c=512,d=512;a?(c=a.width,d=a.height):b&&(c=b.width,d=b.height);var e=h.getTextureType(this.properties.precision,a);this._tex=
+a||this._tex?h.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(c,d,{type:e,format:gl.RGBA,filter:gl.LINEAR});e="";this.properties.uvcode&&(e="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&&(e=this.properties.uvcode));var g="";this.properties.pixelcode&&(g="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(g=this.properties.pixelcode));var f=this._shader;if(!(this.has_error||f&&this._shader_code==e+"|"+g)){var k=
+h.replaceCode(s.pixel_shader,{UV_CODE:e,PIXEL_CODE:g});try{f=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,k),this.boxcolor="#00FF00"}catch(q){console.log("Error compiling shader: ",q,k);this.boxcolor="#FF0000";this.has_error=!0;return}this._shader=f;this._shader_code=e+"|"+g}var l=this.getInputData(2);null!=l?this.properties.value=l:l=parseFloat(this.properties.value);var m=this.graph.getTime();this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);a&&a.bind(0);
+b&&b.bind(1);var e=Mesh.getScreenQuad();f.uniforms({u_texture:0,u_textureB:1,value:l,texSize:[c,d],time:m}).draw(e)});this.setOutputData(0,this._tex)}}};s.pixel_shader="precision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform sampler2D u_textureB;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform float time;\n\t\t\tuniform float value;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 uv = v_coord;\n\t\t\t\t{{UV_CODE}};\n\t\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\t\tvec3 color = color4.rgb;\n\t\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\t\tvec3 colorB = color4B.rgb;\n\t\t\t\tvec3 result = color;\n\t\t\t\tfloat alpha = 1.0;\n\t\t\t\t{{PIXEL_CODE}};\n\t\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t\t}\n\t\t\t";
e.registerNodeType("texture/operation",s);var f=function(){this.addOutput("out","Texture");this.properties={code:"",width:512,height:512,precision:h.DEFAULT};this.properties.code="\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n//your code here\n\ngl_FragColor = vec4(color, 1.0);\n}\n";this._uniforms={in_texture:0,texSize:vec2.create(),time:0}};f.title="Shader";f.desc="Texture shader";f.widgets_info={code:{type:"code"},precision:{widget:"combo",values:h.MODE_VALUES}};f.prototype.onPropertyChanged=
function(a,b){if("code"==a){var c=this.getShader();if(c){var d=c.uniformInfo;if(this.inputs)for(var e={},g=0;g