Merge pull request #3143 from rachel-fenichel/remove_block_render_svg

Remove block_render_svg
This commit is contained in:
Rachel Fenichel
2019-10-02 16:33:47 -07:00
committed by GitHub
6 changed files with 151 additions and 189 deletions

View File

@@ -71,42 +71,7 @@ Blockly.utils.dom.createSvgElement=function(a,b,c){a=document.createElementNS(Bl
Blockly.utils.dom.removeClass=function(a,b){var c=a.getAttribute("class");if(-1==(" "+c+" ").indexOf(" "+b+" "))return!1;c=c.split(/\s+/);for(var d=0;d<c.length;d++)c[d]&&c[d]!=b||(c.splice(d,1),d--);c.length?a.setAttribute("class",c.join(" ")):a.removeAttribute("class");return!0};Blockly.utils.dom.hasClass=function(a,b){return-1!=(" "+a.getAttribute("class")+" ").indexOf(" "+b+" ")};Blockly.utils.dom.removeNode=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};
Blockly.utils.dom.insertAfter=function(a,b){var c=b.nextSibling,d=b.parentNode;if(!d)throw Error("Reference node has no parent.");c?d.insertBefore(a,c):d.appendChild(a)};Blockly.utils.dom.containsNode=function(a,b){return!!(a.compareDocumentPosition(b)&Blockly.utils.dom.Node.DOCUMENT_POSITION_CONTAINED_BY)};Blockly.utils.dom.setCssTransform=function(a,b){a.style.transform=b;a.style["-webkit-transform"]=b};
Blockly.utils.dom.startTextWidthCache=function(){Blockly.utils.dom.cacheReference_++;Blockly.utils.dom.cacheWidths_||(Blockly.utils.dom.cacheWidths_={})};Blockly.utils.dom.stopTextWidthCache=function(){Blockly.utils.dom.cacheReference_--;Blockly.utils.dom.cacheReference_||(Blockly.utils.dom.cacheWidths_=null)};
Blockly.utils.dom.getTextWidth=function(a){var b=a.textContent+"\n"+a.className.baseVal,c;if(Blockly.utils.dom.cacheWidths_&&(c=Blockly.utils.dom.cacheWidths_[b]))return c;try{c=Blockly.utils.userAgent.IE||Blockly.utils.userAgent.EDGE?a.getBBox().width:a.getComputedTextLength()}catch(d){return 8*a.textContent.length}Blockly.utils.dom.cacheWidths_&&(Blockly.utils.dom.cacheWidths_[b]=c);return c};Blockly.Events.CommentBase=function(a){this.commentId=a.id;this.workspaceId=a.workspace.id;this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.utils.object.inherits(Blockly.Events.CommentBase,Blockly.Events.Abstract);Blockly.Events.CommentBase.prototype.toJson=function(){var a=Blockly.Events.CommentBase.superClass_.toJson.call(this);this.commentId&&(a.commentId=this.commentId);return a};
Blockly.Events.CommentBase.prototype.fromJson=function(a){Blockly.Events.CommentBase.superClass_.fromJson.call(this,a);this.commentId=a.commentId};Blockly.Events.CommentChange=function(a,b,c){a&&(Blockly.Events.CommentChange.superClass_.constructor.call(this,a),this.oldContents_=b,this.newContents_=c)};Blockly.utils.object.inherits(Blockly.Events.CommentChange,Blockly.Events.CommentBase);Blockly.Events.CommentChange.prototype.type=Blockly.Events.COMMENT_CHANGE;
Blockly.Events.CommentChange.prototype.toJson=function(){var a=Blockly.Events.CommentChange.superClass_.toJson.call(this);a.newContents=this.newContents_;return a};Blockly.Events.CommentChange.prototype.fromJson=function(a){Blockly.Events.CommentChange.superClass_.fromJson.call(this,a);this.newContents_=a.newValue};Blockly.Events.CommentChange.prototype.isNull=function(){return this.oldContents_==this.newContents_};
Blockly.Events.CommentChange.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);b?b.setContent(a?this.newContents_:this.oldContents_):console.warn("Can't change non-existent comment: "+this.commentId)};Blockly.Events.CommentCreate=function(a){a&&(Blockly.Events.CommentCreate.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};Blockly.utils.object.inherits(Blockly.Events.CommentCreate,Blockly.Events.CommentBase);
Blockly.Events.CommentCreate.prototype.type=Blockly.Events.COMMENT_CREATE;Blockly.Events.CommentCreate.prototype.toJson=function(){var a=Blockly.Events.CommentCreate.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);return a};Blockly.Events.CommentCreate.prototype.fromJson=function(a){Blockly.Events.CommentCreate.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom(a.xml)};
Blockly.Events.CommentCreate.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,a)};Blockly.Events.CommentCreateDeleteHelper=function(a,b){var c=a.getEventWorkspace_();if(b){var d=Blockly.utils.xml.createElement("xml");d.appendChild(a.xml);Blockly.Xml.domToWorkspace(d,c)}else(c=c.getCommentById(a.commentId))?c.dispose(!1,!1):console.warn("Can't uncreate non-existent comment: "+a.commentId)};
Blockly.Events.CommentDelete=function(a){a&&(Blockly.Events.CommentDelete.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};Blockly.utils.object.inherits(Blockly.Events.CommentDelete,Blockly.Events.CommentBase);Blockly.Events.CommentDelete.prototype.type=Blockly.Events.COMMENT_DELETE;Blockly.Events.CommentDelete.prototype.toJson=function(){return Blockly.Events.CommentDelete.superClass_.toJson.call(this)};
Blockly.Events.CommentDelete.prototype.fromJson=function(a){Blockly.Events.CommentDelete.superClass_.fromJson.call(this,a)};Blockly.Events.CommentDelete.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,!a)};Blockly.Events.CommentMove=function(a){a&&(Blockly.Events.CommentMove.superClass_.constructor.call(this,a),this.comment_=a,this.oldCoordinate_=a.getXY(),this.newCoordinate_=null)};Blockly.utils.object.inherits(Blockly.Events.CommentMove,Blockly.Events.CommentBase);
Blockly.Events.CommentMove.prototype.recordNew=function(){if(!this.comment_)throw Error("Tried to record the new position of a comment on the same event twice.");this.newCoordinate_=this.comment_.getXY();this.comment_=null};Blockly.Events.CommentMove.prototype.type=Blockly.Events.COMMENT_MOVE;Blockly.Events.CommentMove.prototype.setOldCoordinate=function(a){this.oldCoordinate_=a};
Blockly.Events.CommentMove.prototype.toJson=function(){var a=Blockly.Events.CommentMove.superClass_.toJson.call(this);this.newCoordinate_&&(a.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y));return a};Blockly.Events.CommentMove.prototype.fromJson=function(a){Blockly.Events.CommentMove.superClass_.fromJson.call(this,a);a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate_=new Blockly.utils.Coordinate(Number(a[0]),Number(a[1])))};
Blockly.Events.CommentMove.prototype.isNull=function(){return Blockly.utils.Coordinate.equals(this.oldCoordinate_,this.newCoordinate_)};Blockly.Events.CommentMove.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);if(b){a=a?this.newCoordinate_:this.oldCoordinate_;var c=b.getXY();b.moveBy(a.x-c.x,a.y-c.y)}else console.warn("Can't move non-existent comment: "+this.commentId)};
Blockly.WorkspaceComment=function(a,b,c,d,e){this.id=e&&!a.getCommentById(e)?e:Blockly.utils.genUid();a.addTopComment(this);this.xy_=new Blockly.utils.Coordinate(0,0);this.height_=c;this.width_=d;this.workspace=a;this.RTL=a.RTL;this.movable_=this.deletable_=!0;this.content_=b;this.isComment=!0;Blockly.WorkspaceComment.fireCreateEvent(this)};
Blockly.WorkspaceComment.prototype.dispose=function(){this.workspace&&(Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.CommentDelete(this)),this.workspace.removeTopComment(this),this.workspace=null)};Blockly.WorkspaceComment.prototype.getHeight=function(){return this.height_};Blockly.WorkspaceComment.prototype.setHeight=function(a){this.height_=a};Blockly.WorkspaceComment.prototype.getWidth=function(){return this.width_};
Blockly.WorkspaceComment.prototype.setWidth=function(a){this.width_=a};Blockly.WorkspaceComment.prototype.getXY=function(){return new Blockly.utils.Coordinate(this.xy_.x,this.xy_.y)};Blockly.WorkspaceComment.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this);this.xy_.translate(a,b);c.recordNew();Blockly.Events.fire(c)};Blockly.WorkspaceComment.prototype.isDeletable=function(){return this.deletable_&&!(this.workspace&&this.workspace.options.readOnly)};
Blockly.WorkspaceComment.prototype.setDeletable=function(a){this.deletable_=a};Blockly.WorkspaceComment.prototype.isMovable=function(){return this.movable_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.WorkspaceComment.prototype.setMovable=function(a){this.movable_=a};Blockly.WorkspaceComment.prototype.getContent=function(){return this.content_};
Blockly.WorkspaceComment.prototype.setContent=function(a){this.content_!=a&&(Blockly.Events.fire(new Blockly.Events.CommentChange(this,this.content_,a)),this.content_=a)};Blockly.WorkspaceComment.prototype.toXmlWithXY=function(a){a=this.toXml(a);a.setAttribute("x",Math.round(this.xy_.x));a.setAttribute("y",Math.round(this.xy_.y));a.setAttribute("h",this.height_);a.setAttribute("w",this.width_);return a};
Blockly.WorkspaceComment.prototype.toXml=function(a){var b=Blockly.utils.xml.createElement("comment");a||(b.id=this.id);b.textContent=this.getContent();return b};Blockly.WorkspaceComment.fireCreateEvent=function(a){if(Blockly.Events.isEnabled()){var b=Blockly.Events.getGroup();b||Blockly.Events.setGroup(!0);try{Blockly.Events.fire(new Blockly.Events.CommentCreate(a))}finally{b||Blockly.Events.setGroup(!1)}}};
Blockly.WorkspaceComment.fromXml=function(a,b){var c=Blockly.WorkspaceComment.parseAttributes(a);c=new Blockly.WorkspaceComment(b,c.content,c.h,c.w,c.id);var d=parseInt(a.getAttribute("x"),10),e=parseInt(a.getAttribute("y"),10);isNaN(d)||isNaN(e)||c.moveBy(d,e);Blockly.WorkspaceComment.fireCreateEvent(c);return c};
Blockly.WorkspaceComment.parseAttributes=function(a){var b=a.getAttribute("h"),c=a.getAttribute("w");return{id:a.getAttribute("id"),h:b?parseInt(b,10):100,w:c?parseInt(c,10):100,x:parseInt(a.getAttribute("x"),10),y:parseInt(a.getAttribute("y"),10),content:a.textContent}};Blockly.Events.Ui=function(a,b,c,d){Blockly.Events.Ui.superClass_.constructor.call(this);this.blockId=a?a.id:null;this.workspaceId=a?a.workspace.id:null;this.element=b;this.oldValue=c;this.newValue=d;this.recordUndo=!1};Blockly.utils.object.inherits(Blockly.Events.Ui,Blockly.Events.Abstract);Blockly.Events.Ui.prototype.type=Blockly.Events.UI;
Blockly.Events.Ui.prototype.toJson=function(){var a=Blockly.Events.Ui.superClass_.toJson.call(this);a.element=this.element;void 0!==this.newValue&&(a.newValue=this.newValue);this.blockId&&(a.blockId=this.blockId);return a};Blockly.Events.Ui.prototype.fromJson=function(a){Blockly.Events.Ui.superClass_.fromJson.call(this,a);this.element=a.element;this.newValue=a.newValue;this.blockId=a.blockId};Blockly.utils.Rect=function(a,b,c,d){this.top=a;this.bottom=b;this.left=c;this.right=d};Blockly.utils.Rect.prototype.contains=function(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom};Blockly.WorkspaceCommentSvg=function(a,b,c,d,e){this.svgGroup_=Blockly.utils.dom.createSvgElement("g",{"class":"blocklyComment"},null);this.svgGroup_.translate_="";this.svgRect_=Blockly.utils.dom.createSvgElement("rect",{"class":"blocklyCommentRect",x:0,y:0,rx:Blockly.WorkspaceCommentSvg.BORDER_RADIUS,ry:Blockly.WorkspaceCommentSvg.BORDER_RADIUS});this.svgGroup_.appendChild(this.svgRect_);this.rendered_=!1;this.useDragSurface_=Blockly.utils.is3dSupported()&&!!a.blockDragSurface_;Blockly.WorkspaceCommentSvg.superClass_.constructor.call(this,
a,b,c,d,e);this.render()};Blockly.utils.object.inherits(Blockly.WorkspaceCommentSvg,Blockly.WorkspaceComment);Blockly.WorkspaceCommentSvg.DEFAULT_SIZE=100;
Blockly.WorkspaceCommentSvg.prototype.dispose=function(){this.workspace&&(Blockly.selected==this&&(this.unselect(),this.workspace.cancelCurrentGesture()),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.CommentDelete(this)),Blockly.utils.dom.removeNode(this.svgGroup_),this.svgRect_=this.svgGroup_=null,this.disposeInternal_(),Blockly.Events.disable(),Blockly.WorkspaceCommentSvg.superClass_.dispose.call(this),Blockly.Events.enable())};
Blockly.WorkspaceCommentSvg.prototype.initSvg=function(){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");this.workspace.options.readOnly||this.eventsInit_||(Blockly.bindEventWithChecks_(this.svgRectTarget_,"mousedown",this,this.pathMouseDown_),Blockly.bindEventWithChecks_(this.svgHandleTarget_,"mousedown",this,this.pathMouseDown_));this.eventsInit_=!0;this.updateMovable();this.getSvgRoot().parentNode||this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot())};
Blockly.WorkspaceCommentSvg.prototype.pathMouseDown_=function(a){var b=this.workspace.getGesture(a);b&&b.handleBubbleStart(a,this)};Blockly.WorkspaceCommentSvg.prototype.showContextMenu_=function(a){if(!this.workspace.options.readOnly){var b=[];this.isDeletable()&&this.isMovable()&&(b.push(Blockly.ContextMenu.commentDuplicateOption(this)),b.push(Blockly.ContextMenu.commentDeleteOption(this)));Blockly.ContextMenu.show(a,b,this.RTL)}};
Blockly.WorkspaceCommentSvg.prototype.select=function(){if(Blockly.selected!=this){var a=null;if(Blockly.selected){a=Blockly.selected.id;Blockly.Events.disable();try{Blockly.selected.unselect()}finally{Blockly.Events.enable()}}a=new Blockly.Events.Ui(null,"selected",a,this.id);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=this;this.addSelect()}};
Blockly.WorkspaceCommentSvg.prototype.unselect=function(){if(Blockly.selected==this){var a=new Blockly.Events.Ui(null,"selected",this.id,null);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=null;this.removeSelect();this.blurFocus()}};Blockly.WorkspaceCommentSvg.prototype.addSelect=function(){Blockly.utils.dom.addClass(this.svgGroup_,"blocklySelected");this.setFocus()};
Blockly.WorkspaceCommentSvg.prototype.removeSelect=function(){Blockly.utils.dom.removeClass(this.svgGroup_,"blocklySelected");this.blurFocus()};Blockly.WorkspaceCommentSvg.prototype.addFocus=function(){Blockly.utils.dom.addClass(this.svgGroup_,"blocklyFocused")};Blockly.WorkspaceCommentSvg.prototype.removeFocus=function(){Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyFocused")};
Blockly.WorkspaceCommentSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.useDragSurface_?this.workspace.blockDragSurface_.getGroup():null,d=this.getSvgRoot();if(d){do{var e=Blockly.utils.getRelativeXY(d);a+=e.x;b+=e.y;this.useDragSurface_&&this.workspace.blockDragSurface_.getCurrentBlock()==d&&(e=this.workspace.blockDragSurface_.getSurfaceTranslation(),a+=e.x,b+=e.y);d=d.parentNode}while(d&&d!=this.workspace.getBubbleCanvas()&&d!=c)}return this.xy_=new Blockly.utils.Coordinate(a,
b)};Blockly.WorkspaceCommentSvg.prototype.moveBy=function(a,b){var c=new Blockly.Events.CommentMove(this),d=this.getRelativeToSurfaceXY();this.translate(d.x+a,d.y+b);this.xy_=new Blockly.utils.Coordinate(d.x+a,d.y+b);c.recordNew();Blockly.Events.fire(c);this.workspace.resizeContents()};Blockly.WorkspaceCommentSvg.prototype.translate=function(a,b){this.xy_=new Blockly.utils.Coordinate(a,b);this.getSvgRoot().setAttribute("transform","translate("+a+","+b+")")};
Blockly.WorkspaceCommentSvg.prototype.moveToDragSurface_=function(){if(this.useDragSurface_){var a=this.getRelativeToSurfaceXY();this.clearTransformAttributes_();this.workspace.blockDragSurface_.translateSurface(a.x,a.y);this.workspace.blockDragSurface_.setBlocksAndShow(this.getSvgRoot())}};Blockly.WorkspaceCommentSvg.prototype.moveOffDragSurface_=function(a){this.useDragSurface_&&(this.translate(a.x,a.y),this.workspace.blockDragSurface_.clearAndHide(this.workspace.getCanvas()))};
Blockly.WorkspaceCommentSvg.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):(this.svgGroup_.translate_="translate("+b.x+","+b.y+")",this.svgGroup_.setAttribute("transform",this.svgGroup_.translate_+this.svgGroup_.skew_))};Blockly.WorkspaceCommentSvg.prototype.moveTo=function(a,b){this.translate(a,b)};Blockly.WorkspaceCommentSvg.prototype.clearTransformAttributes_=function(){this.getSvgRoot().removeAttribute("transform")};
Blockly.WorkspaceCommentSvg.prototype.getBoundingRectangle=function(){var a=this.getRelativeToSurfaceXY(),b=this.getHeightWidth(),c=a.y,d=a.y+b.height;if(this.RTL){var e=a.x-b.width;a=a.x}else e=a.x,a=a.x+b.width;return new Blockly.utils.Rect(c,d,e,a)};Blockly.WorkspaceCommentSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDraggable"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDraggable")};
Blockly.WorkspaceCommentSvg.prototype.setMovable=function(a){Blockly.WorkspaceCommentSvg.superClass_.setMovable.call(this,a);this.updateMovable()};Blockly.WorkspaceCommentSvg.prototype.setDragging=function(a){a?(a=this.getSvgRoot(),a.translate_="",a.skew_="",Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDragging")):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDragging")};Blockly.WorkspaceCommentSvg.prototype.getSvgRoot=function(){return this.svgGroup_};
Blockly.WorkspaceCommentSvg.prototype.getContent=function(){return this.textarea_?this.textarea_.value:this.content_};Blockly.WorkspaceCommentSvg.prototype.setContent=function(a){Blockly.WorkspaceCommentSvg.superClass_.setContent.call(this,a);this.textarea_&&(this.textarea_.value=a)};Blockly.WorkspaceCommentSvg.prototype.setDeleteStyle=function(a){a?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyDraggingDelete"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyDraggingDelete")};
Blockly.WorkspaceCommentSvg.prototype.setAutoLayout=function(){};Blockly.WorkspaceCommentSvg.fromXml=function(a,b,c){Blockly.Events.disable();try{var d=Blockly.WorkspaceComment.parseAttributes(a),e=new Blockly.WorkspaceCommentSvg(b,d.content,d.h,d.w,d.id);b.rendered&&(e.initSvg(),e.render(!1));if(!isNaN(d.x)&&!isNaN(d.y))if(b.RTL){var f=c||b.getWidth();e.moveBy(f-d.x,d.y)}else e.moveBy(d.x,d.y)}finally{Blockly.Events.enable()}Blockly.WorkspaceComment.fireCreateEvent(e);return e};
Blockly.WorkspaceCommentSvg.prototype.toXmlWithXY=function(a){var b;this.workspace.RTL&&(b=this.workspace.getWidth());a=this.toXml(a);var c=this.getRelativeToSurfaceXY();a.setAttribute("x",Math.round(this.workspace.RTL?b-c.x:c.x));a.setAttribute("y",Math.round(c.y));a.setAttribute("h",this.getHeight());a.setAttribute("w",this.getWidth());return a};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a,b){var c=Blockly.utils.xml.createElement("xml"),d=Blockly.Xml.variablesToDom(Blockly.Variables.allUsedVarModels(a));d.hasChildNodes()&&c.appendChild(d);var e=a.getTopComments(!0);d=0;for(var f;f=e[d];d++)c.appendChild(f.toXmlWithXY(b));e=a.getTopBlocks(!0);for(d=0;f=e[d];d++)c.appendChild(Blockly.Xml.blockToDomWithXY(f,b));return c};
Blockly.utils.dom.getTextWidth=function(a){var b=a.textContent+"\n"+a.className.baseVal,c;if(Blockly.utils.dom.cacheWidths_&&(c=Blockly.utils.dom.cacheWidths_[b]))return c;try{c=Blockly.utils.userAgent.IE||Blockly.utils.userAgent.EDGE?a.getBBox().width:a.getComputedTextLength()}catch(d){return 8*a.textContent.length}Blockly.utils.dom.cacheWidths_&&(Blockly.utils.dom.cacheWidths_[b]=c);return c};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a,b){var c=Blockly.utils.xml.createElement("xml"),d=Blockly.Xml.variablesToDom(Blockly.Variables.allUsedVarModels(a));d.hasChildNodes()&&c.appendChild(d);var e=a.getTopComments(!0);d=0;for(var f;f=e[d];d++)c.appendChild(f.toXmlWithXY(b));e=a.getTopBlocks(!0);for(d=0;f=e[d];d++)c.appendChild(Blockly.Xml.blockToDomWithXY(f,b));return c};
Blockly.Xml.variablesToDom=function(a){for(var b=Blockly.utils.xml.createElement("variables"),c=0,d;d=a[c];c++){var e=Blockly.utils.xml.createElement("variable");e.appendChild(Blockly.utils.xml.createTextNode(d.name));d.type&&e.setAttribute("type",d.type);e.id=d.getId();b.appendChild(e)}return b};
Blockly.Xml.blockToDomWithXY=function(a,b){var c;a.workspace.RTL&&(c=a.workspace.getWidth());var d=Blockly.Xml.blockToDom(a,b),e=a.getRelativeToSurfaceXY();d.setAttribute("x",Math.round(a.workspace.RTL?c-e.x:e.x));d.setAttribute("y",Math.round(e.y));return d};Blockly.Xml.fieldToDom_=function(a){if(a.isSerializable()){var b=Blockly.utils.xml.createElement("field");b.setAttribute("name",a.name);return a.toXml(b)}return null};
Blockly.Xml.allFieldsToDom_=function(a,b){for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)(f=Blockly.Xml.fieldToDom_(f))&&b.appendChild(f)};
@@ -132,12 +97,12 @@ case "data":c.data=g.textContent;break;case "title":case "field":Blockly.Xml.dom
break;case "next":h&&c.nextConnection&&c.nextConnection.setShadowDom(h);if(f){if(!c.nextConnection)throw TypeError("Next statement does not exist.");if(c.nextConnection.isConnected())throw TypeError("Next statement is already connected.");f=Blockly.Xml.domToBlockHeadless_(f,b);if(!f.previousConnection)throw TypeError("Next block does not have previous statement.");c.nextConnection.connect(f.previousConnection)}break;default:console.warn("Ignoring unknown tag: "+g.nodeName)}}(e=a.getAttribute("inline"))&&
c.setInputsInline("true"==e);(e=a.getAttribute("disabled"))&&c.setEnabled("true"!=e&&"disabled"!=e);(e=a.getAttribute("deletable"))&&c.setDeletable("true"==e);(e=a.getAttribute("movable"))&&c.setMovable("true"==e);(e=a.getAttribute("editable"))&&c.setEditable("true"==e);(e=a.getAttribute("collapsed"))&&c.setCollapsed("true"==e);if("shadow"==a.nodeName.toLowerCase()){d=c.getChildren(!1);for(e=0;g=d[e];e++)if(!g.isShadow())throw TypeError("Shadow block not allowed non-shadow child.");if(c.getVarModels().length)throw TypeError("Shadow blocks cannot have variable references.");
c.setShadow(!0)}return c};Blockly.Xml.domToField_=function(a,b,c){var d=a.getField(b);d?d.fromXml(c):console.warn("Ignoring non-existent field "+b+" in block "+a.type)};Blockly.Xml.deleteNext=function(a){for(var b=0,c;c=a.childNodes[b];b++)if("next"==c.nodeName.toLowerCase()){a.removeChild(c);break}};
Blockly.Connection=function(a,b){this.sourceBlock_=a;this.type=b;a.workspace.connectionDBList&&(this.db_=a.workspace.connectionDBList[b],this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]],this.hidden_=!this.db_)};Blockly.Connection.CAN_CONNECT=0;Blockly.Connection.REASON_SELF_CONNECTION=1;Blockly.Connection.REASON_WRONG_TYPE=2;Blockly.Connection.REASON_TARGET_NULL=3;Blockly.Connection.REASON_CHECKS_FAILED=4;Blockly.Connection.REASON_DIFFERENT_WORKSPACES=5;
Blockly.Connection.REASON_SHADOW_PARENT=6;Blockly.Connection.prototype.targetConnection=null;Blockly.Connection.prototype.disposed=!1;Blockly.Connection.prototype.check_=null;Blockly.Connection.prototype.shadowDom_=null;Blockly.Connection.prototype.x_=0;Blockly.Connection.prototype.y_=0;Blockly.Connection.prototype.inDB_=!1;Blockly.Connection.prototype.db_=null;Blockly.Connection.prototype.dbOpposite_=null;Blockly.Connection.prototype.hidden_=null;
Blockly.Connection=function(a,b){this.sourceBlock_=a;this.type=b};Blockly.Connection.CAN_CONNECT=0;Blockly.Connection.REASON_SELF_CONNECTION=1;Blockly.Connection.REASON_WRONG_TYPE=2;Blockly.Connection.REASON_TARGET_NULL=3;Blockly.Connection.REASON_CHECKS_FAILED=4;Blockly.Connection.REASON_DIFFERENT_WORKSPACES=5;Blockly.Connection.REASON_SHADOW_PARENT=6;Blockly.Connection.prototype.targetConnection=null;Blockly.Connection.prototype.disposed=!1;Blockly.Connection.prototype.check_=null;
Blockly.Connection.prototype.shadowDom_=null;Blockly.Connection.prototype.x_=0;Blockly.Connection.prototype.y_=0;
Blockly.Connection.prototype.connect_=function(a){var b=this,c=b.getSourceBlock(),d=a.getSourceBlock();a.isConnected()&&a.disconnect();if(b.isConnected()){var e=b.targetBlock(),f=b.getShadowDom();b.setShadowDom(null);if(e.isShadow())f=Blockly.Xml.blockToDom(e),e.dispose(),e=null;else if(b.type==Blockly.INPUT_VALUE){if(!e.outputConnection)throw Error("Orphan block does not have an output connection.");var g=Blockly.Connection.lastConnectionInRow_(d,e);g&&(e.outputConnection.connect(g),e=null)}else if(b.type==
Blockly.NEXT_STATEMENT){if(!e.previousConnection)throw Error("Orphan block does not have a previous connection.");for(g=d;g.nextConnection;){var h=g.getNextBlock();if(h&&!h.isShadow())g=h;else{e.previousConnection.checkType_(g.nextConnection)&&(g.nextConnection.connect(e.previousConnection),e=null);break}}}if(e&&(b.disconnect(),Blockly.Events.recordUndo)){var k=Blockly.Events.getGroup();setTimeout(function(){if(e.workspace&&!e.getParent()){Blockly.Events.setGroup(k);if(e.outputConnection)e.outputConnection.onFailedConnect(b);
else if(e.previousConnection)e.previousConnection.onFailedConnect(b);Blockly.Events.setGroup(!1)}},Blockly.BUMP_DELAY)}b.setShadowDom(f)}var l;Blockly.Events.isEnabled()&&(l=new Blockly.Events.BlockMove(d));Blockly.Connection.connectReciprocally_(b,a);d.setParent(c);l&&(l.recordNew(),Blockly.Events.fire(l))};
Blockly.Connection.prototype.dispose=function(){if(this.isConnected()){this.setShadowDom(null);var a=this.targetBlock();a.isShadow()?a.dispose():a.unplug()}this.inDB_&&this.db_.removeConnection_(this);this.disposed=!0};Blockly.Connection.prototype.getSourceBlock=function(){return this.sourceBlock_};Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};Blockly.Connection.prototype.isConnected=function(){return!!this.targetConnection};
else if(e.previousConnection)e.previousConnection.onFailedConnect(b);Blockly.Events.setGroup(!1)}},Blockly.BUMP_DELAY)}b.setShadowDom(f)}var l;Blockly.Events.isEnabled()&&(l=new Blockly.Events.BlockMove(d));Blockly.Connection.connectReciprocally_(b,a);d.setParent(c);l&&(l.recordNew(),Blockly.Events.fire(l))};Blockly.Connection.prototype.dispose=function(){if(this.isConnected()){this.setShadowDom(null);var a=this.targetBlock();a.isShadow()?a.dispose():a.unplug()}this.disposed=!0};
Blockly.Connection.prototype.getSourceBlock=function(){return this.sourceBlock_};Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};Blockly.Connection.prototype.isConnected=function(){return!!this.targetConnection};
Blockly.Connection.prototype.canConnectWithReason_=function(a){if(!a)return Blockly.Connection.REASON_TARGET_NULL;if(this.isSuperior())var b=this.sourceBlock_,c=a.getSourceBlock();else c=this.sourceBlock_,b=a.getSourceBlock();return b&&b==c?Blockly.Connection.REASON_SELF_CONNECTION:a.type!=Blockly.OPPOSITE_TYPE[this.type]?Blockly.Connection.REASON_WRONG_TYPE:b&&c&&b.workspace!==c.workspace?Blockly.Connection.REASON_DIFFERENT_WORKSPACES:this.checkType_(a)?b.isShadow()&&!c.isShadow()?Blockly.Connection.REASON_SHADOW_PARENT:
Blockly.Connection.CAN_CONNECT:Blockly.Connection.REASON_CHECKS_FAILED};
Blockly.Connection.prototype.checkConnection_=function(a){switch(this.canConnectWithReason_(a)){case Blockly.Connection.CAN_CONNECT:break;case Blockly.Connection.REASON_SELF_CONNECTION:throw Error("Attempted to connect a block to itself.");case Blockly.Connection.REASON_DIFFERENT_WORKSPACES:throw Error("Blocks not on same workspace.");case Blockly.Connection.REASON_WRONG_TYPE:throw Error("Attempt to connect incompatible types.");case Blockly.Connection.REASON_TARGET_NULL:throw Error("Target connection is null.");
@@ -154,7 +119,8 @@ Blockly.Connection.prototype.targetBlock=function(){return this.isConnected()?th
Blockly.Connection.prototype.setCheck=function(a){a?(Array.isArray(a)||(a=[a]),this.check_=a,this.onCheckChanged_()):this.check_=null;return this};Blockly.Connection.prototype.getCheck=function(){return this.check_};Blockly.Connection.prototype.setShadowDom=function(a){this.shadowDom_=a};Blockly.Connection.prototype.getShadowDom=function(){return this.shadowDom_};Blockly.Connection.prototype.neighbours_=function(a){return[]};
Blockly.Connection.prototype.getParentInput=function(){for(var a=null,b=this.sourceBlock_,c=b.inputList,d=0;d<b.inputList.length;d++)if(c[d].connection===this){a=c[d];break}return a};
Blockly.Connection.prototype.toString=function(){var a=this.sourceBlock_;if(a)if(a.outputConnection==this)var b="Output Connection of ";else if(a.previousConnection==this)b="Previous Connection of ";else if(a.nextConnection==this)b="Next Connection of ";else{b=null;for(var c=0,d;d=a.inputList[c];c++)if(d.connection==this){b=d;break}if(b)b='Input "'+b.name+'" connection on ';else return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection"}else return"Orphan Connection";
return b+a.toDevString()};Blockly.Extensions={};Blockly.Extensions.ALL_={};Blockly.Extensions.register=function(a,b){if("string"!=typeof a||""==a.trim())throw Error('Error: Invalid extension name "'+a+'"');if(Blockly.Extensions.ALL_[a])throw Error('Error: Extension "'+a+'" is already registered.');if("function"!=typeof b)throw Error('Error: Extension "'+a+'" must be a function');Blockly.Extensions.ALL_[a]=b};
return b+a.toDevString()};
Blockly.Extensions={};Blockly.Extensions.ALL_={};Blockly.Extensions.register=function(a,b){if("string"!=typeof a||""==a.trim())throw Error('Error: Invalid extension name "'+a+'"');if(Blockly.Extensions.ALL_[a])throw Error('Error: Extension "'+a+'" is already registered.');if("function"!=typeof b)throw Error('Error: Extension "'+a+'" must be a function');Blockly.Extensions.ALL_[a]=b};
Blockly.Extensions.registerMixin=function(a,b){if(!b||"object"!=typeof b)throw Error('Error: Mixin "'+a+'" must be a object');Blockly.Extensions.register(a,function(){this.mixin(b)})};
Blockly.Extensions.registerMutator=function(a,b,c,d){var e='Error when registering mutator "'+a+'": ';Blockly.Extensions.checkHasFunction_(e,b.domToMutation,"domToMutation");Blockly.Extensions.checkHasFunction_(e,b.mutationToDom,"mutationToDom");var f=Blockly.Extensions.checkMutatorDialog_(b,e);if(c&&"function"!=typeof c)throw Error('Extension "'+a+'" is not a function');Blockly.Extensions.register(a,function(){if(f){if(!Blockly.Mutator)throw Error(e+"Missing require for Blockly.Mutator");this.setMutator(new Blockly.Mutator(d))}this.mixin(b);
c&&c.apply(this)})};Blockly.Extensions.unregister=function(a){Blockly.Extensions.ALL_[a]?Blockly.Extensions.ALL_[a]=void 0:console.warn('No extension mapping for name "'+a+'" found to unregister')};
@@ -236,8 +202,7 @@ a.stopPropagation(),a.preventDefault())};Blockly.Scrollbar.prototype.onMouseMove
Blockly.Scrollbar.prototype.cleanUp_=function(){Blockly.hideChaff(!0);Blockly.Scrollbar.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseUpWrapper_),Blockly.Scrollbar.onMouseUpWrapper_=null);Blockly.Scrollbar.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseMoveWrapper_),Blockly.Scrollbar.onMouseMoveWrapper_=null)};
Blockly.Scrollbar.prototype.constrainHandle_=function(a){return a=0>=a||isNaN(a)||this.scrollViewSize_<this.handleLength_?0:Math.min(a,this.scrollViewSize_-this.handleLength_)};Blockly.Scrollbar.prototype.onScroll_=function(){var a=this.handlePosition_/this.scrollViewSize_;isNaN(a)&&(a=0);var b={};this.horizontal_?b.x=a:b.y=a;this.workspace_.setMetrics(b)};Blockly.Scrollbar.prototype.set=function(a){this.setHandlePosition(this.constrainHandle_(a*this.ratio_));this.onScroll_()};
Blockly.Scrollbar.prototype.setOrigin=function(a,b){this.origin_=new Blockly.utils.Coordinate(a,b)};Blockly.utils.math={};Blockly.utils.math.toRadians=function(a){return a*Math.PI/180};Blockly.utils.math.toDegrees=function(a){return 180*a/Math.PI};Blockly.utils.math.clamp=function(a,b,c){if(c<a){var d=c;c=a;a=d}return Math.max(a,Math.min(b,c))};Blockly.Cursor=function(){this.drawer_=this.curNode_=null};Blockly.Cursor.prototype.setDrawer=function(a){this.drawer_=a};Blockly.Cursor.prototype.getDrawer=function(){return this.drawer_};Blockly.Cursor.prototype.getCurNode=function(){return this.curNode_};Blockly.Cursor.prototype.setCurNode=function(a){this.curNode_=a;this.drawer_&&this.drawer_.draw(this.getCurNode())};Blockly.Cursor.prototype.hide=function(){this.drawer_&&this.drawer_.hide()};
Blockly.Cursor.prototype.next=function(){var a=this.getCurNode();if(!a)return null;for(a=a.next();a&&a.next()&&(a.getType()==Blockly.ASTNode.types.NEXT||a.getType()==Blockly.ASTNode.types.BLOCK);)a=a.next();a&&this.setCurNode(a);return a};
Blockly.Cursor.prototype["in"]=function(){var a=this.getCurNode();if(!a)return null;if(a.getType()==Blockly.ASTNode.types.PREVIOUS||a.getType()==Blockly.ASTNode.types.OUTPUT)a=a.next();(a=a["in"]())&&a.getType()==Blockly.ASTNode.types.OUTPUT&&(a=a.next()||a);a&&this.setCurNode(a);return a};
Blockly.Cursor.prototype.next=function(){var a=this.getCurNode();if(!a)return null;for(a=a.next();a&&a.next()&&(a.getType()==Blockly.ASTNode.types.NEXT||a.getType()==Blockly.ASTNode.types.BLOCK);)a=a.next();a&&this.setCurNode(a);return a};Blockly.Cursor.prototype["in"]=function(){var a=this.getCurNode();if(!a)return null;if(a.getType()==Blockly.ASTNode.types.PREVIOUS||a.getType()==Blockly.ASTNode.types.OUTPUT)a=a.next();(a=a["in"]())&&this.setCurNode(a);return a};
Blockly.Cursor.prototype.prev=function(){var a=this.getCurNode();if(!a)return null;for(a=a.prev();a&&a.prev()&&(a.getType()==Blockly.ASTNode.types.NEXT||a.getType()==Blockly.ASTNode.types.BLOCK);)a=a.prev();a&&this.setCurNode(a);return a};Blockly.Cursor.prototype.out=function(){var a=this.getCurNode();if(!a)return null;(a=a.out())&&a.getType()==Blockly.ASTNode.types.BLOCK&&(a=a.prev()||a);a&&this.setCurNode(a);return a};Blockly.MarkerCursor=function(){Blockly.MarkerCursor.superClass_.constructor.call(this)};Blockly.utils.object.inherits(Blockly.MarkerCursor,Blockly.Cursor);Blockly.MarkerCursor.prototype.next=function(){return null};Blockly.MarkerCursor.prototype["in"]=function(){return null};Blockly.MarkerCursor.prototype.prev=function(){return null};Blockly.MarkerCursor.prototype.out=function(){return null};Blockly.Theme=function(a,b,c){this.blockStyles_=a;this.categoryStyles_=b;this.componentStyles_=c||Object.create(null)};Blockly.Theme.prototype.setAllBlockStyles=function(a){for(var b in a)this.setBlockStyle(b,a[b])};Blockly.Theme.prototype.getAllBlockStyles=function(){return this.blockStyles_};Blockly.Theme.prototype.getBlockStyle=function(a){return this.blockStyles_[a]};Blockly.Theme.prototype.setBlockStyle=function(a,b){this.blockStyles_[a]=b};Blockly.Theme.prototype.getCategoryStyle=function(a){return this.categoryStyles_[a]};
Blockly.Theme.prototype.setCategoryStyle=function(a,b){this.categoryStyles_[a]=b};Blockly.Theme.prototype.getComponentStyle=function(a){return(a=this.componentStyles_[a])&&"string"==typeof propertyValue&&this.getComponentStyle(a)?this.getComponentStyle(a):a?String(a):null};Blockly.Theme.prototype.setComponentStyle=function(a,b){this.componentStyles_[a]=b};Blockly.ThemeManager=function(a){this.theme_=a;this.subscribedWorkspaces_=[];this.componentDB_=Object.create(null)};Blockly.ThemeManager.prototype.getTheme=function(){return this.theme_};
Blockly.ThemeManager.prototype.setTheme=function(a){if(this.theme_!==a){this.theme_=a;a=0;for(var b;b=this.subscribedWorkspaces_[a];a++)b.refreshTheme();a=0;b=Object.keys(this.componentDB_);for(var c;c=b[a];a++)for(var d=0,e;e=this.componentDB_[c][d];d++){var f=e.element;e=e.propertyName;var g=this.theme_&&this.theme_.getComponentStyle(c);f.style[e]=g||""}}};Blockly.ThemeManager.prototype.subscribeWorkspace=function(a){this.subscribedWorkspaces_.push(a)};
@@ -296,7 +261,17 @@ this.positionBubble_();this.renderArrow_();this.resizeCallback_&&this.resizeCall
Blockly.Bubble.prototype.renderArrow_=function(){var a=[],b=this.width_/2,c=this.height_/2,d=-this.relativeLeft_,e=-this.relativeTop_;if(b==d&&c==e)a.push("M "+b+","+c);else{e-=c;d-=b;this.workspace_.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);0>e&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>2*Math.PI&&(h-=2*Math.PI);var k=Math.sin(h),l=Math.cos(h),m=this.getBubbleSize();h=(m.width+m.height)/Blockly.Bubble.ARROW_THICKNESS;h=Math.min(h,m.width,m.height)/4;m=1-Blockly.Bubble.ANCHOR_RADIUS/f;d=b+
m*d;e=c+m*e;m=b+h*l;var n=c+h*k;b-=h*l;c-=h*k;k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+m+","+n);a.push("C"+(m+f)+","+(n+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)};
Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_();Blockly.utils.dom.removeNode(this.bubbleGroup_);this.shape_=this.content_=this.workspace_=this.resizeGroup_=this.bubbleBack_=this.bubbleArrow_=this.bubbleGroup_=null};Blockly.Bubble.prototype.moveDuringDrag=function(a,b){a?a.translateSurface(b.x,b.y):this.moveTo(b.x,b.y);this.relativeLeft_=this.workspace_.RTL?this.anchorXY_.x-b.x-this.width_:b.x-this.anchorXY_.x;this.relativeTop_=b.y-this.anchorXY_.y;this.renderArrow_()};
Blockly.Bubble.prototype.getRelativeToSurfaceXY=function(){return new Blockly.utils.Coordinate(this.anchorXY_.x+this.relativeLeft_,this.anchorXY_.y+this.relativeTop_)};Blockly.Bubble.prototype.setAutoLayout=function(a){this.autoLayout_=a};Blockly.BubbleDragger=function(a,b){this.draggingBubble_=a;this.workspace_=b;this.deleteArea_=null;this.wouldDeleteBubble_=!1;this.startXY_=this.draggingBubble_.getRelativeToSurfaceXY();this.dragSurface_=Blockly.utils.is3dSupported()&&b.getBlockDragSurface()?b.getBlockDragSurface():null};Blockly.BubbleDragger.prototype.dispose=function(){this.dragSurface_=this.workspace_=this.draggingBubble_=null};
Blockly.Bubble.prototype.getRelativeToSurfaceXY=function(){return new Blockly.utils.Coordinate(this.anchorXY_.x+this.relativeLeft_,this.anchorXY_.y+this.relativeTop_)};Blockly.Bubble.prototype.setAutoLayout=function(a){this.autoLayout_=a};Blockly.Events.CommentBase=function(a){this.commentId=a.id;this.workspaceId=a.workspace.id;this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.utils.object.inherits(Blockly.Events.CommentBase,Blockly.Events.Abstract);Blockly.Events.CommentBase.prototype.toJson=function(){var a=Blockly.Events.CommentBase.superClass_.toJson.call(this);this.commentId&&(a.commentId=this.commentId);return a};
Blockly.Events.CommentBase.prototype.fromJson=function(a){Blockly.Events.CommentBase.superClass_.fromJson.call(this,a);this.commentId=a.commentId};Blockly.Events.CommentChange=function(a,b,c){a&&(Blockly.Events.CommentChange.superClass_.constructor.call(this,a),this.oldContents_=b,this.newContents_=c)};Blockly.utils.object.inherits(Blockly.Events.CommentChange,Blockly.Events.CommentBase);Blockly.Events.CommentChange.prototype.type=Blockly.Events.COMMENT_CHANGE;
Blockly.Events.CommentChange.prototype.toJson=function(){var a=Blockly.Events.CommentChange.superClass_.toJson.call(this);a.newContents=this.newContents_;return a};Blockly.Events.CommentChange.prototype.fromJson=function(a){Blockly.Events.CommentChange.superClass_.fromJson.call(this,a);this.newContents_=a.newValue};Blockly.Events.CommentChange.prototype.isNull=function(){return this.oldContents_==this.newContents_};
Blockly.Events.CommentChange.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);b?b.setContent(a?this.newContents_:this.oldContents_):console.warn("Can't change non-existent comment: "+this.commentId)};Blockly.Events.CommentCreate=function(a){a&&(Blockly.Events.CommentCreate.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};Blockly.utils.object.inherits(Blockly.Events.CommentCreate,Blockly.Events.CommentBase);
Blockly.Events.CommentCreate.prototype.type=Blockly.Events.COMMENT_CREATE;Blockly.Events.CommentCreate.prototype.toJson=function(){var a=Blockly.Events.CommentCreate.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);return a};Blockly.Events.CommentCreate.prototype.fromJson=function(a){Blockly.Events.CommentCreate.superClass_.fromJson.call(this,a);this.xml=Blockly.Xml.textToDom(a.xml)};
Blockly.Events.CommentCreate.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,a)};Blockly.Events.CommentCreateDeleteHelper=function(a,b){var c=a.getEventWorkspace_();if(b){var d=Blockly.utils.xml.createElement("xml");d.appendChild(a.xml);Blockly.Xml.domToWorkspace(d,c)}else(c=c.getCommentById(a.commentId))?c.dispose(!1,!1):console.warn("Can't uncreate non-existent comment: "+a.commentId)};
Blockly.Events.CommentDelete=function(a){a&&(Blockly.Events.CommentDelete.superClass_.constructor.call(this,a),this.xml=a.toXmlWithXY())};Blockly.utils.object.inherits(Blockly.Events.CommentDelete,Blockly.Events.CommentBase);Blockly.Events.CommentDelete.prototype.type=Blockly.Events.COMMENT_DELETE;Blockly.Events.CommentDelete.prototype.toJson=function(){return Blockly.Events.CommentDelete.superClass_.toJson.call(this)};
Blockly.Events.CommentDelete.prototype.fromJson=function(a){Blockly.Events.CommentDelete.superClass_.fromJson.call(this,a)};Blockly.Events.CommentDelete.prototype.run=function(a){Blockly.Events.CommentCreateDeleteHelper(this,!a)};Blockly.Events.CommentMove=function(a){a&&(Blockly.Events.CommentMove.superClass_.constructor.call(this,a),this.comment_=a,this.oldCoordinate_=a.getXY(),this.newCoordinate_=null)};Blockly.utils.object.inherits(Blockly.Events.CommentMove,Blockly.Events.CommentBase);
Blockly.Events.CommentMove.prototype.recordNew=function(){if(!this.comment_)throw Error("Tried to record the new position of a comment on the same event twice.");this.newCoordinate_=this.comment_.getXY();this.comment_=null};Blockly.Events.CommentMove.prototype.type=Blockly.Events.COMMENT_MOVE;Blockly.Events.CommentMove.prototype.setOldCoordinate=function(a){this.oldCoordinate_=a};
Blockly.Events.CommentMove.prototype.toJson=function(){var a=Blockly.Events.CommentMove.superClass_.toJson.call(this);this.newCoordinate_&&(a.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y));return a};Blockly.Events.CommentMove.prototype.fromJson=function(a){Blockly.Events.CommentMove.superClass_.fromJson.call(this,a);a.newCoordinate&&(a=a.newCoordinate.split(","),this.newCoordinate_=new Blockly.utils.Coordinate(Number(a[0]),Number(a[1])))};
Blockly.Events.CommentMove.prototype.isNull=function(){return Blockly.utils.Coordinate.equals(this.oldCoordinate_,this.newCoordinate_)};Blockly.Events.CommentMove.prototype.run=function(a){var b=this.getEventWorkspace_().getCommentById(this.commentId);if(b){a=a?this.newCoordinate_:this.oldCoordinate_;var c=b.getXY();b.moveBy(a.x-c.x,a.y-c.y)}else console.warn("Can't move non-existent comment: "+this.commentId)};Blockly.BubbleDragger=function(a,b){this.draggingBubble_=a;this.workspace_=b;this.deleteArea_=null;this.wouldDeleteBubble_=!1;this.startXY_=this.draggingBubble_.getRelativeToSurfaceXY();this.dragSurface_=Blockly.utils.is3dSupported()&&b.getBlockDragSurface()?b.getBlockDragSurface():null};Blockly.BubbleDragger.prototype.dispose=function(){this.dragSurface_=this.workspace_=this.draggingBubble_=null};
Blockly.BubbleDragger.prototype.startBubbleDrag=function(){Blockly.Events.getGroup()||Blockly.Events.setGroup(!0);this.workspace_.setResizesEnabled(!1);this.draggingBubble_.setAutoLayout(!1);this.dragSurface_&&this.moveToDragSurface_();this.draggingBubble_.setDragging&&this.draggingBubble_.setDragging(!0);var a=this.workspace_.getToolbox();if(a){var b=this.draggingBubble_.isDeletable()?"blocklyToolboxDelete":"blocklyToolboxGrab";a.addStyle(b)}};
Blockly.BubbleDragger.prototype.dragBubble=function(a,b){var c=this.pixelsToWorkspaceUnits_(b);c=Blockly.utils.Coordinate.sum(this.startXY_,c);this.draggingBubble_.moveDuringDrag(this.dragSurface_,c);this.draggingBubble_.isDeletable()&&(this.deleteArea_=this.workspace_.isDeleteArea(a),this.updateCursorDuringBubbleDrag_())};
Blockly.BubbleDragger.prototype.maybeDeleteBubble_=function(){var a=this.workspace_.trashcan;this.wouldDeleteBubble_?(a&&setTimeout(a.close.bind(a),100),this.fireMoveEvent_(),this.draggingBubble_.dispose(!1,!0)):a&&a.close();return this.wouldDeleteBubble_};
@@ -306,7 +281,8 @@ Blockly.BubbleDragger.prototype.endBubbleDrag=function(a,b){this.dragBubble(a,b)
Blockly.BubbleDragger.prototype.pixelsToWorkspaceUnits_=function(a){a=new Blockly.utils.Coordinate(a.x/this.workspace_.scale,a.y/this.workspace_.scale);this.workspace_.isMutator&&a.scale(1/this.workspace_.options.parentWorkspace.scale);return a};Blockly.BubbleDragger.prototype.moveToDragSurface_=function(){this.draggingBubble_.moveTo(0,0);this.dragSurface_.translateSurface(this.startXY_.x,this.startXY_.y);this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot())};Blockly.constants={};Blockly.LINE_MODE_MULTIPLIER=40;Blockly.PAGE_MODE_MULTIPLIER=125;Blockly.DRAG_RADIUS=5;Blockly.FLYOUT_DRAG_RADIUS=10;Blockly.SNAP_RADIUS=28;Blockly.CONNECTING_SNAP_RADIUS=Blockly.SNAP_RADIUS;Blockly.CURRENT_CONNECTION_PREFERENCE=8;Blockly.INSERTION_MARKER_COLOUR="#000000";Blockly.BUMP_DELAY=250;Blockly.BUMP_RANDOMNESS=10;Blockly.COLLAPSE_CHARS=30;Blockly.LONGPRESS=750;Blockly.SOUND_LIMIT=100;Blockly.DRAG_STACK=!0;Blockly.HSV_SATURATION=.45;Blockly.HSV_VALUE=.65;
Blockly.SPRITE={width:96,height:124,url:"sprites.png"};Blockly.INPUT_VALUE=1;Blockly.OUTPUT_VALUE=2;Blockly.NEXT_STATEMENT=3;Blockly.PREVIOUS_STATEMENT=4;Blockly.DUMMY_INPUT=5;Blockly.ALIGN_LEFT=-1;Blockly.ALIGN_CENTRE=0;Blockly.ALIGN_RIGHT=1;Blockly.DRAG_NONE=0;Blockly.DRAG_STICKY=1;Blockly.DRAG_BEGIN=1;Blockly.DRAG_FREE=2;Blockly.OPPOSITE_TYPE=[];Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE]=Blockly.OUTPUT_VALUE;Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE]=Blockly.INPUT_VALUE;
Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT]=Blockly.PREVIOUS_STATEMENT;Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT]=Blockly.NEXT_STATEMENT;Blockly.TOOLBOX_AT_TOP=0;Blockly.TOOLBOX_AT_BOTTOM=1;Blockly.TOOLBOX_AT_LEFT=2;Blockly.TOOLBOX_AT_RIGHT=3;Blockly.DELETE_AREA_NONE=null;Blockly.DELETE_AREA_TRASH=1;Blockly.DELETE_AREA_TOOLBOX=2;Blockly.VARIABLE_CATEGORY_NAME="VARIABLE";Blockly.VARIABLE_DYNAMIC_CATEGORY_NAME="VARIABLE_DYNAMIC";Blockly.PROCEDURE_CATEGORY_NAME="PROCEDURE";
Blockly.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID";Blockly.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID";Blockly.WorkspaceDragger=function(a){this.workspace_=a;this.startScrollXY_=new Blockly.utils.Coordinate(a.scrollX,a.scrollY)};Blockly.WorkspaceDragger.prototype.dispose=function(){this.workspace_=null};Blockly.WorkspaceDragger.prototype.startDrag=function(){Blockly.selected&&Blockly.selected.unselect();this.workspace_.setupDragSurface()};Blockly.WorkspaceDragger.prototype.endDrag=function(a){this.drag(a);this.workspace_.resetDragSurface()};
Blockly.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID";Blockly.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID";Blockly.Events.Ui=function(a,b,c,d){Blockly.Events.Ui.superClass_.constructor.call(this);this.blockId=a?a.id:null;this.workspaceId=a?a.workspace.id:null;this.element=b;this.oldValue=c;this.newValue=d;this.recordUndo=!1};Blockly.utils.object.inherits(Blockly.Events.Ui,Blockly.Events.Abstract);Blockly.Events.Ui.prototype.type=Blockly.Events.UI;
Blockly.Events.Ui.prototype.toJson=function(){var a=Blockly.Events.Ui.superClass_.toJson.call(this);a.element=this.element;void 0!==this.newValue&&(a.newValue=this.newValue);this.blockId&&(a.blockId=this.blockId);return a};Blockly.Events.Ui.prototype.fromJson=function(a){Blockly.Events.Ui.superClass_.fromJson.call(this,a);this.element=a.element;this.newValue=a.newValue;this.blockId=a.blockId};Blockly.WorkspaceDragger=function(a){this.workspace_=a;this.startScrollXY_=new Blockly.utils.Coordinate(a.scrollX,a.scrollY)};Blockly.WorkspaceDragger.prototype.dispose=function(){this.workspace_=null};Blockly.WorkspaceDragger.prototype.startDrag=function(){Blockly.selected&&Blockly.selected.unselect();this.workspace_.setupDragSurface()};Blockly.WorkspaceDragger.prototype.endDrag=function(a){this.drag(a);this.workspace_.resetDragSurface()};
Blockly.WorkspaceDragger.prototype.drag=function(a){a=Blockly.utils.Coordinate.sum(this.startScrollXY_,a);this.workspace_.scroll(a.x,a.y)};Blockly.FlyoutDragger=function(a){Blockly.FlyoutDragger.superClass_.constructor.call(this,a.getWorkspace());this.scrollbar_=a.scrollbar_;this.horizontalLayout_=a.horizontalLayout_};Blockly.utils.object.inherits(Blockly.FlyoutDragger,Blockly.WorkspaceDragger);Blockly.FlyoutDragger.prototype.drag=function(a){a=Blockly.utils.Coordinate.sum(this.startScrollXY_,a);this.horizontalLayout_?this.scrollbar_.set(-a.x):this.scrollbar_.set(-a.y)};Blockly.Tooltip={};Blockly.Tooltip.visible=!1;Blockly.Tooltip.blocked_=!1;Blockly.Tooltip.LIMIT=50;Blockly.Tooltip.mouseOutPid_=0;Blockly.Tooltip.showPid_=0;Blockly.Tooltip.lastX_=0;Blockly.Tooltip.lastY_=0;Blockly.Tooltip.element_=null;Blockly.Tooltip.poisonedElement_=null;Blockly.Tooltip.OFFSET_X=0;Blockly.Tooltip.OFFSET_Y=10;Blockly.Tooltip.RADIUS_OK=10;Blockly.Tooltip.HOVER_MS=750;Blockly.Tooltip.MARGINS=5;Blockly.Tooltip.DIV=null;
Blockly.Tooltip.createDom=function(){Blockly.Tooltip.DIV||(Blockly.Tooltip.DIV=document.createElement("div"),Blockly.Tooltip.DIV.className="blocklyTooltipDiv",document.body.appendChild(Blockly.Tooltip.DIV))};Blockly.Tooltip.bindMouseEvents=function(a){Blockly.bindEvent_(a,"mouseover",null,Blockly.Tooltip.onMouseOver_);Blockly.bindEvent_(a,"mouseout",null,Blockly.Tooltip.onMouseOut_);a.addEventListener("mousemove",Blockly.Tooltip.onMouseMove_,!1)};
Blockly.Tooltip.onMouseOver_=function(a){if(!Blockly.Tooltip.blocked_){for(a=a.currentTarget;"string"!=typeof a.tooltip&&"function"!=typeof a.tooltip;)a=a.tooltip;Blockly.Tooltip.element_!=a&&(Blockly.Tooltip.hide(),Blockly.Tooltip.poisonedElement_=null,Blockly.Tooltip.element_=a);clearTimeout(Blockly.Tooltip.mouseOutPid_)}};
@@ -394,7 +370,6 @@ Blockly.Block.prototype.setParent=function(a){if(a!=this.parentBlock_){if(this.p
Blockly.Block.prototype.getDescendants=function(a){for(var b=[this],c=this.getChildren(a),d,e=0;d=c[e];e++)b.push.apply(b,d.getDescendants(a));return b};Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setDeletable=function(a){this.deletable_=a};Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};
Blockly.Block.prototype.setMovable=function(a){this.movable_=a};Blockly.Block.prototype.isDuplicatable=function(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(Blockly.utils.getBlockTypeCounts(this,!0)):!0};Blockly.Block.prototype.isShadow=function(){return this.isShadow_};Blockly.Block.prototype.setShadow=function(a){this.isShadow_=a};Blockly.Block.prototype.isInsertionMarker=function(){return this.isInsertionMarker_};
Blockly.Block.prototype.setInsertionMarker=function(a){this.isInsertionMarker_=a};Blockly.Block.prototype.isEditable=function(){return this.editable_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setEditable=function(a){this.editable_=a;a=0;for(var b;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.updateEditable()};
Blockly.Block.prototype.setConnectionsHidden=function(a){if(!a&&this.isCollapsed()){if(this.outputConnection&&this.outputConnection.setHidden(a),this.previousConnection&&this.previousConnection.setHidden(a),this.nextConnection){this.nextConnection.setHidden(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionsHidden(a)}}else for(var c=this.getConnections_(!0),d=0;b=c[d];d++)b.setHidden(a),b.isSuperior()&&(b=b.targetBlock())&&b.setConnectionsHidden(a)};
Blockly.Block.prototype.getMatchingConnection=function(a,b){var c=this.getConnections_(!0),d=a.getConnections_(!0);if(c.length!=d.length)throw Error("Connection lists did not match in length.");for(var e=0;e<d.length;e++)if(d[e]==b)return c[e];return null};Blockly.Block.prototype.setHelpUrl=function(a){this.helpUrl=a};Blockly.Block.prototype.setTooltip=function(a){this.tooltip=a};Blockly.Block.prototype.getColour=function(){return this.colour_};Blockly.Block.prototype.getColourSecondary=function(){return this.colourSecondary_};
Blockly.Block.prototype.getColourTertiary=function(){return this.colourTertiary_};Blockly.Block.prototype.getColourShadow=function(){var a=this.getColourSecondary();return a?a:Blockly.utils.colour.blend("white",this.getColour(),.6)};
Blockly.Block.prototype.getColourBorder=function(){var a=this.getColourTertiary();if(a)return{colourBorder:a,colourLight:null,colourDark:null};a=this.getColour();return{colourBorder:null,colourLight:Blockly.utils.colour.blend("white",a,.3),colourDark:Blockly.utils.colour.blend("black",a,.2)}};Blockly.Block.prototype.getStyleName=function(){return this.styleName_};Blockly.Block.prototype.getHue=function(){return this.hue_};
@@ -432,8 +407,7 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom=function(){this.SVG_||(this.SVG_
Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow=function(a){if(this.dragGroup_.childNodes.length)throw Error("Already dragging a block.");this.dragGroup_.appendChild(a);this.SVG_.style.display="block";this.surfaceXY_=new Blockly.utils.Coordinate(0,0)};Blockly.BlockDragSurfaceSvg.prototype.translateAndScaleGroup=function(a,b,c){this.scale_=c;a=a.toFixed(0);b=b.toFixed(0);this.dragGroup_.setAttribute("transform","translate("+a+","+b+") scale("+c+")")};
Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_=function(){var a=this.surfaceXY_.x,b=this.surfaceXY_.y;a=a.toFixed(0);b=b.toFixed(0);this.SVG_.style.display="block";Blockly.utils.dom.setCssTransform(this.SVG_,"translate3d("+a+"px, "+b+"px, 0px)")};Blockly.BlockDragSurfaceSvg.prototype.translateSurface=function(a,b){this.surfaceXY_=new Blockly.utils.Coordinate(a*this.scale_,b*this.scale_);this.translateSurfaceInternal_()};
Blockly.BlockDragSurfaceSvg.prototype.getSurfaceTranslation=function(){var a=Blockly.utils.getRelativeXY(this.SVG_);return new Blockly.utils.Coordinate(a.x/this.scale_,a.y/this.scale_)};Blockly.BlockDragSurfaceSvg.prototype.getGroup=function(){return this.dragGroup_};Blockly.BlockDragSurfaceSvg.prototype.getCurrentBlock=function(){return this.dragGroup_.firstChild};
Blockly.BlockDragSurfaceSvg.prototype.clearAndHide=function(a){a?a.appendChild(this.getCurrentBlock()):this.dragGroup_.removeChild(this.getCurrentBlock());this.SVG_.style.display="none";if(this.dragGroup_.childNodes.length)throw Error("Drag group was not cleared.");this.surfaceXY_=null};Blockly.blockRendering={};Blockly.blockRendering.rendererMap_={};Blockly.blockRendering.useDebugger=!1;Blockly.blockRendering.register=function(a,b){if(Blockly.blockRendering.rendererMap_[a])throw Error("Renderer has already been registered.");Blockly.blockRendering.rendererMap_[a]=b};Blockly.blockRendering.unregister=function(a){Blockly.blockRendering.rendererMap_[a]?Blockly.blockRendering.rendererMap_[a]=void 0:console.warn('No renderer mapping for name "'+a+'" found to unregister')};
Blockly.blockRendering.startDebugger=function(){Blockly.blockRendering.useDebugger=!0};Blockly.blockRendering.stopDebugger=function(){Blockly.blockRendering.useDebugger=!1};Blockly.blockRendering.init=function(a){if(!Blockly.blockRendering.rendererMap_[a])throw Error("Renderer not registered: ",a);var b=function(){b.superClass_.constructor.call(this)};Blockly.utils.object.inherits(b,Blockly.blockRendering.rendererMap_[a]);a=new b;a.init();return a};Blockly.blockRendering.IPathObject=function(a){};Blockly.blockRendering.PathObject=function(a){this.svgRoot=a;this.svgPath=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPath"},this.svgRoot);this.svgPathLight=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPathLight"},this.svgRoot);this.svgPathDark=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPathDark",transform:"translate(1,1)"},this.svgRoot)};
Blockly.BlockDragSurfaceSvg.prototype.clearAndHide=function(a){a?a.appendChild(this.getCurrentBlock()):this.dragGroup_.removeChild(this.getCurrentBlock());this.SVG_.style.display="none";if(this.dragGroup_.childNodes.length)throw Error("Drag group was not cleared.");this.surfaceXY_=null};Blockly.blockRendering={};Blockly.blockRendering.IPathObject=function(a){};Blockly.blockRendering.PathObject=function(a){this.svgRoot=a;this.svgPath=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPath"},this.svgRoot);this.svgPathLight=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPathLight"},this.svgRoot);this.svgPathDark=Blockly.utils.dom.createSvgElement("path",{"class":"blocklyPathDark",transform:"translate(1,1)"},this.svgRoot)};
Blockly.blockRendering.PathObject.prototype.setPaths=function(a){this.svgPath.setAttribute("d",a);this.svgPathLight.style.display="none";this.svgPathDark.style.display="none"};Blockly.blockRendering.PathObject.prototype.flipRTL=function(){this.svgPath.setAttribute("transform","scale(-1 1)")};Blockly.utils.IdGenerator={};Blockly.utils.IdGenerator.nextId_=0;Blockly.utils.IdGenerator.getNextUniqueId=function(){return"blockly:"+(Blockly.utils.IdGenerator.nextId_++).toString(36)};Blockly.Component=function(){this.rightToLeft_=Blockly.Component.defaultRightToLeft;this.id_=null;this.inDocument_=!1;this.parent_=this.element_=null;this.children_=[];this.childIndex_={}};Blockly.Component.defaultRightToLeft=!1;Blockly.Component.Error={ALREADY_RENDERED:"Component already rendered",PARENT_UNABLE_TO_BE_SET:"Unable to set parent component",CHILD_INDEX_OUT_OF_BOUNDS:"Child component index out of bounds"};Blockly.Component.prototype.getId=function(){return this.id_||(this.id_=Blockly.utils.IdGenerator.getNextUniqueId())};
Blockly.Component.prototype.getElement=function(){return this.element_};Blockly.Component.prototype.setElementInternal=function(a){this.element_=a};Blockly.Component.prototype.setParent=function(a){if(this==a)throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET);if(a&&this.parent_&&this.id_&&this.parent_.getChild(this.id_)&&this.parent_!=a)throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET);this.parent_=a};Blockly.Component.prototype.getParent=function(){return this.parent_};
Blockly.Component.prototype.isInDocument=function(){return this.inDocument_};Blockly.Component.prototype.createDom=function(){this.element_=document.createElement("div")};Blockly.Component.prototype.render=function(a){this.render_(a)};Blockly.Component.prototype.renderBefore=function(a){this.render_(a.parentNode,a)};
@@ -474,7 +448,8 @@ Blockly.ContextMenu.blockDeleteOption=function(a){var b=a.getDescendants(!1).len
Blockly.ContextMenu.blockDuplicateOption=function(a){var b=a.isDuplicatable();return{text:Blockly.Msg.DUPLICATE_BLOCK,enabled:b,callback:function(){Blockly.duplicate_(a)}}};Blockly.ContextMenu.blockCommentOption=function(a){var b={enabled:!Blockly.utils.userAgent.IE};a.comment?(b.text=Blockly.Msg.REMOVE_COMMENT,b.callback=function(){a.setCommentText(null)}):(b.text=Blockly.Msg.ADD_COMMENT,b.callback=function(){a.setCommentText("")});return b};
Blockly.ContextMenu.commentDeleteOption=function(a){return{text:Blockly.Msg.REMOVE_COMMENT,enabled:!0,callback:function(){Blockly.Events.setGroup(!0);a.dispose(!0,!0);Blockly.Events.setGroup(!1)}}};Blockly.ContextMenu.commentDuplicateOption=function(a){return{text:Blockly.Msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){Blockly.duplicate_(a)}}};
Blockly.ContextMenu.workspaceCommentOption=function(a,b){if(!Blockly.WorkspaceCommentSvg)throw Error("Missing require for Blockly.WorkspaceCommentSvg");var c={enabled:!Blockly.utils.userAgent.IE};c.text=Blockly.Msg.ADD_COMMENT;c.callback=function(){var c=new Blockly.WorkspaceCommentSvg(a,Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT,Blockly.WorkspaceCommentSvg.DEFAULT_SIZE,Blockly.WorkspaceCommentSvg.DEFAULT_SIZE),e=a.getInjectionDiv().getBoundingClientRect();e=new Blockly.utils.Coordinate(b.clientX-
e.left,b.clientY-e.top);var f=a.getOriginOffsetInPixels();e=Blockly.utils.Coordinate.difference(e,f);e.scale(1/a.scale);c.moveBy(e.x,e.y);a.rendered&&(c.initSvg(),c.render(),c.select())};return c};Blockly.RenderedConnection=function(a,b){Blockly.RenderedConnection.superClass_.constructor.call(this,a,b);this.offsetInBlock_=new Blockly.utils.Coordinate(0,0)};Blockly.utils.object.inherits(Blockly.RenderedConnection,Blockly.Connection);Blockly.RenderedConnection.prototype.distanceFrom=function(a){var b=this.x_-a.x_;a=this.y_-a.y_;return Math.sqrt(b*b+a*a)};
e.left,b.clientY-e.top);var f=a.getOriginOffsetInPixels();e=Blockly.utils.Coordinate.difference(e,f);e.scale(1/a.scale);c.moveBy(e.x,e.y);a.rendered&&(c.initSvg(),c.render(),c.select())};return c};Blockly.RenderedConnection=function(a,b){Blockly.RenderedConnection.superClass_.constructor.call(this,a,b);this.db_=a.workspace.connectionDBList[b];this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]];this.offsetInBlock_=new Blockly.utils.Coordinate(0,0);this.inDB_=!1;this.hidden_=!this.db_};Blockly.utils.object.inherits(Blockly.RenderedConnection,Blockly.Connection);Blockly.RenderedConnection.prototype.dispose=function(){this.inDB_&&this.db_.removeConnection_(this);Blockly.RenderedConnection.superClass_.dispose.call(this)};
Blockly.RenderedConnection.prototype.distanceFrom=function(a){var b=this.x_-a.x_;a=this.y_-a.y_;return Math.sqrt(b*b+a*a)};
Blockly.RenderedConnection.prototype.bumpAwayFrom_=function(a){if(!this.sourceBlock_.workspace.isDragging()){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.getSourceBlock().getRootBlock();if(!b.isMovable())return;a=this;c=!0}var d=Blockly.selected==b;d||b.addSelect();var e=a.x_+Blockly.SNAP_RADIUS+Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.x_,f=a.y_+Blockly.SNAP_RADIUS+Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.y_;c&&(f=-f);b.RTL&&
(e=a.x_-Blockly.SNAP_RADIUS-Math.floor(Math.random()*Blockly.BUMP_RANDOMNESS)-this.x_);b.moveBy(e,f);d||b.removeSelect()}}};Blockly.RenderedConnection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeConnection_(this);this.x_=a;this.y_=b;this.hidden_||this.db_.addConnection(this)};Blockly.RenderedConnection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)};Blockly.RenderedConnection.prototype.moveToOffset=function(a){this.moveTo(a.x+this.offsetInBlock_.x,a.y+this.offsetInBlock_.y)};
Blockly.RenderedConnection.prototype.setOffsetInBlock=function(a,b){this.offsetInBlock_.x=a;this.offsetInBlock_.y=b};Blockly.RenderedConnection.prototype.getOffsetInBlock=function(){return this.offsetInBlock_};
@@ -487,7 +462,7 @@ Blockly.RenderedConnection.prototype.hideAll=function(){this.setHidden(!0);if(th
Blockly.RenderedConnection.prototype.onFailedConnect=function(a){this.bumpAwayFrom_(a)};Blockly.RenderedConnection.prototype.disconnectInternal_=function(a,b){Blockly.RenderedConnection.superClass_.disconnectInternal_.call(this,a,b);a.rendered&&a.render();b.rendered&&(b.updateDisabled(),b.render())};
Blockly.RenderedConnection.prototype.respawnShadow_=function(){var a=this.getSourceBlock(),b=this.getShadowDom();if(a.workspace&&b&&Blockly.Events.recordUndo){Blockly.RenderedConnection.superClass_.respawnShadow_.call(this);b=this.targetBlock();if(!b)throw Error("Couldn't respawn the shadow block that should exist here.");b.initSvg();b.render(!1);a.rendered&&a.render()}};Blockly.RenderedConnection.prototype.neighbours_=function(a){return this.dbOpposite_.getNeighbours(this,a)};
Blockly.RenderedConnection.prototype.connect_=function(a){Blockly.RenderedConnection.superClass_.connect_.call(this,a);var b=this.getSourceBlock();a=a.getSourceBlock();b.rendered&&b.updateDisabled();a.rendered&&a.updateDisabled();b.rendered&&a.rendered&&(this.type==Blockly.NEXT_STATEMENT||this.type==Blockly.PREVIOUS_STATEMENT?a.render():b.render())};
Blockly.RenderedConnection.prototype.onCheckChanged_=function(){this.isConnected()&&!this.checkType_(this.targetConnection)&&((this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug(),this.sourceBlock_.bumpNeighbours_())};Blockly.Icon=function(a){this.block_=a};Blockly.Icon.prototype.collapseHidden=!0;Blockly.Icon.prototype.SIZE=17;Blockly.Icon.prototype.bubble_=null;Blockly.Icon.prototype.iconXY_=null;
Blockly.RenderedConnection.prototype.onCheckChanged_=function(){this.isConnected()&&!this.checkType_(this.targetConnection)&&((this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug(),this.sourceBlock_.bumpNeighbours_())};Blockly.utils.Rect=function(a,b,c,d){this.top=a;this.bottom=b;this.left=c;this.right=d};Blockly.utils.Rect.prototype.contains=function(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom};Blockly.Icon=function(a){this.block_=a};Blockly.Icon.prototype.collapseHidden=!0;Blockly.Icon.prototype.SIZE=17;Blockly.Icon.prototype.bubble_=null;Blockly.Icon.prototype.iconXY_=null;
Blockly.Icon.prototype.createIcon=function(){this.iconGroup_||(this.iconGroup_=Blockly.utils.dom.createSvgElement("g",{"class":"blocklyIconGroup"},null),this.block_.isInFlyout&&Blockly.utils.dom.addClass(this.iconGroup_,"blocklyIconGroupReadonly"),this.drawIcon_(this.iconGroup_),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEventWithChecks_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable())};
Blockly.Icon.prototype.dispose=function(){Blockly.utils.dom.removeNode(this.iconGroup_);this.iconGroup_=null;this.setVisible(!1);this.block_=null};Blockly.Icon.prototype.updateEditable=function(){};Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_};Blockly.Icon.prototype.iconClick_=function(a){this.block_.workspace.isDragging()||this.block_.isInFlyout||Blockly.utils.isRightButton(a)||this.setVisible(!this.isVisible())};
Blockly.Icon.prototype.updateColour=function(){this.isVisible()&&this.bubble_.setColour(this.block_.getColour())};Blockly.Icon.prototype.setIconLocation=function(a){this.iconXY_=a;this.isVisible()&&this.bubble_.setAnchorLocation(a)};
@@ -500,6 +475,7 @@ Blockly.Warning.prototype.createBubble=function(){this.paragraphElement_=Blockly
Blockly.Warning.prototype.disposeBubble=function(){this.bubble_.dispose();this.paragraphElement_=this.body_=this.bubble_=null};Blockly.Warning.prototype.bodyFocus_=function(a){this.bubble_.promote_()};Blockly.Warning.prototype.setText=function(a,b){this.text_[b]!=a&&(a?this.text_[b]=a:delete this.text_[b],this.isVisible()&&(this.setVisible(!1),this.setVisible(!0)))};Blockly.Warning.prototype.getText=function(){var a=[],b;for(b in this.text_)a.push(this.text_[b]);return a.join("\n")};
Blockly.Warning.prototype.dispose=function(){this.block_.warning=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.BlockSvg=function(a,b,c){this.svgGroup_=Blockly.utils.dom.createSvgElement("g",{},null);this.svgGroup_.translate_="";this.pathObject=a.getRenderer().makePathObject(this.svgGroup_);this.svgPathDark_=this.pathObject.svgPathDark||null;this.svgPath_=this.pathObject.svgPath||null;this.svgPathLight_=this.pathObject.svgPathLight||null;this.svgPath_.tooltip=this;this.rendered=!1;this.useDragSurface_=Blockly.utils.is3dSupported()&&!!a.blockDragSurface_;Blockly.Tooltip.bindMouseEvents(this.svgPath_);
Blockly.BlockSvg.superClass_.constructor.call(this,a,b,c);this.svgGroup_.dataset&&(this.svgGroup_.dataset.id=this.id);this.markerSvg_=this.cursorSvg_=null};Blockly.utils.object.inherits(Blockly.BlockSvg,Blockly.Block);Blockly.BlockSvg.prototype.height=0;Blockly.BlockSvg.prototype.width=0;Blockly.BlockSvg.prototype.dragStartXY_=null;Blockly.BlockSvg.prototype.warningTextDb_=null;Blockly.BlockSvg.INLINE=-1;Blockly.BlockSvg.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";
Blockly.BlockSvg.SEP_SPACE_Y=10;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.START_HAT=!1;
Blockly.BlockSvg.prototype.initSvg=function(){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");for(var a=0,b;b=this.inputList[a];a++)b.init();b=this.getIcons();for(a=0;a<b.length;a++)b[a].createIcon();this.updateColour();this.updateMovable();this.workspace.options.readOnly||this.eventsInit_||Blockly.bindEventWithChecks_(this.getSvgRoot(),"mousedown",this,this.onMouseDown_);this.eventsInit_=!0;this.getSvgRoot().parentNode||this.workspace.getCanvas().appendChild(this.getSvgRoot())};
Blockly.BlockSvg.prototype.select=function(){if(this.isShadow()&&this.getParent())this.getParent().select();else if(Blockly.selected!=this){var a=null;if(Blockly.selected){a=Blockly.selected.id;Blockly.Events.disable();try{Blockly.selected.unselect()}finally{Blockly.Events.enable()}}a=new Blockly.Events.Ui(null,"selected",a,this.id);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=this;this.addSelect()}};
Blockly.BlockSvg.prototype.unselect=function(){if(Blockly.selected==this){var a=new Blockly.Events.Ui(null,"selected",this.id,null);a.workspaceId=this.workspace.id;Blockly.Events.fire(a);Blockly.selected=null;this.removeSelect()}};Blockly.BlockSvg.prototype.mutator=null;Blockly.BlockSvg.prototype.comment=null;Blockly.BlockSvg.prototype.commentIcon_=null;Blockly.BlockSvg.prototype.warning=null;
@@ -537,14 +513,15 @@ Blockly.BlockSvg.prototype.addSelect=function(){Blockly.utils.dom.addClass(this.
Blockly.BlockSvg.prototype.setColour=function(a){Blockly.BlockSvg.superClass_.setColour.call(this,a);this.rendered&&this.updateColour()};Blockly.BlockSvg.prototype.bringToFront=function(){var a=this;do{var b=a.getSvgRoot();b.parentNode.appendChild(b);a=a.getParent()}while(a)};Blockly.BlockSvg.prototype.setPreviousStatement=function(a,b){Blockly.BlockSvg.superClass_.setPreviousStatement.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_())};
Blockly.BlockSvg.prototype.setNextStatement=function(a,b){Blockly.BlockSvg.superClass_.setNextStatement.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_())};Blockly.BlockSvg.prototype.setOutput=function(a,b){Blockly.BlockSvg.superClass_.setOutput.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_())};Blockly.BlockSvg.prototype.setInputsInline=function(a){Blockly.BlockSvg.superClass_.setInputsInline.call(this,a);this.rendered&&(this.render(),this.bumpNeighbours_())};
Blockly.BlockSvg.prototype.removeInput=function(a,b){Blockly.BlockSvg.superClass_.removeInput.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_())};Blockly.BlockSvg.prototype.moveNumberedInputBefore=function(a,b){Blockly.BlockSvg.superClass_.moveNumberedInputBefore.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_())};
Blockly.BlockSvg.prototype.appendInput_=function(a,b){var c=Blockly.BlockSvg.superClass_.appendInput_.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_());return c};Blockly.BlockSvg.prototype.getConnections_=function(a){var b=[];if(a||this.rendered)if(this.outputConnection&&b.push(this.outputConnection),this.previousConnection&&b.push(this.previousConnection),this.nextConnection&&b.push(this.nextConnection),a||!this.collapsed_){a=0;for(var c;c=this.inputList[a];a++)c.connection&&b.push(c.connection)}return b};
Blockly.BlockSvg.prototype.makeConnection_=function(a){return new Blockly.RenderedConnection(this,a)};
Blockly.BlockSvg.prototype.appendInput_=function(a,b){var c=Blockly.BlockSvg.superClass_.appendInput_.call(this,a,b);this.rendered&&(this.render(),this.bumpNeighbours_());return c};
Blockly.BlockSvg.prototype.setConnectionsHidden=function(a){if(!a&&this.isCollapsed()){if(this.outputConnection&&this.outputConnection.setHidden(a),this.previousConnection&&this.previousConnection.setHidden(a),this.nextConnection){this.nextConnection.setHidden(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionsHidden(a)}}else for(var c=this.getConnections_(!0),d=0;b=c[d];d++)b.setHidden(a),b.isSuperior()&&(b=b.targetBlock())&&b.setConnectionsHidden(a)};
Blockly.BlockSvg.prototype.getConnections_=function(a){var b=[];if(a||this.rendered)if(this.outputConnection&&b.push(this.outputConnection),this.previousConnection&&b.push(this.previousConnection),this.nextConnection&&b.push(this.nextConnection),a||!this.collapsed_){a=0;for(var c;c=this.inputList[a];a++)c.connection&&b.push(c.connection)}return b};Blockly.BlockSvg.prototype.makeConnection_=function(a){return new Blockly.RenderedConnection(this,a)};
Blockly.BlockSvg.prototype.bumpNeighbours_=function(){if(this.workspace&&!this.workspace.isDragging()){var a=this.getRootBlock();if(!a.isInFlyout)for(var b=this.getConnections_(!1),c=0,d;d=b[c];c++){d.isConnected()&&d.isSuperior()&&d.targetBlock().bumpNeighbours_();for(var e=d.neighbours_(Blockly.SNAP_RADIUS),f=0,g;g=e[f];f++)d.isConnected()&&g.isConnected()||g.getSourceBlock().getRootBlock()!=a&&(d.isSuperior()?g.bumpAwayFrom_(d):d.bumpAwayFrom_(g))}}};
Blockly.BlockSvg.prototype.scheduleSnapAndBump=function(){var a=this,b=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(b);a.snapToGrid();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY/2);setTimeout(function(){Blockly.Events.setGroup(b);a.bumpNeighbours_();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)};Blockly.BlockSvg.prototype.positionNearConnection=function(a,b){a.type!=Blockly.NEXT_STATEMENT&&a.type!=Blockly.INPUT_VALUE||this.moveBy(b.x_-a.x_,b.y_-a.y_)};
Blockly.BlockSvg.prototype.render=function(a){Blockly.utils.dom.startTextWidthCache();this.rendered=!0;this.workspace.getRenderer().render(this);this.updateConnectionLocations_();!1!==a&&((a=this.getParent())?a.render(!0):this.workspace.resizeContents());Blockly.utils.dom.stopTextWidthCache()};
Blockly.BlockSvg.prototype.updateConnectionLocations_=function(){var a=this.getRelativeToSurfaceXY();this.previousConnection&&this.previousConnection.moveToOffset(a);this.outputConnection&&this.outputConnection.moveToOffset(a);for(var b=0;b<this.inputList.length;b++){var c=this.inputList[b].connection;c&&(c.moveToOffset(a),c.isConnected()&&c.tighten_())}this.nextConnection&&(this.nextConnection.moveToOffset(a),this.nextConnection.isConnected()&&this.nextConnection.tighten_())};
Blockly.BlockSvg.prototype.setCursorSvg=function(a){a?(this.svgGroup_.appendChild(a),this.cursorSvg_=a):this.cursorSvg_=null};Blockly.BlockSvg.prototype.setMarkerSvg=function(a){a?(this.cursorSvg_?this.svgGroup_.insertBefore(a,this.cursorSvg_):this.svgGroup_.appendChild(a),this.markerSvg_=a):this.markerSvg_=null};Blockly.BlockSvg.render={};Blockly.BlockSvg.SEP_SPACE_Y=10;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.START_HAT=!1;Blockly.BlockSvg.prototype.getHeightWidth=function(){var a=this.height,b=this.width,c=this.getNextBlock();c&&(c=c.getHeightWidth(),a+=c.height-4,b=Math.max(b,c.width));return{height:a,width:b}};Blockly.BlockSvg.prototype.positionNewBlock=function(a,b,c){b.type!=Blockly.NEXT_STATEMENT&&b.type!=Blockly.INPUT_VALUE||a.moveBy(c.x_-b.x_,c.y_-b.y_)};
Blockly.BlockSvg.prototype.highlightForReplacement=function(a){a?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyReplaceable"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyReplaceable")};Blockly.Action=function(a,b){this.name=a;this.desc=b};Blockly.ASTNode=function(a,b,c){if(!b)throw Error("Cannot create a node without a location.");this.type_=a;this.isConnection_=Blockly.ASTNode.isConnectionType_(a);this.location_=b;this.processParams_(c||null)};Blockly.ASTNode.types={FIELD:"field",BLOCK:"block",INPUT:"input",OUTPUT:"output",NEXT:"next",PREVIOUS:"previous",STACK:"stack",WORKSPACE:"workspace"};Blockly.ASTNode.DEFAULT_OFFSET_Y=-20;Blockly.ASTNode.isConnectionType_=function(a){switch(a){case Blockly.ASTNode.types.PREVIOUS:case Blockly.ASTNode.types.NEXT:case Blockly.ASTNode.types.INPUT:case Blockly.ASTNode.types.OUTPUT:return!0}return!1};
Blockly.BlockSvg.prototype.setCursorSvg=function(a){a?(this.svgGroup_.appendChild(a),this.cursorSvg_=a):this.cursorSvg_=null};Blockly.BlockSvg.prototype.setMarkerSvg=function(a){a?(this.cursorSvg_?this.svgGroup_.insertBefore(a,this.cursorSvg_):this.svgGroup_.appendChild(a),this.markerSvg_=a):this.markerSvg_=null};Blockly.BlockSvg.prototype.getHeightWidth=function(){var a=this.height,b=this.width,c=this.getNextBlock();c&&(c=c.getHeightWidth(),a+=c.height-4,b=Math.max(b,c.width));return{height:a,width:b}};
Blockly.BlockSvg.prototype.positionNewBlock=function(a,b,c){b.type!=Blockly.NEXT_STATEMENT&&b.type!=Blockly.INPUT_VALUE||a.moveBy(c.x_-b.x_,c.y_-b.y_)};Blockly.BlockSvg.prototype.highlightForReplacement=function(a){a?Blockly.utils.dom.addClass(this.svgGroup_,"blocklyReplaceable"):Blockly.utils.dom.removeClass(this.svgGroup_,"blocklyReplaceable")};Blockly.Action=function(a,b){this.name=a;this.desc=b};Blockly.ASTNode=function(a,b,c){if(!b)throw Error("Cannot create a node without a location.");this.type_=a;this.isConnection_=Blockly.ASTNode.isConnectionType_(a);this.location_=b;this.processParams_(c||null)};Blockly.ASTNode.types={FIELD:"field",BLOCK:"block",INPUT:"input",OUTPUT:"output",NEXT:"next",PREVIOUS:"previous",STACK:"stack",WORKSPACE:"workspace"};Blockly.ASTNode.DEFAULT_OFFSET_Y=-20;Blockly.ASTNode.isConnectionType_=function(a){switch(a){case Blockly.ASTNode.types.PREVIOUS:case Blockly.ASTNode.types.NEXT:case Blockly.ASTNode.types.INPUT:case Blockly.ASTNode.types.OUTPUT:return!0}return!1};
Blockly.ASTNode.createFieldNode=function(a){return new Blockly.ASTNode(Blockly.ASTNode.types.FIELD,a)};
Blockly.ASTNode.createConnectionNode=function(a){return a?a.type==Blockly.INPUT_VALUE||a.type==Blockly.NEXT_STATEMENT&&a.getParentInput()?Blockly.ASTNode.createInputNode(a.getParentInput()):a.type==Blockly.NEXT_STATEMENT?new Blockly.ASTNode(Blockly.ASTNode.types.NEXT,a):a.type==Blockly.OUTPUT_VALUE?new Blockly.ASTNode(Blockly.ASTNode.types.OUTPUT,a):a.type==Blockly.PREVIOUS_STATEMENT?new Blockly.ASTNode(Blockly.ASTNode.types.PREVIOUS,a):null:null};
Blockly.ASTNode.createInputNode=function(a){return a?new Blockly.ASTNode(Blockly.ASTNode.types.INPUT,a.connection):null};Blockly.ASTNode.createBlockNode=function(a){return new Blockly.ASTNode(Blockly.ASTNode.types.BLOCK,a)};Blockly.ASTNode.createStackNode=function(a){return new Blockly.ASTNode(Blockly.ASTNode.types.STACK,a)};Blockly.ASTNode.createWorkspaceNode=function(a,b){return new Blockly.ASTNode(Blockly.ASTNode.types.WORKSPACE,a,{wsCoordinate:b})};
@@ -583,8 +560,8 @@ Blockly.navigation.getSourceBlock_(b),Blockly.navigation.moveBlockToWorkspace_(b
Blockly.navigation.moveAndConnect_=function(a,b){if(!a||!b)return!1;var c=a.getSourceBlock();return b.canConnectWithReason_(a)==Blockly.Connection.CAN_CONNECT?(Blockly.navigation.disconnectChild_(a,b),b.isSuperior()||c.getRootBlock().positionNearConnection(a,b),b.connect(a),!0):!1};Blockly.navigation.getInferiorConnection_=function(a){var b=a.getSourceBlock();return a.isSuperior()?b.previousConnection?b.previousConnection:b.outputConnection?b.outputConnection:null:a};
Blockly.navigation.getSuperiorConnection_=function(a){return a.isSuperior()?a:a.targetConnection?a.targetConnection:null};
Blockly.navigation.connect_=function(a,b){if(!a||!b)return!1;var c=Blockly.navigation.getInferiorConnection_(a),d=Blockly.navigation.getSuperiorConnection_(b),e=Blockly.navigation.getSuperiorConnection_(a),f=Blockly.navigation.getInferiorConnection_(b);if(c&&d&&Blockly.navigation.moveAndConnect_(c,d)||e&&f&&Blockly.navigation.moveAndConnect_(e,f)||Blockly.navigation.moveAndConnect_(a,b))return!0;try{b.checkConnection_(a)}catch(g){Blockly.navigation.warn_("Connection failed with error: "+g)}return!1};
Blockly.navigation.insertBlock=function(a,b){switch(b.type){case Blockly.PREVIOUS_STATEMENT:if(Blockly.navigation.connect_(a.nextConnection,b))return!0;break;case Blockly.NEXT_STATEMENT:if(Blockly.navigation.connect_(a.previousConnection,b))return!0;break;case Blockly.INPUT_VALUE:if(Blockly.navigation.connect_(a.outputConnection,b))return!0;break;case Blockly.OUTPUT_VALUE:for(var c=0;c<a.inputList.length;c++){var d=a.inputList[c].connection;if(d.type===Blockly.INPUT_VALUE&&Blockly.navigation.connect_(d,
b))return!0}}Blockly.navigation.warn_("This block can not be inserted at the marked location.");return!1};
Blockly.navigation.insertBlock=function(a,b){switch(b.type){case Blockly.PREVIOUS_STATEMENT:if(Blockly.navigation.connect_(a.nextConnection,b))return!0;break;case Blockly.NEXT_STATEMENT:if(Blockly.navigation.connect_(a.previousConnection,b))return!0;break;case Blockly.INPUT_VALUE:if(Blockly.navigation.connect_(a.outputConnection,b))return!0;break;case Blockly.OUTPUT_VALUE:for(var c=0;c<a.inputList.length;c++){var d=a.inputList[c].connection;if(d&&d.type===Blockly.INPUT_VALUE&&Blockly.navigation.connect_(d,
b))return!0}if(a.outputConnection&&Blockly.navigation.connect_(a.outputConnection,b))return!0}Blockly.navigation.warn_("This block can not be inserted at the marked location.");return!1};
Blockly.navigation.disconnectBlocks_=function(){var a=Blockly.getMainWorkspace(),b=a.getCursor().getCurNode();if(b.isConnection()){var c=b.getLocation();c.isConnected()?(b=c.isSuperior()?c:c.targetConnection,c=c.isSuperior()?c.targetConnection:c,c.getSourceBlock().isShadow()?Blockly.navigation.log_("Cannot disconnect a shadow block"):(b.disconnect(),c.bumpAwayFrom_(b),b.getSourceBlock().getRootBlock().bringToFront(),b=Blockly.ASTNode.createConnectionNode(b),a.getCursor().setCurNode(b))):Blockly.navigation.log_("Cannot disconnect unconnected connection")}else Blockly.navigation.log_("Cannot disconnect blocks when the cursor is not on a connection")};
Blockly.navigation.markAtCursor_=function(){var a=Blockly.getMainWorkspace();a.getMarker().setCurNode(a.getCursor().getCurNode())};Blockly.navigation.removeMark_=function(){var a=Blockly.getMainWorkspace();a.getMarker().setCurNode(null);a.getMarker().hide()};Blockly.navigation.setState=function(a){Blockly.navigation.currentState_=a};
Blockly.navigation.getSourceBlock_=function(a){return a?a.getType()===Blockly.ASTNode.types.BLOCK?a.getLocation():a.getType()===Blockly.ASTNode.types.STACK?a.getLocation():a.getType()===Blockly.ASTNode.types.WORKSPACE?null:a.getLocation().getSourceBlock():null};Blockly.navigation.getTopNode=function(a){var b=a.previousConnection||a.outputConnection;return b?Blockly.ASTNode.createConnectionNode(b):Blockly.ASTNode.createBlockNode(a)};
@@ -619,7 +596,8 @@ Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getTopBlocks(!1),d=0;
Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=Blockly.utils.style.getViewportPageOffset();Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"};
Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.DIV.innerHTML="")};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()};
Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)};
Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.ConnectionDB=function(){this.connections_=[]};Blockly.ConnectionDB.prototype.addConnection=function(a){if(a.inDB_)throw Error("Connection already in database.");if(!a.getSourceBlock().isInFlyout){var b=this.findPositionForConnection_(a);this.connections_.splice(b,0,a);a.inDB_=!0}};
Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.blockRendering.rendererMap_={};Blockly.blockRendering.useDebugger=!1;Blockly.blockRendering.register=function(a,b){if(Blockly.blockRendering.rendererMap_[a])throw Error("Renderer has already been registered.");Blockly.blockRendering.rendererMap_[a]=b};Blockly.blockRendering.unregister=function(a){Blockly.blockRendering.rendererMap_[a]?Blockly.blockRendering.rendererMap_[a]=void 0:console.warn('No renderer mapping for name "'+a+'" found to unregister')};
Blockly.blockRendering.startDebugger=function(){Blockly.blockRendering.useDebugger=!0};Blockly.blockRendering.stopDebugger=function(){Blockly.blockRendering.useDebugger=!1};Blockly.blockRendering.init=function(a){if(!Blockly.blockRendering.rendererMap_[a])throw Error("Renderer not registered: ",a);var b=function(){b.superClass_.constructor.call(this)};Blockly.utils.object.inherits(b,Blockly.blockRendering.rendererMap_[a]);a=new b;a.init();return a};Blockly.ConnectionDB=function(){this.connections_=[]};Blockly.ConnectionDB.prototype.addConnection=function(a){if(a.inDB_)throw Error("Connection already in database.");if(!a.getSourceBlock().isInFlyout){var b=this.findPositionForConnection_(a);this.connections_.splice(b,0,a);a.inDB_=!0}};
Blockly.ConnectionDB.prototype.findConnection=function(a){if(!this.connections_.length)return-1;var b=this.findPositionForConnection_(a);if(b>=this.connections_.length)return-1;for(var c=a.y_,d=b;0<=d&&this.connections_[d].y_==c;){if(this.connections_[d]==a)return d;d--}for(;b<this.connections_.length&&this.connections_[b].y_==c;){if(this.connections_[b]==a)return b;b++}return-1};
Blockly.ConnectionDB.prototype.findPositionForConnection_=function(a){if(!this.connections_.length)return 0;for(var b=0,c=this.connections_.length;b<c;){var d=Math.floor((b+c)/2);if(this.connections_[d].y_<a.y_)b=d+1;else if(this.connections_[d].y_>a.y_)c=d;else{b=d;break}}return b};
Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw Error("Connection not in database.");var b=this.findConnection(a);if(-1==b)throw Error("Unable to find connection in connectionDB.");a.inDB_=!1;this.connections_.splice(b,1)};
@@ -761,7 +739,7 @@ Blockly.DropDownDiv.getPositionAboveMetrics=function(a,b,c,d){a=Blockly.DropDown
Blockly.DropDownDiv.getPositionTopOfPageMetrics=function(a,b,c){a=Blockly.DropDownDiv.getPositionX(a,b.left,b.right,c.width);return{initialX:a.divX,initialY:0,finalX:a.divX,finalY:0,arrowVisible:!1}};Blockly.DropDownDiv.getPositionX=function(a,b,c,d){var e=a;a=Blockly.utils.math.clamp(b,a-d/2,c-d);e-=Blockly.DropDownDiv.ARROW_SIZE/2;b=Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING;d=Blockly.utils.math.clamp(b,e-a,d-b-Blockly.DropDownDiv.ARROW_SIZE);return{arrowX:d,divX:a}};
Blockly.DropDownDiv.isVisible=function(){return!!Blockly.DropDownDiv.owner_};Blockly.DropDownDiv.hideIfOwner=function(a){return Blockly.DropDownDiv.owner_===a?(Blockly.DropDownDiv.hide(),!0):!1};
Blockly.DropDownDiv.hide=function(){var a=Blockly.DropDownDiv.DIV_;a.style.transform="translate(0, 0)";a.style.opacity=0;Blockly.DropDownDiv.animateOutTimer_=setTimeout(Blockly.DropDownDiv.hideWithoutAnimation,1E3*Blockly.DropDownDiv.ANIMATION_TIME);Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_=null)};
Blockly.DropDownDiv.hideWithoutAnimation=function(){if(Blockly.DropDownDiv.isVisible()){Blockly.DropDownDiv.animateOutTimer_&&clearTimeout(Blockly.DropDownDiv.animateOutTimer_);var a=Blockly.DropDownDiv.DIV_;a.style.transform="";a.style.left="";a.style.top="";a.style.opacity=0;a.style.display="none";Blockly.DropDownDiv.clearContent();Blockly.DropDownDiv.owner_=null;Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_=null)}};
Blockly.DropDownDiv.hideWithoutAnimation=function(){if(Blockly.DropDownDiv.isVisible()){Blockly.DropDownDiv.animateOutTimer_&&clearTimeout(Blockly.DropDownDiv.animateOutTimer_);var a=Blockly.DropDownDiv.DIV_;a.style.transform="";a.style.left="";a.style.top="";a.style.opacity=0;a.style.display="none";Blockly.DropDownDiv.onHide_&&(Blockly.DropDownDiv.onHide_(),Blockly.DropDownDiv.onHide_=null);Blockly.DropDownDiv.clearContent();Blockly.DropDownDiv.owner_=null}};
Blockly.DropDownDiv.positionInternal_=function(a,b,c,d){a=Math.floor(a);b=Math.floor(b);c=Math.floor(c);d=Math.floor(d);var e=Blockly.DropDownDiv.DIV_;e.style.left=a+"px";e.style.top=b+"px";e.style.display="block";e.style.opacity=1;e.style.transform="translate("+(c-a)+"px,"+(d-b)+"px)"};
Blockly.DropDownDiv.repositionForWindowResize=function(){if(Blockly.DropDownDiv.owner_){var a=Blockly.DropDownDiv.owner_.getSourceBlock(),b=a.workspace.scale,c=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.size_.width:a.width,d=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.size_.height:a.height;c*=b;d*=b;a=Blockly.DropDownDiv.positionToField_?Blockly.DropDownDiv.owner_.fieldGroup_.getBoundingClientRect():a.getSvgRoot().getBoundingClientRect();c=a.left+c/2;d=Blockly.DropDownDiv.getPositionMetrics(c,
a.top+d,c,a.top);Blockly.DropDownDiv.positionInternal_(d.initialX,d.initialY,d.finalX,d.finalY)}else Blockly.DropDownDiv.hide()};Blockly.inject=function(a,b){Blockly.checkBlockColourConstants();"string"==typeof a&&(a=document.getElementById(a)||document.querySelector(a));if(!Blockly.utils.dom.containsNode(document,a))throw Error("Error: container is not in current document.");var c=new Blockly.Options(b||{}),d=document.createElement("div");d.className="injectionDiv";a.appendChild(d);var e=Blockly.createDom_(d,c),f=new Blockly.BlockDragSurfaceSvg(d);d=new Blockly.WorkspaceDragSurfaceSvg(d);e=Blockly.createMainWorkspace_(e,c,
@@ -1107,13 +1085,17 @@ this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Blockly.blockRe
Blockly.blockRendering.RenderInfo.prototype.addInput_=function(a,b){this.isInline&&a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.InlineInput(this.constants_,a)),b.hasInlineInput=!0):a.type==Blockly.NEXT_STATEMENT?(b.elements.push(new Blockly.blockRendering.StatementInput(this.constants_,a)),b.hasStatement=!0):a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.ExternalValueInput(this.constants_,a)),b.hasExternalInput=!0):a.type==Blockly.DUMMY_INPUT&&(b.hasDummyInput=
!0)};Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_=function(a,b){return b?a.type==Blockly.NEXT_STATEMENT||b.type==Blockly.NEXT_STATEMENT?!0:a.type==Blockly.INPUT_VALUE||a.type==Blockly.DUMMY_INPUT?!this.isInline:!1:!1};
Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_=function(){for(var a=0,b;b=this.rows[a];a++){var c=b.elements;b.elements=[];b.startsWithElemSpacer()&&b.elements.push(new Blockly.blockRendering.InRowSpacer(this.constants_,this.getInRowSpacing_(null,c[0])));for(var d=0;d<c.length-1;d++){b.elements.push(c[d]);var e=this.getInRowSpacing_(c[d],c[d+1]);b.elements.push(new Blockly.blockRendering.InRowSpacer(this.constants_,e))}b.elements.push(c[c.length-1]);b.endsWithElemSpacer()&&b.elements.push(new Blockly.blockRendering.InRowSpacer(this.constants_,
this.getInRowSpacing_(c[c.length-1],null)))}};Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_=function(a,b){if(a&&Blockly.blockRendering.Types.isInput(a)&&!b){if(Blockly.blockRendering.Types.isExternalInput(a))return this.constants_.NO_PADDING;if(Blockly.blockRendering.Types.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Blockly.blockRendering.Types.isStatementInput(a))return this.constants_.NO_PADDING}return this.constants_.MEDIUM_PADDING};
this.getInRowSpacing_(c[c.length-1],null)))}};
Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_=function(a,b){if(a&&Blockly.blockRendering.Types.isInput(a)&&!b){if(Blockly.blockRendering.Types.isExternalInput(a))return this.constants_.NO_PADDING;if(Blockly.blockRendering.Types.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Blockly.blockRendering.Types.isStatementInput(a))return this.constants_.NO_PADDING}return a&&Blockly.blockRendering.Types.isLeftSquareCorner(a)&&b&&(Blockly.blockRendering.Types.isPreviousConnection(b)||Blockly.blockRendering.Types.isNextConnection(b))?
b.notchOffset:a&&Blockly.blockRendering.Types.isLeftRoundedCorner(a)&&b&&(Blockly.blockRendering.Types.isPreviousConnection(b)||Blockly.blockRendering.Types.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING};
Blockly.blockRendering.RenderInfo.prototype.computeBounds_=function(){for(var a=0,b=0,c=0,d=0,e;e=this.rows[d];d++){e.measure();b=Math.max(b,e.width);if(e.hasStatement){var f=e.getLastInput();a=Math.max(a,e.width-f.width)}c=Math.max(c,e.widthWithConnectedBlocks)}this.statementEdge=a;this.width=b;for(d=0;e=this.rows[d];d++)e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(b,c);this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,
this.widthWithChildren+=this.outputConnection.width)};Blockly.blockRendering.RenderInfo.prototype.alignRowElements_=function(){for(var a=0,b;b=this.rows[a];a++)if(b.hasStatement)this.alignStatementRow_(b);else{var c=this.width-this.startX-b.width;c&&this.addAlignmentPadding_(b,c)}};Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.getLastSpacer();c&&(c.width+=b,a.width+=b)};
Blockly.blockRendering.RenderInfo.prototype.alignStatementRow_=function(a){var b=a.getLastInput(),c=a.width-b.width,d=this.statementEdge-this.startX;(c=d-c)&&this.addAlignmentPadding_(a,c);c=a.width;d=this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0);b.width+=d-c;a.width+=d-c;a.widthWithConnectedBlocks=Math.max(a.width,this.statementEdge+a.connectedBlockWidths)};
Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_=function(){var a=this.rows;this.rows=[];for(var b=0;b<a.length;b++)this.rows.push(a[b]),b!=a.length-1&&this.rows.push(this.makeSpacerRow_(a[b],a[b+1]))};Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_=function(a,b){var c=this.getSpacerRowHeight_(a,b),d=this.getSpacerRowWidth_(a,b);c=new Blockly.blockRendering.SpacerRow(this.constants_,c,d);a.hasStatement&&(c.followsStatement=!0);return c};
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_=function(a,b){return this.width-this.startX};Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_=function(a,b){return this.constants_.MEDIUM_PADDING};Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_=function(a,b){var c=a.yPos;return c+=a.height/2};
Blockly.blockRendering.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0,c=0,d;d=this.rows[c];c++){d.yPos=b;d.xPos=this.startX;b+=d.height;a=Math.max(a,d.widthWithConnectedBlocks);for(var e=d.xPos,f=0,g;g=d.elements[f];f++)g.xPos=e,g.centerline=this.getElemCenterline_(d,g),e+=g.width}this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline;this.bottomRow.baseline=b-this.bottomRow.descenderHeight};Blockly.blockRendering.Drawer=function(a,b){this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.inlinePath_=this.outlinePath_="";this.constants_=b.getRenderer().getConstants()};
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_=function(a,b){return this.width-this.startX};Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_=function(a,b){return this.constants_.MEDIUM_PADDING};
Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_=function(a,b){if(Blockly.blockRendering.Types.isSpacer(b))return a.yPos+b.height/2;if(Blockly.blockRendering.Types.isBottomRow(a)){var c=a.yPos+a.height-a.descenderHeight;return Blockly.blockRendering.Types.isNextConnection(b)?c+b.height/2:c-b.height/2}return Blockly.blockRendering.Types.isTopRow(a)?Blockly.blockRendering.Types.isHat(b)?a.capline-b.height/2:a.capline+b.height/2:a.yPos+a.height/2};
Blockly.blockRendering.RenderInfo.prototype.recordElemPositions_=function(a){for(var b=a.xPos,c=0,d;d=a.elements[c];c++)Blockly.blockRendering.Types.isSpacer(d)&&(d.height=a.height),d.xPos=b,d.centerline=this.getElemCenterline_(a,d),b+=d.width};
Blockly.blockRendering.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0,c=0,d;d=this.rows[c];c++)d.yPos=b,d.xPos=this.startX,b+=d.height,a=Math.max(a,d.widthWithConnectedBlocks),this.recordElemPositions_(d);this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline;this.bottomRow.baseline=b-this.bottomRow.descenderHeight};Blockly.blockRendering.Drawer=function(a,b){this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.inlinePath_=this.outlinePath_="";this.constants_=b.getRenderer().getConstants()};
Blockly.blockRendering.Drawer.prototype.draw=function(){this.hideHiddenIcons_();this.drawOutline_();this.drawInternals_();this.block_.pathObject.setPaths(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&this.block_.pathObject.flipRTL();Blockly.blockRendering.useDebugger&&this.block_.renderingDebugger.drawDebug(this.block_,this.info_);this.recordSizeOnBlock_()};Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_=function(){this.block_.height=this.info_.height;this.block_.width=this.info_.widthWithChildren};
Blockly.blockRendering.Drawer.prototype.hideHiddenIcons_=function(){for(var a=0,b;b=this.info_.hiddenIcons[a];a++)b.icon.iconGroup_.setAttribute("display","none")};Blockly.blockRendering.Drawer.prototype.drawOutline_=function(){this.drawTop_();for(var a=1;a<this.info_.rows.length-1;a++){var b=this.info_.rows[a];b.hasJaggedEdge?this.drawJaggedEdge_(b):b.hasStatement?this.drawStatementInput_(b):b.hasExternalInput?this.drawValueInput_(b):this.drawRightSideRow_(b)}this.drawBottom_();this.drawLeft_()};
Blockly.blockRendering.Drawer.prototype.drawTop_=function(){var a=this.info_.topRow,b=a.elements;this.positionPreviousConnection_();this.outlinePath_+=Blockly.utils.svgPaths.moveBy(a.xPos,this.info_.startY);for(var c=0,d;d=b[c];c++)Blockly.blockRendering.Types.isLeftRoundedCorner(d)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:Blockly.blockRendering.Types.isPreviousConnection(d)?this.outlinePath_+=d.shape.pathLeft:Blockly.blockRendering.Types.isHat(d)?this.outlinePath_+=this.constants_.START_HAT.path:
@@ -1156,10 +1138,10 @@ this.constants_.CORNER_RADIUS+c}return!Blockly.blockRendering.Types.isInput(a)&&
Blockly.geras.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.getFirstSpacer(),d=a.getLastSpacer();if(a.hasExternalInput||a.hasStatement)a.widthWithConnectedBlocks+=b;var e=a.getLastInput();e?e.align==Blockly.ALIGN_LEFT?d.width+=b:e.align==Blockly.ALIGN_CENTRE?(c.width+=b/2,d.width+=b/2):e.align==Blockly.ALIGN_RIGHT&&(c.width+=b):d.width+=b;a.width+=b};
Blockly.geras.RenderInfo.prototype.getSpacerRowHeight_=function(a,b){return Blockly.blockRendering.Types.isTopRow(a)&&Blockly.blockRendering.Types.isBottomRow(b)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:Blockly.blockRendering.Types.isTopRow(a)||Blockly.blockRendering.Types.isBottomRow(b)?this.constants_.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?this.constants_.LARGE_PADDING:!a.hasStatement&&b.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||!a.hasStatement&&
b.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING};
Blockly.geras.RenderInfo.prototype.getElemCenterline_=function(a,b){if(Blockly.blockRendering.Types.isBottomRow(a)){var c=a.yPos+a.height-a.descenderHeight;return Blockly.blockRendering.Types.isNextConnection(b)?c+b.height/2:c-b.height/2}if(Blockly.blockRendering.Types.isTopRow(a))return Blockly.blockRendering.Types.isHat(b)?a.capline-b.height/2:a.capline+b.height/2;c=a.yPos;if(Blockly.blockRendering.Types.isField(b)||Blockly.blockRendering.Types.isIcon(b)){if(c+=b.height/2,a.hasInlineInput||a.hasStatement)c+=
this.constants_.TALL_INPUT_FIELD_OFFSET_Y}else c=Blockly.blockRendering.Types.isInlineInput(b)?c+b.height/2:c+a.height/2;return c};
Blockly.geras.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0,c=0,d;d=this.rows[c];c++){d.yPos=b;d.xPos=this.startX;b+=d.height;a=Math.max(a,d.widthWithConnectedBlocks);var e=b-this.topRow.ascenderHeight;d==this.bottomRow&&e<this.constants_.MIN_BLOCK_HEIGHT&&(e=this.constants_.MIN_BLOCK_HEIGHT-e,this.bottomRow.height+=e,b+=e);e=d.xPos;for(var f=0,g;g=d.elements[f];f++)g.xPos=e,g.centerline=this.getElemCenterline_(d,g),e+=g.width}this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=
a+this.startX+this.constants_.DARK_PATH_OFFSET;this.width+=this.constants_.DARK_PATH_OFFSET;this.height=b+this.constants_.DARK_PATH_OFFSET;this.startY=this.topRow.capline};Blockly.geras.Drawer=function(a,b){Blockly.geras.Drawer.superClass_.constructor.call(this,a,b);this.highlighter_=new Blockly.geras.Highlighter(b)};Blockly.utils.object.inherits(Blockly.geras.Drawer,Blockly.blockRendering.Drawer);
Blockly.geras.RenderInfo.prototype.getElemCenterline_=function(a,b){if(Blockly.blockRendering.Types.isSpacer(b))return a.yPos+b.height/2;if(Blockly.blockRendering.Types.isBottomRow(a)){var c=a.yPos+a.height-a.descenderHeight;return Blockly.blockRendering.Types.isNextConnection(b)?c+b.height/2:c-b.height/2}if(Blockly.blockRendering.Types.isTopRow(a))return Blockly.blockRendering.Types.isHat(b)?a.capline-b.height/2:a.capline+b.height/2;c=a.yPos;Blockly.blockRendering.Types.isField(b)||Blockly.blockRendering.Types.isIcon(b)?
(c+=b.height/2,(a.hasInlineInput||a.hasStatement)&&b.height>a.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y&&(c+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):c=Blockly.blockRendering.Types.isInlineInput(b)?c+b.height/2:c+a.height/2;return c};
Blockly.geras.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0,c=0,d;d=this.rows[c];c++){d.yPos=b;d.xPos=this.startX;b+=d.height;a=Math.max(a,d.widthWithConnectedBlocks);var e=b-this.topRow.ascenderHeight;d==this.bottomRow&&e<this.constants_.MIN_BLOCK_HEIGHT&&(e=this.constants_.MIN_BLOCK_HEIGHT-e,this.bottomRow.height+=e,b+=e);this.recordElemPositions_(d)}this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX+this.constants_.DARK_PATH_OFFSET;this.width+=
this.constants_.DARK_PATH_OFFSET;this.height=b+this.constants_.DARK_PATH_OFFSET;this.startY=this.topRow.capline};Blockly.geras.Drawer=function(a,b){Blockly.geras.Drawer.superClass_.constructor.call(this,a,b);this.highlighter_=new Blockly.geras.Highlighter(b)};Blockly.utils.object.inherits(Blockly.geras.Drawer,Blockly.blockRendering.Drawer);
Blockly.geras.Drawer.prototype.draw=function(){this.hideHiddenIcons_();this.drawOutline_();this.drawInternals_();this.block_.pathObject.setPaths(this.outlinePath_+"\n"+this.inlinePath_,this.highlighter_.getPath());this.info_.RTL&&this.block_.pathObject.flipRTL();Blockly.blockRendering.useDebugger&&this.block_.renderingDebugger.drawDebug(this.block_,this.info_);this.recordSizeOnBlock_()};
Blockly.geras.Drawer.prototype.drawTop_=function(){this.highlighter_.drawTopCorner(this.info_.topRow);this.highlighter_.drawRightSideRow(this.info_.topRow);Blockly.geras.Drawer.superClass_.drawTop_.call(this)};Blockly.geras.Drawer.prototype.drawJaggedEdge_=function(a){this.highlighter_.drawJaggedEdge_(a);Blockly.geras.Drawer.superClass_.drawJaggedEdge_.call(this,a)};
Blockly.geras.Drawer.prototype.drawValueInput_=function(a){this.highlighter_.drawValueInput(a);Blockly.geras.Drawer.superClass_.drawValueInput_.call(this,a)};Blockly.geras.Drawer.prototype.drawStatementInput_=function(a){this.highlighter_.drawStatementInput(a);Blockly.geras.Drawer.superClass_.drawStatementInput_.call(this,a)};Blockly.geras.Drawer.prototype.drawRightSideRow_=function(a){this.highlighter_.drawRightSideRow(a);Blockly.geras.Drawer.superClass_.drawRightSideRow_.call(this,a)};
@@ -1184,8 +1166,8 @@ a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0);Blockly.Touch
this.flyout_=new Blockly.VerticalFlyout(b)}Blockly.utils.dom.insertAfter(this.flyout_.createDom("svg"),this.workspace_.getParentSvg());this.flyout_.init(a);this.config_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.config_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl":"Ltr");this.renderTree(a.options.languageTree)};
Blockly.Toolbox.prototype.renderTree=function(a){this.tree_&&(this.tree_.dispose(),this.lastCategory_=null);var b=new Blockly.tree.TreeControl(this,this.config_);this.tree_=b;b.setSelectedItem(null);b.onBeforeSelected(this.handleBeforeTreeSelected_);b.onAfterSelected(this.handleAfterTreeSelected_);var c=null;if(a){this.tree_.blocks=[];this.hasColours_=!1;c=this.syncTrees_(a,this.tree_,this.workspace_.options.pathToMedia);if(this.tree_.blocks.length)throw Error("Toolbox cannot have both blocks and categories in the root level.");
this.workspace_.resizeContents()}b.render(this.HtmlDiv);c&&b.setSelectedItem(c);this.addColour_();this.position();this.horizontalLayout_&&Blockly.utils.aria.setState(this.tree_.getElement(),Blockly.utils.aria.State.ORIENTATION,"horizontal")};Blockly.Toolbox.prototype.handleBeforeTreeSelected_=function(a){if(a==this.tree_)return!1;this.lastCategory_&&(this.lastCategory_.getRowElement().style.backgroundColor="");if(a){var b=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=b;this.addColour_(a)}return!0};
Blockly.Toolbox.prototype.handleAfterTreeSelected_=function(a,b){b&&b.blocks&&b.blocks.length?(this.flyout_.show(b.blocks),this.lastCategory_!=b&&this.flyout_.scrollToStart(),Blockly.keyboardAccessibilityMode&&Blockly.navigation.setState(Blockly.navigation.STATE_TOOLBOX)):(this.flyout_.hide(),Blockly.keyboardAccessibilityMode&&Blockly.navigation.setState(Blockly.navigation.STATE_WS));if(a!=b&&a!=this){var c=new Blockly.Events.Ui(null,"category",a&&a.getText(),b&&b.getText());c.workspaceId=this.workspace_.id;
Blockly.Events.fire(c)}b&&(this.lastCategory_=b)};Blockly.Toolbox.prototype.handleNodeSizeChanged_=function(){Blockly.svgResize(this.workspace_)};
Blockly.Toolbox.prototype.handleAfterTreeSelected_=function(a,b){b&&b.blocks&&b.blocks.length?(this.flyout_.show(b.blocks),this.lastCategory_!=b&&this.flyout_.scrollToStart(),Blockly.keyboardAccessibilityMode&&Blockly.navigation.setState(Blockly.navigation.STATE_TOOLBOX)):(this.flyout_.hide(),!Blockly.keyboardAccessibilityMode||b instanceof Blockly.Toolbox.TreeSeparator||Blockly.navigation.setState(Blockly.navigation.STATE_WS));if(a!=b&&a!=this){var c=new Blockly.Events.Ui(null,"category",a&&a.getText(),
b&&b.getText());c.workspaceId=this.workspace_.id;Blockly.Events.fire(c)}b&&(this.lastCategory_=b)};Blockly.Toolbox.prototype.handleNodeSizeChanged_=function(){Blockly.svgResize(this.workspace_)};
Blockly.Toolbox.prototype.onBlocklyAction=function(a){var b=this.tree_.getSelectedItem();if(!b)return!1;switch(a.name){case Blockly.navigation.actionNames.PREVIOUS:return b.selectPrevious();case Blockly.navigation.actionNames.OUT:return b.selectParent();case Blockly.navigation.actionNames.NEXT:return b.selectNext();case Blockly.navigation.actionNames.IN:return b.selectChild();default:return!1}};
Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv);Blockly.utils.dom.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};Blockly.Toolbox.prototype.getWidth=function(){return this.width};Blockly.Toolbox.prototype.getHeight=function(){return this.height};
Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.getParentSvg();b=Blockly.svgSize(b);this.horizontalLayout_?(a.style.left="0",a.style.height="auto",a.style.width=b.width+"px",this.height=a.offsetHeight,this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?a.style.top="0":a.style.bottom="0"):(this.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT?a.style.right="0":a.style.left="0",a.style.height=b.height+"px",this.width=a.offsetWidth);this.flyout_.position()}};

