diff --git a/build/litegraph.js b/build/litegraph.js index a7deb33b9..90fa7e490 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -7853,7 +7853,15 @@ function ContextMenu( values, options ) root.addEventListener("mouseleave", function(e) { if(that.lock) return; - that.close(e); + if(root.closing_timer) + clearTimeout( root.closing_timer ); + root.closing_timer = setTimeout( that.close.bind(that), 500 ); + //that.close(e); + }); + + root.addEventListener("mouseenter", function(e) { + if(root.closing_timer) + clearTimeout( root.closing_timer ); }); //insert before checking position @@ -7949,6 +7957,7 @@ ContextMenu.prototype.addItem = function( name, value, options ) var value = this.value; if(!value || !value.has_submenu) return; + //if it is a submenu, autoopen like the item was clicked inner_onclick.call(this,e); } diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 7c58d1b2e..41dc02879 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -5,207 +5,207 @@ a&&a.constructor===String&&(a=document.querySelector(a));this.max_zoom=10;this.m a[1]))}function r(a,b,e,c,f,n){return ea&&cb?!0:!1}function s(a,b){var e=a[0]+a[2],c=a[1]+a[3],f=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>f||ek.width-g.width-10&&(n=k.width-g.width-10);l>k.height-g.height-10&&(l=k.height-g.height-10)}f.style.left=n+"px";f.style.top=l+"px"}var k=u.LiteGraph={CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:20,NODE_SLOT_HEIGHT:15,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:"#444",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box", -DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,LINK_COLOR:"#AAD",EVENT_LINK_COLOR:"#F85",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,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"", -debug:!1,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;k.debug&&console.log("Node registered: "+a);a.split("/");var e=b.name,c=a.lastIndexOf("/");b.category=a.substr(0,c);b.title||(b.title=e);if(b.prototype)for(var f in d.prototype)b.prototype[f]||(b.prototype[f]=d.prototype[f]);Object.defineProperty(b.prototype, -"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=k.BOX_SHAPE;break;case "round":this._shape=k.ROUND_SHAPE;break;case "circle":this._shape=k.CIRCLE_SHAPE;break;case "card":this._shape=k.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0});this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[e]=b);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end"); -if(b.supported_extensions)for(f in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[f].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,e,c){for(var f=Array(b.length),n="",l=k.getParameterNames(b),w=0;wl&&(l=f.size[0]),k+=f.size[1]+a;b+=l+a}this.setDirtyCanvas(!0,!0)};h.prototype.getTime=function(){return this.globaltime};h.prototype.getFixedTime=function(){return this.fixedtime};h.prototype.getElapsedTime=function(){return this.elapsed_time}; -h.prototype.sendEventToAllNodes=function(a,b,e){e=e||k.ALWAYS;var c=this._nodes_in_order?this._nodes_in_order:this._nodes;if(c)for(var f=0,n=c.length;f=k.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_ida.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};d.prototype.configure=function(a){this.graph&&this.graph._version++;for(var b in a)if("console"!=b)if("properties"==b)for(var e in a.properties){if(this.properties[e]=a.properties[e],this.onPropertyChanged)this.onPropertyChanged(e,a.properties[e])}else null!= -a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=k.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);if(this.onConnectionsChange){if(this.inputs)for(var c=0;c=this.outputs.length)){var e=this.outputs[a];if(e&&(e._data=b,this.outputs[a].links))for(e=0;e=this.inputs.length||null==this.inputs[a].link)){var e=this.graph.links[this.inputs[a].link]; -if(!e)return null;if(!b)return e.data;var c=this.graph.getNodeById(e.origin_id);if(!c)return e.data;if(c.updateOutputData)c.updateOutputData(e.origin_slot);else if(c.onExecute)c.onExecute();return e.data}};d.prototype.getInputDataByName=function(a,b){var e=this.findInputSlot(a);return-1==e?null:this.getInputData(e,b)};d.prototype.isInputConnected=function(a){return this.inputs?a=this.inputs.length)return null;a=this.inputs[a];return a&&null!==a.link?(a=this.graph.links[a.link])?this.graph.getNodeById(a.origin_id):null:null};d.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,e=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};d.prototype.getOutputInfo=function(a){return this.outputs?a=this.outputs.length)return null;a=this.outputs[a];if(!a.links||0==a.links.length)return null;for(var b=[],e=0;ea&&this.pos[1]-f-eb)return!0;return!1};d.prototype.getSlotInPosition=function(a,b){if(this.inputs)for(var e=0,c=this.inputs.length;e< -c;++e){var f=this.inputs[e],n=this.getConnectionPos(!0,e);if(r(a,b,n[0]-10,n[1]-5,20,10))return{input:f,slot:e,link_pos:n,locked:f.locked}}if(this.outputs)for(e=0,c=this.outputs.length;e=this.outputs.length)return k.debug&& -console.log("Connect: Error, slot number not found"),!1;b&&b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b==this)return!1;if(e.constructor===String){if(e=b.findInputSlot(e),-1==e)return k.debug&&console.log("Connect: Error, no slot of name "+e),!1}else{if(e===k.EVENT)return!1;if(!b.inputs||e>=b.inputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1}null!=b.inputs[e].link&&b.disconnectInput(e);var c=this.outputs[a];if(b.onConnectInput&& -!1===b.onConnectInput(e,c.type,c))return!1;var f=b.inputs[e];if(k.isValidConnection(c.type,f.type)){var n={id:this.graph.last_link_id++,type:f.type,origin_id:this.id,origin_slot:a,target_id:b.id,target_slot:e};this.graph.links[n.id]=n;null==c.links&&(c.links=[]);c.links.push(n.id);b.inputs[e].link=n.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(k.OUTPUT,a,!0,n,c);if(b.onConnectionsChange)b.onConnectionsChange(k.INPUT,e,!0,n,f);this.graph&&this.graph.onNodeConnectionChange&& -(this.graph.onNodeConnectionChange(k.INPUT,b,e,this,a),this.graph.onNodeConnectionChange(k.OUTPUT,this,a,b,e))}this.setDirtyCanvas(!1,!0);this.graph.connectionChange(this);return!0};d.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return k.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1;var e=this.outputs[a];if(!e|| -!e.links||0==e.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var c=0,f=e.links.length;c=this.inputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var e=this.inputs[a].link;this.inputs[a].link=null;var c=this.graph.links[e];if(c){var f=this.graph.getNodeById(c.origin_id);if(!f)return!1;var n=f.outputs[c.origin_slot];if(!n||!n.links||0==n.links.length)return!1;for(var l=0,g=n.links.length;l< -g;l++)if(n.links[l]==e){n.links.splice(l,1);break}delete this.graph.links[e];this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(k.INPUT,a,!1,c,b);if(f.onConnectionsChange)f.onConnectionsChange(k.OUTPUT,l,!1,c,n);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(k.OUTPUT,f,l),this.graph.onNodeConnectionChange(k.INPUT,this,a))}this.setDirtyCanvas(!1,!0);this.graph.connectionChange(this);return!0};d.prototype.getConnectionPos=function(a, -b){return this.flags.collapsed?a?[this.pos[0],this.pos[1]-0.5*k.NODE_TITLE_HEIGHT]:[this.pos[0]+(this._collapsed_width||k.NODE_COLLAPSED_WIDTH),this.pos[1]-0.5*k.NODE_TITLE_HEIGHT]:a&&-1==b?[this.pos[0]+10,this.pos[1]+10]:a&&this.inputs&&this.inputs.length>b&&this.inputs[b].pos?[this.pos[0]+this.inputs[b].pos[0],this.pos[1]+this.inputs[b].pos[1]]:!a&&this.outputs&&this.outputs.length>b&&this.outputs[b].pos?[this.pos[0]+this.outputs[b].pos[0],this.pos[1]+this.outputs[b].pos[1]]:this.flags.horizontal? -a?[this.pos[0]+this.size[0]/this.inputs.length*(b+0.5),this.pos[1]-k.NODE_TITLE_HEIGHT]:[this.pos[0]+this.size[0]/this.outputs.length*(b+0.5),this.pos[1]+this.size[1]]:a?[this.pos[0],this.pos[1]+10+b*k.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0)]:[this.pos[0]+this.size[0]+1,this.pos[1]+10+b*k.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0)]};d.prototype.alignToGrid=function(){this.pos[0]=k.CANVAS_GRID_SIZE*Math.round(this.pos[0]/k.CANVAS_GRID_SIZE);this.pos[1]=k.CANVAS_GRID_SIZE*Math.round(this.pos[1]/ -k.CANVAS_GRID_SIZE)};d.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>d.MAX_CONSOLE&&this.console.shift();this.graph.onNodeTrace(this,a)};d.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};d.prototype.loadImage=function(a){var b=new Image;b.src=k.node_images_path+a;b.ready=!1;var e=this;b.onload=function(){this.ready=!0;e.setDirtyCanvas(!0)};return b};d.prototype.captureInput=function(a){if(this.graph&& -this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,e=0;ea.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos}, -enumerable:!0});Object.defineProperty(this,"size",{set:function(a){!a||2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size},enumerable:!0})};p.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};p.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}}; -p.prototype.move=function(a,b,e){this._pos[0]+=a;this._pos[1]+=b;if(!e)for(e=0;e element, you passed a "+a.localName;throw"This browser doesnt support Canvas";}null==(this.ctx=a.getContext("2d"))&&(a.webgl_enabled||console.warn("This canvas seems to be WebGL, enabling WebGL renderer"),this.enableWebGL());this._mousemove_callback= -this.processMouseMove.bind(this);this._mouseup_callback=this.processMouseUp.bind(this);b||this.bindEvents()}};g.prototype._doNothing=function(a){a.preventDefault();return!1};g.prototype._doReturnTrue=function(a){a.preventDefault();return!0};g.prototype.bindEvents=function(){if(this._events_binded)console.warn("LGraphCanvas: events already binded");else{var a=this.canvas,b=this.getCanvasWindow().document;this._mousedown_callback=this.processMouseDown.bind(this);this._mousewheel_callback=this.processMouseWheel.bind(this); -a.addEventListener("mousedown",this._mousedown_callback,!0);a.addEventListener("mousemove",this._mousemove_callback);a.addEventListener("mousewheel",this._mousewheel_callback,!1);a.addEventListener("contextmenu",this._doNothing);a.addEventListener("DOMMouseScroll",this._mousewheel_callback,!1);a.addEventListener("touchstart",this.touchHandler,!0);a.addEventListener("touchmove",this.touchHandler,!0);a.addEventListener("touchend",this.touchHandler,!0);a.addEventListener("touchcancel",this.touchHandler, -!0);this._key_callback=this.processKey.bind(this);a.addEventListener("keydown",this._key_callback,!0);b.addEventListener("keyup",this._key_callback,!0);this._ondrop_callback=this.processDrop.bind(this);a.addEventListener("dragover",this._doNothing,!1);a.addEventListener("dragend",this._doNothing,!1);a.addEventListener("drop",this._ondrop_callback,!1);a.addEventListener("dragenter",this._doReturnTrue,!1);this._events_binded=!0}};g.prototype.unbindEvents=function(){if(this._events_binded){var a=this.getCanvasWindow().document; -this.canvas.removeEventListener("mousedown",this._mousedown_callback);this.canvas.removeEventListener("mousewheel",this._mousewheel_callback);this.canvas.removeEventListener("DOMMouseScroll",this._mousewheel_callback);this.canvas.removeEventListener("keydown",this._key_callback);a.removeEventListener("keyup",this._key_callback);this.canvas.removeEventListener("contextmenu",this._doNothing);this.canvas.removeEventListener("drop",this._ondrop_callback);this.canvas.removeEventListener("dragenter",this._doReturnTrue); -this.canvas.removeEventListener("touchstart",this.touchHandler);this.canvas.removeEventListener("touchmove",this.touchHandler);this.canvas.removeEventListener("touchend",this.touchHandler);this.canvas.removeEventListener("touchcancel",this.touchHandler);this._ondrop_callback=this._key_callback=this._mousewheel_callback=this._mousedown_callback=null;this._events_binded=!1}else console.warn("LGraphCanvas: no events binded")};g.getFileExtension=function(a){var b=a.indexOf("?");-1!=b&&(a=a.substr(0,b)); -b=a.lastIndexOf(".");return-1==b?"":a.substr(b+1).toLowerCase()};g.prototype.enableWebGL=function(){if(void 0===typeof GL)throw"litegl.js must be included to use a WebGL canvas";if(void 0===typeof enableWebGLCanvas)throw"webglCanvas.js must be included to use this feature";this.gl=this.ctx=enableWebGLCanvas(this.canvas);this.ctx.webgl=!0;this.bgcanvas=this.canvas;this.bgctx=this.gl;this.canvas.webgl_enabled=!0};g.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)}; -g.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument;return a.defaultView||a.parentWindow};g.prototype.startRendering=function(){function a(){this.pause_rendering||this.draw();var b=this.getCanvasWindow();this.is_rendering&&b.requestAnimationFrame(a.bind(this))}this.is_rendering||(this.is_rendering=!0,a.call(this))};g.prototype.stopRendering=function(){this.is_rendering=!1};g.prototype.processMouseDown=function(a){if(this.graph){this.adjustMouseEvent(a); -var b=this.getCanvasWindow();g.active_canvas=this;this.canvas.removeEventListener("mousemove",this._mousemove_callback);b.document.addEventListener("mousemove",this._mousemove_callback,!0);b.document.addEventListener("mouseup",this._mouseup_callback,!0);var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes,5),c=!1,f=300>k.getTime()-this.last_mouseclick;this.canvas_mouse[0]=a.canvasX;this.canvas_mouse[1]=a.canvasY;k.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,c=!0);var n=!1;if(e&&this.allow_interaction&&!c){this.live_mode||e.flags.pinned||this.bringToFront(e);if(!this.connecting_node&&!e.flags.collapsed&&!this.live_mode)if(!c&&!1!==e.flags.resizable&&r(a.canvasX,a.canvasY,e.pos[0]+e.size[0]-5,e.pos[1]+e.size[1]-5,10,10))this.resizing_node=e,this.canvas.style.cursor= -"se-resize",c=!0;else{if(e.outputs)for(var l=0,d=e.outputs.length;lq([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.scale?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes()), -f&&this.showSearchBox(a),n=!0;!c&&n&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}else 2!=a.which&&3==a.which&&this.processContextMenu(e,a);this.last_mouse[0]=a.localX;this.last_mouse[1]=a.localY;this.last_mouseclick=k.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}}};g.prototype.processMouseMove=function(a){this.autoresize&&this.resize();if(this.graph){g.active_canvas=this;this.adjustMouseEvent(a);var b=[a.localX,a.localY],e=[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(e[0]/this.scale,e[1]/this.scale,a.ctrlKey),this.selected_group._nodes.length&&(this.dirty_canvas=!0)),this.dirty_bgcanvas=!0;else if(this.dragging_canvas)this.offset[0]+=e[0]/this.scale,this.offset[1]+= -e[1]/this.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if(this.allow_interaction){this.connecting_node&&(this.dirty_canvas=!0);for(var c=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes),b=0,f=this.graph._nodes.length;bthis.dragging_rectangle[3]?this.dragging_rectangle[1]-f:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-c:this.dragging_rectangle[0];this.dragging_rectangle[1]=n;this.dragging_rectangle[2]=c;this.dragging_rectangle[3]=f;f=[];for(n=0;na.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}};g.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var e=this.scale;0b&&(e*=1/1.1);this.setZoom(e,[a.localX, -a.localY]);this.graph.change();a.preventDefault();return!1}};g.prototype.isOverNodeBox=function(a,b,e){var c=k.NODE_TITLE_HEIGHT;return r(b,e,a.pos[0]+2,a.pos[1]+2-c,c-4,c-4)?!0:!1};g.prototype.isOverNodeInput=function(a,b,e,c){if(a.inputs)for(var f=0,n=a.inputs.length;fthis.max_zoom?this.scale=this.max_zoom:this.scalec-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}};g.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(); -a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1]);for(var b=this.computeVisibleNodes(null,this.visible_nodes),c=0;c> ";b.fillText(g+c.getTitle(),0.5*a.width,40);b.restore()}c=!1;this.onRenderBackground&&(c=this.onRenderBackground(a,b));b.restore();b.setTransform(1,0,0,1,0,0);if(this.graph){b.save();b.scale(this.scale,this.scale);b.translate(this.offset[0],this.offset[1]);if(this.background_image&&0.5this.scale?b.fillRect(0,l,A,p):m==k.ROUND_SHAPE||m==k.CARD_SHAPE?b.roundRect(0,l,A,p,this.round_radius,m==k.CARD_SHAPE?0:this.round_radius):m==k.CIRCLE_SHAPE&&b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0, -2*Math.PI),b.fill());b.shadowColor="transparent";a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&&!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas);if(z||h==k.TRANSPARENT_TITLE){if(h!=k.TRANSPARENT_TITLE){a.flags.collapsed&&(b.shadowColor=k.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var q=g.gradients[d];q||(q=g.gradients[d]=b.createLinearGradient(0,0,400,0),q.addColorStop(0, -d),q.addColorStop(1,"#000"));b.fillStyle=q}else b.fillStyle=d;q=b.globalAlpha;b.beginPath();m==k.BOX_SHAPE||0.5>this.scale?b.rect(0,-f,c[0]+1,f):m!=k.ROUND_SHAPE&&m!=k.CARD_SHAPE||b.roundRect(0,-f,c[0]+1,f,this.round_radius,a.flags.collapsed?this.round_radius:0);b.fill();b.shadowColor="transparent"}m==k.ROUND_SHAPE||m==k.CIRCLE_SHAPE||m==k.CARD_SHAPE?(0.5g[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(s(g,c)){var v=p.outputs[q],q=m.inputs[d];if(v&&q&&(p=v.dir||(p.flags.horizontal?k.DOWN:k.RIGHT),q=q.dir||(m.flags.horizontal?k.UP:k.LEFT),this.renderLink(a,r,t,h,!1,0,null,p,q),h&&h._last_time&&1E3>b-h._last_time)){var v=2-0.002*(b-h._last_time),y=a.globalAlpha;a.globalAlpha= -y*v;this.renderLink(a,r,t,h,!0,v,"white",p,q);a.globalAlpha=y}}}}}}a.globalAlpha=1};g.prototype.renderLink=function(a,b,c,m,f,n,l,d,h){if(this.highquality_render){d=d||k.RIGHT;h=h||k.LEFT;var p=q(b,c);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(f[0],f[1]),a.rotate(p),a.beginPath(),a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(n)for(n=0;5>n;++n)f=(0.001*k.getTime()+0.2*n)%1,f=this.computeConnectionPoint(b, -c,f,d,h),a.beginPath(),a.arc(f[0],f[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};g.prototype.computeConnectionPoint=function(a,b,c,g,f){g=g||k.RIGHT;f=f||k.LEFT;var n=q(a,b),l=[a[0],a[1]],m=[b[0],b[1]];switch(g){case k.LEFT:l[0]+=-0.25*n;break;case k.RIGHT:l[0]+=0.25*n;break;case k.UP:l[1]+=-0.25*n;break;case k.DOWN:l[1]+=0.25*n}switch(f){case k.LEFT:m[0]+=-0.25*n;break;case k.RIGHT:m[0]+=0.25*n;break;case k.UP:m[1]+=-0.25*n;break;case k.DOWN:m[1]+= -0.25*n}g=(1-c)*(1-c)*(1-c);f=3*(1-c)*(1-c)*c;n=3*(1-c)*c*c;c*=c*c;return[g*a[0]+f*l[0]+n*m[0]+c*b[0],g*a[1]+f*l[1]+n*m[1]+c*b[1]]};g.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,c=0;cp.last_y&&np.options.max&&(p.value=p.options.max);else if("mousedown"==c.type)if((g=p.options.values)&&g.constructor===Function&&(g=p.options.values(p,a)),f=40>f?-1:f>l-40?1:0,"number"==p.type)p.value+=0.1*f*(p.options.step||1),null!=p.options.min&&p.valuep.options.max&&(p.value= -p.options.max);else if(f)c=g.indexOf(p.value)+f,c>=g.length&&(c=0),0>c&&(c=g.length-1),p.value=g[c];else{new k.ContextMenu(g,{event:c,className:"dark",callback:q.bind(p)},m);var q=function(a,b,c){this.value=a;d.dirty_canvas=!0;return!1}}p.callback&&setTimeout(function(){this.callback(this.value,d,a,b)}.bind(p),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(p.value=!p.value,p.callback&&setTimeout(function(){p.callback(p.value,d,a,b)},20));break;case "text":"mousedown"==c.type&& -this.prompt("Value",p.value,function(b){this.value=b;p.callback&&p.callback(b,d,a)}.bind(p),c)}return p}}return null};g.prototype.drawGroups=function(a,b){if(this.graph){var c=this.graph._groups;b.save();b.globalAlpha=0.5*this.editor_alpha;for(var g=0;gc&&0.01>b.editor_alpha&&(clearInterval(g),1>c&&(b.live_mode=!0));1"+ -p+""+a+"",value:p});if(h.length)return new k.ContextMenu(h,{event:c,callback:m,parentMenu:d,allow_html:!0,node:f},b),!1}};g.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};g.onResizeNode=function(a,b,c,g,f){f&&(f.size=f.computeSize(),f.setDirtyCanvas(!0,!0))};g.onShowPropertyEditor=function(a,b,c,d,f){function m(){var b=h.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=Boolean(b));f[l]=b;k.parentNode.removeChild(k); -f.setDirtyCanvas(!0,!0)}var l=a.property||"title";b=f[l];var k=document.createElement("div");k.className="graphdialog";k.innerHTML="";k.querySelector(".name").innerText=l;var h=k.querySelector("input");h&&(h.value=b,h.addEventListener("blur",function(a){this.focus()}),h.addEventListener("keydown",function(a){13==a.keyCode&&(m(),a.preventDefault(),a.stopPropagation())}));b=g.active_canvas.canvas;c=b.getBoundingClientRect(); -var p=d=-20;c&&(d-=c.left,p-=c.top);event?(k.style.left=event.pageX+d+"px",k.style.top=event.pageY+p+"px"):(k.style.left=0.5*b.width+d+"px",k.style.top=0.5*b.height+p+"px");k.querySelector("button").addEventListener("click",m);b.parentNode.appendChild(k)};g.prototype.prompt=function(a,b,c,d){var f=this;a=a||"";var m=document.createElement("div");m.className="graphdialog rounded";m.innerHTML=" "; -m.close=function(){f.prompt_box=null;m.parentNode.removeChild(m)};m.addEventListener("mouseleave",function(a){m.close()});f.prompt_box&&f.prompt_box.close();f.prompt_box=m;m.querySelector(".name").innerText=a;m.querySelector(".value").value=b;var l=m.querySelector("input");l.addEventListener("keydown",function(a){if(27==a.keyCode)m.close();else if(13==a.keyCode)c&&c(this.value),m.close();else return;a.preventDefault();a.stopPropagation()});m.querySelector("button").addEventListener("click",function(a){c&& -c(l.value);f.setDirty(!0);m.close()});a=g.active_canvas.canvas;b=a.getBoundingClientRect();var k=-20,h=-20;b&&(k-=b.left,h-=b.top);d?(m.style.left=d.pageX+k+"px",m.style.top=d.pageY+h+"px"):(m.style.left=0.5*a.width+k+"px",m.style.top=0.5*a.height+h+"px");a.parentNode.appendChild(m);setTimeout(function(){l.focus()},10);return m};g.search_limit=-1;g.prototype.showSearchBox=function(a){function b(b){if(b)if(f.onSearchBoxSelection)f.onSearchBoxSelection(b,a,s);else{var c=k.searchbox_extras[b];c&&(b= -c.type);if(b=k.createNode(b))b.pos=s.convertEventToCanvas(a),s.graph.add(b);if(c&&c.data){if(c.data.properties)for(var e in c.data.properties)b.addProperty(c.data.properties[e][0],c.data.properties[e][0]);if(c.data.inputs)for(e in b.inputs=[],c.data.inputs)b.addOutput(c.data.inputs[e][0],c.data.inputs[e][1]);if(c.data.outputs)for(e in b.outputs=[],c.data.outputs)b.addOutput(c.data.outputs[e][0],c.data.outputs[e][1]);c.data.title&&(b.title=c.data.title);c.data.json&&b.configure(c.data.json)}}m.close()} -function c(a){var b=q;q&&q.classList.remove("selected");q?(q=a?q.nextSibling:q.previousSibling)||(q=b):q=a?l.childNodes[0]:l.childNodes[l.childNodes.length];q&&(q.classList.add("selected"),q.scrollIntoView())}function d(){function a(c,e){var y=document.createElement("div");h||(h=c);y.innerText=c;y.dataset.type=escape(c);y.className="litegraph lite-search-item";e&&(y.className+=" "+e);y.addEventListener("click",function(a){b(unescape(this.dataset.type))});l.appendChild(y)}p=null;var c=r.value;h=null; -l.innerHTML="";if(c)if(f.onSearchBox){var e=f.onSearchBox(help,c,s);if(e)for(var y=0;yg.search_limit))break}if(Array.prototype.filter)for(m=Object.keys(k.registered_node_types).filter(function(a){return-1!==a.toLowerCase().indexOf(c)}),y=0;yg.search_limit);y++); -else for(y in k.registered_node_types)if(-1!=y.indexOf(c)&&(a(y),-1!==g.search_limit&&e++>g.search_limit))break}}var f=this,m=document.createElement("div");m.className="litegraph litesearchbox graphdialog rounded";m.innerHTML="Search
";m.close=function(){f.search_box=null;m.parentNode.removeChild(m)};m.addEventListener("mouseleave",function(a){m.close()});f.search_box&&f.search_box.close();f.search_box= -m;var l=m.querySelector(".helper"),h=null,p=null,q=null,r=m.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)m.close();else if(13==a.keyCode)q?b(q.innerHTML):h?b(h):m.close();else{p&&clearInterval(p);p=setTimeout(d,10);return}a.preventDefault();a.stopPropagation()}));var s=g.active_canvas,t=s.canvas,u=t.getBoundingClientRect(),v=-20,y=-20;u&&(v-=u.left,y-= -u.top);a?(m.style.left=a.pageX+v+"px",m.style.top=a.pageY+y+"px"):(m.style.left=0.5*t.width+v+"px",m.style.top=0.5*t.height+y+"px");t.parentNode.appendChild(m);r.focus();return m};g.prototype.showEditPropertyValue=function(a,b,c){function g(){f(q.value)}function f(c){"number"==typeof a.properties[b]&&(c=Number(c));"array"==m&&(c=c.split(",").map(Number));a.properties[b]=c;a._graph&&a._graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,c);p.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!== -a.properties[b]){c=c||{};var m="string";null!==a.properties[b]&&(m=typeof a.properties[b]);"object"==m&&a.properties[b].length&&(m="array");var l=null;a.getPropertyInfo&&(l=a.getPropertyInfo(b));if(a.properties_info)for(var d=0;d";else if("enum"==m&&l.values){k=""}else if("boolean"==m)k="";else{console.warn("unknown type: "+m);return}var p=this.createDialog(""+b+""+k+"",c);if("enum"==m&&l.values){var q=p.querySelector("select");q.addEventListener("change",function(a){f(a.target.value)})}else if("boolean"== -m)(q=p.querySelector("input"))&&q.addEventListener("click",function(a){f(!!q.checked)});else if(q=p.querySelector("input"))q.addEventListener("blur",function(a){this.focus()}),q.value=void 0!==a.properties[b]?a.properties[b]:"",q.addEventListener("keydown",function(a){13==a.keyCode&&(g(),a.preventDefault(),a.stopPropagation())});p.querySelector("button").addEventListener("click",g)}};g.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML= -a;var g=this.canvas.getBoundingClientRect(),f=-20,m=-20;g&&(f-=g.left,m-=g.top);b.position?(f+=b.position[0],m+=b.position[1]):b.event?(f+=b.event.pageX,m+=b.event.pageY):(f+=0.5*this.canvas.width,m+=0.5*this.canvas.height);c.style.left=f+"px";c.style.top=m+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};g.onMenuNodeCollapse=function(a,b,c,m,f){f.collapse()};g.onMenuNodePin=function(a,b,c,m,f){f.pin()};g.onMenuNodeMode=function(a, -b,c,m,f){new k.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(f)switch(a){case "On Event":f.mode=k.ON_EVENT;break;case "On Trigger":f.mode=k.ON_TRIGGER;break;case "Never":f.mode=k.NEVER;break;default:f.mode=k.ALWAYS}},parentMenu:m,node:f});return!1};g.onMenuNodeColors=function(a,b,c,m,f){if(!f)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var d in g.node_colors)a=g.node_colors[d], -a={value:d,content:""+d+""},b.push(a);new k.ContextMenu(b,{event:c,callback:function(a){f&&((a=a.value?g.node_colors[a.value]:null)?f.constructor===k.LGraphGroup?f.color=a.groupcolor:(f.color=a.color,f.bgcolor=a.bgcolor):(delete f.color,delete f.bgcolor),f.setDirtyCanvas(!0,!0))},parentMenu:m,node:f});return!1};g.onMenuNodeShapes=function(a,b,c,m,f){if(!f)throw"no node passed"; -new k.ContextMenu(k.VALID_SHAPES,{event:c,callback:function(a){f&&(f.shape=a,f.setDirtyCanvas(!0))},parentMenu:m,node:f});return!1};g.onMenuNodeRemove=function(a,b,c,m,f){if(!f)throw"no node passed";!1!==f.removable&&(f.graph.remove(f),f.setDirtyCanvas(!0,!0))};g.onMenuNodeClone=function(a,b,c,m,f){!1!=f.clonable&&(a=f.clone())&&(a.pos=[f.pos[0]+5,f.pos[1]+5],f.graph.add(a),f.setDirtyCanvas(!0,!0))};g.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"}};g.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions(): -(a=[{content:"Add Node",has_submenu:!0,callback:g.onMenuAdd},{content:"Add Group",callback:g.onGroupAdd}],this._graph_stack&&0Name",f),d=g.querySelector("input");d&&l&&(d.value=l.label);g.querySelector("button").addEventListener("click",function(a){d.value&&(l&&(l.label=d.value),c.setDirty(!0));g.close()})}},extra:a}, -l=null;a&&(l=a.getSlotInPosition(b.canvasX,b.canvasY),g.active_node=a);l?(f=[],l&&l.output&&l.output.links&&l.output.links.length&&f.push({content:"Disconnect Links",slot:l}),f.push(l.locked?"Cannot remove":{content:"Remove Slot",slot:l}),f.push(l.nameLocked?"Cannot rename":{content:"Rename Slot",slot:l}),d.title=(l.input?l.input.type:l.output.type)||"*",l.input&&l.input.type==k.ACTION&&(d.title="Action"),l.output&&l.output.type==k.EVENT&&(d.title="Event")):a?f=this.getNodeMenuOptions(a):(f=this.getCanvasMenuOptions(), -(l=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&f.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:l,options:this.getGroupMenuOptions(l)}}));f&&new k.ContextMenu(f,d,m)};this.CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,m,f,g){void 0===f&&(f=5);void 0===g&&(g=f);this.moveTo(a+f,b);this.lineTo(a+c-f,b);this.quadraticCurveTo(a+c,b,a+c,b+f);this.lineTo(a+c,b+m-g);this.quadraticCurveTo(a+c,b+m,a+c-g,b+m);this.lineTo(a+g,b+m);this.quadraticCurveTo(a, -b+m,a,b+m-g);this.lineTo(a,b+f);this.quadraticCurveTo(a,b,a+f,b)});k.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};k.distance=q;k.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")+")"};k.isInsideRectangle=r;k.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};k.isInsideBounding=function(a,b){return a[0]< -b[0][0]||a[1]b[1][0]||a[1]>b[1][1]?!1:!0};k.overlapBounding=s;k.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,m,f,g=0;6>g;g+=2)m="0123456789ABCDEF".indexOf(a.charAt(g)),f="0123456789ABCDEF".indexOf(a.charAt(g+1)),b[c]=16*m+f,c++;return b};k.num2hex=function(a){for(var b="#",c,m,f=0;3>f;f++)c=a[f]/16,m=a[f]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(m);return b};t.prototype.addItem=function(a,b,c){function m(a){var b= -this.value;b&&b.has_submenu&&f.call(this,a)}function f(a){var b=this.value,f=!0;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var m=c.callback.call(this,b,c,a,g,c.node);!0===m&&(f=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(m=b.callback.call(this,b,c,a,g,c.extra),!0===m&&(f=!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});f=!1}f&&!g.lock&&g.close()}var g=this;c=c||{};var l=document.createElement("div");l.className="litemenu-entry submenu";var d=!1;if(null===b)l.classList.add("separator");else{l.innerHTML=b&&b.title?b.title:a;if(l.value=b)b.disabled&&(d=!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);d||l.addEventListener("click",f);c.autoopen&&l.addEventListener("mouseenter",m);return l};t.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&&!t.isCursorOverElement(a,this.parentMenu.root)&&t.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0)};t.trigger= -function(a,b,c,m){var f=document.createEvent("CustomEvent");f.initCustomEvent(b,!0,!0,c);f.srcElement=m;a.dispatchEvent?a.dispatchEvent(f):a.__events&&a.__events.dispatchEvent(f);return f};t.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};t.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};t.isCursorOverElement=function(a,b){var c=a.pageX,m=a.pageY,f=b.getBoundingClientRect(); -return f?m>f.top&&mf.left&&ca?c:ek.width-g.width-10&&(n=k.width-g.width-10);l>k.height-g.height-10&&(l=k.height-g.height-10)}f.style.left=n+"px";f.style.top=l+"px"}var k=u.LiteGraph={CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:20,NODE_SLOT_HEIGHT:15,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:"#444",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,LINK_COLOR:"#AAD",EVENT_LINK_COLOR:"#F85",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,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,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;k.debug&&console.log("Node registered: "+a);a.split("/"); +var e=b.name,c=a.lastIndexOf("/");b.category=a.substr(0,c);b.title||(b.title=e);if(b.prototype)for(var f in d.prototype)b.prototype[f]||(b.prototype[f]=d.prototype[f]);Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=k.BOX_SHAPE;break;case "round":this._shape=k.ROUND_SHAPE;break;case "circle":this._shape=k.CIRCLE_SHAPE;break;case "card":this._shape=k.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape}, +enumerable:!0});this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[e]=b);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(f in b.supported_extensions)this.node_types_by_file_extension[b.supported_extensions[f].toLowerCase()]=b},wrapFunctionAsNode:function(a,b,e,c){for(var f=Array(b.length),n="",l=k.getParameterNames(b),w=0;wl&&(l=f.size[0]),k+=f.size[1]+a;b+=l+a}this.setDirtyCanvas(!0,!0)};h.prototype.getTime=function(){return this.globaltime};h.prototype.getFixedTime=function(){return this.fixedtime};h.prototype.getElapsedTime=function(){return this.elapsed_time};h.prototype.sendEventToAllNodes=function(a,b,e){e=e||k.ALWAYS;var c=this._nodes_in_order?this._nodes_in_order:this._nodes;if(c)for(var f=0,n=c.length;f=k.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_ida.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=-1;this.type=null;this.inputs= +[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};d.prototype.configure=function(a){this.graph&&this.graph._version++;for(var b in a)if("console"!=b)if("properties"==b)for(var e in a.properties){if(this.properties[e]=a.properties[e],this.onPropertyChanged)this.onPropertyChanged(e,a.properties[e])}else null!=a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=k.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title= +this.constructor.title);if(this.onConnectionsChange){if(this.inputs)for(var c=0;c=this.outputs.length)){var e=this.outputs[a];if(e&&(e._data=b,this.outputs[a].links))for(e=0;e=this.inputs.length||null==this.inputs[a].link)){var e=this.graph.links[this.inputs[a].link];if(!e)return null;if(!b)return e.data;var c=this.graph.getNodeById(e.origin_id);if(!c)return e.data;if(c.updateOutputData)c.updateOutputData(e.origin_slot);else if(c.onExecute)c.onExecute(); +return e.data}};d.prototype.getInputDataByName=function(a,b){var e=this.findInputSlot(a);return-1==e?null:this.getInputData(e,b)};d.prototype.isInputConnected=function(a){return this.inputs?a=this.inputs.length)return null;a=this.inputs[a];return a&&null!==a.link?(a=this.graph.links[a.link])? +this.graph.getNodeById(a.origin_id):null:null};d.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,e=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};d.prototype.getOutputInfo=function(a){return this.outputs?a=this.outputs.length)return null;a=this.outputs[a];if(!a.links||0==a.links.length)return null; +for(var b=[],e=0;ea&&this.pos[1]-f-eb)return!0;return!1};d.prototype.getSlotInPosition=function(a,b){if(this.inputs)for(var e=0,c=this.inputs.length;e=this.outputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1;b&&b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b== +this)return!1;if(e.constructor===String){if(e=b.findInputSlot(e),-1==e)return k.debug&&console.log("Connect: Error, no slot of name "+e),!1}else{if(e===k.EVENT)return!1;if(!b.inputs||e>=b.inputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1}null!=b.inputs[e].link&&b.disconnectInput(e);var c=this.outputs[a];if(b.onConnectInput&&!1===b.onConnectInput(e,c.type,c))return!1;var f=b.inputs[e];if(k.isValidConnection(c.type,f.type)){var n={id:this.graph.last_link_id++,type:f.type, +origin_id:this.id,origin_slot:a,target_id:b.id,target_slot:e};this.graph.links[n.id]=n;null==c.links&&(c.links=[]);c.links.push(n.id);b.inputs[e].link=n.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(k.OUTPUT,a,!0,n,c);if(b.onConnectionsChange)b.onConnectionsChange(k.INPUT,e,!0,n,f);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(k.INPUT,b,e,this,a),this.graph.onNodeConnectionChange(k.OUTPUT,this,a,b,e))}this.setDirtyCanvas(!1, +!0);this.graph.connectionChange(this);return!0};d.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return k.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1;var e=this.outputs[a];if(!e||!e.links||0==e.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var c= +0,f=e.links.length;c=this.inputs.length)return k.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var e=this.inputs[a].link;this.inputs[a].link=null;var c=this.graph.links[e];if(c){var f=this.graph.getNodeById(c.origin_id);if(!f)return!1;var n=f.outputs[c.origin_slot];if(!n||!n.links||0==n.links.length)return!1;for(var l=0,g=n.links.length;lb&&this.inputs[b].pos?[this.pos[0]+this.inputs[b].pos[0],this.pos[1]+this.inputs[b].pos[1]]:!a&&this.outputs&&this.outputs.length>b&&this.outputs[b].pos?[this.pos[0]+this.outputs[b].pos[0],this.pos[1]+this.outputs[b].pos[1]]:this.flags.horizontal?a?[this.pos[0]+this.size[0]/this.inputs.length*(b+0.5),this.pos[1]-k.NODE_TITLE_HEIGHT]:[this.pos[0]+this.size[0]/this.outputs.length*(b+0.5),this.pos[1]+this.size[1]]:a?[this.pos[0], +this.pos[1]+10+b*k.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0)]:[this.pos[0]+this.size[0]+1,this.pos[1]+10+b*k.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0)]};d.prototype.alignToGrid=function(){this.pos[0]=k.CANVAS_GRID_SIZE*Math.round(this.pos[0]/k.CANVAS_GRID_SIZE);this.pos[1]=k.CANVAS_GRID_SIZE*Math.round(this.pos[1]/k.CANVAS_GRID_SIZE)};d.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>d.MAX_CONSOLE&&this.console.shift();this.graph.onNodeTrace(this, +a)};d.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};d.prototype.loadImage=function(a){var b=new Image;b.src=k.node_images_path+a;b.ready=!1;var e=this;b.onload=function(){this.ready=!0;e.setDirtyCanvas(!0)};return b};d.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,e=0;ea.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});Object.defineProperty(this,"size",{set:function(a){!a||2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size}, +enumerable:!0})};p.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};p.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}};p.prototype.move=function(a,b,e){this._pos[0]+=a;this._pos[1]+=b;if(!e)for(e=0;e element, you passed a "+a.localName;throw"This browser doesnt support Canvas";}null==(this.ctx=a.getContext("2d"))&&(a.webgl_enabled||console.warn("This canvas seems to be WebGL, enabling WebGL renderer"),this.enableWebGL());this._mousemove_callback=this.processMouseMove.bind(this);this._mouseup_callback=this.processMouseUp.bind(this);b||this.bindEvents()}};g.prototype._doNothing=function(a){a.preventDefault();return!1};g.prototype._doReturnTrue= +function(a){a.preventDefault();return!0};g.prototype.bindEvents=function(){if(this._events_binded)console.warn("LGraphCanvas: events already binded");else{var a=this.canvas,b=this.getCanvasWindow().document;this._mousedown_callback=this.processMouseDown.bind(this);this._mousewheel_callback=this.processMouseWheel.bind(this);a.addEventListener("mousedown",this._mousedown_callback,!0);a.addEventListener("mousemove",this._mousemove_callback);a.addEventListener("mousewheel",this._mousewheel_callback,!1); +a.addEventListener("contextmenu",this._doNothing);a.addEventListener("DOMMouseScroll",this._mousewheel_callback,!1);a.addEventListener("touchstart",this.touchHandler,!0);a.addEventListener("touchmove",this.touchHandler,!0);a.addEventListener("touchend",this.touchHandler,!0);a.addEventListener("touchcancel",this.touchHandler,!0);this._key_callback=this.processKey.bind(this);a.addEventListener("keydown",this._key_callback,!0);b.addEventListener("keyup",this._key_callback,!0);this._ondrop_callback=this.processDrop.bind(this); +a.addEventListener("dragover",this._doNothing,!1);a.addEventListener("dragend",this._doNothing,!1);a.addEventListener("drop",this._ondrop_callback,!1);a.addEventListener("dragenter",this._doReturnTrue,!1);this._events_binded=!0}};g.prototype.unbindEvents=function(){if(this._events_binded){var a=this.getCanvasWindow().document;this.canvas.removeEventListener("mousedown",this._mousedown_callback);this.canvas.removeEventListener("mousewheel",this._mousewheel_callback);this.canvas.removeEventListener("DOMMouseScroll", +this._mousewheel_callback);this.canvas.removeEventListener("keydown",this._key_callback);a.removeEventListener("keyup",this._key_callback);this.canvas.removeEventListener("contextmenu",this._doNothing);this.canvas.removeEventListener("drop",this._ondrop_callback);this.canvas.removeEventListener("dragenter",this._doReturnTrue);this.canvas.removeEventListener("touchstart",this.touchHandler);this.canvas.removeEventListener("touchmove",this.touchHandler);this.canvas.removeEventListener("touchend",this.touchHandler); +this.canvas.removeEventListener("touchcancel",this.touchHandler);this._ondrop_callback=this._key_callback=this._mousewheel_callback=this._mousedown_callback=null;this._events_binded=!1}else console.warn("LGraphCanvas: no events binded")};g.getFileExtension=function(a){var b=a.indexOf("?");-1!=b&&(a=a.substr(0,b));b=a.lastIndexOf(".");return-1==b?"":a.substr(b+1).toLowerCase()};g.prototype.enableWebGL=function(){if(void 0===typeof GL)throw"litegl.js must be included to use a WebGL canvas";if(void 0=== +typeof enableWebGLCanvas)throw"webglCanvas.js must be included to use this feature";this.gl=this.ctx=enableWebGLCanvas(this.canvas);this.ctx.webgl=!0;this.bgcanvas=this.canvas;this.bgctx=this.gl;this.canvas.webgl_enabled=!0};g.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)};g.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument;return a.defaultView||a.parentWindow};g.prototype.startRendering=function(){function a(){this.pause_rendering|| +this.draw();var b=this.getCanvasWindow();this.is_rendering&&b.requestAnimationFrame(a.bind(this))}this.is_rendering||(this.is_rendering=!0,a.call(this))};g.prototype.stopRendering=function(){this.is_rendering=!1};g.prototype.processMouseDown=function(a){if(this.graph){this.adjustMouseEvent(a);var b=this.getCanvasWindow();g.active_canvas=this;this.canvas.removeEventListener("mousemove",this._mousemove_callback);b.document.addEventListener("mousemove",this._mousemove_callback,!0);b.document.addEventListener("mouseup", +this._mouseup_callback,!0);var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes,5),c=!1,f=300>k.getTime()-this.last_mouseclick;this.canvas_mouse[0]=a.canvasX;this.canvas_mouse[1]=a.canvasY;k.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,c=!0);var n=!1;if(e&&this.allow_interaction&& +!c){this.live_mode||e.flags.pinned||this.bringToFront(e);if(!this.connecting_node&&!e.flags.collapsed&&!this.live_mode)if(!c&&!1!==e.flags.resizable&&r(a.canvasX,a.canvasY,e.pos[0]+e.size[0]-5,e.pos[1]+e.size[1]-5,10,10))this.resizing_node=e,this.canvas.style.cursor="se-resize",c=!0;else{if(e.outputs)for(var l=0,d=e.outputs.length;lq([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.scale?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes()),f&&this.showSearchBox(a),n=!0;!c&&n&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}else 2!=a.which&&3==a.which&&this.processContextMenu(e,a);this.last_mouse[0]=a.localX;this.last_mouse[1]=a.localY;this.last_mouseclick=k.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}}};g.prototype.processMouseMove=function(a){this.autoresize&&this.resize();if(this.graph){g.active_canvas=this;this.adjustMouseEvent(a);var b=[a.localX,a.localY],e=[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(e[0]/this.scale,e[1]/this.scale,a.ctrlKey),this.selected_group._nodes.length&&(this.dirty_canvas=!0)),this.dirty_bgcanvas=!0;else if(this.dragging_canvas)this.offset[0]+=e[0]/this.scale,this.offset[1]+=e[1]/this.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if(this.allow_interaction){this.connecting_node&&(this.dirty_canvas=!0);for(var c=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes),b=0,f=this.graph._nodes.length;b< +f;++b)if(this.graph._nodes[b].mouseOver&&c!=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(c){if(!c.mouseOver&&(c.mouseOver=!0,this.node_over=c,this.dirty_canvas=!0,c.onMouseEnter))c.onMouseEnter(a);if(c.onMouseMove)c.onMouseMove(a,[a.canvasX-c.pos[0],a.canvasY-c.pos[1]],this);if(this.connecting_node&&(f=this._highlight_input||[0,0],!this.isOverNodeBox(c,a.canvasX,a.canvasY))){var n= +this.isOverNodeInput(c,a.canvasX,a.canvasY,f);-1!=n&&c.inputs[n]?k.isValidConnection(this.connecting_output.type,c.inputs[n].type)&&(this._highlight_input=f):this._highlight_input=null}this.canvas&&(r(a.canvasX,a.canvasY,c.pos[0]+c.size[0]-5,c.pos[1]+c.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="")}else this.canvas&&(this.canvas.style.cursor="");if(this.node_capturing_input&&this.node_capturing_input!=c&&this.node_capturing_input.onMouseMove)this.node_capturing_input.onMouseMove(a); +if(this.node_dragged&&!this.live_mode){for(b in this.selected_nodes)c=this.selected_nodes[b],c.pos[0]+=e[0]/this.scale,c.pos[1]+=e[1]/this.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],e=Math.max(this.resizing_node.inputs?this.resizing_node.inputs.length:0,this.resizing_node.outputs?this.resizing_node.outputs.length:0)*k.NODE_SLOT_HEIGHT+ +(this.resizing_node.widgets?this.resizing_node.widgets.length:0)*(k.NODE_WIDGET_HEIGHT+4)+4,this.resizing_node.size[1]this.dragging_rectangle[3]?this.dragging_rectangle[1]-f:this.dragging_rectangle[1];this.dragging_rectangle[0]= +0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-c:this.dragging_rectangle[0];this.dragging_rectangle[1]=n;this.dragging_rectangle[2]=c;this.dragging_rectangle[3]=f;f=[];for(n=0;na.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}};g.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var e=this.scale;0b&&(e*=1/1.1);this.setZoom(e,[a.localX,a.localY]);this.graph.change();a.preventDefault();return!1}};g.prototype.isOverNodeBox=function(a,b,e){var c=k.NODE_TITLE_HEIGHT;return r(b,e,a.pos[0]+2,a.pos[1]+2-c,c-4,c-4)?!0:!1};g.prototype.isOverNodeInput= +function(a,b,e,c){if(a.inputs)for(var f=0,n=a.inputs.length;fthis.max_zoom?this.scale=this.max_zoom:this.scalec-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}};g.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();a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1]);for(var b=this.computeVisibleNodes(null,this.visible_nodes),c=0;c> ";b.fillText(g+c.getTitle(),0.5*a.width,40);b.restore()}c=!1;this.onRenderBackground&&(c=this.onRenderBackground(a,b));b.restore();b.setTransform(1, +0,0,1,0,0);if(this.graph){b.save();b.scale(this.scale,this.scale);b.translate(this.offset[0],this.offset[1]);if(this.background_image&&0.5this.scale?b.fillRect(0,l,A,p):m==k.ROUND_SHAPE||m==k.CARD_SHAPE?b.roundRect(0,l,A,p,this.round_radius,m==k.CARD_SHAPE?0:this.round_radius):m==k.CIRCLE_SHAPE&&b.arc(0.5*c[0],0.5*c[1],0.5*c[0],0,2*Math.PI),b.fill());b.shadowColor="transparent";a.bgImage&&a.bgImage.width&&b.drawImage(a.bgImage,0.5*(c[0]-a.bgImage.width),0.5*(c[1]-a.bgImage.height));a.bgImageUrl&& +!a.bgImage&&(a.bgImage=a.loadImage(a.bgImageUrl));if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas);if(z||h==k.TRANSPARENT_TITLE){if(h!=k.TRANSPARENT_TITLE){a.flags.collapsed&&(b.shadowColor=k.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var q=g.gradients[d];q||(q=g.gradients[d]=b.createLinearGradient(0,0,400,0),q.addColorStop(0,d),q.addColorStop(1,"#000"));b.fillStyle=q}else b.fillStyle=d;q=b.globalAlpha;b.beginPath();m==k.BOX_SHAPE||0.5>this.scale?b.rect(0,-f,c[0]+1,f):m!=k.ROUND_SHAPE&& +m!=k.CARD_SHAPE||b.roundRect(0,-f,c[0]+1,f,this.round_radius,a.flags.collapsed?this.round_radius:0);b.fill();b.shadowColor="transparent"}m==k.ROUND_SHAPE||m==k.CIRCLE_SHAPE||m==k.CARD_SHAPE?(0.5g[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(s(g,c)){var v=p.outputs[q],q=m.inputs[d];if(v&&q&&(p=v.dir||(p.flags.horizontal?k.DOWN:k.RIGHT),q=q.dir||(m.flags.horizontal?k.UP:k.LEFT),this.renderLink(a,r,t,h,!1,0,null,p,q),h&&h._last_time&&1E3>b-h._last_time)){var v=2-0.002*(b-h._last_time),y=a.globalAlpha;a.globalAlpha=y*v;this.renderLink(a,r,t,h,!0,v,"white",p,q);a.globalAlpha=y}}}}}}a.globalAlpha=1};g.prototype.renderLink=function(a,b,c,m,f,n,l,d,h){if(this.highquality_render){d=d||k.RIGHT;h=h|| +k.LEFT;var p=q(b,c);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(f[0],f[1]),a.rotate(p),a.beginPath(),a.moveTo(-5,-5),a.lineTo(0,5),a.lineTo(5,-5),a.fill(),a.restore());if(n)for(n=0;5>n;++n)f=(0.001*k.getTime()+0.2*n)%1,f=this.computeConnectionPoint(b,c,f,d,h),a.beginPath(),a.arc(f[0],f[1],5,0,2*Math.PI),a.fill()}else a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(c[0],c[1]),a.stroke()};g.prototype.computeConnectionPoint= +function(a,b,c,g,f){g=g||k.RIGHT;f=f||k.LEFT;var n=q(a,b),l=[a[0],a[1]],m=[b[0],b[1]];switch(g){case k.LEFT:l[0]+=-0.25*n;break;case k.RIGHT:l[0]+=0.25*n;break;case k.UP:l[1]+=-0.25*n;break;case k.DOWN:l[1]+=0.25*n}switch(f){case k.LEFT:m[0]+=-0.25*n;break;case k.RIGHT:m[0]+=0.25*n;break;case k.UP:m[1]+=-0.25*n;break;case k.DOWN:m[1]+=0.25*n}g=(1-c)*(1-c)*(1-c);f=3*(1-c)*(1-c)*c;n=3*(1-c)*c*c;c*=c*c;return[g*a[0]+f*l[0]+n*m[0]+c*b[0],g*a[1]+f*l[1]+n*m[1]+c*b[1]]};g.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,c=0;cp.last_y&&np.options.max&&(p.value=p.options.max);else if("mousedown"== +c.type)if((g=p.options.values)&&g.constructor===Function&&(g=p.options.values(p,a)),f=40>f?-1:f>l-40?1:0,"number"==p.type)p.value+=0.1*f*(p.options.step||1),null!=p.options.min&&p.valuep.options.max&&(p.value=p.options.max);else if(f)c=g.indexOf(p.value)+f,c>=g.length&&(c=0),0>c&&(c=g.length-1),p.value=g[c];else{new k.ContextMenu(g,{event:c,className:"dark",callback:q.bind(p)},m);var q=function(a,b,c){this.value=a;d.dirty_canvas= +!0;return!1}}p.callback&&setTimeout(function(){this.callback(this.value,d,a,b)}.bind(p),20);this.dirty_canvas=!0;break;case "toggle":"mousedown"==c.type&&(p.value=!p.value,p.callback&&setTimeout(function(){p.callback(p.value,d,a,b)},20));break;case "text":"mousedown"==c.type&&this.prompt("Value",p.value,function(b){this.value=b;p.callback&&p.callback(b,d,a)}.bind(p),c)}return p}}return null};g.prototype.drawGroups=function(a,b){if(this.graph){var c=this.graph._groups;b.save();b.globalAlpha=0.5*this.editor_alpha; +for(var g=0;gc&&0.01>b.editor_alpha&&(clearInterval(g),1>c&&(b.live_mode=!0));1"+p+""+a+"",value:p});if(h.length)return new k.ContextMenu(h,{event:c,callback:m,parentMenu:d,allow_html:!0,node:f},b),!1}};g.decodeHTML=function(a){var b=document.createElement("div"); +b.innerText=a;return b.innerHTML};g.onResizeNode=function(a,b,c,g,f){f&&(f.size=f.computeSize(),f.setDirtyCanvas(!0,!0))};g.onShowPropertyEditor=function(a,b,c,d,f){function m(){var b=h.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=Boolean(b));f[l]=b;k.parentNode.removeChild(k);f.setDirtyCanvas(!0,!0)}var l=a.property||"title";b=f[l];var k=document.createElement("div");k.className="graphdialog";k.innerHTML=""; +k.querySelector(".name").innerText=l;var h=k.querySelector("input");h&&(h.value=b,h.addEventListener("blur",function(a){this.focus()}),h.addEventListener("keydown",function(a){13==a.keyCode&&(m(),a.preventDefault(),a.stopPropagation())}));b=g.active_canvas.canvas;c=b.getBoundingClientRect();var p=d=-20;c&&(d-=c.left,p-=c.top);event?(k.style.left=event.pageX+d+"px",k.style.top=event.pageY+p+"px"):(k.style.left=0.5*b.width+d+"px",k.style.top=0.5*b.height+p+"px");k.querySelector("button").addEventListener("click", +m);b.parentNode.appendChild(k)};g.prototype.prompt=function(a,b,c,d){var f=this;a=a||"";var m=document.createElement("div");m.className="graphdialog rounded";m.innerHTML=" ";m.close=function(){f.prompt_box=null;m.parentNode.removeChild(m)};m.addEventListener("mouseleave",function(a){m.close()});f.prompt_box&&f.prompt_box.close();f.prompt_box=m;m.querySelector(".name").innerText=a;m.querySelector(".value").value= +b;var l=m.querySelector("input");l.addEventListener("keydown",function(a){if(27==a.keyCode)m.close();else if(13==a.keyCode)c&&c(this.value),m.close();else return;a.preventDefault();a.stopPropagation()});m.querySelector("button").addEventListener("click",function(a){c&&c(l.value);f.setDirty(!0);m.close()});a=g.active_canvas.canvas;b=a.getBoundingClientRect();var k=-20,h=-20;b&&(k-=b.left,h-=b.top);d?(m.style.left=d.pageX+k+"px",m.style.top=d.pageY+h+"px"):(m.style.left=0.5*a.width+k+"px",m.style.top= +0.5*a.height+h+"px");a.parentNode.appendChild(m);setTimeout(function(){l.focus()},10);return m};g.search_limit=-1;g.prototype.showSearchBox=function(a){function b(b){if(b)if(f.onSearchBoxSelection)f.onSearchBoxSelection(b,a,s);else{var c=k.searchbox_extras[b];c&&(b=c.type);if(b=k.createNode(b))b.pos=s.convertEventToCanvas(a),s.graph.add(b);if(c&&c.data){if(c.data.properties)for(var e in c.data.properties)b.addProperty(c.data.properties[e][0],c.data.properties[e][0]);if(c.data.inputs)for(e in b.inputs= +[],c.data.inputs)b.addOutput(c.data.inputs[e][0],c.data.inputs[e][1]);if(c.data.outputs)for(e in b.outputs=[],c.data.outputs)b.addOutput(c.data.outputs[e][0],c.data.outputs[e][1]);c.data.title&&(b.title=c.data.title);c.data.json&&b.configure(c.data.json)}}m.close()}function c(a){var b=q;q&&q.classList.remove("selected");q?(q=a?q.nextSibling:q.previousSibling)||(q=b):q=a?l.childNodes[0]:l.childNodes[l.childNodes.length];q&&(q.classList.add("selected"),q.scrollIntoView())}function d(){function a(c, +e){var y=document.createElement("div");h||(h=c);y.innerText=c;y.dataset.type=escape(c);y.className="litegraph lite-search-item";e&&(y.className+=" "+e);y.addEventListener("click",function(a){b(unescape(this.dataset.type))});l.appendChild(y)}p=null;var c=r.value;h=null;l.innerHTML="";if(c)if(f.onSearchBox){var e=f.onSearchBox(help,c,s);if(e)for(var y=0;yg.search_limit))break}if(Array.prototype.filter)for(m=Object.keys(k.registered_node_types).filter(function(a){return-1!==a.toLowerCase().indexOf(c)}),y=0;yg.search_limit);y++);else for(y in k.registered_node_types)if(-1!=y.indexOf(c)&&(a(y),-1!==g.search_limit&&e++>g.search_limit))break}}var f=this,m=document.createElement("div");m.className="litegraph litesearchbox graphdialog rounded";m.innerHTML= +"Search
";m.close=function(){f.search_box=null;m.parentNode.removeChild(m)};m.addEventListener("mouseleave",function(a){m.close()});f.search_box&&f.search_box.close();f.search_box=m;var l=m.querySelector(".helper"),h=null,p=null,q=null,r=m.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)m.close();else if(13==a.keyCode)q?b(q.innerHTML):h?b(h):m.close();else{p&&clearInterval(p);p=setTimeout(d,10);return}a.preventDefault();a.stopPropagation()}));var s=g.active_canvas,t=s.canvas,u=t.getBoundingClientRect(),v=-20,y=-20;u&&(v-=u.left,y-=u.top);a?(m.style.left=a.pageX+v+"px",m.style.top=a.pageY+y+"px"):(m.style.left=0.5*t.width+v+"px",m.style.top=0.5*t.height+y+"px");t.parentNode.appendChild(m);r.focus();return m};g.prototype.showEditPropertyValue=function(a,b,c){function g(){f(q.value)} +function f(c){"number"==typeof a.properties[b]&&(c=Number(c));"array"==m&&(c=c.split(",").map(Number));a.properties[b]=c;a._graph&&a._graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,c);p.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var m="string";null!==a.properties[b]&&(m=typeof a.properties[b]);"object"==m&&a.properties[b].length&&(m="array");var l=null;a.getPropertyInfo&&(l=a.getPropertyInfo(b));if(a.properties_info)for(var d=0;d";else if("enum"==m&&l.values){k=""}else if("boolean"==m)k="";else{console.warn("unknown type: "+m);return}var p=this.createDialog(""+b+""+k+"",c);if("enum"==m&&l.values){var q=p.querySelector("select");q.addEventListener("change",function(a){f(a.target.value)})}else if("boolean"==m)(q=p.querySelector("input"))&&q.addEventListener("click",function(a){f(!!q.checked)});else if(q=p.querySelector("input"))q.addEventListener("blur",function(a){this.focus()}),q.value=void 0!==a.properties[b]?a.properties[b]: +"",q.addEventListener("keydown",function(a){13==a.keyCode&&(g(),a.preventDefault(),a.stopPropagation())});p.querySelector("button").addEventListener("click",g)}};g.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;var g=this.canvas.getBoundingClientRect(),f=-20,m=-20;g&&(f-=g.left,m-=g.top);b.position?(f+=b.position[0],m+=b.position[1]):b.event?(f+=b.event.pageX,m+=b.event.pageY):(f+=0.5*this.canvas.width,m+=0.5*this.canvas.height); +c.style.left=f+"px";c.style.top=m+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};g.onMenuNodeCollapse=function(a,b,c,m,f){f.collapse()};g.onMenuNodePin=function(a,b,c,m,f){f.pin()};g.onMenuNodeMode=function(a,b,c,m,f){new k.ContextMenu(["Always","On Event","On Trigger","Never"],{event:c,callback:function(a){if(f)switch(a){case "On Event":f.mode=k.ON_EVENT;break;case "On Trigger":f.mode=k.ON_TRIGGER;break;case "Never":f.mode= +k.NEVER;break;default:f.mode=k.ALWAYS}},parentMenu:m,node:f});return!1};g.onMenuNodeColors=function(a,b,c,m,f){if(!f)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var d in g.node_colors)a=g.node_colors[d],a={value:d,content:""+d+""},b.push(a);new k.ContextMenu(b,{event:c,callback:function(a){f&& +((a=a.value?g.node_colors[a.value]:null)?f.constructor===k.LGraphGroup?f.color=a.groupcolor:(f.color=a.color,f.bgcolor=a.bgcolor):(delete f.color,delete f.bgcolor),f.setDirtyCanvas(!0,!0))},parentMenu:m,node:f});return!1};g.onMenuNodeShapes=function(a,b,c,m,f){if(!f)throw"no node passed";new k.ContextMenu(k.VALID_SHAPES,{event:c,callback:function(a){f&&(f.shape=a,f.setDirtyCanvas(!0))},parentMenu:m,node:f});return!1};g.onMenuNodeRemove=function(a,b,c,m,f){if(!f)throw"no node passed";!1!==f.removable&& +(f.graph.remove(f),f.setDirtyCanvas(!0,!0))};g.onMenuNodeClone=function(a,b,c,m,f){!1!=f.clonable&&(a=f.clone())&&(a.pos=[f.pos[0]+5,f.pos[1]+5],f.graph.add(a),f.setDirtyCanvas(!0,!0))};g.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"}};g.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:g.onMenuAdd},{content:"Add Group",callback:g.onGroupAdd}],this._graph_stack&&0Name",f),d=g.querySelector("input");d&&l&&(d.value=l.label);g.querySelector("button").addEventListener("click",function(a){d.value&&(l&&(l.label=d.value),c.setDirty(!0));g.close()})}},extra:a},l=null;a&&(l=a.getSlotInPosition(b.canvasX,b.canvasY),g.active_node=a);l?(f=[],l&&l.output&&l.output.links&&l.output.links.length&&f.push({content:"Disconnect Links",slot:l}),f.push(l.locked?"Cannot remove":{content:"Remove Slot", +slot:l}),f.push(l.nameLocked?"Cannot rename":{content:"Rename Slot",slot:l}),d.title=(l.input?l.input.type:l.output.type)||"*",l.input&&l.input.type==k.ACTION&&(d.title="Action"),l.output&&l.output.type==k.EVENT&&(d.title="Event")):a?f=this.getNodeMenuOptions(a):(f=this.getCanvasMenuOptions(),(l=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&f.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:l,options:this.getGroupMenuOptions(l)}}));f&&new k.ContextMenu(f,d,m)};this.CanvasRenderingContext2D&& +(CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,m,f,g){void 0===f&&(f=5);void 0===g&&(g=f);this.moveTo(a+f,b);this.lineTo(a+c-f,b);this.quadraticCurveTo(a+c,b,a+c,b+f);this.lineTo(a+c,b+m-g);this.quadraticCurveTo(a+c,b+m,a+c-g,b+m);this.lineTo(a+g,b+m);this.quadraticCurveTo(a,b+m,a,b+m-g);this.lineTo(a,b+f);this.quadraticCurveTo(a,b,a+f,b)});k.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};k.distance=q;k.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")+")"};k.isInsideRectangle=r;k.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};k.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};k.overlapBounding=s;k.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,m,f,g=0;6>g;g+=2)m="0123456789ABCDEF".indexOf(a.charAt(g)), +f="0123456789ABCDEF".indexOf(a.charAt(g+1)),b[c]=16*m+f,c++;return b};k.num2hex=function(a){for(var b="#",c,m,f=0;3>f;f++)c=a[f]/16,m=a[f]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(m);return b};t.prototype.addItem=function(a,b,c){function m(a){var b=this.value;b&&b.has_submenu&&f.call(this,a)}function f(a){var b=this.value,f=!0;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var m=c.callback.call(this,b,c,a,g,c.node);!0===m&&(f=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&& +!0!==b.disabled&&(m=b.callback.call(this,b,c,a,g,c.extra),!0===m&&(f=!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});f=!1}f&&!g.lock&&g.close()}var g=this;c=c||{};var l=document.createElement("div");l.className="litemenu-entry submenu";var d=!1;if(null===b)l.classList.add("separator"); +else{l.innerHTML=b&&b.title?b.title:a;if(l.value=b)b.disabled&&(d=!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);d||l.addEventListener("click",f);c.autoopen&&l.addEventListener("mouseenter",m);return l};t.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&&!t.isCursorOverElement(a,this.parentMenu.root)&&t.trigger(this.parentMenu.root,"mouseleave",a));this.current_submenu&&this.current_submenu.close(a,!0)};t.trigger=function(a,b,c,m){var f=document.createEvent("CustomEvent");f.initCustomEvent(b,!0,!0,c);f.srcElement=m;a.dispatchEvent?a.dispatchEvent(f):a.__events&&a.__events.dispatchEvent(f);return f};t.prototype.getTopMenu=function(){return this.options.parentMenu? +this.options.parentMenu.getTopMenu():this};t.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};t.isCursorOverElement=function(a,b){var c=a.pageX,m=a.pageY,f=b.getBoundingClientRect();return f?m>f.top&&mf.left&&ca?c:eB":value=a>b;break;case "A=B":value=a>=b}this.setOutputData(c,value)}}};B.prototype.onGetOutputs=function(){return[["A==B", +function(){var a=this.getInputData(0),b=this.getInputData(1);void 0!==a?this.properties.A=a:a=this.properties.A;void 0!==b?this.properties.B=b:b=this.properties.B;for(var c=0,e=this.outputs.length;cB":value=a>b;break;case "A=B":value=a>=b}this.setOutputData(c,value)}}};B.prototype.onGetOutputs=function(){return[["A==B", "boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};v.registerNodeType("math/compare",B);v.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"});v.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});v.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]],title:"A>B"});v.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});v.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});f.values="> < == != <= >=".split(" ");f["@OP"]={type:"enum",title:"operation",values:f.values};f.title="Condition";f.desc="evaluates condition between A and B";f.prototype.onExecute=function(){var a=this.getInputData(0);void 0===a?a=this.properties.A:this.properties.A=a;var b=this.getInputData(1);void 0===b?b=this.properties.B:this.properties.B=b;var c=!0;switch(this.properties.OP){case ">":c= a>b;break;case "<":c=a=":c=a>=b}this.setOutputData(0,c)};v.registerNodeType("math/condition",f);n.title="Accumulate";n.desc="Increments a value every time";n.prototype.onExecute=function(){null===this.properties.value&&(this.properties.value=0);var a=this.getInputData(0);this.properties.value=null!==a?this.properties.value+a:this.properties.value+this.properties.increment;this.setOutputData(0,this.properties.value)}; -v.registerNodeType("math/accumulate",n);l.title="Trigonometry";l.desc="Sin Cos Tan";l.filter="shader";l.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.properties.amplitude,c=this.findInputSlot("amplitude");-1!=c&&(b=this.getInputData(c));var e=this.properties.offset,c=this.findInputSlot("offset");-1!=c&&(e=this.getInputData(c));for(var c=0,d=this.outputs.length;cXY";x.desc="vector 2 to components";x.prototype.onExecute= function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};v.registerNodeType("math3d/vec2-to-xyz",x);z.title="XY->Vec2";z.desc="components to vector2";z.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this._data;c[0]=a;c[1]=b;this.setOutputData(0,c)};v.registerNodeType("math3d/xy-to-vec2",z);A.title="Vec3->XYZ";A.desc="vector 3 to components";A.prototype.onExecute= function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]))};v.registerNodeType("math3d/vec3-to-xyz",A);D.title="XYZ->Vec3";D.desc="components to vector3";D.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z);var e=this._data;e[0]=a;e[1]=b;e[2]=c;this.setOutputData(0,e)};v.registerNodeType("math3d/xyz-to-vec3", D);C.title="Vec4->XYZW";C.desc="vector 4 to components";C.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]),this.setOutputData(3,a[3]))};v.registerNodeType("math3d/vec4-to-xyzw",C);E.title="XYZW->Vec4";E.desc="components to vector4";E.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2); -null==c&&(c=this.properties.z);var e=this.getInputData(3);null==e&&(e=this.properties.w);var d=this._data;d[0]=a;d[1]=b;d[2]=c;d[3]=e;this.setOutputData(0,d)};v.registerNodeType("math3d/xyzw-to-vec4",E);u.glMatrix&&(u=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1};this._value=quat.create()},u.title="Quaternion",u.desc="quaternion",u.prototype.onExecute=function(){this._value[0]=this.properties.x;this._value[1]=this.properties.y;this._value[2]=this.properties.z;this._value[3]= +null==c&&(c=this.properties.z);var e=this.getInputData(3);null==e&&(e=this.properties.w);var f=this._data;f[0]=a;f[1]=b;f[2]=c;f[3]=e;this.setOutputData(0,f)};v.registerNodeType("math3d/xyzw-to-vec4",E);u.glMatrix&&(u=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1};this._value=quat.create()},u.title="Quaternion",u.desc="quaternion",u.prototype.onExecute=function(){this._value[0]=this.properties.x;this._value[1]=this.properties.y;this._value[2]=this.properties.z;this._value[3]= this.properties.w;this.setOutputData(0,this._value)},v.registerNodeType("math3d/quaternion",u),u=function(){this.addInputs([["degrees","number"],["axis","vec3"]]);this.addOutput("quat","quat");this.properties={angle:90,axis:vec3.fromValues(0,1,0)};this._value=quat.create()},u.title="Rotation",u.desc="quaternion rotation",u.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.angle);var b=this.getInputData(1);null==b&&(b=this.properties.axis);a=quat.setAxisAngle(this._value, b,0.0174532925*a);this.setOutputData(0,a)},v.registerNodeType("math3d/rotation",u),u=function(){this.addInputs([["vec3","vec3"],["quat","quat"]]);this.addOutput("result","vec3");this.properties={vec:[0,0,1]}},u.title="Rot. Vec3",u.desc="rotate a point",u.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.vec);var b=this.getInputData(1);null==b?this.setOutputData(a):this.setOutputData(0,vec3.transformQuat(vec3.create(),a,b))},v.registerNodeType("math3d/rotate_vec3", u),u=function(){this.addInputs([["A","quat"],["B","quat"]]);this.addOutput("A*B","quat");this._value=quat.create()},u.title="Mult. Quat",u.desc="rotate quaternion",u.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a){var b=this.getInputData(1);null!=b&&(a=quat.multiply(this._value,a,b),this.setOutputData(0,a))}},v.registerNodeType("math3d/mult-quat",u),u=function(){this.addInputs([["A","quat"],["B","quat"],["factor","number"]]);this.addOutput("slerp","quat");this.addProperty("factor", diff --git a/src/litegraph.js b/src/litegraph.js index 97f55392e..9e8c3fc82 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -7851,7 +7851,15 @@ function ContextMenu( values, options ) root.addEventListener("mouseleave", function(e) { if(that.lock) return; - that.close(e); + if(root.closing_timer) + clearTimeout( root.closing_timer ); + root.closing_timer = setTimeout( that.close.bind(that), 500 ); + //that.close(e); + }); + + root.addEventListener("mouseenter", function(e) { + if(root.closing_timer) + clearTimeout( root.closing_timer ); }); //insert before checking position @@ -7947,6 +7955,7 @@ ContextMenu.prototype.addItem = function( name, value, options ) var value = this.value; if(!value || !value.has_submenu) return; + //if it is a submenu, autoopen like the item was clicked inner_onclick.call(this,e); }