This commit is contained in:
tamat
2021-07-12 17:03:12 +02:00
parent 998de17038
commit 0a21262238
6 changed files with 91 additions and 40 deletions

View File

@@ -40,7 +40,7 @@ this.execution_timer_id=null);this.sendEventToAllNodes("onStop")}};m.prototype.r
a;f++){for(g=0;g<c;++g)if(n=e[g],n.mode==k.ALWAYS&&n.onExecute)n.onExecute();this.fixedtime+=this.fixedtime_lapse;if(this.onExecuteStep)this.onExecuteStep()}if(this.onAfterExecute)this.onAfterExecute();this.errors_in_execution=!1}catch(r){this.errors_in_execution=!0;if(k.throw_errors)throw r;k.debug&&console.log("Error during execution: "+r);this.stop()}a=k.getTime();d=a-d;0==d&&(d=1);this.execution_time=.001*d;this.globaltime+=.001*d;this.iteration+=1;this.elapsed_time=.001*(a-this.last_update_time);
this.last_update_time=a}};m.prototype.updateExecutionOrder=function(){this._nodes_in_order=this.computeExecutionOrder(!1);this._nodes_executable=[];for(var a=0;a<this._nodes_in_order.length;++a)this._nodes_in_order[a].onExecute&&this._nodes_executable.push(this._nodes_in_order[a])};m.prototype.computeExecutionOrder=function(a,b){for(var c=[],d=[],e={},f={},g={},n=0,r=this._nodes.length;n<r;++n){var h=this._nodes[n];if(!a||h.onExecute){e[h.id]=h;var u=0;if(h.inputs)for(var p=0,z=h.inputs.length;p<
z;p++)h.inputs[p]&&null!=h.inputs[p].link&&(u+=1);0==u?(d.push(h),b&&(h._level=1)):(b&&(h._level=0),g[h.id]=u)}}for(;0!=d.length;)if(h=d.shift(),c.push(h),delete e[h.id],h.outputs)for(n=0;n<h.outputs.length;n++)if(a=h.outputs[n],null!=a&&null!=a.links&&0!=a.links.length)for(p=0;p<a.links.length;p++)(r=this.links[a.links[p]])&&!f[r.id]&&(u=this.getNodeById(r.target_id),null==u?f[r.id]=!0:(b&&(!u._level||u._level<=h._level)&&(u._level=h._level+1),f[r.id]=!0,--g[u.id],0==g[u.id]&&d.push(u)));for(n in e)c.push(e[n]);
c.length!=this._nodes.length&&k.debug&&console.warn("something went wrong, nodes missing");r=c.length;for(n=0;n<r;++n)c[n].order=n;c=c.sort(function(a,b){var c=a.constructor.priority||a.priority||0,e=b.constructor.priority||b.priority||0;return c==e?a.order-b.order:c-e});for(n=0;n<r;++n)c[n].order=n;return c};m.prototype.getAncestors=function(a){for(var b=[],c=[a],d={};c.length;){var e=c.shift();if(e.inputs){d[e.id]||e==a||(d[e.id]=!0,b.push(e));for(var f=0;f<e.inputs.length;++f){var g=e.getInputNode(f);
c.length!=this._nodes.length&&k.debug&&console.warn("something went wrong, nodes missing");r=c.length;for(n=0;n<r;++n)c[n].order=n;c=c.sort(function(a,b){var c=a.constructor.priority||a.priority||0,d=b.constructor.priority||b.priority||0;return c==d?a.order-b.order:c-d});for(n=0;n<r;++n)c[n].order=n;return c};m.prototype.getAncestors=function(a){for(var b=[],c=[a],d={};c.length;){var e=c.shift();if(e.inputs){d[e.id]||e==a||(d[e.id]=!0,b.push(e));for(var f=0;f<e.inputs.length;++f){var g=e.getInputNode(f);
g&&-1==b.indexOf(g)&&c.push(g)}}}b.sort(function(a,b){return a.order-b.order});return b};m.prototype.arrange=function(a){a=a||100;for(var b=this.computeExecutionOrder(!1,!0),c=[],d=0;d<b.length;++d){var e=b[d],f=e._level||1;c[f]||(c[f]=[]);c[f].push(e)}b=a;for(d=0;d<c.length;++d)if(f=c[d]){for(var g=100,n=a+k.NODE_TITLE_HEIGHT,r=0;r<f.length;++r)e=f[r],e.pos[0]=b,e.pos[1]=n,e.size[0]>g&&(g=e.size[0]),n+=e.size[1]+a+k.NODE_TITLE_HEIGHT;b+=g+a}this.setDirtyCanvas(!0,!0)};m.prototype.getTime=function(){return this.globaltime};
m.prototype.getFixedTime=function(){return this.fixedtime};m.prototype.getElapsedTime=function(){return this.elapsed_time};m.prototype.sendEventToAllNodes=function(a,b,c){c=c||k.ALWAYS;var d=this._nodes_in_order?this._nodes_in_order:this._nodes;if(d)for(var e=0,f=d.length;e<f;++e){var g=d[e];if(g.constructor===k.Subgraph&&"onExecute"!=a)g.mode==c&&g.sendEventToAllNodes(a,b,c);else if(g[a]&&g.mode==c)if(void 0===b)g[a]();else if(b&&b.constructor===Array)g[a].apply(g,b);else g[a](b)}};m.prototype.sendActionToCanvas=
function(a,b){if(this.list_of_graphcanvas)for(var c=0;c<this.list_of_graphcanvas.length;++c){var d=this.list_of_graphcanvas[c];d[a]&&d[a].apply(d,b)}};m.prototype.add=function(a,b){if(a)if(a.constructor===t)this._groups.push(a),this.setDirtyCanvas(!0),this.change(),a.graph=this,this._version++;else{-1!=a.id&&null!=this._nodes_by_id[a.id]&&(console.warn("LiteGraph: there is already a node with this ID, changing it"),a.id=++this.last_node_id);if(this._nodes.length>=k.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";
@@ -136,9 +136,9 @@ if(this.onMouseDown)this.onMouseDown(a);return!1}}}};h.prototype.processMouseMov
this.last_mouse_dragging;this.node_widget&&(this.processNodeWidgets(this.node_widget[0],this.graph_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(c[0]/this.ds.scale,c[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]+=c[0]/this.ds.scale,this.ds.offset[1]+=c[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);var d=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);b=0;for(var e=this.graph._nodes.length;b<
e;++b)if(this.graph._nodes[b].mouseOver&&d!=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(d){d.redraw_on_mouse&&(this.dirty_canvas=!0);if(!d.mouseOver&&(d.mouseOver=!0,this.node_over=d,this.dirty_canvas=!0,d.onMouseEnter))d.onMouseEnter(a);if(d.onMouseMove)d.onMouseMove(a,[a.canvasX-d.pos[0],a.canvasY-d.pos[1]],this);if(this.connecting_node&&(e=this._highlight_input||
[0,0],!this.isOverNodeBox(d,a.canvasX,a.canvasY))){var f=this.isOverNodeInput(d,a.canvasX,a.canvasY,e);-1!=f&&d.inputs[f]?k.isValidConnection(this.connecting_output.type,d.inputs[f].type)&&(this._highlight_input=e):this._highlight_input=null}this.canvas&&(C(a.canvasX,a.canvasY,d.pos[0]+d.size[0]-5,d.pos[1]+d.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="crosshair")}else{e=null;for(b=0;b<this.visible_links.length;++b){f=this.visible_links[b];var g=f._pos;if(!(!g||a.canvasX<
g[0]-4||a.canvasX>g[0]+4||a.canvasY<g[1]-4||a.canvasY>g[1]+4)){e=f;break}}e!=this.over_link_center&&(this.over_link_center=e,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&&this.node_capturing_input!=d&&this.node_capturing_input.onMouseMove)this.node_capturing_input.onMouseMove(a,[a.canvasX-this.node_capturing_input.pos[0],a.canvasY-this.node_capturing_input.pos[1]],this);if(this.node_dragged&&!this.live_mode){for(b in this.selected_nodes)d=this.selected_nodes[b],
d.pos[0]+=c[0]/this.ds.scale,d.pos[1]+=c[1]/this.ds.scale;this.dirty_bgcanvas=this.dirty_canvas=!0}this.resizing_node&&!this.live_mode&&(c=[a.canvasX-this.resizing_node.pos[0],a.canvasY-this.resizing_node.pos[1]],b=this.resizing_node.computeSize(),c[0]=Math.max(b[0],c[0]),c[1]=Math.max(b[1],c[1]),this.resizing_node.setSize(c),this.canvas.style.cursor="se-resize",this.dirty_bgcanvas=this.dirty_canvas=!0)}a.preventDefault();return!1}};h.prototype.processMouseUp=function(a){this.set_canvas_dirty_on_mouse_event&&
[0,0],!this.isOverNodeBox(d,a.canvasX,a.canvasY))){var f=this.isOverNodeInput(d,a.canvasX,a.canvasY,e);-1!=f&&d.inputs[f]?k.isValidConnection(this.connecting_output.type,d.inputs[f].type)&&(this._highlight_input=e,this._highlight_input_slot=d.inputs[f]):this._highlight_input_slot=this._highlight_input=null}this.canvas&&(C(a.canvasX,a.canvasY,d.pos[0]+d.size[0]-5,d.pos[1]+d.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="crosshair")}else{e=null;for(b=0;b<this.visible_links.length;++b){f=
this.visible_links[b];var g=f._pos;if(!(!g||a.canvasX<g[0]-4||a.canvasX>g[0]+4||a.canvasY<g[1]-4||a.canvasY>g[1]+4)){e=f;break}}e!=this.over_link_center&&(this.over_link_center=e,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&&this.node_capturing_input!=d&&this.node_capturing_input.onMouseMove)this.node_capturing_input.onMouseMove(a,[a.canvasX-this.node_capturing_input.pos[0],a.canvasY-this.node_capturing_input.pos[1]],this);if(this.node_dragged&&!this.live_mode){for(b in this.selected_nodes)d=
this.selected_nodes[b],d.pos[0]+=c[0]/this.ds.scale,d.pos[1]+=c[1]/this.ds.scale;this.dirty_bgcanvas=this.dirty_canvas=!0}this.resizing_node&&!this.live_mode&&(c=[a.canvasX-this.resizing_node.pos[0],a.canvasY-this.resizing_node.pos[1]],b=this.resizing_node.computeSize(),c[0]=Math.max(b[0],c[0]),c[1]=Math.max(b[1],c[1]),this.resizing_node.setSize(c),this.canvas.style.cursor="se-resize",this.dirty_bgcanvas=this.dirty_canvas=!0)}a.preventDefault();return!1}};h.prototype.processMouseUp=function(a){this.set_canvas_dirty_on_mouse_event&&
(this.dirty_canvas=!0);if(this.graph){var b=this.getCanvasWindow().document;h.active_canvas=this;this.options.skip_events||(b.removeEventListener("mousemove",this._mousemove_callback,!0),this.canvas.addEventListener("mousemove",this._mousemove_callback,!0),b.removeEventListener("mouseup",this._mouseup_callback,!0));this.adjustMouseEvent(a);b=k.getTime();a.click_time=b-this.last_mouseclick;this.last_mouse_dragging=!1;this.last_click_position=null;this.block_click&&(console.log("foo"),this.block_click=
!1);if(1==a.which)if(this.node_widget&&this.processNodeWidgets(this.node_widget[0],this.graph_mouse,a),this.node_widget=null,this.selected_group&&(this.selected_group.move(this.selected_group.pos[0]-Math.round(this.selected_group.pos[0]),this.selected_group.pos[1]-Math.round(this.selected_group.pos[1]),a.ctrlKey),this.selected_group.pos[0]=Math.round(this.selected_group.pos[0]),this.selected_group.pos[1]=Math.round(this.selected_group.pos[1]),this.selected_group._nodes.length&&(this.dirty_canvas=
!0),this.selected_group=null),this.selected_group_resizing=!1,this.dragging_rectangle){if(this.graph){b=this.graph._nodes;var c=new Float32Array(4);this.deselectAllNodes();var d=Math.abs(this.dragging_rectangle[2]),e=Math.abs(this.dragging_rectangle[3]),f=0>this.dragging_rectangle[3]?this.dragging_rectangle[1]-e:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-d:this.dragging_rectangle[0];this.dragging_rectangle[1]=f;this.dragging_rectangle[2]=
@@ -166,7 +166,8 @@ b)};h.prototype.convertCanvasToOffset=function(a,b){return this.ds.convertCanvas
(this.dirty_bgcanvas||b||this.always_render_background||this.graph&&this.graph._last_trigger_time&&1E3>c-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}};h.prototype.drawFrontCanvas=function(){this.dirty_canvas=!1;this.ctx||(this.ctx=this.bgcanvas.getContext("2d"));var a=this.ctx;if(a){var b=this.canvas;a.start2D&&!this.viewport&&(a.start2D(),a.restore(),a.setTransform(1,0,0,1,0,0));
var c=this.viewport||this.dirty_area;c&&(a.save(),a.beginPath(),a.rect(c[0],c[1],c[2],c[3]),a.clip());this.clear_background&&(c?a.clearRect(c[0],c[1],c[2],c[3]):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,c?c[0]:0,c?c[1]:0);if(this.graph){a.save();this.ds.toCanvasContext(a);b=this.computeVisibleNodes(null,this.visible_nodes);for(var d=0;d<b.length;++d){var e=
b[d];a.save();a.translate(e.pos[0],e.pos[1]);this.drawNode(e,a);a.restore()}this.render_execution_order&&this.drawExecutionOrder(a);this.graph.config.links_ontop&&(this.live_mode||this.drawConnections(a));if(null!=this.connecting_pos){a.lineWidth=this.connections_width;switch(this.connecting_output.type){case k.EVENT:b=k.EVENT_LINK_COLOR;break;default:b=k.CONNECTING_LINK_COLOR}this.renderLink(a,this.connecting_pos,[this.graph_mouse[0],this.graph_mouse[1]],null,!1,null,b,this.connecting_output.dir||
(this.connecting_node.horizontal?k.DOWN:k.RIGHT),k.CENTER);a.beginPath();this.connecting_output.type===k.EVENT||this.connecting_output.shape===k.BOX_SHAPE?a.rect(this.connecting_pos[0]-6+.5,this.connecting_pos[1]-5+.5,14,10):a.arc(this.connecting_pos[0],this.connecting_pos[1],4,0,2*Math.PI);a.fill();a.fillStyle="#ffcc00";this._highlight_input&&(a.beginPath(),a.arc(this._highlight_input[0],this._highlight_input[1],6,0,2*Math.PI),a.fill())}this.dragging_rectangle&&(a.strokeStyle="#FFF",a.strokeRect(this.dragging_rectangle[0],
(this.connecting_node.horizontal?k.DOWN:k.RIGHT),k.CENTER);a.beginPath();this.connecting_output.type===k.EVENT||this.connecting_output.shape===k.BOX_SHAPE?a.rect(this.connecting_pos[0]-6+.5,this.connecting_pos[1]-5+.5,14,10):this.connecting_output.shape===k.ARROW_SHAPE?(a.moveTo(this.connecting_pos[0]+8,this.connecting_pos[1]+.5),a.lineTo(this.connecting_pos[0]-4,this.connecting_pos[1]+6+.5),a.lineTo(this.connecting_pos[0]-4,this.connecting_pos[1]-6+.5),a.closePath()):a.arc(this.connecting_pos[0],
this.connecting_pos[1],4,0,2*Math.PI);a.fill();a.fillStyle="#ffcc00";this._highlight_input&&(a.beginPath(),this._highlight_input_slot.shape===k.ARROW_SHAPE?(a.moveTo(this._highlight_input[0]+8,this._highlight_input[1]+.5),a.lineTo(this._highlight_input[0]-4,this._highlight_input[1]+6+.5),a.lineTo(this._highlight_input[0]-4,this._highlight_input[1]-6+.5),a.closePath()):a.arc(this._highlight_input[0],this._highlight_input[1],6,0,2*Math.PI),a.fill())}this.dragging_rectangle&&(a.strokeStyle="#FFF",a.strokeRect(this.dragging_rectangle[0],
this.dragging_rectangle[1],this.dragging_rectangle[2],this.dragging_rectangle[3]));if(this.over_link_center&&this.render_link_tooltip)this.drawLinkTooltip(a,this.over_link_center);else if(this.onDrawLinkTooltip)this.onDrawLinkTooltip(a,null);if(this.onDrawForeground)this.onDrawForeground(a,this.visible_rect);a.restore()}this._graph_stack&&this._graph_stack.length&&this.drawSubgraphPanel(a);if(this.onDrawOverlay)this.onDrawOverlay(a);c&&a.restore();a.finish2D&&a.finish2D()}};h.prototype.drawSubgraphPanel=
function(a){var b=this.graph,c=b._subgraph_node;if(c){var d=c.inputs?c.inputs.length:0,e=Math.floor(1.6*k.NODE_SLOT_HEIGHT);a.fillStyle="#111";a.globalAlpha=.8;a.beginPath();a.roundRect(10,10,300,(d+1)*e+50,8);a.fill();a.globalAlpha=1;a.fillStyle="#888";a.font="14px Arial";a.textAlign="left";a.fillText("Graph Inputs",20,34);if(this.drawButton(280,20,20,20,"X","#151515"))this.closeSubgraph();else{d=50;a.font="20px Arial";if(c.inputs)for(var f=0;f<c.inputs.length;++f){var g=c.inputs[f];if(!g.not_subgraph_input){if(this.drawButton(20,
d+2,280,e-2)){var n=c.constructor.input_node_type||"graph/input";this.graph.beforeChange();var r=k.createNode(n);r?(b.add(r),this.block_click=!1,this.last_click_position=null,this.selectNodes([r]),this.node_dragged=r,this.dragging_canvas=!1,r.setProperty("name",g.name),r.setProperty("type",g.type),this.node_dragged.pos[0]=this.graph_mouse[0]-5,this.node_dragged.pos[1]=this.graph_mouse[1]-5,this.graph.afterChange()):console.error("graph input node not found:",n)}a.fillStyle="#9C9";a.beginPath();a.arc(284,
@@ -209,7 +210,7 @@ c,.5,n,r);d&&d._pos&&(d._pos[0]=e[0],d._pos[1]=e[1]);.6<=this.ds.scale&&this.hig
"right",c.fillText(y.value?y.options.on||"true":y.options.off||"false",m-40,t+.7*g));break;case "slider":c.fillStyle=h;c.fillRect(15,t,m-30,g);var q=y.options.max-y.options.min,w=(y.value-y.options.min)/q;c.fillStyle=d==y?"#89A":"#678";c.fillRect(15,t,w*(m-30),g);n&&!y.disabled&&c.strokeRect(15,t,m-30,g);y.marker&&(q=(y.marker-y.options.min)/q,c.fillStyle="#AA9",c.fillRect(15+q*(m-30),t,2,g));n&&(c.textAlign="center",c.fillStyle=l,c.fillText(y.name+" "+Number(y.value).toFixed(3),.5*m,t+.7*g));break;
case "number":case "combo":c.textAlign="left";c.strokeStyle=r;c.fillStyle=h;c.beginPath();n?c.roundRect(15,b,m-30,g,.5*g):c.rect(15,b,m-30,g);c.fill();n&&(y.disabled||c.stroke(),c.fillStyle=l,y.disabled||(c.beginPath(),c.moveTo(31,b+5),c.lineTo(21,b+.5*g),c.lineTo(31,b+g-5),c.fill(),c.beginPath(),c.moveTo(m-15-16,b+5),c.lineTo(m-15-6,b+.5*g),c.lineTo(m-15-16,b+g-5),c.fill()),c.fillStyle=p,c.fillText(y.name,35,t+.7*g),c.fillStyle=l,c.textAlign="right","number"==y.type?c.fillText(Number(y.value).toFixed(void 0!==
y.options.precision?y.options.precision:3),m-30-20,t+.7*g):(q=y.value,y.options.values&&(w=y.options.values,w.constructor===Function&&(w=w()),w&&w.constructor!==Array&&(q=w[y.value])),c.fillText(q,m-30-20,t+.7*g)));break;case "string":case "text":c.textAlign="left";c.strokeStyle=r;c.fillStyle=h;c.beginPath();n?c.roundRect(15,b,m-30,g,.5*g):c.rect(15,b,m-30,g);c.fill();n&&(y.disabled||c.stroke(),c.save(),c.beginPath(),c.rect(15,b,m-30,g),c.clip(),c.fillStyle=p,null!=y.name&&c.fillText(y.name,30,t+
.7*g),c.fillStyle=l,c.textAlign="right",c.fillText(String(y.value).substr(0,30),m-30,t+.7*g),c.restore());break;default:y.draw&&y.draw(c,a,m,t,g)}b+=(y.computeSize?y.computeSize(m)[1]:g)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};h.prototype.processNodeWidgets=function(a,b,c,d){function e(e,d){e.value=d;e.options&&e.options.property&&void 0!==a.properties[e.options.property]&&a.setProperty(e.options.property,d);e.callback&&e.callback(e.value,r,a,b,c)}if(!a.widgets||!a.widgets.length)return null;
.7*g),c.fillStyle=l,c.textAlign="right",c.fillText(String(y.value).substr(0,30),m-30,t+.7*g),c.restore());break;default:y.draw&&y.draw(c,a,m,t,g)}b+=(y.computeSize?y.computeSize(m)[1]:g)+4;c.globalAlpha=this.editor_alpha}c.restore();c.textAlign="left"};h.prototype.processNodeWidgets=function(a,b,c,d){function e(d,e){d.value=e;d.options&&d.options.property&&void 0!==a.properties[d.options.property]&&a.setProperty(d.options.property,e);d.callback&&d.callback(d.value,r,a,b,c)}if(!a.widgets||!a.widgets.length)return null;
for(var f=b[0]-a.pos[0],g=b[1]-a.pos[1],n=a.size[0],r=this,h=this.getCanvasWindow(),l=0;l<a.widgets.length;++l){var p=a.widgets[l];if(p&&!p.disabled){var z=p.computeSize?p.computeSize(n)[1]:k.NODE_WIDGET_HEIGHT,t=p.width||n;if(p==d||!(6>f||f>t-12||g<p.last_y||g>p.last_y+z||void 0===p.last_y)){d=p.value;switch(p.type){case "button":"mousedown"===c.type&&(p.callback&&setTimeout(function(){p.callback(p,r,a,b,c)},20),this.dirty_canvas=p.clicked=!0);break;case "slider":h=Math.clamp((f-15)/(t-30),0,1);
p.value=p.options.min+(p.options.max-p.options.min)*h;p.callback&&setTimeout(function(){e(p,p.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d=p.value;if("mousemove"==c.type&&"number"==p.type)p.value+=.1*c.deltaX*(p.options.step||1),null!=p.options.min&&p.value<p.options.min&&(p.value=p.options.min),null!=p.options.max&&p.value>p.options.max&&(p.value=p.options.max);else if("mousedown"==c.type){var m=p.options.values;m&&m.constructor===Function&&(m=p.options.values(p,a));var q=
null;"number"!=p.type&&(q=m.constructor===Array?m:Object.keys(m));f=40>f?-1:f>t-40?1:0;if("number"==p.type)p.value+=.1*f*(p.options.step||1),null!=p.options.min&&p.value<p.options.min&&(p.value=p.options.min),null!=p.options.max&&p.value>p.options.max&&(p.value=p.options.max);else if(f)h=-1,this.last_mouseclick=0,h=m.constructor===Object?q.indexOf(String(p.value))+f:q.indexOf(p.value)+f,h>=q.length&&(h=q.length-1),0>h&&(h=0),p.value=m.constructor===Array?m[h]:h;else{var w=m!=q?Object.values(m):m;
@@ -219,14 +220,14 @@ for(var c=0;c<a.length;++c){var d=a[c];if(B(this.visible_area,d._bounding)){b.fi
f)}}b.restore()}};h.prototype.adjustNodesSize=function(){for(var a=this.graph._nodes,b=0;b<a.length;++b)a[b].size=a[b].computeSize();this.setDirty(!0,!0)};h.prototype.resize=function(a,b){a||b||(b=this.canvas.parentNode,a=b.offsetWidth,b=b.offsetHeight);if(this.canvas.width!=a||this.canvas.height!=b)this.canvas.width=a,this.canvas.height=b,this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height,this.setDirty(!0,!0)};h.prototype.switchLiveMode=function(a){if(a){var b=this,c=this.live_mode?
1.1:.9;this.live_mode&&(this.live_mode=!1,this.editor_alpha=.1);var d=setInterval(function(){b.editor_alpha*=c;b.dirty_canvas=!0;b.dirty_bgcanvas=!0;1>c&&.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1<c&&.99<b.editor_alpha&&(clearInterval(d),b.editor_alpha=1)},1)}else this.live_mode=!this.live_mode,this.dirty_bgcanvas=this.dirty_canvas=!0};h.prototype.onNodeSelectionChange=function(a){};h.prototype.touchHandler=function(a){var b=a.changedTouches[0];switch(a.type){case "touchstart":var c=
"mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var d=this.getCanvasWindow(),e=d.document.createEvent("MouseEvent");e.initMouseEvent(c,!0,!0,d,1,b.screenX,b.screenY,b.clientX,b.clientY,!1,!1,!1,!1,0,null);b.target.dispatchEvent(e);a.preventDefault()};h.onGroupAdd=function(a,b,c){a=h.active_canvas;a.getCanvasWindow();b=new k.LGraphGroup;b.pos=a.convertEventToCanvasOffset(c);a.graph.add(b)};h.onMenuAdd=function(a,b,c,d,e){function f(a,b){var d=
[];k.getNodeTypesCategories(g.filter||r.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var c=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===d.findIndex(function(a){return a.value===c})&&d.push({value:c,content:b,has_submenu:!0,callback:function(a,b,c,e){f(a.value,e)}})}});k.getNodeTypesInCategory(a.slice(0,-1),g.filter||r.filter).map(function(a){a.skip_list||d.push({value:a.type,content:a.title,has_submenu:!1,
[];k.getNodeTypesCategories(g.filter||r.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var c=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===d.findIndex(function(a){return a.value===c})&&d.push({value:c,content:b,has_submenu:!0,callback:function(a,b,c,d){f(a.value,d)}})}});k.getNodeTypesInCategory(a.slice(0,-1),g.filter||r.filter).map(function(a){a.skip_list||d.push({value:a.type,content:a.title,has_submenu:!1,
callback:function(a,b,c,d){b=d.getFirstEvent();g.graph.beforeChange();if(a=k.createNode(a.value))a.pos=g.convertEventToCanvasOffset(b),g.graph.add(a);e&&e(a);g.graph.afterChange()}})});new k.ContextMenu(d,{event:c,parentMenu:b},n)}var g=h.active_canvas,n=g.getCanvasWindow(),r=g.graph;if(r)return f("",d),!1};h.onMenuCollapseAll=function(){};h.onMenuNodeEdit=function(){};h.showMenuNodeOptionalInputs=function(a,b,c,d,e){if(e){var f=this;a=h.active_canvas.getCanvasWindow();b=e.optional_inputs;e.onGetInputs&&
(b=e.onGetInputs());var g=[];if(b)for(var n=0;n<b.length;n++){var r=b[n];if(r){var l=r[0];r[2]&&r[2].label&&(l=r[2].label);l={content:l,value:r};r[1]==k.ACTION&&(l.className="event");g.push(l)}else g.push(null)}this.onMenuNodeInputs&&(g=this.onMenuNodeInputs(g));if(g.length)return new k.ContextMenu(g,{event:c,callback:function(a,b,c){e&&(a.callback&&a.callback.call(f,e,a,b,c),a.value&&(e.graph.beforeChange(),e.addInput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,!0),e.graph.afterChange()))},
parentMenu:d,node:e},a),!1;console.log("no input entries")}};h.showMenuNodeOptionalOutputs=function(a,b,c,d,e){function f(a,b,c){if(e&&(a.callback&&a.callback.call(g,e,a,b,c),a.value))if(c=a.value[1],!c||c.constructor!==Object&&c.constructor!==Array)e.graph.beforeChange(),e.addOutput(a.value[0],a.value[1],a.value[2]),e.setDirtyCanvas(!0,!0),e.graph.afterChange();else{a=[];for(var n in c)a.push({content:n,value:c[n]});new k.ContextMenu(a,{event:b,callback:f,parentMenu:d,node:e});return!1}}if(e){var g=
this;a=h.active_canvas.getCanvasWindow();b=e.optional_outputs;e.onGetOutputs&&(b=e.onGetOutputs());var n=[];if(b)for(var r=0;r<b.length;r++){var l=b[r];if(!l)n.push(null);else if(!e.flags||!e.flags.skip_repeated_outputs||-1==e.findOutputSlot(l[0])){var m=l[0];l[2]&&l[2].label&&(m=l[2].label);m={content:m,value:l};l[1]==k.EVENT&&(m.className="event");n.push(m)}}this.onMenuNodeOutputs&&(n=this.onMenuNodeOutputs(n));if(n.length)return new k.ContextMenu(n,{event:c,callback:f,parentMenu:d,node:e},a),!1}};
h.onShowMenuNodeProperties=function(a,b,c,d,e){if(e&&e.properties){var f=h.active_canvas;b=f.getCanvasWindow();var g=[],n;for(n in e.properties){a=void 0!==e.properties[n]?e.properties[n]:" ";"object"==typeof a&&(a=JSON.stringify(a));var r=e.getPropertyInfo(n);if("enum"==r.type||"combo"==r.type)a=h.getPropertyPrintableValue(a,r.values);a=h.decodeHTML(a);g.push({content:"<span class='property_name'>"+(r.label?r.label:n)+"</span><span class='property_value'>"+a+"</span>",value:n})}if(g.length)return new k.ContextMenu(g,
{event:c,callback:function(a,b,c,d){e&&(b=this.getBoundingClientRect(),f.showEditPropertyValue(e,a.value,{position:[b.left,b.top]}))},parentMenu:d,allow_html:!0,node:e},b),!1}};h.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};h.onResizeNode=function(a,b,c,d,e){if(e){e.size=e.computeSize();if(e.onResize)e.onResize(e.size);e.setDirtyCanvas(!0,!0)}};h.prototype.showLinkMenu=function(a,b){var c=this;console.log(a);var d=new k.ContextMenu(["Add Node",null,
"Delete"],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,f,g){switch(b){case "Add Node":h.onMenuAdd(null,null,g,d,function(b){console.log("node autoconnect");var e=c.graph.getNodeById(a.origin_id),d=c.graph.getNodeById(a.target_id);b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&e.outputs[a.origin_slot].type==b.inputs[0].type&&b.outputs[0].type==d.inputs[0].type&&(e.connect(a.origin_slot,b,0),b.connect(0,d,a.target_slot),b.pos[0]-=.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});
"Delete"],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,f,g){switch(b){case "Add Node":h.onMenuAdd(null,null,g,d,function(b){console.log("node autoconnect");var d=c.graph.getNodeById(a.origin_id),e=c.graph.getNodeById(a.target_id);b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&d.outputs[a.origin_slot].type==b.inputs[0].type&&b.outputs[0].type==e.inputs[0].type&&(d.connect(a.origin_slot,b,0),b.connect(0,e,a.target_slot),b.pos[0]-=.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});
return!1};h.onShowPropertyEditor=function(a,b,c,d,e){function f(){var b=k.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);e[g]=b;n.parentNode&&n.parentNode.removeChild(n);e.setDirtyCanvas(!0,!0)}var g=a.property||"title";b=e[g];var n=document.createElement("div");n.className="graphdialog";n.innerHTML="<span class='name'></span><input autofocus type='text' class='value'/><button>OK</button>";n.querySelector(".name").innerText=g;var k=n.querySelector(".value");k&&(k.value=b,k.addEventListener("blur",
function(a){this.focus()}),k.addEventListener("keydown",function(a){if(13==a.keyCode||"textarea"==a.target.localName)f(),a.preventDefault(),a.stopPropagation()}));b=h.active_canvas.canvas;c=b.getBoundingClientRect();var l=d=-20;c&&(d-=c.left,l-=c.top);event?(n.style.left=event.clientX+d+"px",n.style.top=event.clientY+l+"px"):(n.style.left=.5*b.width+d+"px",n.style.top=.5*b.height+l+"px");n.querySelector("button").addEventListener("click",f);b.parentNode.appendChild(n)};h.prototype.prompt=function(a,
b,c,d,e){var f=this;a=a||"";var g=!1,n=document.createElement("div");n.className="graphdialog rounded";n.innerHTML=e?"<span class='name'></span> <textarea autofocus class='value'></textarea><button class='rounded'>OK</button>":"<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>";n.close=function(){f.prompt_box=null;n.parentNode&&n.parentNode.removeChild(n)};1<this.ds.scale&&(n.style.transform="scale("+this.ds.scale+")");n.addEventListener("mouseleave",