View File

@@ -26,9 +26,8 @@ goog.addDependency("../../core/block_animations.js", ['Blockly.blockAnimations']
goog.addDependency("../../core/block_drag_surface.js", ['Blockly.BlockDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
goog.addDependency("../../core/block_dragger.js", ['Blockly.BlockDragger'], ['Blockly.blockAnimations', 'Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.InsertionMarkerManager', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
goog.addDependency("../../core/block_events.js", ['Blockly.Events.BlockBase', 'Blockly.Events.BlockChange', 'Blockly.Events.BlockCreate', 'Blockly.Events.BlockDelete', 'Blockly.Events.BlockMove', 'Blockly.Events.Change', 'Blockly.Events.Create', 'Blockly.Events.Delete', 'Blockly.Events.Move'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.Coordinate', 'Blockly.utils.object', 'Blockly.utils.xml']);
goog.addDependency("../../core/block_render_svg.js", ['Blockly.BlockSvg.render'], ['Blockly.blockRendering', 'Blockly.BlockSvg', 'Blockly.utils.dom']);
goog.addDependency("../../core/block_svg.js", ['Blockly.BlockSvg'], ['Blockly.Block', 'Blockly.blockAnimations', 'Blockly.blockRendering.IPathObject', 'Blockly.ContextMenu', 'Blockly.Events', 'Blockly.Events.Ui', 'Blockly.Events.BlockMove', 'Blockly.Msg', 'Blockly.RenderedConnection', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.Rect', 'Blockly.Warning']);
goog.addDependency("../../core/blockly.js", ['Blockly'], ['Blockly.BlockSvg.render', 'Blockly.Events', 'Blockly.Events.Ui', 'Blockly.navigation', 'Blockly.Procedures', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.constants', 'Blockly.inject', 'Blockly.utils', 'Blockly.utils.colour', 'Blockly.Xml']);
goog.addDependency("../../core/blockly.js", ['Blockly'], ['Blockly.Events', 'Blockly.Events.Ui', 'Blockly.navigation', 'Blockly.Procedures', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.constants', 'Blockly.inject', 'Blockly.utils', 'Blockly.utils.colour', 'Blockly.Xml']);
goog.addDependency("../../core/blocks.js", ['Blockly.Blocks'], []);
goog.addDependency("../../core/bubble.js", ['Blockly.Bubble'], ['Blockly.Scrollbar', 'Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.userAgent', 'Blockly.Workspace']);
goog.addDependency("../../core/bubble_dragger.js", ['Blockly.BubbleDragger'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.CommentMove', 'Blockly.utils', 'Blockly.utils.Coordinate']);
@@ -109,10 +108,10 @@ goog.addDependency("../../core/renderers/measurables/inputs.js", ['Blockly.block
goog.addDependency("../../core/renderers/measurables/row_elements.js", ['Blockly.blockRendering.Field', 'Blockly.blockRendering.Hat', 'Blockly.blockRendering.Icon', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.JaggedEdge', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.SquareCorner'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/measurables/rows.js", ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow'], ['Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.Types', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/measurables/types.js", ['Blockly.blockRendering.Types'], []);
goog.addDependency("../../core/renderers/sample/constants.js", ['Blockly.sample.ConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/sample/drawer.js", ['Blockly.sample.Drawer'], ['Blockly.blockRendering.Drawer', 'Blockly.utils.object', 'Blockly.sample.RenderInfo']);
goog.addDependency("../../core/renderers/sample/info.js", ['Blockly.sample', 'Blockly.sample.RenderInfo'], ['Blockly.utils.object']);
goog.addDependency("../../core/renderers/sample/renderer.js", ['Blockly.sample.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.sample.ConstantProvider', 'Blockly.sample.Drawer', 'Blockly.sample.RenderInfo']);
goog.addDependency("../../core/renderers/minimalist/constants.js", ['Blockly.minimalist.ConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/minimalist/drawer.js", ['Blockly.minimalist.Drawer'], ['Blockly.blockRendering.Drawer', 'Blockly.utils.object', 'Blockly.minimalist.RenderInfo']);
goog.addDependency("../../core/renderers/minimalist/info.js", ['Blockly.minimalist', 'Blockly.minimalist.RenderInfo'], ['Blockly.utils.object']);
goog.addDependency("../../core/renderers/minimalist/renderer.js", ['Blockly.minimalist.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.minimalist.ConstantProvider', 'Blockly.minimalist.Drawer', 'Blockly.minimalist.RenderInfo']);
goog.addDependency("../../core/renderers/thrasos/info.js", ['Blockly.thrasos', 'Blockly.thrasos.RenderInfo'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/thrasos/renderer.js", ['Blockly.thrasos.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.thrasos.RenderInfo', 'Blockly.utils.object']);
goog.addDependency("../../core/renderers/zelos/constants.js", ['Blockly.zelos.ConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.object', 'Blockly.utils.svgPaths']);
@@ -167,7 +166,7 @@ goog.addDependency("../../core/workspace_comment_svg.js", ['Blockly.WorkspaceCom
goog.addDependency("../../core/workspace_drag_surface_svg.js", ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.dom']);
goog.addDependency("../../core/workspace_dragger.js", ['Blockly.WorkspaceDragger'], ['Blockly.utils.Coordinate']);
goog.addDependency("../../core/workspace_events.js", ['Blockly.Events.FinishedLoading'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.object']);
goog.addDependency("../../core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.blockRendering', 'Blockly.ConnectionDB', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.TouchGesture', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.Rect', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml']);
goog.addDependency("../../core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.blockRendering', 'Blockly.ConnectionDB', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.TouchGesture', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.Rect', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml']);
goog.addDependency("../../core/ws_comment_events.js", ['Blockly.Events.CommentBase', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.Coordinate', 'Blockly.utils.object', 'Blockly.utils.xml']);
goog.addDependency("../../core/xml.js", ['Blockly.Xml'], ['Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.VarCreate', 'Blockly.utils', 'Blockly.utils.dom', 'Blockly.utils.global', 'Blockly.utils.xml']);
goog.addDependency("../../core/zoom_controls.js", ['Blockly.ZoomControls'], ['Blockly.Css', 'Blockly.Scrollbar', 'Blockly.Touch', 'Blockly.utils.dom']);

View File

@@ -1,112 +0,0 @@
/**
* @license
* Copyright 2016 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Methods for graphically rendering a block as SVG.
* @author fenichel@google.com (Rachel Fenichel)
*/
'use strict';
goog.provide('Blockly.BlockSvg.render');
goog.require('Blockly.blockRendering');
goog.require('Blockly.BlockSvg');
goog.require('Blockly.utils.dom');
// UI constants for rendering blocks.
/**
* Vertical space between elements.
* @const
*/
Blockly.BlockSvg.SEP_SPACE_Y = 10;
/**
* Minimum height of a block.
* @const
*/
Blockly.BlockSvg.MIN_BLOCK_Y = 25;
/**
* Width of horizontal puzzle tab.
* @const
*/
Blockly.BlockSvg.TAB_WIDTH = 8;
/**
* Do blocks with no previous or output connections have a 'hat' on top?
* @const
*/
Blockly.BlockSvg.START_HAT = false;
/**
* Returns a bounding box describing the dimensions of this block
* and any blocks stacked below it.
* @return {!{height: number, width: number}} Object with height and width
* properties in workspace units.
*/
Blockly.BlockSvg.prototype.getHeightWidth = function() {
var height = this.height;
var width = this.width;
// Recursively add size of subsequent blocks.
var nextBlock = this.getNextBlock();
if (nextBlock) {
var nextHeightWidth = nextBlock.getHeightWidth();
height += nextHeightWidth.height - 4; // Height of tab.
width = Math.max(width, nextHeightWidth.width);
}
return {height: height, width: width};
};
/**
* Position an new block correctly, so that it doesn't move the existing block
* when connected to it.
* @param {!Blockly.Block} newBlock The block to position - either the first
* block in a dragged stack or an insertion marker.
* @param {!Blockly.Connection} newConnection The connection on the new block's
* stack - either a connection on newBlock, or the last NEXT_STATEMENT
* connection on the stack if the stack's being dropped before another
* block.
* @param {!Blockly.Connection} existingConnection The connection on the
* existing block, which newBlock should line up with.
*/
Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection,
existingConnection) {
// We only need to position the new block if it's before the existing one,
// otherwise its position is set by the previous block.
if (newConnection.type == Blockly.NEXT_STATEMENT ||
newConnection.type == Blockly.INPUT_VALUE) {
var dx = existingConnection.x_ - newConnection.x_;
var dy = existingConnection.y_ - newConnection.y_;
newBlock.moveBy(dx, dy);
}
};
/**
* Visual effect to show that if the dragging block is dropped, this block will
* be replaced. If a shadow block, it will disappear. Otherwise it will bump.
* @param {boolean} add True if highlighting should be added.
*/
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
if (add) {
Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
} else {
Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
}
};

View File

@@ -175,6 +175,39 @@ Blockly.BlockSvg.INLINE = -1;
*/
Blockly.BlockSvg.COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_';
// Leftover UI constants from block_render_svg.js.
/**
* Vertical space between elements.
* TODO (#3142): Remove.
* @const
* @package
*/
Blockly.BlockSvg.SEP_SPACE_Y = 10;
/**
* Minimum height of a block.
* TODO (#3142): Remove.
* @const
* @package
*/
Blockly.BlockSvg.MIN_BLOCK_Y = 25;
/**
* Width of horizontal puzzle tab.
* TODO (#3142): Remove.
* @const
* @package
*/
Blockly.BlockSvg.TAB_WIDTH = 8;
/**
* Do blocks with no previous or output connections have a 'hat' on top?
* TODO (#3142): Remove.
* @const
* @package
*/
Blockly.BlockSvg.START_HAT = false;
/**
* Create and initialize the SVG representation of the block.
* May be called more than once.
@@ -1696,3 +1729,65 @@ Blockly.BlockSvg.prototype.setMarkerSvg = function(markerSvg) {
}
this.markerSvg_ = markerSvg;
};
/**
* Returns a bounding box describing the dimensions of this block
* and any blocks stacked below it.
* @return {!{height: number, width: number}} Object with height and width
* properties in workspace units.
* @package
*/
Blockly.BlockSvg.prototype.getHeightWidth = function() {
var height = this.height;
var width = this.width;
// Recursively add size of subsequent blocks.
var nextBlock = this.getNextBlock();
if (nextBlock) {
var nextHeightWidth = nextBlock.getHeightWidth();
height += nextHeightWidth.height - 4; // Height of tab.
width = Math.max(width, nextHeightWidth.width);
}
return {height: height, width: width};
};
/**
* Position a new block correctly, so that it doesn't move the existing block
* when connected to it.
* @param {!Blockly.Block} newBlock The block to position - either the first
* block in a dragged stack or an insertion marker.
* @param {!Blockly.Connection} newConnection The connection on the new block's
* stack - either a connection on newBlock, or the last NEXT_STATEMENT
* connection on the stack if the stack's being dropped before another
* block.
* @param {!Blockly.Connection} existingConnection The connection on the
* existing block, which newBlock should line up with.
* @package
*/
Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection,
existingConnection) {
// We only need to position the new block if it's before the existing one,
// otherwise its position is set by the previous block.
if (newConnection.type == Blockly.NEXT_STATEMENT ||
newConnection.type == Blockly.INPUT_VALUE) {
var dx = existingConnection.x_ - newConnection.x_;
var dy = existingConnection.y_ - newConnection.y_;
newBlock.moveBy(dx, dy);
}
};
/**
* Visual effect to show that if the dragging block is dropped, this block will
* be replaced. If a shadow block, it will disappear. Otherwise it will bump.
* @param {boolean} add True if highlighting should be added.
* @package
*/
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
if (add) {
Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
} else {
Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
}
};

View File

@@ -27,7 +27,6 @@
*/
goog.provide('Blockly');
goog.require('Blockly.BlockSvg.render');
goog.require('Blockly.Events');
goog.require('Blockly.Events.Ui');
goog.require('Blockly.navigation');

View File

@@ -23,8 +23,7 @@
goog.provide('Blockly.WorkspaceSvg');
// TODO(scr): Fix circular dependencies
// goog.require('Blockly.BlockSvg');
goog.require('Blockly.BlockSvg');
goog.require('Blockly.blockRendering');
goog.require('Blockly.ConnectionDB');
goog.require('Blockly.constants');