forked from OpenRoberta/blockly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocks_compressed.js
372 lines (370 loc) · 161 KB
/
blocks_compressed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
// Do not edit this file; automatically generated by build.py.
'use strict';
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.Blocks.procedures={};Blockly.Blocks.procedures.HUE=290;
Blockly.Blocks.procedures_defnoreturn={init:function(){var a=new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);this.setColour(Blockly.CAT_PROCEDURE_RGB);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.setStatements_(!0);this.statementConnection_=null},validate:function(){var a=Blockly.Procedures.findLegalName(this.getFieldValue("NAME"),this);this.setFieldValue(a,"NAME")},setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK",
"RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){for(var a=!1,b={},c=0;c<this.arguments_.length;c++){if(b["arg_"+this.arguments_[c].toLowerCase()]){a=!0;break}b["arg_"+this.arguments_[c].toLowerCase()]=!0}a?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null);a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));Blockly.Events.disable();this.setFieldValue(a,"PARAMS");Blockly.Events.enable()},
mutationToDom:function(a){var b=document.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c<this.arguments_.length;c++){var d=document.createElement("arg");d.setAttribute("name",this.arguments_[c]);a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];for(var b=0,c;c=a.childNodes[b];b++)"arg"==c.nodeName.toLowerCase()&&
this.arguments_.push(c.getAttribute("name"));this.updateParams_();Blockly.Procedures.mutateCallers(this);this.setStatements_("false"!==a.getAttribute("statements"))},decompose:function(a){var b=a.newBlock("procedures_mutatorcontainer");b.initSvg();this.getInput("RETURN")?b.setFieldValue(this.hasStatements_?"TRUE":"FALSE","STATEMENTS"):b.getInput("STATEMENT_INPUT").setVisible(!1);for(var c=b.getInput("STACK").connection,d=0;d<this.arguments_.length;d++){var e=a.newBlock("procedures_mutatorarg");e.initSvg();
e.setFieldValue(this.arguments_[d],"NAME");e.oldLocation=d;c.connect(e.previousConnection);c=e.nextConnection}Blockly.Procedures.mutateCallers(this);return b},compose:function(a){this.arguments_=[];this.paramIds_=[];for(var b=a.getInputTargetBlock("STACK");b;)this.arguments_.push(b.getFieldValue("NAME")),this.paramIds_.push(b.id),b=b.nextConnection&&b.nextConnection.targetBlock();this.updateParams_();Blockly.Procedures.mutateCallers(this);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"==a,
this.hasStatements_!=a))if(a)this.setStatements_(!0),Blockly.Mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null;else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.unplug(),a.bumpNeighbours_();this.setStatements_(!1)}},dispose:function(){var a=this.getFieldValue("NAME");Blockly.Procedures.disposeCallers(a,this.workspace);this.constructor.prototype.dispose.apply(this,arguments)},getProcedureDef:function(){return[this.getFieldValue("NAME"),
this.arguments_,!1]},getVars:function(){return this.arguments_},renameVar:function(a,b){for(var c=!1,d=0;d<this.arguments_.length;d++)Blockly.Names.equals(a,this.arguments_[d])&&(this.arguments_[d]=b,c=!0);if(c&&(this.updateParams_(),this.mutator.isVisible()))for(var c=this.mutator.workspace_.getAllBlocks(),d=0,e;e=c[d];d++)"procedures_mutatorarg"==e.type&&Blockly.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")},customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("NAME");
b.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=goog.dom.createDom("mutation");d.setAttribute("name",c);for(var e=0;e<this.arguments_.length;e++)c=goog.dom.createDom("arg"),c.setAttribute("name",this.arguments_[e]),d.appendChild(c);d=goog.dom.createDom("block",null,d);d.setAttribute("type",this.callType_);b.callback=Blockly.ContextMenu.callbackFactory(this,d);a.push(b);if(!this.isCollapsed())for(e=0;e<this.arguments_.length;e++)b={enabled:!0},c=this.arguments_[e],b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",
c),d=goog.dom.createDom("field",null,c),d.setAttribute("name","VAR"),d=goog.dom.createDom("block",null,d),d.setAttribute("type","variables_get"),b.callback=Blockly.ContextMenu.callbackFactory(this,d),a.push(b)},callType_:"procedures_callnoreturn"};
Blockly.Blocks.procedures_defreturn={init:function(){var a=new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT&&
this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);this.setColour(Blockly.CAT_PROCEDURE_RGB);this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.setStatements_(!0);this.statementConnection_=null},setStatements_:Blockly.Blocks.procedures_defnoreturn.setStatements_,validate:Blockly.Blocks.procedures_defnoreturn.validate,updateParams_:Blockly.Blocks.procedures_defnoreturn.updateParams_,mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,
domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,dispose:Blockly.Blocks.procedures_defnoreturn.dispose,getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},getVars:Blockly.Blocks.procedures_defnoreturn.getVars,renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,callType_:"procedures_callreturn"};
Blockly.Blocks.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new Blockly.FieldCheckbox("TRUE"),"STATEMENTS");this.setColour(Blockly.CAT_PROCEDURE_RGB);this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.procedures_mutatorarg={init:function(){this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(new Blockly.FieldTextInput("x",this.validator_),"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.CAT_PROCEDURE_RGB);this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1},validator_:function(a){return(a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""))||null}};
Blockly.Blocks.procedures_callnoreturn={init:function(){this.appendDummyInput("TOPROW").appendField(this.id,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkIds_=null},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,
"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=Blockly.Procedures.getDefinition(this.getProcedureCall(),this.workspace),d=c&&c.mutator&&c.mutator.isVisible();d||(this.quarkConnections_={},this.quarkIds_=null);if(b)if(goog.array.equals(this.arguments_,a))this.quarkIds_=b;else{if(b.length!=a.length)throw"Error: paramNames and paramIds must be the same length.";
this.setCollapsed(!1);this.quarkIds_||(this.quarkConnections_={},a.join("\n")==this.arguments_.join("\n")?this.quarkIds_=b:this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(var e=0;e<this.arguments_.length;e++){var f=this.getInput("ARG"+e);f&&(f=f.connection.targetConnection,this.quarkConnections_[this.quarkIds_[e]]=f,d&&f&&-1==b.indexOf(this.quarkIds_[e])&&(f.disconnect(),f.getSourceBlock().bumpNeighbours_()))}this.arguments_=[].concat(a);this.updateShape_();if(this.quarkIds_=b)for(e=0;e<this.arguments_.length;e++)d=
this.quarkIds_[e],d in this.quarkConnections_&&(f=this.quarkConnections_[d],Blockly.Mutator.reconnect(f,this,"ARG"+e)||delete this.quarkConnections_[d]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);b?(Blockly.Events.disable(),b.setValue(this.arguments_[a]),Blockly.Events.enable()):(b=new Blockly.FieldLabel(this.arguments_[a]),this.appendValueInput("ARG"+a).setAlign(Blockly.ALIGN_RIGHT).appendField(b,"ARGNAME"+
a).init())}for(;this.getInput("ARG"+a);)this.removeInput("ARG"+a),a++;if(a=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(a.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),a.init()):this.getField("WITH")&&a.removeField("WITH")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},
domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);for(var b=[],c=[],d=0,e;e=a.childNodes[d];d++)"arg"==e.nodeName.toLowerCase()&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,c)},renameVar:function(a,b){for(var c=0;c<this.arguments_.length;c++)Blockly.Names.equals(a,this.arguments_[c])&&(this.arguments_[c]=b,this.getField("ARGNAME"+c).setValue(b))},customContextMenu:function(a){var b={enabled:!0};
b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&a.select()};a.push(b)}};
Blockly.Blocks.procedures_callreturn={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setColour(Blockly.CAT_PROCEDURE_RGB);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkIds_=null},getProcedureCall:Blockly.Blocks.procedures_callnoreturn.getProcedureCall,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,setProcedureParameters_:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters_,
updateShape_:Blockly.Blocks.procedures_callnoreturn.updateShape_,mutationToDom:Blockly.Blocks.procedures_callnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callnoreturn.domToMutation,renameVar:Blockly.Blocks.procedures_callnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_callnoreturn.customContextMenu};
Blockly.Blocks.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},
mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("value",Number(this.hasReturnValue_));return a},domToMutation:function(a){this.hasReturnValue_=1==a.getAttribute("value");this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(a){a=!1;var b=this;do{if(-1!=this.FUNCTION_TYPES.indexOf(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?("procedures_defnoreturn"==b.type&&
this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=b.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING)},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};
Blockly.Blocks.robProcedures_defnoreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.setColour(Blockly.CAT_PROCEDURE_RGB);var a=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,this),b=new Blockly.FieldTextInput(a,Blockly.Procedures.robRename);b.nameOld=a;b.setSpellcheck(!1);this.appendDummyInput().appendField(b,"NAME").appendField("","WITH");this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);this.setMutator(new Blockly.MutatorPlus(["robProcedures_defnoreturn"]));
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.declare_=!1},validate:function(){var a=Blockly.Procedures.findLegalName(this.getFieldValue("NAME"),this);this.setFieldValue(a,"NAME")},getProcedureDef:function(){return[this.getFieldValue("NAME"),this,!1]},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("declare",1==this.declare_);return a},domToMutation:function(a){if(this.declare_="false"!=a.getAttribute("declare"))this.setFieldValue(Blockly.Msg.PROCEDURES_BEFORE_PARAMS,
"WITH"),a=this.getInput("STACK").connection.targetConnection,this.removeInput("STACK"),this.appendStatementInput("ST"),this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),a&&this.getInput("STACK").connection.connect(a)},updateShape_:function(a){if(1==a){if(!this.declare_){this.declare_=!0;this.setFieldValue(Blockly.Msg.PROCEDURES_BEFORE_PARAMS,"WITH");var b=this.getInput("STACK").connection.targetConnection;this.removeInput("STACK");this.appendStatementInput("ST");
this.getInput("ST").connection.setCheck("declaration_only");this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);b&&this.getInput("STACK").connection.connect(b)}b=this.workspace.newBlock("robLocalVariables_declare");b.initSvg();b.render();var c;if(this.getInput("ST").connection.targetConnection){if(c=this.getInput("ST").connection.targetConnection.sourceBlock_)for(;c.getNextBlock();)c=c.getNextBlock();c.setNext(!0);c=c.nextConnection}else c=this.getInput("ST").connection;
c.connect(b.previousConnection);Blockly.Procedures.updateCallers(b.getFieldValue("VAR"),"Number",this.workspace,a)}else-1==a&&(this.setFieldValue("","WITH"),this.removeInput("ST"),this.declare_=!1)}};
Blockly.Blocks.robProcedures_defreturn={init:function(){var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_NUMBER,"Array_Number"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_BOOLEAN,"Array_Boolean"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_STRING,"Array_String"]],function(a){a&&
this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType(a)});this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.setColour(Blockly.CAT_PROCEDURE_RGB);var b=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,this),c=new Blockly.FieldTextInput(b,Blockly.Procedures.robRename);c.nameOld=b;c.setSpellcheck(!1);this.appendDummyInput().appendField(c,"NAME").appendField("","WITH");this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);
this.setMutator(new Blockly.MutatorPlus(["robProcedures_defreturn"]));this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.GET).appendField(a,"TYPE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_BACK).setCheck("Number");this.declare_=!1;this.returnType_="Number"},validate:function(){var a=Blockly.Procedures.findLegalName(this.getFieldValue("NAME"),this);this.setFieldValue(a,"NAME")},getProcedureDef:function(){return[this.getFieldValue("NAME"),
this,!0]},getReturnType:function(){return this.returnType_},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("declare",1==this.declare_);a.setAttribute("return_type",this.returnType_);return a},domToMutation:function(a){(this.declare_="false"!=a.getAttribute("declare"))&&this.addDeclarationStatement_();(this.returnType_=a.getAttribute("return_type"))&&this.updateType(this.returnType_)},updateShape_:function(a,b){if(1==a){this.declare_||(this.addDeclarationStatement_(),
this.declare_=!0);var c=this.workspace.newBlock("robLocalVariables_declare");c.initSvg();c.render();var d;if(this.getInput("ST").connection.targetConnection){if(d=this.getInput("ST").connection.targetConnection.sourceBlock_)for(;d.getNextBlock();)d=d.getNextBlock();d.setNext(!0);d=d.nextConnection}else d=this.getInput("ST").connection;d.connect(c.previousConnection);Blockly.Procedures.updateCallers(c.getFieldValue("VAR"),"Number",this.workspace,a)}else 0==a?(c=b||this.getFieldValue("TYPE"),this.getInput("RETURN").connection.setCheck(c)):
-1==a&&(this.setFieldValue("","WITH"),this.removeInput("ST"),this.declare_=!1)},addDeclarationStatement_:function(){var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_NUMBER,"Array_Number"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_BOOLEAN,"Array_Boolean"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_STRING,
"Array_String"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType(a)});this.setFieldValue(Blockly.Msg.PROCEDURES_BEFORE_PARAMS,"WITH");var b=this.getInput("RETURN").connection.targetConnection,c=this.getInput("STACK").connection.targetConnection;this.removeInput("RETURN");this.removeInput("STACK");this.appendStatementInput("ST");this.getInput("ST").connection.setCheck("declaration_only");this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);
this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.GET).appendField(a,"TYPE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_BACK).setCheck(this.returnType_);this.setFieldValue(this.returnType_,"TYPE");b&&this.getInput("RETURN").connection.connect(b);c&&this.getInput("STACK").connection.connect(c)},updateType:function(a){a&&this.getFieldValue("TYPE")!==a&&(this.returnType_=a,this.updateShape_(0,this.returnType_),Blockly.Procedures.updateCallers(this.getFieldValue("NAME"),
this.returnType_,this.workspace,99,this.getFieldValue("NAME")))}};
Blockly.Blocks.robProcedures_callnoreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.setColour(Blockly.CAT_PROCEDURE_RGB);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL).appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.arguments_=[];this.argumentsTypes_=[]},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,this.getProcedureCall())&&
(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters:function(a,b){if(b.length!=a.length)throw"Error: paramNames and paramIds must be the same length.";var c=this.rendered;this.rendered=!1;for(var d=[],e=this.arguments_.length-1;0<=e;e--){var f=this.getInput("ARG"+e);if(f){var g=f.connection.targetConnection,f=f.fieldRow[0].getText();d[e]={name:f,conn:g};
this.removeInput("ARG"+e)}}this.arguments_=[].concat(a);this.argumentsTypes_=[].concat(b);for(e=0;e<this.arguments_.length;e++)if(f=this.appendValueInput("ARG"+e).setAlign(Blockly.ALIGN_RIGHT).appendField(this.arguments_[e]).setCheck(this.argumentsTypes_[e]),f.init(),0<d.length){for(g=0;g<d.length;g++)if(d[g].name==this.arguments_[e]){var h=d[g];d.splice(g,1);break}h&&h.conn&&((g=h.conn)&&g.targetConnection&&g.sourceBlock_.workspace!=this.workspace||f.connection.connect(g))}for(g=0;g<d.length;g++)(e=
d[g])&&e.conn&&(e.conn.sourceBlock_.moveBy(50,15),e.conn.sourceBlock_.setDisabled(!0));this.rendered=c;this.render()},updateProcedureParameters:function(a,b,c){if(1==c){c=this.arguments_.slice(0);var d=this.argumentsTypes_.slice(0);c.push(a);d.push(b);this.setProcedureParameters(c,d)}else-1==c?(c=this.arguments_.slice(0),d=this.argumentsTypes_.slice(0),a=this.arguments_.indexOf(a),0<=a&&(c.splice(a,1),d.splice(a,1),this.setProcedureParameters(c,d))):0==c&&(a=this.arguments_.indexOf(a),0<=a&&(this.argumentsTypes_[a]=
b,this.getInput("ARG"+a).setCheck(this.argumentsTypes_[a])));this.render()},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);c.setAttribute("type",this.argumentsTypes_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.setFieldValue(b,"NAME");this.setTooltip((this.outputConnection?
Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b));Blockly.Procedures.getDefinition(b,this.workspace);this.arguments_=[];this.argumentsTypes_=[];for(var b=0,c;c=a.childNodes[b];b++)"arg"==c.nodeName.toLowerCase()&&(this.arguments_.push(c.getAttribute("name")),this.argumentsTypes_.push(c.getAttribute("type")));this.setProcedureParameters(this.arguments_,this.argumentsTypes_)},renameVar:function(a,b){for(var c=0;c<this.arguments_.length;c++)Blockly.Names.equals(a,
this.arguments_[c])&&(this.arguments_[c]=b,this.getInput("ARG"+c).fieldRow[0].setText(b))},customContextMenu:function(a){var b={enabled:!0};b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&a.select()};a.push(b)}};
Blockly.Blocks.robProcedures_callreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.setColour(Blockly.CAT_PROCEDURE_RGB);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL).appendField("","NAME");this.setOutput(!0,"Number");this.arguments_=[];this.argumentsTypes_=[];this.outputType_="Number"},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,this.getProcedureCall())&&
(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters:function(a,b){if(b.length!=a.length)throw"Error: paramNames and paramIds must be the same length.";var c=this.rendered;this.rendered=!1;for(var d=[],e=this.arguments_.length-1;0<=e;e--){var f=this.getInput("ARG"+e);if(f){var g=f.connection.targetConnection,f=f.fieldRow[0].getText();d[e]={name:f,conn:g};
this.removeInput("ARG"+e)}}this.arguments_=[].concat(a);this.argumentsTypes_=[].concat(b);for(e=0;e<this.arguments_.length;e++)if(f=this.appendValueInput("ARG"+e).setAlign(Blockly.ALIGN_RIGHT).appendField(this.arguments_[e]).setCheck(this.argumentsTypes_[e]),f.init(),0<d.length){for(g=0;g<d.length;g++)if(d[g].name==this.arguments_[e]){var h=d[g];d.splice(g,1);break}h&&h.conn&&((g=h.conn)&&g.targetConnection&&g.sourceBlock_.workspace!=this.workspace||f.connection.connect(g))}for(g=0;g<d.length;g++)(e=
d[g])&&e.conn&&(e.conn.sourceBlock_.moveBy(50,15),e.conn.sourceBlock_.setDisabled(!0));this.rendered=c;this.render()},updateProcedureParameters:function(a,b,c){if(1==c){c=this.arguments_.slice(0);var d=this.argumentsTypes_.slice(0);c.push(a);d.push(b);this.setProcedureParameters(c,d)}else-1==c?(c=this.arguments_.slice(0),d=this.argumentsTypes_.slice(0),a=this.arguments_.indexOf(a),0<=a&&(c.splice(a,1),d.splice(a,1),this.setProcedureParameters(c,d))):0==c?(a=this.arguments_.indexOf(a),0<=a&&(this.argumentsTypes_[a]=
b,this.getInput("ARG"+a).setCheck(this.argumentsTypes_[a]))):99==c&&(this.outputType_=b,this.outputConnection.setCheck(this.outputType_));this.render()},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);c.setAttribute("type",this.argumentsTypes_[b]);a.appendChild(c)}a.setAttribute("output_type",this.outputType_);return a},
domToMutation:function(a){var b=a.getAttribute("name");this.setFieldValue(b,"NAME");this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b));Blockly.Procedures.getDefinition(b,this.workspace);this.arguments_=[];this.argumentsTypes_=[];for(var b=0,c;c=a.childNodes[b];b++)"arg"==c.nodeName.toLowerCase()&&(this.arguments_.push(c.getAttribute("name")),this.argumentsTypes_.push(c.getAttribute("type")));this.setProcedureParameters(this.arguments_,
this.argumentsTypes_);this.outputType_=a.getAttribute("output_type");this.setOutput(!0,this.outputType_)},renameVar:function(a,b){for(var c=0;c<this.arguments_.length;c++)Blockly.Names.equals(a,this.arguments_[c])&&(this.arguments_[c]=b,this.getInput("ARG"+c).fieldRow[0].setText(b))},customContextMenu:function(a){var b={enabled:!0};b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&a.select()};
a.push(b)}};
Blockly.Blocks.robProcedures_ifreturn={init:function(){this.setHelpUrl("http://c2.com/cgi/wiki?GuardClause");this.setColour(Blockly.CAT_PROCEDURE_RGB);this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);this.hasReturnValue_=!0;this.returnType_=
null},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("value",Number(this.hasReturnValue_));this.returnType_&&a.setAttribute("return_type",this.returnType_);return a},domToMutation:function(a){(this.hasReturnValue_=1==a.getAttribute("value"))?this.returnType_&&this.getInput("VALUE").setCheck(this.returnType_):(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))},getProcedureCall:function(){return this.type},
updateProcedureParameters:function(a,b,c){if(99==c){c=this;do{if("robProcedures_defreturn"==c.type&&c.getFieldValue("NAME")==a){this.returnType_=b;this.getInput("VALUE").setCheck(this.returnType_);this.render();break}c=c.getSurroundParent()}while(c)}},onchange:function(){var a=!1,b=this;do{if("robProcedures_defnoreturn"==b.type||"robProcedures_defreturn"==b.type){a=!0;break}b=b.getSurroundParent()}while(b);a?("robProcedures_defnoreturn"==b.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),
this.hasReturnValue_=!1):"robProcedures_defreturn"!=b.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),"robProcedures_defreturn"==b.type&&(this.returnType_=b.getReturnType(),this.getInput("VALUE").setCheck(this.returnType_),this.render()),this.setWarningText(null)):(this.returnType_=null,this.hasReturnValue&&this.getInput("VALUE").setCheck(this.returnType_),this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING))}};Blockly.Blocks.simSensors={};
Blockly.Blocks.sim_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TOUCH+Blockly.Msg.SENSOR_PRESSED,"TOUCH"],[Blockly.Msg.MODE_DISTANCE+" "+Blockly.Msg.SENSOR_ULTRASONIC,"ULTRASONIC_DISTANCE"],[Blockly.Msg.MODE_COLOUR+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_COLOUR"],[Blockly.Msg.MODE_LIGHT+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_LIGHT"]],function(a){a&&this.sourceBlock_.getFieldValue("SENSORTYPE")!==a&&this.sourceBlock_.updateShape_(a)}),
b=new Blockly.Field("1",!1);b.setVisible(!1);this.appendDummyInput("DROPDOWN").appendField(Blockly.Msg.GET,"GET").appendField(a,"SENSORTYPE").appendField(b,"SENSORPORT");this.sensorType_="TOUCH";this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.GETSAMPLE_TOOLTIP);this.setMovable(!1);this.setDeletable(!1)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("input",this.sensorType_);return a},domToMutation:function(a){this.sensorType_=a.getAttribute("input");this.updateShape_(this.sensorType_)},
updateShape_:function(a){this.sensorType_=a;a=new Blockly.Field("1",!1);a.setVisible(!1);new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TIMER+" 1","1"],[Blockly.Msg.SENSOR_TIMER+" 2","2"],[Blockly.Msg.SENSOR_TIMER+" 3","3"],[Blockly.Msg.SENSOR_TIMER+" 4","4"],[Blockly.Msg.SENSOR_TIMER+" 5","5"]]);for(var b=this.getInput("DROPDOWN"),c=[],d=0,e;e=b.fieldRow[d];d++)"SENSORTYPE"!==e.name&&"GET"!==e.name&&c.push(e.name);for(d=0;d<c.length;d++)b.removeField(c[d]);b.appendField(a,"SENSORPORT");"TOUCH"==
this.sensorType_?(this.appendValue_("BOOL"),this.changeOutput("Boolean")):"ULTRASONIC_DISTANCE"==this.sensorType_?(this.appendValue_("NUM"),a.setValue("4"),this.changeOutput("Number")):"COLOUR_COLOUR"==this.sensorType_?(this.appendValue_("COLOUR"),a.setValue("3"),this.changeOutput("Colour")):"COLOUR_LIGHT"==this.sensorType_&&(this.appendValue_("NUM"),a.setValue("3"),this.changeOutput("Number"))},appendValue_:function(a,b){b=b||30;var c=this.getParent();c&&"logic_compare"!=c.type&&(c=null);if(c){c.getInputTargetBlock("B")&&
c.getInputTargetBlock("B").dispose();var d;c.updateShape(a);"NUM"==a?(d=this.workspace.newBlock("math_number"),d.setFieldValue(b.toString(),"NUM")):"NUM_REV"==a?(d=this.workspace.newBlock("math_number"),d.setFieldValue(b.toString(),"NUM")):"BOOL"==a?d=this.workspace.newBlock("logic_boolean"):(d=this.workspace.newBlock("robColour_picker"),d.setFieldValue("#b30006","COLOUR"));d.initSvg();d.render();c.getInput("B").connection.connect(d.outputConnection)}}};
Blockly.Blocks.sim_touch_isPressed={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.Field("1",!1);a.setVisible(!1);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_TOUCH).appendField(a,"SENSORPORT").appendField(Blockly.Msg.SENSOR_IS_PRESSED);this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.TOUCH_ISPRESSED_TOOLTIP)}};
Blockly.Blocks.sim_ultrasonic_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.Field("4");a.setVisible(!1);var b=new Blockly.FieldDropdown([[Blockly.Msg.MODE_DISTANCE,"DISTANCE"]],function(a){a&&this.sourceBlock_.getFieldValue("MODE")!==a&&this.sourceBlock_.updateShape_(a)});this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(b,"MODE").appendField(Blockly.Msg.SENSOR_ULTRASONIC).appendField(a,"SENSORPORT");this.sensorMode_="DISTANCE";this.setOutput(!0,
"Number");this.setTooltip(Blockly.Msg.ULTRASONIC_GETSAMPLE_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("mode",this.sensorMode_);return a},domToMutation:function(a){this.sensorMode_=a.getAttribute("mode");this.updateShape_(this.sensorMode_)},updateShape_:function(a){this.sensorMode_=a;"DISTANCE"==this.sensorMode_?this.changeOutput("Number"):"PRESENCE"==this.sensorMode_&&this.changeOutput("Boolean")}};
Blockly.Blocks.sim_colour_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MODE_COLOUR,"COLOUR"],[Blockly.Msg.MODE_LIGHT,"RED"]],function(a){a&&this.sourceBlock_.getFieldValue("MODE")!==a&&this.sourceBlock_.updateShape_(a)}),b=new Blockly.Field("4");b.setVisible(!1);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(a,"MODE").appendField(Blockly.Msg.SENSOR_COLOUR).appendField(b,"SENSORPORT");this.setOutput(!0,"Colour");this.setTooltip(Blockly.Msg.COLOUR_GETSAMPLE_TOOLTIP);
this.sensorMode_="COLOUR"},mutationToDom:Blockly.Blocks.sim_ultrasonic_getSample.mutationToDom,domToMutation:Blockly.Blocks.sim_ultrasonic_getSample.domToMutation,updateShape_:function(a){this.sensorMode_=a;"COLOUR"==this.sensorMode_?this.changeOutput("Colour"):"RGB"==this.sensorMode_?this.changeOutput("Array_Number"):this.changeOutput("Number")}};Blockly.Blocks.robColour={};
Blockly.Blocks.robColour_picker={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_PICKER_HELPURL);this.setColour(Blockly.CAT_COLOUR_RGB);var a=new Blockly.FieldColour("#585858");"nxt"===this.workspace.device?(Blockly.FieldColour.COLUMNS=7,Blockly.FieldColour.COLOURS="#585858 #000000 #0057a6 #00642e #f7d117 #b30006 #FFFFFF".split(" "),this.data="nxt"):(Blockly.FieldColour.COLUMNS=8,Blockly.FieldColour.COLOURS="#585858 #000000 #0057a6 #00642e #f7d117 #b30006 #FFFFFF #532115".split(" "),this.data=
"ev3");this.appendDummyInput().appendField(a,"COLOUR");this.setOutput(!0,"Colour");this.setTooltip(Blockly.Msg.COLOUR_PICKER_TOOLTIP)}};Blockly.Blocks.texts={};Blockly.Blocks.texts.HUE=160;
Blockly.Blocks.text={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");var a=this;this.setTooltip(function(){var b=a.getParent();return b&&b.getInputsInline()&&b.tooltip||Blockly.Msg.TEXT_TEXT_TOOLTIP})},newQuote_:function(a){return new Blockly.FieldImage(a==this.RTL?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==":
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",12,12,'"')}};
Blockly.Blocks.text_join={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.itemCount_=2;this.updateShape_();this.setOutput(!0,"String");this.setMutator(new Blockly.Mutator(["text_create_join_item"]));this.setTooltip(Blockly.Msg.TEXT_JOIN_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},
decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&
-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));
for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++},newQuote_:Blockly.Blocks.text.newQuote_};
Blockly.Blocks.text_create_join_container={init:function(){this.setColour(Blockly.CAT_TEXT_RGB);this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.text_create_join_item={init:function(){this.setColour(Blockly.CAT_TEXT_RGB);this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.text_append={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.appendValueInput("TEXT").appendField(Blockly.Msg.TEXT_APPEND_TO).appendField(new Blockly.FieldVariable(Blockly.Msg.TEXT_APPEND_VARIABLE),"VAR").appendField(Blockly.Msg.TEXT_APPEND_APPENDTEXT);this.setPreviousStatement(!0);this.setNextStatement(!0);var a=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};
Blockly.Blocks.text_length={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",colour:Blockly.CAT_TEXT_RGB,tooltip:Blockly.Msg.TEXT_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.TEXT_LENGTH_HELPURL})}};
Blockly.Blocks.text_isEmpty={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_ISEMPTY_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",colour:Blockly.CAT_TEXT_RGB,tooltip:Blockly.Msg.TEXT_ISEMPTY_TOOLTIP,helpUrl:Blockly.Msg.TEXT_ISEMPTY_HELPURL})}};
Blockly.Blocks.text_indexOf={init:function(){var a=[[Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST,"FIRST"],[Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.TEXT_INDEXOF_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT);this.appendValueInput("FIND").setCheck("String").appendField(new Blockly.FieldDropdown(a),"END");Blockly.Msg.TEXT_INDEXOF_TAIL&&this.appendDummyInput().appendField(Blockly.Msg.TEXT_INDEXOF_TAIL);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.TEXT_INDEXOF_TOOLTIP)}};
Blockly.Blocks.text_charAt={init:function(){this.WHERE_OPTIONS=[[Blockly.Msg.TEXT_CHARAT_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_CHARAT_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_CHARAT_FIRST,"FIRST"],[Blockly.Msg.TEXT_CHARAT_LAST,"LAST"],[Blockly.Msg.TEXT_CHARAT_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.TEXT_CHARAT_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.setOutput(!0,"String");this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_CHARAT_INPUT_INTEXT);this.appendDummyInput("AT");
this.setInputsInline(!0);this.updateAt_(!0);this.setTooltip(Blockly.Msg.TEXT_CHARAT_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):
this.appendDummyInput("AT");Blockly.Msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_CHARAT_TAIL));var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var d="FROM_START"==b||"FROM_END"==b;if(d!=a){var e=this.sourceBlock_;e.updateAt_(d);e.setFieldValue(b,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE")}};
Blockly.Blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);
this.appendValueInput("STRING").setCheck("String").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL);this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),
b=this.getInput("AT1").type==Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):
this.appendDummyInput("AT"+a);2==a&&Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var f=this.sourceBlock_;f.updateAt_(a,e);f.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&this.moveInputBefore("AT1","AT2")}};
Blockly.Blocks.text_changeCase={init:function(){var a=[[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a),"CASE");this.setOutput(!0,"String");this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP)}};
Blockly.Blocks.text_trim={init:function(){var a=[[Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a),"MODE");this.setOutput(!0,"String");this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)}};
Blockly.Blocks.text_print={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_TEXT_RGB,tooltip:Blockly.Msg.TEXT_PRINT_TOOLTIP,helpUrl:Blockly.Msg.TEXT_PRINT_HELPURL})}};
Blockly.Blocks.text_prompt_ext={init:function(){var a=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);var b=this,a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendValueInput("TEXT").appendField(a,"TYPE");this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"==b.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})},
updateType_:function(a){this.outputConnection.setCheck("NUMBER"==a?"Number":"String")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
Blockly.Blocks.text_prompt={init:function(){var a=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],b=this;this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"==
b.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})},newQuote_:Blockly.Blocks.text.newQuote_,updateType_:Blockly.Blocks.text_prompt_ext.updateType_,mutationToDom:Blockly.Blocks.text_prompt_ext.mutationToDom,domToMutation:Blockly.Blocks.text_prompt_ext.domToMutation};
Blockly.Blocks.robText_join={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.appendValueInput("ADD0").appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH);this.appendValueInput("ADD1");this.setOutput(!0,"String");this.setMutatorPlus(new Blockly.MutatorPlus(this));this.setTooltip(Blockly.Msg.TEXT_JOIN_TOOLTIP);this.itemCount_=2},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},
domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);for(a=2;a<this.itemCount_;a++)this.appendValueInput("ADD"+a),2==a&&this.setMutatorMinus(new Blockly.MutatorMinus(this))},updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;if(1==a)2==this.itemCount_&&(this.setMutatorMinus(new Blockly.MutatorMinus(this)),this.render()),this.appendValueInput("ADD"+this.itemCount_),this.itemCount_++;else if(-1==a){this.itemCount_--;if(a=this.getInputTargetBlock("ADD"+this.itemCount_))a.unplug(),
a.bumpNeighbours_();this.removeInput("ADD"+this.itemCount_)}2==this.itemCount_&&(this.mutatorMinus.dispose(),this.mutatorMinus=null,this.render())}};
Blockly.Blocks.robText_append={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL);this.setColour(Blockly.CAT_TEXT_RGB);this.setInputsInline(!0);this.appendValueInput("VAR").appendField(Blockly.Msg.TEXT_APPEND_TO).setCheck("String");this.appendValueInput("TEXT").appendField(Blockly.Msg.TEXT_APPEND_APPENDTEXT);this.setPreviousStatement(!0);this.setNextStatement(!0);var a=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};Blockly.Blocks.variables={};Blockly.Blocks.variables.HUE=330;
Blockly.Blocks.variables_get={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);this.setColour(Blockly.CAT_VARIABLE_RGB);this.appendDummyInput().appendField(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_DEFAULT_NAME),"VAR");this.setOutput(!0);this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);this.contextMenuMsg_=Blockly.Msg.VARIABLES_GET_CREATE_SET;this.dataType_=null},getVars:function(){return[this.getFieldValue("VAR")]},setType:function(a,b){b!==this.dataType_&&(this.dataType_=
b,this.setOutput(!0,this.dataType_))},mutationToDom:function(){if(!this.dataType_)return null;var a=document.createElement("mutation");this.dataType_&&a.setAttribute("datatype",this.dataType_);return a},domToMutation:function(a){(a=a.getAttribute("datatype")||Blockly.Variables.getType(this.getFieldValue("VAR")))&&this.workspace.variableDeclaration&&(this.dataType_=a,this.setOutput(!0,this.dataType_))},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,
"VAR")},onchange:function(){if(this.workspace&&Blockly.getMainWorkspace().variableDeclaration){var a=this.getFieldValue("VAR");if(a=Blockly.Variables.getProcedureName(a)){var b=!1,c=this;do{if(("robProcedures_defnoreturn"==c.type||"robProcedures_defreturn"==c.type)&&c.getFieldValue("NAME")==a){b=!0;break}if(c.id===a){b=!0;break}if("global"===a){b=!0;break}c=c.getSurroundParent()}while(c);b?this.setErrorText(null):a.match(/^[a-zA-Z][a-zA-Z0-9_]*$/)?this.setErrorText(Blockly.Msg.PROCEDURES_VARIABLES_ERROR+
a+Blockly.Msg.PROCEDURES_TITLE):this.setErrorText(Blockly.Msg.PROCEDURES_VARIABLES_LOOP_ERROR+this.getFieldValue("VAR"))}}},contextMenuType_:"variables_set",customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=this.contextMenuMsg_.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type",this.contextMenuType_);c.setAttribute("intask",!1);var d=goog.dom.createDom("mutation");c.appendChild(d);
b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}};
Blockly.Blocks.variables_set={init:function(){this.jsonInit({message0:Blockly.Msg.VARIABLES_SET,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.VARIABLES_DEFAULT_NAME},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_VARIABLE_RGB,tooltip:Blockly.Msg.VARIABLES_SET_TOOLTIP,helpUrl:Blockly.Msg.VARIABLES_SET_HELPURL});this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET},getVars:function(){return[this.getFieldValue("VAR")]},setType:function(a,
b){this.dataType_=b;this.getInput("VALUE").setCheck(this.dataType_)},mutationToDom:function(){if(!this.dataType_)return null;var a=document.createElement("mutation");this.dataType_&&a.setAttribute("datatype",this.dataType_);return a},domToMutation:function(a){(a=a.getAttribute("datatype")||Blockly.Variables.getType(this.getFieldValue("VAR")))&&this.workspace.variableDeclaration&&(this.dataType_=a,this.getInput("VALUE").setCheck(this.dataType_))},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&
this.setFieldValue(b,"VAR")},onchange:Blockly.Blocks.variables_get.onchange,contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu};
Blockly.Blocks.robGlobalVariables_declare={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL);this.setColour(Blockly.CAT_ACTIVITY_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_NUMBER,"Array_Number"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_BOOLEAN,
"Array_Boolean"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_STRING,"Array_String"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_CONNECTION,"Array_Connection"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&(this.sourceBlock_.updateType(a),this.sourceBlock_.updateShape_(0,a))}),b=Blockly.Variables.findLegalName(Blockly.Msg.VARIABLES_DEFAULT_NAME,this);this.nameOld=b;b=new Blockly.FieldTextInput(b,this.validateName);this.appendValueInput("VALUE").appendField(Blockly.Msg.VARIABLES_TITLE).appendField(b,"VAR").appendField(":").appendField(a,
"TYPE").appendField(Blockly.RTL?"\u2192":"\u2190").setCheck("Number");this.setPreviousStatement(!0,"declaration_only");this.setMutatorMinus(new Blockly.MutatorMinus(["robGlobalVariables_declare"]));this.setMovable(!1);this.setDeletable(!1);this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET;this.contextMenudeclarationType_="variables_get";this.declarationType_="Number";this.nextStatement_=!1;this.setNextStatement(!1)},validate:function(){var a=Blockly.Variables.findLegalName(this.getFieldValue("VAR"),
this);this.setFieldValue(a,"VAR")},validateName:function(a){var b=this.sourceBlock_;a=a.replace(/[\s\xa0]+/g,"").replace(/^ | $/g,"");if(""===a||!a.match(/^[a-zA-Z][a-zA-Z_$0-9]*$/))return null;a=Blockly.Variables.findLegalName(a,b);Blockly.Variables.renameVariable(b.nameOld,a,Blockly.getMainWorkspace());return b.nameOld=a},mutationToDom:function(){if(void 0===this.nextStatement_||void 0===this.declarationType_)return!1;var a=document.createElement("mutation");a.setAttribute("next",this.nextStatement_);
a.setAttribute("declaration_type",this.declarationType_);return a},domToMutation:function(a){(this.nextStatement_="true"==a.getAttribute("next"))&&this.setNext(this.nextStatement_);(this.declarationType_=a.getAttribute("declaration_type"))&&this.getInput("VALUE").setCheck(this.declarationType_)},setNext:function(a){this.nextStatement_=a;this.setNextStatement(a,"declaration_only")},getType:function(){return this.declarationType_},getVarDecl:function(){return[this.getFieldValue("VAR")]},getVars:function(){return[this.getFieldValue("VAR")]},
updateShape_:function(a,b){if(-1==a){var c=this.getParent(),d=this.getNextBlock();this.unplug(!0,!0);c&&"robControls_start"==c.type&&!d?c.updateShape_(a):c&&!d&&c.setNext(!1);Blockly.Variables.deleteAll(this.getFieldValue("VAR"));this.dispose()}else 0==a&&(this.getInputTargetBlock("VALUE")&&this.getInputTargetBlock("VALUE").dispose(),c=null,this.getInput("VALUE").setCheck(b),"Number"===b?c=this.workspace.newBlock("math_number"):"String"===b?c=this.workspace.newBlock("text"):"Boolean"===b?c=this.workspace.newBlock("logic_boolean"):
"Array"===b.substr(0,5)?(c=this.workspace.newBlock("robLists_create_with"),c.setFieldValue(b.substr(6),"LIST_TYPE")):"Colour"===b?c=this.workspace.newBlock("robColour_picker"):"Connection"===b&&(c=this.workspace.newBlock("logic_null")),d=this.getInput("VALUE"),c&&(c.initSvg(),c.render(),"Array"===b.substr(0,5)&&c.updateType_(b.substr(6)),d.connection.connect(c.outputConnection)))},updateType:function(a){this.declarationType_=a;Blockly.Variables.updateType(this.getFieldValue("VAR"),this.declarationType_)},
contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu};
Blockly.Blocks.robLocalVariables_declare={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL);this.setColour(Blockly.CAT_PROCEDURE_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_NUMBER,"Array_Number"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_BOOLEAN,
"Array_Boolean"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_STRING,"Array_String"],[Blockly.Msg.VARIABLES_TYPE_ARRAY_CONNECTION,"Array_Connection"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType(a)}),b=Blockly.Variables.findLegalName("x",this);this.nameOld=b;b=new Blockly.FieldTextInput(b,this.validateName);this.appendDummyInput().appendField(Blockly.Msg.VARIABLES_TITLE).appendField(b,"VAR").appendField(":").appendField(a,"TYPE");this.setPreviousStatement(!0,"declaration_only");
this.setTooltip(Blockly.Msg.VARIABLES_LOCAL_DECLARE_TOOLTIP);this.setMutatorMinus(new Blockly.MutatorMinus(this));this.setMovable(!1);this.setDeletable(!1);this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET;this.contextMenudeclarationType_="variables_get";this.nextStatement_=!1;this.declarationType_="Number"},validate:Blockly.Blocks.robGlobalVariables_declare.validate,validateName:Blockly.Blocks.robGlobalVariables_declare.validateName,mutationToDom:Blockly.Blocks.robGlobalVariables_declare.mutationToDom,
domToMutation:function(a){(this.nextStatement_="true"==a.getAttribute("next"))&&this.setNext(this.nextStatement_);this.declarationType_=a.getAttribute("declaration_type")},setNext:Blockly.Blocks.robGlobalVariables_declare.setNext,getType:function(){return this.declarationType_},getVarDecl:function(){return[this.getFieldValue("VAR")]},getVars:function(){return[this.getFieldValue("VAR")]},updateShape_:function(a,b){if(-1==a){Blockly.Variables.deleteAll(this.getFieldValue("VAR"));Blockly.Procedures.updateCallers(this.getFieldValue("VAR"),
this.declarationType_,this.workspace,a);var c=this.getParent(),d=this.getNextBlock();this.unplug(!0,!0);!c||"robProcedures_defnoreturn"!=c.type&&"robProcedures_defreturn"!=c.type||d?c&&!d&&c.setNextStatement(!1):c.updateShape_(a);this.dispose()}},updateType:function(a){this.declarationType_=a;Blockly.Variables.updateType(this.getFieldValue("VAR"),a);Blockly.Procedures.updateCallers(this.getFieldValue("VAR"),a,Blockly.mainWorkspace,0)},contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu};Blockly.Blocks.lists={};Blockly.Blocks.lists.HUE=260;Blockly.Blocks.lists_create_empty={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_CREATE_EMPTY_TITLE,output:"Array",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP,helpUrl:Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL})}};
Blockly.Blocks.lists_create_with={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),
10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;
c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||
this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++}};
Blockly.Blocks.lists_create_with_container={init:function(){this.setColour(Blockly.CAT_LIST_RGB);this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.lists_create_with_item={init:function(){this.setColour(Blockly.CAT_LIST_RGB);this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.lists_repeat={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_REPEAT_TITLE,args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.LISTS_REPEAT_HELPURL})}};
Blockly.Blocks.lists_length={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.LISTS_LENGTH_HELPURL})}};
Blockly.Blocks.lists_isEmpty={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_ISEMPTY_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_ISEMPTY_TOOLTIP,helpUrl:Blockly.Msg.LISTS_ISEMPTY_HELPURL})}};
Blockly.Blocks.lists_indexOf={init:function(){var a=[[Blockly.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[Blockly.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST);this.appendValueInput("FIND").appendField(new Blockly.FieldDropdown(a),"END");this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LISTS_INDEX_OF_TOOLTIP)}};
Blockly.Blocks.lists_getIndex={init:function(){var a=[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"],[Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[Blockly.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
this.setColour(Blockly.CAT_LIST_RGB);a=new Blockly.FieldDropdown(a,function(a){this.sourceBlock_.updateStatement_("REMOVE"==a)});this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(a,"MODE").appendField("","SPACE");this.appendDummyInput("AT");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0);this.updateAt_(!0);
var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE")+"_"+b.getFieldValue("WHERE");return Blockly.Msg["LISTS_GET_INDEX_TOOLTIP_"+a]})},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("statement",!this.outputConnection);var b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("statement");this.updateStatement_(b);a="false"!=a.getAttribute("at");this.updateAt_(a)},updateStatement_:function(a){a!=
!this.outputConnection&&(this.unplug(!0,!0),a?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,
function(b){var d="FROM_START"==b||"FROM_END"==b;if(d!=a){var e=this.sourceBlock_;e.updateAt_(d);e.setFieldValue(b,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};
Blockly.Blocks.lists_setIndex={init:function(){var a=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"],[Blockly.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
this.appendDummyInput().appendField(new Blockly.FieldDropdown(a),"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE")+"_"+b.getFieldValue("WHERE");return Blockly.Msg["LISTS_SET_INDEX_TOOLTIP_"+a]})},
mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,
function(b){var d="FROM_START"==b||"FROM_END"==b;if(d!=a){var e=this.sourceBlock_;e.updateAt_(d);e.setFieldValue(b,"WHERE");return null}});this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO");this.getInput("AT").appendField(b,"WHERE")}};
Blockly.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);
this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL);this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT1").type==
Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):
this.appendDummyInput("AT"+a);var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var f=this.sourceBlock_;f.updateAt_(a,e);f.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"));Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
Blockly.Blocks.lists_sort={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_SORT_TITLE,args0:[{type:"field_dropdown",name:"TYPE",options:[[Blockly.Msg.LISTS_SORT_TYPE_NUMERIC,"NUMERIC"],[Blockly.Msg.LISTS_SORT_TYPE_TEXT,"TEXT"],[Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE,"IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[[Blockly.Msg.LISTS_SORT_ORDER_ASCENDING,"1"],[Blockly.Msg.LISTS_SORT_ORDER_DESCENDING,"-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",colour:Blockly.Blocks.lists.HUE,
tooltip:Blockly.Msg.LISTS_SORT_TOOLTIP,helpUrl:Blockly.Msg.LISTS_SORT_HELPURL})}};
Blockly.Blocks.lists_split={init:function(){var a=this,b=new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(b){a.updateType_(b)});this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.appendValueInput("INPUT").setCheck("String").appendField(b,"MODE");this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0);this.setOutput(!0,
"Array");this.setTooltip(function(){var b=a.getFieldValue("MODE");if("SPLIT"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"==b)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw"Unknown mode: "+b;})},updateType_:function(a){"SPLIT"==a?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("mode",
this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))}};
Blockly.Blocks.robLists_create_with={init:function(){this.setColour(Blockly.CAT_LIST_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"]],function(a){this.sourceBlock_.updateType_(a)});this.appendValueInput("ADD0").appendField(Blockly.Msg.LISTS_CREATE_TITLE).appendField(":").appendField(a,
"LIST_TYPE").appendField(Blockly.RTL?"\u2192":"\u2190").setCheck("Number");this.setInputsInline(!1);this.appendValueInput("ADD1").setCheck("Number");this.appendValueInput("ADD2").setCheck("Number");this.setOutput(!0,"Array_Number");this.setMutatorPlus(new Blockly.MutatorPlus(this));this.setMutatorMinus(new Blockly.MutatorMinus(this));this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP);this.listType_="Number";this.itemCount_=3},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("items",
this.itemCount_);a.setAttribute("list_type",this.listType_);return a},domToMutation:function(a){for(var b=0;b<this.itemCount_;b++)this.removeInput("ADD"+b);this.itemCount_=parseInt(a.getAttribute("items"),10);this.listType_=a.getAttribute("list_type");var c=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,
"Connection"]],function(a){this.sourceBlock_.updateType_(a)});this.itemCount_=parseInt(a.getAttribute("items"),10);for(b=0;b<this.itemCount_;b++)0==b?(this.appendValueInput("ADD0").appendField(Blockly.Msg.LISTS_CREATE_TITLE).appendField(":").appendField(c,"LIST_TYPE").appendField(Blockly.RTL?"\u2192":"\u2190").setCheck(this.listType_),this.setInputsInline(!1)):this.appendValueInput("ADD"+b).setCheck(this.listType_);0==this.itemCount_?(this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE).appendField(":").appendField(c,
"LIST_TYPE"),this.mutatorMinus.dispose(),this.mutatorMinus=null):this.setMutatorMinus(new Blockly.MutatorMinus(this));this.setOutput(!0,"Array_"+this.listType_)},updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;var b=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"]],function(a){this.sourceBlock_.updateType_(a)});
b.setValue(this.listType_);if(1==a)0==this.itemCount_?(this.removeInput("EMPTY"),this.appendValueInput("ADD0").appendField(Blockly.Msg.LISTS_CREATE_TITLE).appendField(":").appendField(b,"LIST_TYPE").appendField(Blockly.RTL?"\u2192":"\u2190").setCheck(this.listType_),this.setInputsInline(!1),this.setMutatorMinus(new Blockly.MutatorMinus(this))):this.appendValueInput("ADD"+this.itemCount_).setCheck(this.listType_),a=this.getNewValue(),a.initSvg(),a.render(),this.getInput("ADD"+this.itemCount_).connection.connect(a.outputConnection),
this.itemCount_++;else if(-1==a){this.itemCount_--;if(a=this.getInputTargetBlock("ADD"+this.itemCount_))a.unplug(),a.bumpNeighbours_();this.removeInput("ADD"+this.itemCount_)}0==this.itemCount_&&(this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE).appendField(":").appendField(b,"LIST_TYPE"),this.mutatorMinus.dispose(),this.mutatorMinus=null);this.render()},updateType_:function(a){this.listType_=a;for(var b=0;b<this.itemCount_;b++){var c=this.getInputTargetBlock("ADD"+
b);c&&c.dispose();c=this.getInput("ADD"+b);c.setCheck(a);var d=this.getNewValue();d.initSvg();d.render();c.connection.connect(d.outputConnection)}this.setOutput(!0,"Array_"+this.listType_)},getNewValue:function(){var a;switch(this.listType_){case "Number":return a=this.workspace.newBlock("math_number");case "String":return a=this.workspace.newBlock("text");case "Boolean":return a=this.workspace.newBlock("logic_boolean");case "Colour":return a=this.workspace.newBlock("robColour_picker");case "Connection":return a=
this.workspace.newBlock("logic_null")}}};
Blockly.Blocks.robLists_repeat={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_REPEAT_TITLE,args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array_Number",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.LISTS_REPEAT_HELPURL});var a=this.getInput("ITEM").fieldRow[0].text_,b=this.getInput("NUM").fieldRow[0].text_,c=this.getInput("").fieldRow[0].text_;this.removeInput("NUM");this.removeInput("ITEM");this.removeInput("");
var d=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"]],function(a){this.sourceBlock_.updateType_(a)});this.appendValueInput("ITEM").appendField(a).appendField(d,"LIST_TYPE");this.appendValueInput("NUM").appendField(b).setCheck("Number");this.appendDummyInput().appendField(c);this.listType_=
"Number"},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("list_type",this.listType_);return a},domToMutation:function(a){this.listType_=a.getAttribute("list_type");this.updateType_(this.listType_)},updateType_:function(a){this.listType_=a;this.getInput("ITEM").setCheck(a);this.setOutput(!0,"Array_"+this.listType_)}};
Blockly.Blocks.robLists_length={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["Array_Number","Array_String","Array_Boolean","Array_Colour","Array_Connection"]}],output:"Number",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.LISTS_LENGTH_HELPURL})}};
Blockly.Blocks.robLists_isEmpty={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_ISEMPTY_TITLE,args0:[{type:"input_value",name:"VALUE",check:["Array_Number","Array_String","Array_Boolean","Array_Colour","Array_Connection"]}],output:"Boolean",colour:Blockly.CAT_LIST_RGB,tooltip:Blockly.Msg.LISTS_ISEMPTY_TOOLTIP,helpUrl:Blockly.Msg.LISTS_ISEMPTY_HELPURL})}};
Blockly.Blocks.robLists_indexOf={init:function(){var a=[[Blockly.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[Blockly.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck(["Array_Number","Array_String","Array_Boolean","Array_Colour","Array_Connection"]).appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST);this.appendValueInput("FIND").appendField(new Blockly.FieldDropdown(a),
"END");this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LISTS_INDEX_OF_TOOLTIP)},onchange:function(){if(this.workspace&&2!=Blockly.Block.dragMode_){var a=this.getInputTargetBlock("VALUE"),b=this.getInputTargetBlock("FIND");a?this.getInput("FIND").setCheck(a.outputConnection.check_[0].replace("Array_","")):this.getInput("FIND").setCheck("Number String Boolean Colour Connection String".split(" "));b?this.getInput("VALUE").setCheck("Array_"+b.outputConnection.check_[0]):this.getInput("VALUE").setCheck(["Array_Number",
"Array_String","Array_Boolean","Array_Colour","Array_Connection"]);this.render()}}};
Blockly.Blocks.robLists_getIndex={init:function(){var a;a="nxt"===this.workspace.device?[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"]]:[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"],[Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[Blockly.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS="nxt"===this.workspace.device?[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"]]:[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,
"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);a=new Blockly.FieldDropdown(a,function(a){this.sourceBlock_.updateStatement_("REMOVE"==a)});this.appendValueInput("VALUE").setCheck(["Array_Number","Array_String","Array_Boolean","Array_Colour","Array_Connection"]).appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(a,"MODE").appendField("",
"SPACE");this.appendDummyInput("AT");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0,["Number","String","Boolean","Colour","Connection"]);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE")+"_"+b.getFieldValue("WHERE");return Blockly.Msg["LISTS_GET_INDEX_TOOLTIP_"+a]})},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("statement",
!this.outputConnection);var b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("statement");this.updateStatement_(b);a="false"!=a.getAttribute("at");this.updateAt_(a)},updateStatement_:function(a){a!=!this.outputConnection&&(this.unplug(!0,!0),a?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(a){this.removeInput("AT");
this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var d="FROM_START"==b||"FROM_END"==b;if(d!=a){var e=this.sourceBlock_;e.updateAt_(d);e.setFieldValue(b,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",
null)},onchange:function(){if(this.workspace&&2!=Blockly.Block.dragMode_){var a=this.getInputTargetBlock("VALUE");a?this.setOutput(!0,a.outputConnection.check_[0].replace("Array_","")):this.setOutput(!0,"Number String Boolean Colour Connection String".split(" "));this.render()}}};
Blockly.Blocks.robLists_setIndex={init:function(){var a;"nxt"===this.workspace.device?(a=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"]],this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"]]):(a=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"],[Blockly.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]],this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],
[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]]);this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);this.appendValueInput("LIST").setCheck("Array_Number Array_String Array_Boolean Array_Colour Array_Connection String".split(" ")).appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(new Blockly.FieldDropdown(a),"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO);
this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE")+"_"+b.getFieldValue("WHERE");return Blockly.Msg["LISTS_SET_INDEX_TOOLTIP_"+a]})},mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");
this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var d="FROM_START"==b||"FROM_END"==b;if(d!=a){var e=this.sourceBlock_;e.updateAt_(d);e.setFieldValue(b,"WHERE");return null}});this.moveInputBefore("AT",
"TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO");this.getInput("AT").appendField(b,"WHERE")},onchange:function(){if(this.workspace&&2!=Blockly.Block.dragMode_){var a=this.getInputTargetBlock("LIST"),b=this.getInputTargetBlock("TO");a?this.getInput("TO").setCheck(a.outputConnection.check_[0].replace("Array_","")):this.getInput("TO").setCheck("Number String Boolean Colour Connection String".split(" "));b?this.getInput("LIST").setCheck("Array_"+b.outputConnection.check_[0]):this.getInput("LIST").setCheck("Array_Number Array_String Array_Boolean Array_Colour Array_Connection String".split(" "));
this.render()}}};
Blockly.Blocks.robLists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);this.setColour(Blockly.CAT_LIST_RGB);
this.appendValueInput("LIST").setCheck("Array_Number Array_String Array_Boolean Array_Colour Array_Connection String".split(" ")).appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL);this.setInputsInline(!0);this.setOutput(!0,"Array_Number Array_String Array_Boolean Array_Colour Array_Connection String".split(" "));this.updateAt_(1,
!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b=this.getInput("AT1").type==Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+
a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var f=this.sourceBlock_;f.updateAt_(a,e);f.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&
this.moveInputBefore("ORDINAL1","AT2"));Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)},onchange:function(){if(this.workspace&&2!=Blockly.Block.dragMode_){var a=this.getInputTargetBlock("LIST");a?this.setOutput(!0,a.outputConnection.check_[0]):this.setOutput(!0,"Array_Number Array_String Array_Boolean Array_Colour Array_Connection String".split(" "));this.render()}}};Blockly.Blocks.robSensors={};
Blockly.Blocks.robSensors_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a;"nxt"===this.workspace.device?(a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TOUCH+Blockly.Msg.SENSOR_PRESSED,"TOUCH"],[Blockly.Msg.MODE_SOUND+" "+Blockly.Msg.SENSOR_SOUND,"SOUND_SOUND"],[Blockly.Msg.MODE_LIGHT+" "+Blockly.Msg.SENSOR_LIGHT,"LIGHT_LIGHT"],[Blockly.Msg.MODE_AMBIENTLIGHT+" "+Blockly.Msg.SENSOR_LIGHT,"LIGHT_AMBIENTLIGHT"],[Blockly.Msg.MODE_DISTANCE+" "+Blockly.Msg.SENSOR_ULTRASONIC,"ULTRASONIC_DISTANCE"],
[Blockly.Msg.MODE_ROTATION+" "+Blockly.Msg.SENSOR_ENCODER,"ENCODER_ROTATION"],[Blockly.Msg.MODE_DEGREE+" "+Blockly.Msg.SENSOR_ENCODER,"ENCODER_DEGREE"],[Blockly.Msg.SENSOR_KEY+" "+Blockly.Msg.SENSOR_PRESSED,"KEYS_PRESSED"],[Blockly.Msg.MODE_COLOUR+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_COLOUR"],[Blockly.Msg.MODE_LIGHT+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_LIGHT"],[Blockly.Msg.MODE_AMBIENTLIGHT+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_AMBIENTLIGHT"]],function(a){a&&this.sourceBlock_.getFieldValue("SENSORTYPE")!==
a&&this.sourceBlock_.updateShape_(a)}),this.data="nxt"):(a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TOUCH+Blockly.Msg.SENSOR_PRESSED,"TOUCH"],[Blockly.Msg.MODE_DISTANCE+" "+Blockly.Msg.SENSOR_ULTRASONIC,"ULTRASONIC_DISTANCE"],[Blockly.Msg.MODE_PRESENCE+" "+Blockly.Msg.SENSOR_ULTRASONIC,"ULTRASONIC_PRESENCE"],[Blockly.Msg.MODE_COLOUR+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_COLOUR"],[Blockly.Msg.MODE_LIGHT+" "+Blockly.Msg.SENSOR_COLOUR,"COLOUR_LIGHT"],[Blockly.Msg.MODE_AMBIENTLIGHT+" "+Blockly.Msg.SENSOR_COLOUR,
"COLOUR_AMBIENTLIGHT"],[Blockly.Msg.MODE_DISTANCE+" "+Blockly.Msg.SENSOR_INFRARED,"INFRARED_DISTANCE"],[Blockly.Msg.MODE_ROTATION+" "+Blockly.Msg.SENSOR_ENCODER,"ENCODER_ROTATION"],[Blockly.Msg.MODE_DEGREE+" "+Blockly.Msg.SENSOR_ENCODER,"ENCODER_DEGREE"],[Blockly.Msg.SENSOR_KEY+" "+Blockly.Msg.SENSOR_PRESSED,"KEYS_PRESSED"],[Blockly.Msg.MODE_ANGLE+" "+Blockly.Msg.SENSOR_GYRO,"GYRO_ANGLE"],[Blockly.Msg.MODE_RATE+" "+Blockly.Msg.SENSOR_GYRO,"GYRO_RATE"],[Blockly.Msg.SENSOR_TIME,"TIME"]],function(a){a&&
this.sourceBlock_.getFieldValue("SENSORTYPE")!==a&&this.sourceBlock_.updateShape_(a)}),this.data="ev3");var b=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput("DROPDOWN").appendField(Blockly.Msg.GET,"GET").appendField(a,"SENSORTYPE").appendField(b,"SENSORPORT");this.sensorType_="TOUCH";this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.GETSAMPLE_TOOLTIP);this.setMovable(!1);this.setDeletable(!1)},mutationToDom:function(){var a=document.createElement("mutation");
a.setAttribute("input",this.sensorType_);return a},domToMutation:function(a){this.sensorType_=a.getAttribute("input");this.updateShape_(this.sensorType_)},updateShape_:function(a){this.sensorType_=a;var b;"nxt"===this.workspace.device?(a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_KEY_ENTER,"ENTER"],[Blockly.Msg.SENSOR_KEY_LEFT,"LEFT"],[Blockly.Msg.SENSOR_KEY_RIGHT,"RIGHT"]]),b=new Blockly.FieldDropdown([["Motor Port A","A"],["Motor Port B","B"],["Motor Port C","C"]])):(a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_KEY_ENTER,
"ENTER"],[Blockly.Msg.SENSOR_KEY_UP,"UP"],[Blockly.Msg.SENSOR_KEY_DOWN,"DOWN"],[Blockly.Msg.SENSOR_KEY_LEFT,"LEFT"],[Blockly.Msg.SENSOR_KEY_RIGHT,"RIGHT"],[Blockly.Msg.SENSOR_KEY_ESCAPE,"ESCAPE"],[Blockly.Msg.SENSOR_KEY_ANY,"ANY"]]),b=new Blockly.FieldDropdown([["Motor Port A","A"],["Motor Port B","B"],["Motor Port C","C"],["Motor Port D","D"]]));for(var c=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]),d=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TIMER+
" 1","1"],[Blockly.Msg.SENSOR_TIMER+" 2","2"],[Blockly.Msg.SENSOR_TIMER+" 3","3"],[Blockly.Msg.SENSOR_TIMER+" 4","4"],[Blockly.Msg.SENSOR_TIMER+" 5","5"]]),e=this.getInput("DROPDOWN"),f=[],g=0,h;h=e.fieldRow[g];g++)"SENSORTYPE"!==h.name&&"GET"!==h.name&&f.push(h.name);for(g=0;g<f.length;g++)e.removeField(f[g]);"ENCODER_ROTATION"==this.sensorType_?(e.appendField(b,"MOTORPORT"),this.appendValue_("NUM_REV",2),this.setOutput(!0,"Number")):"ENCODER_DEGREE"==this.sensorType_?(e.appendField(b,"MOTORPORT"),
this.appendValue_("NUM_REV",180),this.setOutput(!0,"Number")):"KEYS_PRESSED"==this.sensorType_?(e.appendField(a,"KEY"),this.appendValue_("BOOL"),this.setOutput(!0,"Boolean")):"TIME"==this.sensorType_?(e.appendField(Blockly.Msg.SENSOR_MS_TIMER).appendField(d,"SENSORNUM"),this.appendValue_("NUM_REV",500),this.setOutput(!0,"Number")):(e.appendField(c,"SENSORPORT"),"TOUCH"==this.sensorType_?(this.appendValue_("BOOL"),this.setOutput(!0,"Boolean")):"SOUND_SOUND"==this.sensorType_?(this.appendValue_("NUM_REV",
50),c.setValue("2"),this.setOutput(!0,"Number")):"LIGHT_AMBIENTLIGHT"==this.sensorType_||"LIGHT_LIGHT"==this.sensorType_?(this.appendValue_("NUM",50),c.setValue("3"),this.setOutput(!0,"Number")):"GYRO_ANGLE"==this.sensorType_||"GYRO_RATE"==this.sensorType_?(this.appendValue_("NUM_REV",90),c.setValue("2"),this.setOutput(!0,"Number")):"ULTRASONIC_DISTANCE"==this.sensorType_?(this.appendValue_("NUM"),c.setValue("4"),this.setOutput(!0,"Number")):"ULTRASONIC_PRESENCE"==this.sensorType_?(this.appendValue_("BOOL"),
c.setValue("4"),this.setOutput(!0,"Boolean")):"COLOUR_COLOUR"==this.sensorType_?(this.appendValue_("COLOUR"),c.setValue("3"),this.setOutput(!0,"Colour")):"COLOUR_LIGHT"==this.sensorType_||"COLOUR_AMBIENTLIGHT"==this.sensorType_?(this.appendValue_("NUM",50),c.setValue("3"),this.setOutput(!0,"Number")):"INFRARED_DISTANCE"==this.sensorType_&&(this.appendValue_("NUM"),c.setValue("4"),this.setOutput(!0,"Number")))},appendValue_:function(a,b){b=b||30;var c=this.getParent();c&&"logic_compare"!=c.type&&(c=
null);if(c){c.getInputTargetBlock("B")&&c.getInputTargetBlock("B").dispose();var d;c.updateShape(a);"NUM"==a||"NUM_REV"==a?(d=this.workspace.newBlock("math_number"),d.setFieldValue(b.toString(),"NUM")):"BOOL"==a?d=this.workspace.newBlock("logic_boolean"):(d=this.workspace.newBlock("robColour_picker"),d.setFieldValue("#b30006","COLOUR"));d.initSvg();d.render();c.inTask||d.setInTask(!1);c.getInput("B").connection.connect(d.outputConnection)}}};
Blockly.Blocks.robSensors_touch_isPressed={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_TOUCH).appendField(a,"SENSORPORT").appendField(Blockly.Msg.SENSOR_IS_PRESSED);this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.TOUCH_ISPRESSED_TOOLTIP)}};
Blockly.Blocks.robSensors_key_isPressed={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a;a="nxt"===this.workspace.device?new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_KEY_ENTER,"ENTER"],[Blockly.Msg.SENSOR_KEY_LEFT,"LEFT"],[Blockly.Msg.SENSOR_KEY_RIGHT,"RIGHT"]]):new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_KEY_ENTER,"ENTER"],[Blockly.Msg.SENSOR_KEY_UP,"UP"],[Blockly.Msg.SENSOR_KEY_DOWN,"DOWN"],[Blockly.Msg.SENSOR_KEY_LEFT,"LEFT"],[Blockly.Msg.SENSOR_KEY_RIGHT,"RIGHT"],[Blockly.Msg.SENSOR_KEY_ESCAPE,
"ESCAPE"],[Blockly.Msg.SENSOR_KEY_ANY,"ANY"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_KEY).appendField(a,"KEY").appendField(Blockly.Msg.SENSOR_IS_PRESSED);this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.KEY_ISPRESSED_TOOLTIP)}};
Blockly.Blocks.robSensors_ultrasonic_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.MODE_DISTANCE,"DISTANCE"],[Blockly.Msg.MODE_PRESENCE,"PRESENCE"]],function(a){a&&this.sourceBlock_.getFieldValue("MODE")!==a&&this.sourceBlock_.updateShape_(a)});this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(b,"MODE").appendField(Blockly.Msg.SENSOR_ULTRASONIC).appendField(a,
"SENSORPORT");this.sensorMode_="DISTANCE";this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.ULTRASONIC_GETSAMPLE_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("mode",this.sensorMode_);return a},domToMutation:function(a){this.sensorMode_=a.getAttribute("mode");this.updateShape_(this.sensorMode_)},updateShape_:function(a){this.sensorMode_=a;"DISTANCE"==this.sensorMode_?this.setOutput(!0,"Number"):"PRESENCE"==this.sensorMode_&&this.setOutput(!0,"Boolean")}};
Blockly.Blocks.robSensors_colour_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MODE_COLOUR,"COLOUR"],[Blockly.Msg.MODE_LIGHT,"RED"],[Blockly.Msg.MODE_RGB,"RGB"],[Blockly.Msg.MODE_AMBIENTLIGHT,"AMBIENTLIGHT"]],function(a){a&&this.sourceBlock_.getFieldValue("MODE")!==a&&this.sourceBlock_.updateShape_(a)}),b=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(a,
"MODE").appendField(Blockly.Msg.SENSOR_COLOUR).appendField(b,"SENSORPORT");this.setOutput(!0,"Colour");this.setTooltip(Blockly.Msg.COLOUR_GETSAMPLE_TOOLTIP);this.sensorMode_="COLOUR"},mutationToDom:Blockly.Blocks.robSensors_ultrasonic_getSample.mutationToDom,domToMutation:Blockly.Blocks.robSensors_ultrasonic_getSample.domToMutation,updateShape_:function(a){this.sensorMode_=a;"COLOUR"==this.sensorMode_?this.setOutput(!0,"Colour"):"RGB"==this.sensorMode_?this.setOutput(!0,"Array_Number"):this.setOutput(!0,
"Number")}};
Blockly.Blocks.robSensors_infrared_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MODE_DISTANCE,"DISTANCE"],[Blockly.Msg.MODE_PRESENCE,"SEEK"]],function(a){a&&this.sourceBlock_.getFieldValue("MODE")!==a&&this.sourceBlock_.updateShape_(a)}),b=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(a,"MODE").appendField(Blockly.Msg.SENSOR_INFRARED).appendField(b,"SENSORPORT");
this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.INFRARED_GETSAMPLE_TOOLTIP);this.sensorMode_="DISTANCE"},mutationToDom:Blockly.Blocks.robSensors_ultrasonic_getSample.mutationToDom,domToMutation:Blockly.Blocks.robSensors_ultrasonic_getSample.domToMutation,updateShape_:function(a){this.sensorMode_=a;"DISTANCE"==this.sensorMode_?this.setOutput(!0,"Number"):"SEEK"==this.sensorMode_&&this.setOutput(!0,"Array_Number")}};
Blockly.Blocks.robSensors_encoder_reset={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_RESET).appendField(Blockly.Msg.SENSOR_ENCODER).appendField(a,"MOTORPORT").appendField(Blockly.Msg.SENSOR_RESET_II);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.ENCODER_RESET_TOOLTIP)}};
Blockly.Blocks.robSensors_encoder_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MODE_ROTATION,"ROTATION"],[Blockly.Msg.MODE_DEGREE,"DEGREE"],[Blockly.Msg.MODE_DISTANCE,"DISTANCE"]]),b=new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(a,"MODE").appendField(Blockly.Msg.SENSOR_ENCODER).appendField(b,"MOTORPORT");this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.ENCODER_GETSAMPLE_TOOLTIP)}};
Blockly.Blocks.robSensors_gyro_reset={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_RESET).appendField(Blockly.Msg.SENSOR_GYRO).appendField(a,"SENSORPORT").appendField(Blockly.Msg.SENSOR_RESET_II);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.GYRO_RESET_TOOLTIP)}};
Blockly.Blocks.robSensors_gyro_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.MODE_ANGLE,"ANGLE"],[Blockly.Msg.MODE_RATE,"RATE"]]);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(b,"MODE").appendField(Blockly.Msg.SENSOR_GYRO).appendField(a,"SENSORPORT");this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.GYRO_GETSAMPLE_TOOLTIP)}};
Blockly.Blocks.robSensors_timer_reset={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TIMER+" 1","1"],[Blockly.Msg.SENSOR_TIMER+" 2","2"],[Blockly.Msg.SENSOR_TIMER+" 3","3"],[Blockly.Msg.SENSOR_TIMER+" 4","4"],[Blockly.Msg.SENSOR_TIMER+" 5","5"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_RESET).appendField(a,"SENSORNUM").appendField(Blockly.Msg.SENSOR_RESET_II);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.TIMER_RESET_TOOLTIP)}};
Blockly.Blocks.robSensors_timer_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.SENSOR_TIMER+" 1 ","1"],[Blockly.Msg.SENSOR_TIMER+" 2","2"],[Blockly.Msg.SENSOR_TIMER+" 3","3"],[Blockly.Msg.SENSOR_TIMER+" 4","4"],[Blockly.Msg.SENSOR_TIMER+" 5","5"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_GET_SAMPLE).appendField(a,"SENSORNUM").appendField(Blockly.Msg.SENSOR_MS_TIMER);this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.TIMER_GETSAMPLE_TOOLTIP)}};
Blockly.Blocks.robSensors_sound_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_GET_SAMPLE).appendField(Blockly.Msg.SENSOR_SOUND).appendField(a,"SENSORPORT");this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.SOUND_GETSAMPLE_TOOLTIP)}};
Blockly.Blocks.robSensors_light_getSample={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MODE_LIGHT,"RED"],[Blockly.Msg.MODE_AMBIENTLIGHT,"AMBIENTLIGHT"]]),b=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(a,"MODE").appendField(Blockly.Msg.SENSOR_LIGHT).appendField(b,"SENSORPORT");this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.LIGHT_GETSAMPLE_TOOLTIP);
this.sensorMode_="COLOUR"}};Blockly.Blocks.robSensors_battery_voltage={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.GET).appendField(Blockly.Msg.SENSOR_BATTERY);this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.BATTERY_GETSAMPLE_TOOLTIP);this.sensorMode_="COLOUR"}};Blockly.Blocks.robCommunication={};Blockly.Blocks.robCommunication_startConnection={init:function(){this.setColour(Blockly.CAT_COMMUNICATION_RGB);this.setPreviousStatement(!1);this.setNextStatement(!1);this.setOutput(!0,"Connection");this.appendValueInput("ADDRESS").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_CONNECT).setCheck("String");this.setInputsInline(!0);this.setTooltip(Blockly.Msg.CONNECTION_START_TOOLTIP)}};
Blockly.Blocks.robCommunication_sendBlock={init:function(){this.setColour(Blockly.CAT_COMMUNICATION_RGB);var a=new Blockly.FieldDropdown([["Bluetooth","BLUETOOTH"]]),b,c;"nxt"===this.workspace.device?(b=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType_(a)}),c=new Blockly.FieldDropdown([["0","0"],
["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"]]),this.dataType_="Number",this.data="nxt"):(b=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_STRING,"String"]]),this.dataType_="String",this.data="ev3");this.appendValueInput("sendData").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_SEND_DATA).appendField(b,"TYPE").setCheck(this.dataType_);this.appendDummyInput().appendField("via").setAlign(Blockly.ALIGN_RIGHT).appendField(a,"PROTOCOL");
c?this.appendValueInput("CONNECTION").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_OVER_CHANNEL).appendField(c,"CHANNEL").appendField(Blockly.Msg.CONNECTION_TO_ROBOT).setCheck("Connection"):this.appendValueInput("CONNECTION").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_TO_CONNECTION).setCheck("Connection");this.setTooltip(Blockly.Msg.CONNECTION_SEND_TOOLTIP);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setInputsInline(!1)},mutationToDom:function(){if(void 0===
this.dataType_)return!1;var a=document.createElement("mutation");a.setAttribute("data_type",this.dataType_);return a},domToMutation:function(a){(this.dataType_=a.getAttribute("data_type"))&&this.getInput("sendData").setCheck(this.dataType_)},updateType_:function(a){this.dataType_=a;this.getInput("sendData").setCheck(this.dataType_)}};
Blockly.Blocks.robCommunication_receiveBlock={init:function(){this.setColour(Blockly.CAT_COMMUNICATION_RGB);var a=new Blockly.FieldDropdown([["Bluetooth","BLUETOOTH"]]),b,c;"nxt"===this.workspace.device?(b=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType_(a)}),c=new Blockly.FieldDropdown([["0","0"],
["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"]]),this.dataType_="Number",this.data="nxt"):(b=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_STRING,"String"]]),this.dataType_="String",this.data="ev3");this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_RECEIVED_DATA).appendField(b,"TYPE");this.appendDummyInput().appendField("via").setAlign(Blockly.ALIGN_RIGHT).appendField(a,"PROTOCOL");c?this.appendValueInput("CONNECTION").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_OVER_CHANNEL).appendField(c,
"CHANNEL").appendField(Blockly.Msg.CONNECTION_FROM_ROBOT).setCheck("Connection"):this.appendValueInput("CONNECTION").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_TO_CONNECTION).setCheck("Connection");this.setOutput(!0,this.dataType_);this.setTooltip(Blockly.Msg.CONNECTION_RECEIVE_TOOLTIP);this.setInputsInline(!1)},mutationToDom:function(){if(void 0===this.dataType_)return!1;var a=document.createElement("mutation");a.setAttribute("data_type",this.dataType_);return a},domToMutation:function(a){(this.dataType_=
a.getAttribute("data_type"))&&this.setOutput(!0,this.dataType_)},updateType_:function(a){this.dataType_=a;this.setOutput(!0,this.dataType_)}};Blockly.Blocks.robCommunication_waitForConnection={init:function(){this.setColour(Blockly.CAT_COMMUNICATION_RGB);this.appendDummyInput("").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.CONNECTION_WAIT_FOR_CONNECTION);this.setOutput(!0,"Connection");this.setTooltip(Blockly.Msg.CONNECTION_WAIT_TOOLTIP)}};
Blockly.Blocks.robCommunication_connection={init:function(){this.setColour(Blockly.CAT_COMMUNICATION_RGB);if("nxt"===this.workspace.device){var a=new Blockly.FieldDropdown([["0 Master","0"],["1 Slave","1"],["2 Slave","2"],["3 Slave","3"]]);this.data="nxt";this.appendDummyInput().appendField(a,"CONNECTION")}this.setOutput(!0,"Connection");this.setTooltip(Blockly.Msg.CONNECTION_TOOLTIP)}};
Blockly.Blocks.robCommunication_checkConnection={init:function(){this.jsonInit({message0:Blockly.Msg.CONNECTION_CHECK,args0:[{type:"input_value",name:"CONNECTION",check:"Connection"}],output:"Boolean",colour:Blockly.CAT_COMMUNICATION_RGB,tooltip:Blockly.Msg.CONNECTION_TOOLTIP})}};Blockly.Blocks.loops={};Blockly.Blocks.loops.HUE=120;Blockly.Blocks.controls_repeat_ext={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)}};
Blockly.Blocks.controls_repeat={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"field_number",name:"TIMES",text:"10"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);this.getField("TIMES").setValidator(Blockly.FieldTextInput.nonnegativeIntegerValidator)}};
Blockly.Blocks.controls_whileUntil={init:function(){var a=[[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]];this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);this.setColour(Blockly.CAT_CONTROL_RGB);this.appendValueInput("BOOL").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a),"MODE");this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);
var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE");return{WHILE:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[a]})}};
Blockly.Blocks.controls_for={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOR_TITLE,args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],inputsInline:!0,previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,helpUrl:Blockly.Msg.CONTROLS_FOR_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);
var a=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})},customContextMenu:function(a){if(!this.isCollapsed()){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type","variables_get");b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}}};
Blockly.Blocks.controls_forEach={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOREACH_TITLE,args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,helpUrl:Blockly.Msg.CONTROLS_FOREACH_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO);var a=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1",
a.getFieldValue("VAR"))})},customContextMenu:Blockly.Blocks.controls_for.customContextMenu};
Blockly.Blocks.controls_flow_statements={init:function(){var a=[[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK,"BREAK"],[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE,"CONTINUE"]];this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL);this.setColour(Blockly.CAT_CONTROL_RGB);this.appendDummyInput().appendField(new Blockly.FieldDropdown(a),"FLOW");this.setPreviousStatement(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("FLOW");return{BREAK:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,
CONTINUE:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[a]})},onchange:function(a){a=!1;var b=this;do{if(-1!=this.LOOP_TYPES.indexOf(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?this.setWarningText(null):this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING)},LOOP_TYPES:"controls_repeat controls_repeat_ext controls_forEach controls_for controls_whileUntil robControls_forEach robControls_for robControls_loopForever".split(" ")};
Blockly.Blocks.robControls_for={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOR_TITLE,args0:[{type:"field_input",name:"VAR"},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],inputsInline:!0,previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,helpUrl:Blockly.Msg.CONTROLS_FOR_HELPURL});this.nameOld="i";this.getField("VAR").setText("i");
this.getField("VAR").setValidator(this.validateName);this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setInputsInline(!0);this.declarationType_="Number";this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",thisBlock.getFieldValue("VAR"))})},validate:function(){if(!Blockly.Variables.isLegalName(this.getFieldValue("VAR"),this)){var a=Blockly.Variables.generateUniqueName(Blockly.getMainWorkspace());
this.setFieldValue(a,"VAR")}},validateName:function(a){var b=this.sourceBlock_;a=a.replace(/[\s\xa0]+/g,"").replace(/^ | $/g,"");return""!==a&&a.match(/^[a-zA-Z][a-zA-Z_$0-9]*$/)&&Blockly.Variables.isLegalName(a,b)?(Blockly.Variables.renameVariable(b.nameOld,a,Blockly.getMainWorkspace()),b.nameOld=a):null},getType:function(){return this.declarationType_},getVars:function(){return[this.getFieldValue("VAR")]},getVarDecl:function(){return[this.getFieldValue("VAR")]},customContextMenu:function(a){if(!this.isCollapsed()){var b=
{enabled:!0},c=this.getFieldValue("VAR");b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type","variables_get");c.setAttribute("intask",!1);var d=goog.dom.createDom("mutation");c.appendChild(d);b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}}};
Blockly.Blocks.robControls_forEach={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOREACH_TITLE,args0:[{type:"field_input",name:"VAR"},{type:"input_value",name:"LIST",check:["Array_Number","Array_String","Array_Boolean","Array_Colour","Array_Connection"]}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_CONTROL_RGB,helpUrl:Blockly.Msg.CONTROLS_FOREACH_HELPURL});this.nameOld=Blockly.Msg.VARIABLES_TITLE;this.getField("VAR").setText(Blockly.Msg.VARIABLES_DEFAULT_NAME);this.getField("VAR").setValidator(this.validateName);
var a=new Blockly.FieldDropdown([[Blockly.Msg.VARIABLES_TYPE_NUMBER,"Number"],[Blockly.Msg.VARIABLES_TYPE_STRING,"String"],[Blockly.Msg.VARIABLES_TYPE_BOOLEAN,"Boolean"],[Blockly.Msg.VARIABLES_TYPE_COLOUR,"Colour"],[Blockly.Msg.VARIABLES_TYPE_CONNECTION,"Connection"]],function(a){a&&this.sourceBlock_.getFieldValue("TYPE")!==a&&this.sourceBlock_.updateType(a)});this.getInput("LIST").appendField(a,"TYPE");a=this.getInput("LIST").fieldRow.pop();this.getInput("LIST").fieldRow.splice(1,0,a);this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO);
var b=this;this.listType_="Number";this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1",b.getFieldValue("VAR"))})},validate:function(){var a=Blockly.Variables.findLegalName(this.getFieldValue("VAR"),this);this.setFieldValue(a,"VAR")},validateName:Blockly.Blocks.robControls_for.validateName,mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("list_type",this.listType_);return a},domToMutation:function(a){(this.listType_=a.getAttribute("list_type"))&&
this.getInput("LIST").connection.setCheck("Array_"+this.listType_)},getVars:function(){return[this.getFieldValue("VAR")]},getVarDecl:function(){return[this.getFieldValue("VAR")]},getType:function(){return this.listType_},onchange:function(){if(this.workspace&&2!=Blockly.Block.dragMode_){var a=this.getInputTargetBlock("LIST");a&&(a=a.outputConnection.check_[0],Blockly.Variables.updateType(this.getFieldValue("VAR"),a.replace("Array_","")))}},updateType:function(a){this.listType_=a;this.getInput("LIST").connection.setCheck("Array_"+
this.listType_);Blockly.Variables.updateType(this.getFieldValue("VAR"),a)},customContextMenu:Blockly.Blocks.robControls_for.customContextMenu};Blockly.Blocks.logic={};Blockly.Blocks.logic.HUE=210;
Blockly.Blocks.controls_if={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL);this.setColour(Blockly.CAT_LOGIC_RGB);this.appendValueInput("IF0").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setMutator(new Blockly.Mutator(["controls_if_elseif","controls_if_else"]));var a=this;this.setTooltip(function(){if(a.elseifCount_||a.elseCount_){if(!a.elseifCount_&&
a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;if(a.elseifCount_&&!a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;if(a.elseifCount_&&a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_4}else return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;return""});this.elseCount_=this.elseifCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=document.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",
1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;this.updateShape_()},decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},
compose:function(a){var b=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;a=[null];for(var c=[null],d=null;b;){switch(b.type){case "controls_if_elseif":this.elseifCount_++;a.push(b.valueConnection_);c.push(b.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=b.statementConnection_;break;default:throw"Unknown block type.";}b=b.nextConnection&&b.nextConnection.targetBlock()}this.updateShape_();for(b=1;b<=this.elseifCount_;b++)Blockly.Mutator.reconnect(a[b],this,
"IF"+b),Blockly.Mutator.reconnect(c[b],this,"DO"+b);Blockly.Mutator.reconnect(d,this,"ELSE")},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&d.connection.targetConnection;break;default:throw"Unknown block type.";
}a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)}};
Blockly.Blocks.controls_if_if={init:function(){this.setColour(Blockly.CAT_LOGIC_RGB);this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.controls_if_elseif={init:function(){this.setColour(Blockly.CAT_LOGIC_RGB);this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.controls_if_else={init:function(){this.setColour(Blockly.CAT_LOGIC_RGB);this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.logic_compare={init:function(){var a=this.RTL?[["=","EQ"],["\u2260","NEQ"],[">","LT"],["\u2265","LTE"],["<","GT"],["\u2264","GTE"]]:[["=","EQ"],["\u2260","NEQ"],["<","LT"],["\u2264","LTE"],[">","GT"],["\u2265","GTE"]];this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL);this.setColour(Blockly.CAT_LOGIC_RGB);this.setOutput(!0,"Boolean");this.appendValueInput("A");this.appendValueInput("B").appendField(new Blockly.FieldDropdown(a),"OP");this.setInputsInline(!0);var b=this;this.setTooltip(function(){var a=
b.getFieldValue("OP");return{EQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,LT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT,LTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE,GT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT,GTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE}[a]});this.prevBlocks_=[null,null]},updateShape:function(a){if(a){this.operatorRange_=a;var b=this.getInputTargetBlock("B");this.removeInput("B",!0);this.removeInput("OP_DROP",!0);a="NUM_REV"==a?Blockly.RTL?[["<","GT"],["\u2264",
"GTE"],[">","LT"],["\u2265","LTE"],["=","EQ"],["\u2260","NEQ"]]:[[">","GT"],["\u2265","GTE"],["<","LT"],["\u2264","LTE"],["=","EQ"],["\u2260","NEQ"]]:"BOOL"==a?[["=","EQ"],["\u2260","NEQ"]]:"COLOUR"==a?[["=","EQ"],["\u2260","NEQ"]]:Blockly.RTL?[[">","LT"],["\u2265","LTE"],["<","GT"],["\u2264","GTE"],["=","EQ"],["\u2260","NEQ"]]:[["<","LT"],["\u2264","LTE"],[">","GT"],["\u2265","GTE"],["=","EQ"],["\u2260","NEQ"]];this.appendDummyInput("OP_DROP").appendField(new Blockly.FieldDropdown(a),"OP");a=this.appendValueInput("B");
b&&a.connection.connect(b)}},onchange:function(a){if(this.workspace&&2!=Blockly.Block.dragMode_){a=this.getInputTargetBlock("A");var b=this.getInputTargetBlock("B");if(a&&b){if(!a.outputConnection.check_||!b.outputConnection.check_)return;Blockly.Events.setGroup(!1);if(a.outputConnection.check_[0]===b.outputConnection.check_[0])return;this.getInput("A").setCheck(a.outputConnection.check_);this.getInput("B").setCheck(a.outputConnection.check_)}else a?this.getInput("B").setCheck(a.outputConnection.check_):
b?this.getInput("A").setCheck(b.outputConnection.check_):(this.getInput("A").setCheck(null),this.getInput("B").setCheck(null));this.render()}}};
Blockly.Blocks.logic_operation={init:function(){var a=[[Blockly.Msg.LOGIC_OPERATION_AND,"AND"],[Blockly.Msg.LOGIC_OPERATION_OR,"OR"]];this.setHelpUrl(Blockly.Msg.LOGIC_OPERATION_HELPURL);this.setColour(Blockly.CAT_LOGIC_RGB);this.setOutput(!0,"Boolean");this.appendValueInput("A").setCheck("Boolean");this.appendValueInput("B").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a),"OP");this.setInputsInline(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("OP");return{AND:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND,
OR:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR}[a]})}};Blockly.Blocks.logic_negate={init:function(){this.jsonInit({message0:Blockly.Msg.LOGIC_NEGATE_TITLE,args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",colour:Blockly.CAT_LOGIC_RGB,tooltip:Blockly.Msg.LOGIC_NEGATE_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_NEGATE_HELPURL})}};
Blockly.Blocks.logic_boolean={init:function(){this.jsonInit({message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[[Blockly.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Blockly.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]]}],output:"Boolean",colour:Blockly.CAT_LOGIC_RGB,tooltip:Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_BOOLEAN_HELPURL})}};
Blockly.Blocks.logic_null={init:function(){this.jsonInit({message0:Blockly.Msg.LOGIC_NULL,output:null,colour:Blockly.CAT_LOGIC_RGB,tooltip:Blockly.Msg.LOGIC_NULL_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_NULL_HELPURL})}};
Blockly.Blocks.logic_ternary={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL);this.setColour(Blockly.CAT_LOGIC_RGB);this.appendValueInput("IF").setCheck("Boolean").appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION);this.appendValueInput("THEN").appendField(Blockly.Msg.LOGIC_TERNARY_IF_TRUE);this.appendValueInput("ELSE").appendField(Blockly.Msg.LOGIC_TERNARY_IF_FALSE);this.setOutput(!0);this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP);this.prevParentConnection_=null},onchange:function(a){var b=
this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(var e=0;2>e;e++){var f=1==e?b:c;f&&!f.outputConnection.checkType_(d)&&(Blockly.Events.setGroup(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours_()):(f.unplug(),f.bumpNeighbours_()),Blockly.Events.setGroup(!1))}this.prevParentConnection_=d}};
Blockly.Blocks.robControls_ifElse={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);this.appendValueInput("IF0").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF).setCheck("Boolean");this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setMutatorPlus(new Blockly.MutatorPlus(this));this.elseIfCount_=0;this.elseCount_=1;var a=this;this.setTooltip(function(){return 0===
a.elseIfCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_2:Blockly.Msg.CONTROLS_IF_TOOLTIP_4})},mutationToDom:function(){if(!this.elseIfCount_&&!this.elseCount_)return null;var a=document.createElement("mutation");this.elseIfCount_&&a.setAttribute("elseIf",this.elseIfCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){a.hasAttribute("elseif")&&(this.elseIfCount_=parseInt(a.getAttribute("elseif"),10));this.removeInput("ELSE");for(a=1;a<=this.elseIfCount_;a++)this.appendValueInput("IF"+
a).appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF).setCheck("Boolean"),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);1<=this.elseIfCount_&&this.setMutatorMinus(new Blockly.MutatorMinus(this))},updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;if(1==a)this.elseIfCount_++,this.removeInput("ELSE"),this.appendValueInput("IF"+this.elseIfCount_).appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF).setCheck("Boolean"),
this.appendStatementInput("DO"+this.elseIfCount_).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN),this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);else if(0==a)this.elseIfCount_=0;else if(-1==a){if(a=this.getInputTargetBlock("IF"+this.elseIfCount_))a.unplug(!1),a.bumpNeighbours_();this.removeInput("ELSE");this.removeInput("DO"+this.elseIfCount_);this.removeInput("IF"+this.elseIfCount_);this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);this.elseIfCount_--}1<=
this.elseIfCount_?1==this.elseIfCount_&&(this.setMutatorMinus(new Blockly.MutatorMinus(this)),this.render()):(this.mutatorMinus.dispose(),this.mutatorMinus=null)}};
Blockly.Blocks.robControls_if={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);this.appendValueInput("IF0").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF).setCheck("Boolean");this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setMutatorPlus(new Blockly.MutatorPlus(this));this.elseIfCount_=0;var a=this;this.setTooltip(function(){return 0===a.elseIfCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_1:Blockly.Msg.CONTROLS_IF_TOOLTIP_3})},
mutationToDom:function(){if(!this.elseIfCount_)return null;var a=document.createElement("mutation");this.elseIfCount_&&a.setAttribute("elseIf",this.elseIfCount_);return a},domToMutation:function(a){this.elseIfCount_=parseInt(a.getAttribute("elseif"),10);for(a=1;a<=this.elseIfCount_;a++)this.appendValueInput("IF"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF).setCheck("Boolean"),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);1<=this.elseIfCount_&&this.setMutatorMinus(new Blockly.MutatorMinus(this))},
updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;if(1==a)this.elseIfCount_++,this.appendValueInput("IF"+this.elseIfCount_).appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF).setCheck("Boolean"),this.appendStatementInput("DO"+this.elseIfCount_).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);else if(-1==a){if(a=this.getInputTargetBlock("IF"+this.elseIfCount_))a.unplug(),a.bumpNeighbours_();this.removeInput("DO"+this.elseIfCount_);this.removeInput("IF"+this.elseIfCount_);this.elseIfCount_--}1<=
this.elseIfCount_?1==this.elseIfCount_&&(this.setMutatorMinus(new Blockly.MutatorMinus(this)),this.render()):(this.mutatorMinus.dispose(),this.mutatorMinus=null)}};Blockly.Blocks.colour={};Blockly.Blocks.colour.HUE=20;Blockly.Blocks.colour_picker={init:function(){this.jsonInit({message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",colour:Blockly.Blocks.colour.HUE,helpUrl:Blockly.Msg.COLOUR_PICKER_HELPURL});var a=this;this.setTooltip(function(){var b=a.getParent();return b&&b.getInputsInline()&&b.tooltip||Blockly.Msg.COLOUR_PICKER_TOOLTIP})}};
Blockly.Blocks.colour_random={init:function(){this.jsonInit({message0:Blockly.Msg.COLOUR_RANDOM_TITLE,output:"Colour",colour:Blockly.Blocks.colour.HUE,tooltip:Blockly.Msg.COLOUR_RANDOM_TOOLTIP,helpUrl:Blockly.Msg.COLOUR_RANDOM_HELPURL})}};
Blockly.Blocks.colour_rgb={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL);this.setColour(Blockly.Blocks.colour.HUE);this.appendValueInput("RED").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_TITLE).appendField(Blockly.Msg.COLOUR_RGB_RED);this.appendValueInput("GREEN").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_GREEN);this.appendValueInput("BLUE").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_BLUE);
this.setOutput(!0,"Colour");this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP)}};
Blockly.Blocks.colour_blend={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL);this.setColour(Blockly.Blocks.colour.HUE);this.appendValueInput("COLOUR1").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_TITLE).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR1);this.appendValueInput("COLOUR2").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR2);this.appendValueInput("RATIO").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_RATIO);
this.setOutput(!0,"Colour");this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP)}};Blockly.Blocks.robActions={};
Blockly.Blocks.robActions_motor_on={init:function(){var a=[[Blockly.Msg.MOTOR_PORT+" A","A"],[Blockly.Msg.MOTOR_PORT+" B","B"],[Blockly.Msg.MOTOR_PORT+" C","C"]];"ev3"===this.workspace.device&&a.push([Blockly.Msg.MOTOR_PORT+" D","D"]);this.setColour(Blockly.CAT_ACTION_RGB);a=new Blockly.FieldDropdown(a);this.appendValueInput("POWER").appendField(a,"MOTORPORT").appendField(Blockly.Msg.ON).appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);
this.setTooltip(Blockly.Msg.MOTOR_ON_TOOLTIP)}};
Blockly.Blocks.robActions_motor_on_for={init:function(){var a=[[Blockly.Msg.MOTOR_PORT+" A","A"],[Blockly.Msg.MOTOR_PORT+" B","B"],[Blockly.Msg.MOTOR_PORT+" C","C"]];"ev3"===this.workspace.device&&a.push([Blockly.Msg.MOTOR_PORT+" D","D"]);this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown(a),b=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_ROTATION,"ROTATIONS"],[Blockly.Msg.MOTOR_DEGREE,"DEGREE"]]);this.appendValueInput("POWER").appendField(a,"MOTORPORT").appendField(Blockly.Msg.ON).appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");
this.appendValueInput("VALUE").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.FOR).appendField(b,"MOTORROTATION").setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTOR_ON_FOR_TOOLTIP)}};
Blockly.Blocks.robActions_motor_getPower={init:function(){var a=[[Blockly.Msg.MOTOR_PORT+" A","A"],[Blockly.Msg.MOTOR_PORT+" B","B"],[Blockly.Msg.MOTOR_PORT+" C","C"]];"ev3"===this.workspace.device&&a.push([Blockly.Msg.MOTOR_PORT+" D","D"]);this.setColour(Blockly.CAT_ACTION_RGB);a=new Blockly.FieldDropdown(a);this.appendDummyInput().appendField(Blockly.Msg.GET+" "+Blockly.Msg.MOTOR_SPEED).appendField(a,"MOTORPORT");this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.MOTOR_GETPOWER_TOOLTIP)}};
Blockly.Blocks.robActions_motor_setPower={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_PORT+" A","A"],[Blockly.Msg.MOTOR_PORT+" B","B"],[Blockly.Msg.MOTOR_PORT+" C","C"],[Blockly.Msg.MOTOR_PORT+" D","D"]]);this.appendValueInput("POWER").appendField(Blockly.Msg.SET).appendField(a,"MOTORPORT").appendField(Blockly.Msg.MOTOR_SPEED);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTOR_SETPOWER_TOOLTIP)}};
Blockly.Blocks.robActions_motor_stop={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=[[Blockly.Msg.MOTOR_PORT+" A","A"],[Blockly.Msg.MOTOR_PORT+" B","B"],[Blockly.Msg.MOTOR_PORT+" C","C"]];"ev3"===this.workspace.device&&a.push([Blockly.Msg.MOTOR_PORT+" D","D"]);var a=new Blockly.FieldDropdown(a),b=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FLOAT,"FLOAT"],[Blockly.Msg.MOTOR_BRAKE,"NONFLOAT"]]);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_STOP).appendField(a,"MOTORPORT").appendField(b,
"MODE");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTOR_STOP_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_on={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"FOREWARD"],[Blockly.Msg.MOTOR_BACKWARD,"BACKWARD"]]);this.appendValueInput("POWER").appendField(Blockly.Msg.MOTOR_DRIVE).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_ON_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_on_for={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"FOREWARD"],[Blockly.Msg.MOTOR_BACKWARD,"BACKWARDS"]]);this.appendValueInput("POWER").appendField(Blockly.Msg.MOTOR_DRIVE).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.appendValueInput("DISTANCE").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOTOR_DISTANCE).setCheck("Number");this.setPreviousStatement(!0);
this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_ON_FOR_TOOLTIP)}};Blockly.Blocks.robActions_motorDiff_stop={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.setInputsInline(!0);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_STOP);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_STOP_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_turn={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_RIGHT,"RIGHT"],[Blockly.Msg.MOTOR_LEFT,"LEFT"]]);this.appendValueInput("POWER").appendField(Blockly.Msg.MOTOR_TURN).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_TURN_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_turn_for={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_RIGHT,"RIGHT"],[Blockly.Msg.MOTOR_LEFT,"LEFT"]]);this.appendValueInput("POWER").appendField(Blockly.Msg.MOTOR_TURN).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.appendValueInput("DEGREE").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOTOR_DEGREE).setCheck("Number");this.setPreviousStatement(!0);
this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_TURN_FOR_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_curve={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"FOREWARD"],[Blockly.Msg.MOTOR_BACKWARD,"BACKWARD"]]);this.appendValueInput("POWER_LEFT").appendField(Blockly.Msg.MOTOR_STEER).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).appendField(Blockly.Msg.MOTOR_LEFT).setCheck("Number");this.appendValueInput("POWER_RIGHT").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOTOR_SPEED).appendField(Blockly.Msg.MOTOR_RIGHT).setCheck("Number");this.setPreviousStatement(!0);
this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_ON_TOOLTIP)}};
Blockly.Blocks.robActions_motorDiff_curve_for={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"FOREWARD"],[Blockly.Msg.MOTOR_BACKWARD,"BACKWARDS"]]);this.appendValueInput("POWER_LEFT").appendField(Blockly.Msg.MOTOR_STEER).appendField(a,"DIRECTION").appendField(Blockly.Msg.MOTOR_SPEED).appendField(Blockly.Msg.MOTOR_LEFT).setCheck("Number");this.appendValueInput("POWER_RIGHT").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOTOR_SPEED).appendField(Blockly.Msg.MOTOR_RIGHT).setCheck("Number");this.appendValueInput("DISTANCE").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOTOR_DISTANCE).setCheck("Number");
this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTORDIFF_ON_FOR_TOOLTIP)}};
Blockly.Blocks.robActions_display_picture={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.DISPLAY_PICTURE_GLASSES,"OLDGLASSES"],[Blockly.Msg.DISPLAY_PICTURE_EYES_OPEN,"EYESOPEN"],[Blockly.Msg.DISPLAY_PICTURE_EYES_CLOSED,"EYESCLOSED"],[Blockly.Msg.DISPLAY_PICTURE_FLOWERS,"FLOWERS"],[Blockly.Msg.DISPLAY_PICTURE_TACHO,"TACHO"]]);this.appendDummyInput().appendField(Blockly.Msg.DISPLAY_SHOW+" "+Blockly.Msg.DISPLAY_PICTURE).appendField(a,"PICTURE");
this.appendValueInput("X").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField("x");this.appendValueInput("Y").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField("y");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.DISPLAY_PICTURE_TOOLTIP)}};
Blockly.Blocks.robActions_display_text={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendValueInput("OUT").appendField(Blockly.Msg.DISPLAY_SHOW+" "+Blockly.Msg.DISPLAY_TEXT);this.appendValueInput("COL").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.DISPLAY_COL);this.appendValueInput("ROW").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.DISPLAY_ROW);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.DISPLAY_TEXT_TOOLTIP)}};
Blockly.Blocks.robActions_display_clear={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput().appendField(Blockly.Msg.DISPLAY_CLEAR);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.DISPLAY_CLEAR_TOOLTIP)}};
Blockly.Blocks.robActions_display_matrix={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=[];this.appendDummyInput().appendField(Blockly.Msg.DISPLAY_SHOW+" "+Blockly.Msg.DISPLAY_PICTURE);for(var b=0;8>b;b++){for(var c=0;8>c;c++)a.push(new Blockly.FieldCheckbox);this.appendDummyInput().appendField(a[8*b+0],"POINT"+(8*b+0)).appendField(a[8*b+1],"POINT"+(8*b+1)).appendField(a[8*b+2],"POINT"+(8*b+2)).appendField(a[8*b+3],"POINT"+(8*b+3)).appendField(a[8*b+4],"POINT"+(8*b+4)).appendField(a[8*
b+5],"POINT"+(8*b+5)).appendField(a[8*b+6],"POINT"+(8*b+6)).appendField(a[8*b+7],"POINT"+(8*b+7))}this.setPreviousStatement(!0);this.setNextStatement(!0)}};
Blockly.Blocks.robActions_play_tone={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendValueInput("FREQUENCE").appendField(Blockly.Msg.PLAY).appendField(Blockly.Msg.PLAY_FREQUENZ).setCheck("Number");this.appendValueInput("DURATION").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PLAY_DURATION);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.PLAY_TONE_TOOLTIP)}};
Blockly.Blocks.robActions_play_file={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([["1","0"],["2","1"],["3","2"],["4","3"],["5","4"]]);this.appendDummyInput().appendField(Blockly.Msg.PLAY+" "+Blockly.Msg.PLAY_FILE).appendField(a,"FILE");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.PLAY_FILE_TOOLTIP)}};
Blockly.Blocks.robActions_play_setVolume={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendValueInput("VOLUME").appendField(Blockly.Msg.SET+" "+Blockly.Msg.PLAY_VOLUME).setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.PLAY_SETVOLUME_TOOLTIP)}};
Blockly.Blocks.robActions_play_getVolume={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput().appendField(Blockly.Msg.GET+" "+Blockly.Msg.PLAY_VOLUME);this.setOutput(!0,"Number");this.setTooltip(Blockly.Msg.PLAY_GETVOLUME_TOOLTIP)}};
Blockly.Blocks.robActions_brickLight_on={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.BRICKLIGHT_GREEN,"GREEN"],[Blockly.Msg.BRICKLIGHT_ORANGE,"ORANGE"],[Blockly.Msg.BRICKLIGHT_RED,"RED"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.BRICKLIGHT_ON,"ON"],[Blockly.Msg.BRICKLIGHT_FLASH,"FLASH"],[Blockly.Msg.BRICKLIGHT_DOUBLE_FLASH,"DOUBLE_FLASH"]]);this.appendDummyInput().appendField(Blockly.Msg.BRICKLIGHT);this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.BRICKLIGHT_COLOR).appendField(a,
"SWITCH_COLOR");this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOD).appendField(b,"SWITCH_BLINK");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_ON_TOOLTIP)}};
Blockly.Blocks.robActions_sensorLight_on={init:function(){var a=new Blockly.FieldDropdown([["Port 1","1"],["Port 2","2"],["Port 3","3"],["Port 4","4"]]);this.setColour(Blockly.CAT_ACTION_RGB);var b=new Blockly.FieldDropdown([[Blockly.Msg.BRICKLIGHT_RED,"RED"],[Blockly.Msg.BRICKLIGHT_GREEN,"GREEN"],[Blockly.Msg.BRICKLIGHT_BLUE,"BLUE"]]),c=new Blockly.FieldDropdown([[Blockly.Msg.ON,"ON"],[Blockly.Msg.OFF,"OFF"]]);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_TURN).appendField(Blockly.Msg.SENSOR_COLOUR);
this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.BRICKLIGHT_COLOR).appendField(b,"SWITCH_COLOR");this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOD).appendField(c,"SWITCH_STATE");this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(a,"SENSORPORT");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_ON_TOOLTIP)}};
Blockly.Blocks.robActions_brickLight_off={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput().appendField(Blockly.Msg.BRICKLIGHT).appendField(Blockly.Msg.OFF);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_OFF_TOOLTIP)}};
Blockly.Blocks.robActions_brickLight_reset={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_RESET).appendField(Blockly.Msg.BRICKLIGHT).appendField(Blockly.Msg.SENSOR_RESET_II);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_RESET_TOOLTIP)}};Blockly.Blocks.simActions={};Blockly.Blocks.sim_motor_on={init:function(){this.setHelpUrl(Blockly.Msg.MOTOR_ON_HELPURL);this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_RIGHT,"B"],[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_LEFT,"C"]]);this.appendValueInput("POWER").appendField(a,"MOTORPORT").appendField(Blockly.Msg.ON).appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTOR_ON_TOOLTIP)}};
Blockly.Blocks.sim_motor_on_for={init:function(){this.setHelpUrl(Blockly.Msg.MOTOR_ON_FOR_HELPURL);this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_RIGHT,"B"],[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_LEFT,"C"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_ROTATION,"ROTATIONS"],[Blockly.Msg.MOTOR_DEGREE,"DEGREE"]]);this.appendValueInput("POWER").appendField(a,"MOTORPORT").appendField(Blockly.Msg.ON).appendField(Blockly.Msg.MOTOR_SPEED).setCheck("Number");
this.appendValueInput("VALUE").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.FOR).appendField(b,"MOTORROTATION").setCheck("Number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.MOTOR_ON_FOR_TOOLTIP)}};
Blockly.Blocks.sim_motor_stop={init:function(){this.setHelpUrl(Blockly.Msg.MOTOR_STOP_HELPURL);this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_RIGHT,"B"],[Blockly.Msg.MOTOR+" "+Blockly.Msg.MOTOR_LEFT,"C"]]),b=new Blockly.FieldDropdown([["","FLOAT"],["","NONFLOAT"]]);b.setVisible(!1);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_STOP).appendField(a,"MOTORPORT").appendField(b,"MODE");this.setPreviousStatement(!0);this.setNextStatement(!0);
this.setTooltip(Blockly.Msg.MOTOR_STOP_TOOLTIP)}};
Blockly.Blocks.sim_LED_on={init:function(){this.setHelpUrl(Blockly.Msg.BRICKLIGHT_ON_HELPURL);this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.BRICKLIGHT_GREEN,"GREEN"],[Blockly.Msg.BRICKLIGHT_ORANGE,"ORANGE"],[Blockly.Msg.BRICKLIGHT_RED,"RED"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.BRICKLIGHT_ON,"ON"],[Blockly.Msg.BRICKLIGHT_FLASH,"FLASH"],[Blockly.Msg.BRICKLIGHT_DOUBLE_FLASH,"DOUBLE_FLASH"]]);this.appendDummyInput().appendField(Blockly.Msg.BRICKLIGHT);this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.BRICKLIGHT_COLOR).appendField(a,
"SWITCH_COLOR");this.appendDummyInput().setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.MOD).appendField(b,"SWITCH_BLINK");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_ON_TOOLTIP)}};
Blockly.Blocks.sim_LED_off={init:function(){this.setHelpUrl(Blockly.Msg.BRICKLIGHT_OFF_HELP);this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput().appendField(Blockly.Msg.BRICKLIGHT).appendField(Blockly.Msg.OFF);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.BRICKLIGHT_OFF_TOOLTIP)}};Blockly.Blocks.robControls={};
Blockly.Blocks.robControls_start={init:function(){this.setColour(Blockly.CAT_ACTIVITY_RGB);this.appendDummyInput().appendField(Blockly.Msg.START_PROGRAM).appendField(" ").appendField(new Blockly.FieldCheckbox("FALSE"),"DEBUG").appendField(Blockly.Msg.START_PROGRAM_DEBUG);this.declare_=!1;this.setPreviousStatement(!1);this.setNextStatement(!0);this.setDeletable(!1);this.setMutatorPlus(new Blockly.MutatorPlus(["robControls_start"]));this.setTooltip(Blockly.Msg.START_TOOLTIP)},mutationToDom:function(){var a=
document.createElement("mutation");a.setAttribute("declare",1==this.declare_);return a},domToMutation:function(a){(this.declare_="false"!=a.getAttribute("declare"))&&this.appendStatementInput("ST")},updateShape_:function(a){if(1==a){this.declare_||(this.appendStatementInput("ST"),this.getInput("ST").connection.setCheck("declaration_only"),this.declare_=!0);a=this.workspace.newBlock("robGlobalVariables_declare");a.initSvg();a.render();var b=a.getInput("VALUE"),c=this.workspace.newBlock("math_number");
c.initSvg();c.render();b.connection.connect(c.outputConnection);if(this.getInput("ST").connection.targetConnection){if(c=this.getInput("ST").connection.targetConnection.sourceBlock_)for(;c.getNextBlock();)c=c.getNextBlock();c.setNext(!0);b=c.nextConnection}else b=this.getInput("ST").connection;b.connect(a.previousConnection)}else-1==a&&(this.removeInput("ST"),this.declare_=!1)}};
Blockly.Blocks.robControls_activity={init:function(){this.setColour(Blockly.CAT_ACTIVITY_RGB);this.appendDummyInput().appendField(new Blockly.FieldTextInput(Blockly.Msg.START_ACTIVITY,Blockly.Procedures.rename),"ACTIVITY");this.setPreviousStatement(!1);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.ACTIVITY_TOOLTIP)}};
Blockly.Blocks.robControls_start_activity={init:function(){this.setColour(Blockly.CAT_ACTIVITY_RGB);this.appendDummyInput().appendField(Blockly.Msg.START).appendField(new Blockly.FieldTextInput(Blockly.Msg.START_ACTIVITY,Blockly.Procedures.rename),"ACTIVITY");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.START_ACTIVITY_TOOLTIP)}};
Blockly.Blocks.robControls_wait={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);this.appendValueInput("WAIT0").appendField(Blockly.Msg.WAIT_UNTIL).setCheck("Boolean");this.setPreviousStatement(!0);this.setNextStatement(!0);this.waitCount_=0;this.setMutatorPlus(new Blockly.MutatorPlus(this));this.setTooltip(Blockly.Msg.WAIT_TOOLTIP)},mutationToDom:function(){if(!this.waitCount_)return null;var a=document.createElement("mutation");this.waitCount_&&a.setAttribute("wait",this.waitCount_);return a},
domToMutation:function(a){this.waitCount_=parseInt(a.getAttribute("wait"),10);for(a=1;a<=this.waitCount_;a++)1==a&&this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.appendValueInput("WAIT"+a).appendField(Blockly.Msg.CONTROLS_WAIT_OR).setCheck("Boolean"),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);1<=this.waitCount_&&this.setMutatorMinus(new Blockly.MutatorMinus(this))},updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;
if(1==a)this.waitCount_++,1==this.waitCount_&&this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.appendValueInput("WAIT"+this.waitCount_).appendField(Blockly.Msg.WAIT_OR).setCheck("Boolean"),this.appendStatementInput("DO"+this.waitCount_).appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);else if(-1==a){if(a=this.getInputTargetBlock("DO"+this.waitCount_))a.unplug(),a.bumpNeighbours_();if(a=this.getInputTargetBlock("WAIT"+this.waitCount_))a.unplug(),a.bumpNeighbours_();
this.removeInput("DO"+this.waitCount_);this.removeInput("WAIT"+this.waitCount_);this.waitCount_--;0==this.waitCount_&&this.removeInput("DO0");this.itemCount_--;this.removeInput("ADD"+this.itemCount_)}1<=this.waitCount_?1==this.waitCount_&&(this.setMutatorMinus(new Blockly.MutatorMinus(this)),this.render()):(this.mutatorMinus.dispose(),this.mutatorMinus=null,this.render())}};
Blockly.Blocks.robControls_wait_time={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);this.setInputsInline(!0);this.appendValueInput("WAIT").appendField(Blockly.Msg.WAIT).setCheck("Number");this.appendDummyInput().appendField("ms");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.WAIT_TOOLTIP)}};
Blockly.Blocks.robControls_wait_for={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);this.appendValueInput("WAIT0").appendField(Blockly.Msg.WAIT_UNTIL).setCheck("Boolean");this.setPreviousStatement(!0);this.setNextStatement(!0);this.waitCount_=0;this.setMutatorPlus(new Blockly.MutatorPlus(this));this.setTooltip(Blockly.Msg.WAIT_FOR_TOOLTIP)},mutationToDom:function(){if(!this.waitCount_)return null;var a=document.createElement("mutation");this.waitCount_&&a.setAttribute("wait",this.waitCount_);
return a},domToMutation:function(a){this.waitCount_=parseInt(a.getAttribute("wait"),10);for(a=1;a<=this.waitCount_;a++)1==a&&this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.appendValueInput("WAIT"+a).appendField(Blockly.Msg.WAIT_OR).setCheck("Boolean"),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);1<=this.waitCount_&&this.setMutatorMinus(new Blockly.MutatorMinus(this))},updateShape_:function(a){Blockly.dragMode_=Blockly.DRAG_NONE;
if(1==a){this.waitCount_++;1==this.waitCount_&&this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);this.appendValueInput("WAIT"+this.waitCount_).appendField(Blockly.Msg.WAIT_OR).setCheck("Boolean");this.appendStatementInput("DO"+this.waitCount_).appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);a=this.workspace.newBlock("logic_compare");a.initSvg();a.render();a.updateShape("BOOL");var b=this.getInput("WAIT"+this.waitCount_).connection;b.connect(a.outputConnection);var c=
this.workspace.newBlock("robSensors_getSample");c.initSvg();c.render();b=a.getInput("A").connection;b.connect(c.outputConnection);c=this.workspace.newBlock("logic_boolean");c.initSvg();c.render();b=a.getInput("B").connection;b.connect(c.outputConnection)}else if(-1==a){if(a=this.getInputTargetBlock("DO"+this.waitCount_))a.unplug(),a.bumpNeighbours_();if(a=this.getInputTargetBlock("WAIT"+this.waitCount_))a.unplug(),a.bumpNeighbours_();this.removeInput("DO"+this.waitCount_);this.removeInput("WAIT"+
this.waitCount_);this.waitCount_--;0==this.waitCount_&&this.removeInput("DO0")}1<=this.waitCount_?1==this.waitCount_&&(this.setMutatorMinus(new Blockly.MutatorMinus(this)),this.render()):(this.mutatorMinus.dispose(),this.mutatorMinus=null,this.render())}};
Blockly.Blocks.robControls_loopForever={init:function(){this.setColour(Blockly.CAT_CONTROL_RGB);var a=new Blockly.FieldLabel(Blockly.Msg.LOOP_FOREVER);this.appendDummyInput().appendField(a,"TITLE_FOREVER");this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LOOPFOREVER_TOOLTIP)}};Blockly.Blocks.robBrick={};
Blockly.Blocks["robBrick_EV3-Brick"]={init:function(){this.setColour("#BBBBBB");this.setInputsInline(!1);var a=new Blockly.FieldTextInput("0",Blockly.FieldTextInput.nonnegativeNumberValidator),b=new Blockly.FieldTextInput("0",Blockly.FieldTextInput.nonnegativeNumberValidator);this.appendDummyInput().appendField(new Blockly.FieldLabel(this.workspace.device.toUpperCase(),"brick_label"));this.appendDummyInput().appendField(Blockly.Msg.BRICK_WHEEL_DIAMETER).appendField(a,"WHEEL_DIAMETER").appendField("cm");this.appendDummyInput().appendField(Blockly.Msg.BRICK_TRACK_WIDTH).appendField(b,
"TRACK_WIDTH").appendField("cm");this.appendValueInput("S1").appendField("Sensor 1").setAlign(Blockly.ALIGN_RIGHT).setCheck("Sensor");this.appendValueInput("S2").appendField("Sensor 2").setAlign(Blockly.ALIGN_RIGHT).setCheck("Sensor");this.appendValueInput("S3").appendField("Sensor 3").setAlign(Blockly.ALIGN_RIGHT).setCheck("Sensor");this.appendValueInput("S4").appendField("Sensor 4").setAlign(Blockly.ALIGN_RIGHT).setCheck("Sensor");this.appendValueInput("MA").appendField("Motor A").setAlign(Blockly.ALIGN_RIGHT).setCheck("Actor");
this.appendValueInput("MB").appendField("Motor B").setAlign(Blockly.ALIGN_RIGHT).setCheck("Actor");this.appendValueInput("MC").appendField("Motor C").setAlign(Blockly.ALIGN_RIGHT).setCheck("Actor");"ev3"===this.workspace.device?(this.appendValueInput("MD").appendField("Motor D").setAlign(Blockly.ALIGN_RIGHT).setCheck("Actor"),this.setTooltip(Blockly.Msg.EV3BRICK_TOOLTIP)):this.setTooltip(Blockly.Msg.NXTBRICK_TOOLTIP);this.setDeletable(!1)}};
Blockly.Blocks.robBrick_ultrasonic={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_ULTRASONIC);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.ULTRASONIC_TOOLTIP)}};Blockly.Blocks.robBrick_colour={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_COLOUR);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.COLOUR_TOOLTIP)}};
Blockly.Blocks.robBrick_light={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_LIGHT);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.COLOUR_TOOLTIP)}};Blockly.Blocks.robBrick_infrared={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_INFRARED);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.INFRARED_TOOLTIP)}};
Blockly.Blocks.robBrick_touch={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_TOUCH);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.TOUCH_TOOLTIP)}};Blockly.Blocks.robBrick_gyro={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_GYRO);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.GYRO_TOOLTIP)}};
Blockly.Blocks.robBrick_sound={init:function(){this.setColour(Blockly.CAT_SENSOR_RGB);this.appendDummyInput().appendField(Blockly.Msg.SENSOR_SOUND);this.setOutput(!0,"Sensor");this.setTooltip(Blockly.Msg.GYRO_TOOLTIP);this.data="nxt"}};
Blockly.Blocks.robBrick_motor_big={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.YES,"TRUE"],[Blockly.Msg.NO,"FALSE"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"OFF"],[Blockly.Msg.MOTOR_BACKWARD,"ON"]]),c=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_NONE,"NONE"],[Blockly.Msg.MOTOR_RIGHT,"RIGHT"],[Blockly.Msg.MOTOR_LEFT,"LEFT"]]);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_BIG+" "+Blockly.Msg.MOTOR);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_REGULATION).appendField(a,
"MOTOR_REGULATION").setAlign(Blockly.ALIGN_RIGHT);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_ROTATION_REVERSE).appendField(b,"MOTOR_REVERSE").setAlign(Blockly.ALIGN_RIGHT);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_SIDE).appendField(c,"MOTOR_DRIVE").setAlign(Blockly.ALIGN_RIGHT);this.setOutput(!0,"Actor");this.setTooltip(Blockly.Msg.MOTOR_BIG_TOOLTIP)}};
Blockly.Blocks.robBrick_motor_middle={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);var a=new Blockly.FieldDropdown([[Blockly.Msg.YES,"TRUE"],[Blockly.Msg.NO,"FALSE"]]),b=new Blockly.FieldDropdown([[Blockly.Msg.MOTOR_FOREWARD,"OFF"],[Blockly.Msg.MOTOR_BACKWARD,"ON"]]);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_MIDDLE+" "+Blockly.Msg.MOTOR);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_REGULATION).appendField(a,"MOTOR_REGULATION").setAlign(Blockly.ALIGN_RIGHT);this.appendDummyInput().appendField(Blockly.Msg.MOTOR_ROTATION_REVERSE).appendField(b,
"MOTOR_REVERSE").setAlign(Blockly.ALIGN_RIGHT);this.setOutput(!0,"Actor");this.setTooltip(Blockly.Msg.MOTOR_MIDDLE_TOOLTIP)}};Blockly.Blocks.robBrick_actor={init:function(){this.setColour(Blockly.CAT_ACTION_RGB);this.appendDummyInput("ACTOR").appendField(Blockly.Msg.MOTOR_OTHER);this.setOutput(!0,"Actor");this.setTooltip(Blockly.Msg.ACTOR_TOOLTIP)}};Blockly.Blocks.math={};Blockly.Blocks.math.HUE=230;Blockly.Blocks.math_number={init:function(){this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL);this.setColour(Blockly.CAT_MATH_RGB);this.appendDummyInput().appendField(new Blockly.FieldNumber("0",Blockly.FieldTextInput.numberValidator),"NUM");this.setOutput(!0,"Number");var a=this;this.setTooltip(function(){var b=a.getParent();return b&&b.getInputsInline()&&b.tooltip||Blockly.Msg.MATH_NUMBER_TOOLTIP})}};
Blockly.Blocks.math_arithmetic={init:function(){this.jsonInit({message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[[Blockly.Msg.MATH_ADDITION_SYMBOL,"ADD"],[Blockly.Msg.MATH_SUBTRACTION_SYMBOL,"MINUS"],[Blockly.Msg.MATH_MULTIPLICATION_SYMBOL,"MULTIPLY"],[Blockly.Msg.MATH_DIVISION_SYMBOL,"DIVIDE"],[Blockly.Msg.MATH_POWER_SYMBOL,"POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",colour:Blockly.CAT_MATH_RGB,
helpUrl:Blockly.Msg.MATH_ARITHMETIC_HELPURL});var a=this;this.setTooltip(function(){var b=a.getFieldValue("OP");return{ADD:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[b]})}};
Blockly.Blocks.math_single={init:function(){this.jsonInit({message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[[Blockly.Msg.MATH_SINGLE_OP_ROOT,"ROOT"],[Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE,"ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",colour:Blockly.CAT_MATH_RGB,helpUrl:Blockly.Msg.MATH_SINGLE_HELPURL});var a=this;this.setTooltip(function(){var b=a.getFieldValue("OP");return{ROOT:Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT,
ABS:Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS,NEG:Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG,LN:Blockly.Msg.MATH_SINGLE_TOOLTIP_LN,LOG10:Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10,EXP:Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP,POW10:Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10}[b]})}};
Blockly.Blocks.math_trig={init:function(){this.jsonInit({message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[[Blockly.Msg.MATH_TRIG_SIN,"SIN"],[Blockly.Msg.MATH_TRIG_COS,"COS"],[Blockly.Msg.MATH_TRIG_TAN,"TAN"],[Blockly.Msg.MATH_TRIG_ASIN,"ASIN"],[Blockly.Msg.MATH_TRIG_ACOS,"ACOS"],[Blockly.Msg.MATH_TRIG_ATAN,"ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",colour:Blockly.CAT_MATH_RGB,helpUrl:Blockly.Msg.MATH_TRIG_HELPURL});var a=this;this.setTooltip(function(){var b=
a.getFieldValue("OP");return{SIN:Blockly.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Blockly.Msg.MATH_TRIG_TOOLTIP_COS,TAN:Blockly.Msg.MATH_TRIG_TOOLTIP_TAN,ASIN:Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN,ACOS:Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS,ATAN:Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN}[b]})}};
Blockly.Blocks.math_constant={init:function(){this.jsonInit({message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["\u03c0","PI"],["e","E"],["\u03c6","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(\u00bd)","SQRT1_2"],["\u221e","INFINITY"]]}],output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_CONSTANT_TOOLTIP,helpUrl:Blockly.Msg.MATH_CONSTANT_HELPURL})}};
Blockly.Blocks.math_number_property={init:function(){var a=[[Blockly.Msg.MATH_IS_EVEN,"EVEN"],[Blockly.Msg.MATH_IS_ODD,"ODD"],[Blockly.Msg.MATH_IS_PRIME,"PRIME"],[Blockly.Msg.MATH_IS_WHOLE,"WHOLE"],[Blockly.Msg.MATH_IS_POSITIVE,"POSITIVE"],[Blockly.Msg.MATH_IS_NEGATIVE,"NEGATIVE"],[Blockly.Msg.MATH_IS_DIVISIBLE_BY,"DIVISIBLE_BY"]];this.setColour(Blockly.CAT_MATH_RGB);this.appendValueInput("NUMBER_TO_CHECK").setCheck("Number");a=new Blockly.FieldDropdown(a,function(a){this.sourceBlock_.updateShape_("DIVISIBLE_BY"==
a)});this.appendDummyInput().appendField(a,"PROPERTY");this.setInputsInline(!0);this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.MATH_IS_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"==a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):
b&&this.removeInput("DIVISOR")}};Blockly.Blocks.math_change={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_CHANGE_TITLE,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.MATH_CHANGE_TITLE_ITEM},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.CAT_MATH_RGB,helpUrl:Blockly.Msg.MATH_CHANGE_HELPURL});var a=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};
Blockly.Blocks.math_round={init:function(){this.jsonInit({message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[[Blockly.Msg.MATH_ROUND_OPERATOR_ROUND,"ROUND"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP,"ROUNDUP"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN,"ROUNDDOWN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_ROUND_TOOLTIP,helpUrl:Blockly.Msg.MATH_ROUND_HELPURL})}};
Blockly.Blocks.math_on_list={init:function(){var a=[[Blockly.Msg.MATH_ONLIST_OPERATOR_SUM,"SUM"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MIN,"MIN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MAX,"MAX"],[Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE,"AVERAGE"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN,"MEDIAN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV,"STD_DEV"],[Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM,"RANDOM"]],b=this;this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL);this.setColour(Blockly.CAT_MATH_RGB);this.setOutput(!0,
"Number");a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendValueInput("LIST").setCheck("Array_Number").appendField(a,"OP");this.setTooltip(function(){var a=b.getFieldValue("OP");return{SUM:Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM,MIN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN,MAX:Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX,AVERAGE:Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE,MEDIAN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN,MODE:Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE,STD_DEV:Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV,
RANDOM:Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM}[a]})},updateType_:function(a){"MODE"==a?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("op"))}};
Blockly.Blocks.math_modulo={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_MODULO_TITLE,args0:[{type:"input_value",name:"DIVIDEND",check:"Number"},{type:"input_value",name:"DIVISOR",check:"Number"}],inputsInline:!0,output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_MODULO_TOOLTIP,helpUrl:Blockly.Msg.MATH_MODULO_HELPURL})}};
Blockly.Blocks.math_constrain={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_CONSTRAIN_TITLE,args0:[{type:"input_value",name:"VALUE",check:"Number"},{type:"input_value",name:"LOW",check:"Number"},{type:"input_value",name:"HIGH",check:"Number"}],inputsInline:!0,output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_CONSTRAIN_TOOLTIP,helpUrl:Blockly.Msg.MATH_CONSTRAIN_HELPURL})}};
Blockly.Blocks.math_random_int={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_RANDOM_INT_TITLE,args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:"TO",check:"Number"}],inputsInline:!0,output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_RANDOM_INT_TOOLTIP,helpUrl:Blockly.Msg.MATH_RANDOM_INT_HELPURL})}};
Blockly.Blocks.math_random_float={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM,output:"Number",colour:Blockly.CAT_MATH_RGB,tooltip:Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP,helpUrl:Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL})}};
Blockly.Blocks.robMath_change={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_CHANGE_TITLE,args0:[{type:"input_value",name:"VAR",check:"Number"},{type:"input_value",name:"DELTA",check:"Number"}],inputsInline:!0,previousStatement:null,nextStatement:null,colour:Blockly.CAT_MATH_RGB,helpUrl:Blockly.Msg.MATH_CHANGE_HELPURL});var a=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};