text: // Do not edit this file; automatically generated by build.py.
  'use strict';
  
  
  // Copyright 2014 Google Inc.  Apache License 2.0
  Blockly.C=new Blockly.Generator("C");Blockly.C.type="wink";Blockly.C.addReservedWords("auto","else","long","switch","break","enum","register","typedef","case","extern","return","union","char","float","short","unsigned","const","for","signed","void","continue","goto","sizeof","volatile","default","if","static","while","do","int","struct","_Packed","double");Blockly.C.ORDER_ATOMIC=0;Blockly.C.ORDER_UNARY_POSTFIX=1;Blockly.C.ORDER_FUNCTION_CALL=1;Blockly.C.ORDER_FUNCTIONAL_CAST=1;
  Blockly.C.ORDER_SUBSCRIPT=1;Blockly.C.ORDER_MEMBER_ACCESS=1;Blockly.C.ORDER_UNARY_PREFIX=2;Blockly.C.ORDER_NOT=2;Blockly.C.ORDER_C_STYLE_CAST=2;Blockly.C.ORDER_INDIRECTION=2;Blockly.C.ORDER_ADDRESS_OF=2;Blockly.C.ORDER_SIZEOF=2;Blockly.C.ORDER_NEW=2;Blockly.C.ORDER_DELETE=2;Blockly.C.ORDER_POINTER_TO_MEMBER=3;Blockly.C.ORDER_MULTIPLICATIVE=4;Blockly.C.ORDER_ADDITIVE=5;Blockly.C.ORDER_SHIFT=6;Blockly.C.ORDER_RELATIONAL=7;Blockly.C.ORDER_EQUALITY=8;Blockly.C.ORDER_BITWISE_AND=9;
  Blockly.C.ORDER_BITWISE_XOR=10;Blockly.C.ORDER_BITWISE_OR=11;Blockly.C.ORDER_LOGICAL_AND=12;Blockly.C.ORDER_LOGICAL_OR=13;Blockly.C.ORDER_CONDITIONAL=14;Blockly.C.ORDER_THROW=14;Blockly.C.ORDER_ASSIGNMENT=14;Blockly.C.ORDER_COMMA=15;Blockly.C.ORDER_NONE=99;function DefineVar(a,b){return b+" "+Blockly.C.variableDB_.getName(a,Blockly.Variables.NAME_TYPE)+";"}Blockly.C.TYPE_CONVERSION=[];Blockly.C.TYPE_CONVERSION.INTEGER=["int",Blockly.Msg.TYPE_INT];Blockly.C.TYPE_CONVERSION.BOOLEAN=["bool",Blockly.Msg.TYPE_BOOL];
  Blockly.C.TYPE_CONVERSION.FLOAT=["float",Blockly.Msg.TYPE_FLOAT];Blockly.C.TYPE_CONVERSION.STRING=["String",Blockly.Msg.TYPE_STRING];Blockly.C.TYPE_CONVERSION.ArrayINT=["int *",Blockly.Msg.TYPE_INT_ARR];Blockly.C.TYPE_CONVERSION.ArrayFLOAT=["float *",Blockly.Msg.TYPE_FLOAT_ARR];Blockly.C.TYPE_CONVERSION.ArrayBoolean=["bool *",Blockly.Msg.TYPE_BOOL_ARR];Blockly.C.TYPE_CONVERSION.ArrayString=["String *",Blockly.Msg.TYPE_STRING_ARR];
  Blockly.C.init=function(a){Blockly.C.definitions_=Object.create(null);Blockly.C.functions_=Object.create(null);Blockly.C.functionNames_=Object.create(null);Blockly.C.variableDB_?Blockly.C.variableDB_.reset():Blockly.C.variableDB_=new Blockly.Names(Blockly.C.RESERVED_WORDS_);for(var b=[],c=Blockly.Variables.allVariables(a),d=0;d<c.length;d++){var e=a.getVariableType(c[d]);b[d]=DefineVar(c[d],Blockly.C.TYPE_CONVERSION[e][0])}Blockly.C.definitions_.variables=b.join("\n")};
  Blockly.C.finish=function(a){a&&(a=Blockly.C.prefixLines(a,Blockly.C.INDENT));var b=[],c=[];for(e in Blockly.C.definitions_){var d=Blockly.C.definitions_[e];d.match(/^include\s/)?b.push(d):c.push(d)}var e=[];for(var f in Blockly.C.functions_)e.push(Blockly.C.functions_[f]);delete Blockly.C.definitions_;delete Blockly.C.functionNames_;delete Blockly.C.functions_;Blockly.C.variableDB_.reset();return('/*Wink Robot\nWink_BaseSketch_Rev01_03\nVersion 1.3 01/2016\nThis is a basic sketch that can be used as a starting point\nfor various functionality of the Wink robot.\nThis code was written by Kevin King and\nDustin Soodak for Plum Geek LLC.\nPortions from other open source projects where noted.\nThis code is licensed under:\nCreative Commons Attribution-ShareAlike 2.0 Generic (CC BY-SA 2.0)\nhttps://creativecommons.org/licenses/by-sa/2.0/\nVisit http://www.plumgeek.com for Wink information.\nVisit http://www.arduino.cc to learn about the Arduino.\n*/\n#include "WinkHardware.hpp"  // Leave this line first. Do not edit this line. This causes Arduino\n                           // to include background functions when turning your code into\n                           // machine language Wink can understand.\n'+
  b.join("\n")+e.join("\n")+"\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n")+a};Blockly.C.scrubNakedValue=function(a){return a+";\n"};Blockly.C.quote_=function(a){return goog.string.quote(a)};
  Blockly.C.scrub_=function(a,b){var c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var d=a.getCommentText();d&&(c+=Blockly.C.prefixLines(d,"// ")+"\n");for(var e=0;e<a.inputList.length;e++)a.inputList[e].type==Blockly.INPUT_VALUE&&(d=a.inputList[e].connection.targetBlock())&&(d=Blockly.C.allNestedComments(d))&&(c+=Blockly.C.prefixLines(d,"// "))}e=a.nextConnection&&a.nextConnection.targetBlock();e=Blockly.C.blockToCode(e);return c+b+e};Blockly.CReservedWords="alignas alignof and and_eq asm atomic_cancel atomic_commit atomic_noexcept audit auto axiom bitand bitor bool break case catch char char16_t char32_t char8_t class co_await co_return co_yield compl concept const_cast consteval constexpr continue decltype default delete do double dynamic_cast else enum explicit export extern false final float for friend goto if import inline int long module mutable namespace new noexcept not not_eq nullptr operator or or_eq override private protected public reflexpr register reinterpret_cast requires return short signed sizeof static static_assert static_cast struct switch synchronized template this thread_local throw transaction_safe transaction_safe_dynamic true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq".split(" ");Blockly.C.arduino_eeprom={};function AddInclude(){Blockly.C.definitions_.import_eeprom="#include <EEPROM.h>"}Blockly.C.eeprom_read=function(a){AddInclude();return["EEPROM.read("+Blockly.C.valueToCode(a,"ADDRESS",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.eeprom_write=function(a){AddInclude();var b=Blockly.C.valueToCode(a,"ADDRESS",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return"EEPROM.write("+b+", "+a+");\n"};
  Blockly.C.eeprom_update=function(a){AddInclude();var b=Blockly.C.valueToCode(a,"ADDRESS",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return"EEPROM.update("+b+", "+a+");\n"};Blockly.C.eeprom_get=function(a){AddInclude();var b=Blockly.C.valueToCode(a,"ADDRESS",Blockly.C.ORDER_ATOMIC);a=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return"EEPROM.get("+b+", "+a+");\n"};
  Blockly.C.eeprom_put=function(a){AddInclude();var b=Blockly.C.valueToCode(a,"ADDRESS",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return"EEPROM.put("+b+", "+a+");\n"};Blockly.C.variables={};Blockly.C.variables_get=function(a){return[Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.C.ORDER_ATOMIC]};Blockly.C.variables_set=function(a){var b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ASSIGNMENT)||"0";return Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};
  Blockly.C.variable_set_typed=function(a){switch(a.cType){case "STRING":var b='""';break;case "BOOLEAN":b="true";break;case "FLOAT":b="0.0";break;default:b="0"}b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ASSIGNMENT)||b;b.match(/\d+\.\d+$/)&&(b+="f");var c=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return"INTEGER"==a.cType?c+" = (int)"+b+";\n":c+" = "+b+";\n"};
  Blockly.C.variables_get_typed=function(a){return[Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.C.ORDER_ATOMIC]};Blockly.C.logic={};Blockly.C.controls_if=function(a){var b=0,c=Blockly.C.valueToCode(a,"IF"+b,Blockly.C.ORDER_NONE)||"false",d=Blockly.C.statementToCode(a,"DO"+b),e="if ("+c+") {\n"+d+"}";for(b=1;b<=a.elseifCount_;b++)c=Blockly.C.valueToCode(a,"IF"+b,Blockly.C.ORDER_NONE)||"false",d=Blockly.C.statementToCode(a,"DO"+b),e+=" else if ("+c+") {\n"+d+"}";a.elseCount_&&(d=Blockly.C.statementToCode(a,"ELSE"),e+=" else {\n"+d+"}");return e+"\n"};
  Blockly.C.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="==b||"!="==b?Blockly.C.ORDER_EQUALITY:Blockly.C.ORDER_RELATIONAL,d=Blockly.C.valueToCode(a,"A",c)||"0";a=Blockly.C.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
  Blockly.C.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"&&":"||",c="&&"==b?Blockly.C.ORDER_LOGICAL_AND:Blockly.C.ORDER_LOGICAL_OR,d=Blockly.C.valueToCode(a,"A",c);a=Blockly.C.valueToCode(a,"B",c);if(d||a){var e="&&"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
  Blockly.C.logic_operation_and=Blockly.C.logic_operation_or=function(a){var b="AND"==a.operator?" && ":" || ",c=" && "==b?Blockly.C.ORDER_LOGICAL_AND:Blockly.C.ORDER_LOGICAL_OR,d="&&"==b?"true":"false",e=Blockly.C.valueToCode(a,"A",c)||d,f=Blockly.C.valueToCode(a,"B",c)||d;e=e+b+f;for(var g=0;g<a.itemCount_;g++)e+=b,(f=Blockly.C.valueToCode(a,"ADD"+g,c))||(f=d),e+=f;return[e,c]};
  Blockly.C.logic_negate=function(a){var b=Blockly.C.ORDER_UNARY_PREFIX;return["!"+(Blockly.C.valueToCode(a,"BOOL",b)||"true"),b]};Blockly.C.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.C.ORDER_ATOMIC]};Blockly.C.logic_null=function(a){return["null",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.logic_ternary=function(a){var b=Blockly.C.valueToCode(a,"IF",Blockly.C.ORDER_CONDITIONAL)||"false",c=Blockly.C.valueToCode(a,"THEN",Blockly.C.ORDER_CONDITIONAL)||"0";a=Blockly.C.valueToCode(a,"ELSE",Blockly.C.ORDER_CONDITIONAL)||"0";return[b+" ? "+c+" : "+a,Blockly.C.ORDER_CONDITIONAL]};Blockly.C.seteyesred=function(a){return"eyesRed()"};Blockly.C.arduino_string={};Blockly.C.arduino_string_create=function(a){return["String("+(Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_ATOMIC)||"String()")+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_string_create_base=function(a){var b=Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"BASE",Blockly.C.ORDER_ATOMIC);return["String("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_char_at=function(a){var b=Blockly.C.valueToCode(a,"LOCATION",Blockly.C.ORDER_ATOMIC);return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".charAt("+b+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_string_compare_to=function(a){var b=Blockly.C.valueToCode(a,"LHS",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"RHS",Blockly.C.ORDER_ATOMIC)||"String()";return[b+".compareTo("+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_concat=function(a){var b=Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_ATOMIC)||"String()";return(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".concat("+b+");\n"};Blockly.C.arduino_string_ends_with=function(a){var b=Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_ATOMIC)||"String()";return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".endsWith("+b+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_equals=function(a){var b=Blockly.C.valueToCode(a,"LHS",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"RHS",Blockly.C.ORDER_ATOMIC)||"String()";return[b+".equals("+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_string_equals_ignore_case=function(a){var b=Blockly.C.valueToCode(a,"LHS",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"RHS",Blockly.C.ORDER_ATOMIC)||"String()";return[b+".equalsIgnoreCase("+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_index_of=function(a){var b=Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_ATOMIC)||"String()",c=Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"POSITION",Blockly.C.ORDER_ATOMIC);return c+".indexOf("+b+", "+a+");\n"};Blockly.C.arduino_string_length=function(a){return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".length()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_remove=function(a){var b=Blockly.C.valueToCode(a,"START",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"END",Blockly.C.ORDER_ATOMIC);return c+".remove("+b+", "+a+");\n"};
  Blockly.C.arduino_string_replace=function(a){var b=Blockly.C.valueToCode(a,"LHS",Blockly.C.ORDER_ATOMIC)||"String()",c=Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"RHS",Blockly.C.ORDER_ATOMIC)||"String()";return c+".replace("+b+", "+a+");\n"};
  Blockly.C.arduino_string_starts_with=function(a){var b=Blockly.C.valueToCode(a,"LHS",Blockly.C.ORDER_ATOMIC)||"String()";a=Blockly.C.valueToCode(a,"RHS",Blockly.C.ORDER_ATOMIC)||"String()";return[b+".startsWith("+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_substring=function(a){var b=Blockly.C.valueToCode(a,"START",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"END",Blockly.C.ORDER_ATOMIC);return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".substring("+b+", "+c+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_string_to_int=function(a){return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".toInt()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_string_to_float=function(a){return[(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".toFloat()",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_string_to_lower=function(a){return(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".toLowerCase();\n"};Blockly.C.arduino_string_to_upper=function(a){return(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".toUpperCase();\n"};
  Blockly.C.arduino_string_trim=function(a){return(Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_ATOMIC)||"String()")+".trim();\n"};Blockly.C.arduino_servo={};Blockly.C.servo_attach=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";var b=Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC);return b+".attach("+a+");\n"};
  Blockly.C.servo_write=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";var b=Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"ANGLE",Blockly.C.ORDER_ATOMIC);return b+".write("+a+");\n"};Blockly.C.servo_write_microseconds=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";var b=Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"MICROS",Blockly.C.ORDER_ATOMIC);return b+".writeMicroseconds("+a+");\n"};
  Blockly.C.servo_read=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";return[Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC)+".read()",Blockly.C.ORDER_ATOMIC]};Blockly.C.servo_attached=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";return[Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC)+".attached()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.servo_detach=function(a){Blockly.C.definitions_.include_servo="#include <Servo.h>";return Blockly.C.valueToCode(a,"SERVO",Blockly.C.ORDER_ATOMIC)+".detach();\n"};Blockly.C.arduino_pwm={};Blockly.C.serial_begin=function(a){return"Serial.begin("+Blockly.C.valueToCode(a,"SPEED",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.serial_end=function(a){return"Serial.end();\n"};Blockly.C.serial_print=function(a){return"Serial.print("+Blockly.C.valueToCode(a,"OUTPUT",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.serial_print_line=function(a){return"Serial.println("+Blockly.C.valueToCode(a,"OUTPUT",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.serial_read=function(a){return["Serial.read()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.serial_available=function(){return["Serial.available()",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_available_write=function(){return["Serial.availableForWrite()",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_find=function(a){return["Serial.find("+Blockly.C.valueToCode(a,"TARGET",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.serial_find_until=function(a){var b=Blockly.C.valueToCode(a,"TARGET",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"terminal",Blockly.C.ORDER_ATOMIC);return["Serial.find("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_flush=function(){return"Serial.flush();\n"};Blockly.C.serial_parse_int=function(){return["Serial.parseInt()",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_parse_float=function(){return["Serial.parseFloat()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.serial_peek=function(){return["Serial.peek()",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_read_bytes=function(a){var b=Blockly.C.valueToCode(a,"BUFFER",Blockly.C.ORDER_ATOMIC)||"nullptr";a=Blockly.C.valueToCode(a,"LENGTH",Blockly.C.ORDER_ATOMIC)||"0";return["Serial.readBytes("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.serial_read_bytes_until=function(a){var b=Blockly.C.valueToCode(a,"BUFFER",Blockly.C.ORDER_ATOMIC)||"nullptr",c=Blockly.C.valueToCode(a,"LENGTH",Blockly.C.ORDER_ATOMIC)||"0";return["Serial.readBytes("+(Blockly.C.valueToCode(a,"TERMINAL",Blockly.C.ORDER_ATOMIC)||"0")+", "+b+", "+c+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.serial_set_timeout=function(a){return"Serial.setTimeout("+(Blockly.C.valueToCode(a,"MILLISECONDS",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.arrays={};Blockly.C.typed_arrays_create_with=function(a){switch(a.ctype){case "INTEGER":var b="int";var c="0";break;case "FLOAT":b="float";c="0";break;case "STRING":b="string";c='""';break;case "BOOLEAN":b="bool";c="false";break;default:b="int",c="0"}for(var d=Array(a.itemCount_),e=0;e<a.itemCount_;e++)d[e]=Blockly.C.valueToCode(a,"ADD"+e,Blockly.C.ORDER_NONE)||c;d="new "+b+"["+a.itemCount_+"]{"+d.join(", ")+"}";return[d,Blockly.C.ORDER_ATOMIC]};
  Blockly.C.typed_arrays_setIndex=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("ARRAY"),Blockly.Variables.NAME_TYPE),c=Blockly.C.valueToCode(a,"INDEX",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return b+"[(int)"+c+"] = "+a+";\n"};
  Blockly.C.typed_arrays_getIndex=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("ARRAY"),Blockly.Variables.NAME_TYPE);a=Blockly.C.valueToCode(a,"INDEX",Blockly.C.ORDER_ATOMIC);return[b+"[(int)"+a+"]",Blockly.C.ORDER_NONE]};Blockly.C.typed_arrays_delete=function(a){return"delete "+Blockly.C.variableDB_.getName(a.getFieldValue("ARRAY"),Blockly.Variables.NAME_TYPE)+";\n"};Blockly.C.winks={};Blockly.C.seteyesred=function(a){return"eyesRed("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyesgreen=function(a){return"eyesGreen("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyesblue=function(a){return"eyesBlue("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.seteyespurple=function(a){return"eyesPurple("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyespink=function(a){return"eyesPink("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyesyellow=function(a){return"eyesYellow("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.seteyescyan=function(a){return"eyesCyan("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyesorange=function(a){return"eyesOrange("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.seteyeswhite=function(a){return"eyesWhite("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.seteyesrgb=function(a){var b=a.getFieldValue("NAME")||"#000000";a=parseInt(b.substring(1,3),16);var c=parseInt(b.substring(3,5),16);b=parseInt(b.substring(5,7),16);return"eyesRGB("+a+", "+c+", "+b+");\n"};Blockly.C.set_eyes=function(a){var b=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_ATOMIC)||"0";return"eyesRGB("+b+","+c+","+a+");\n"};Blockly.C.turneyesoff=function(a){return"eyesOff();\n"};
  Blockly.C.eyesprevcolour=function(a){return"eyesPrevCol();\n"};Blockly.C.setleftred=function(a){return"leftRed("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftgreen=function(a){return"leftGreen("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftblue=function(a){return"leftBlue("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setleftpurple=function(a){return"leftPurple("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftpink=function(a){return"leftPink("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftyellow=function(a){return"leftYellow("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setleftcyan=function(a){return"leftCyan("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftorange=function(a){return"leftOrange("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setleftwhite=function(a){return"leftWhite("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setleftrgb=function(a){var b=a.getFieldValue("NAME")||"#000000";a=parseInt(b.substring(1,3),16);var c=parseInt(b.substring(3,5),16);b=parseInt(b.substring(5,7),16);return"leftRGB("+a+", "+c+", "+b+");\n"};Blockly.C.set_left_eye=function(a){var b=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_ATOMIC)||"0";return"leftRGB("+b+","+c+","+a+");\n"};
  Blockly.C.turnlefteyeoff=function(a){return"leftOff();\n"};Blockly.C.leftprevcolour=function(a){return"leftPrevCol();\n"};Blockly.C.setrightred=function(a){return"rightRed("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightgreen=function(a){return"rightGreen("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setrightblue=function(a){return"rightBlue("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightpurple=function(a){return"rightPurple("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightpink=function(a){return"rightPink("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setrightyellow=function(a){return"rightYellow("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightcyan=function(a){return"rightCyan("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightorange=function(a){return"rightOrange("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.setrightwhite=function(a){return"rightWhite("+(Blockly.C.valueToCode(a,"INTENSITY",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.setrightrgb=function(a){var b=a.getFieldValue("NAME")||"#000000";a=parseInt(b.substring(1,3),16);var c=parseInt(b.substring(3,5),16);b=parseInt(b.substring(5,7),16);return"rightRGB("+a+", "+c+", "+b+");\n"};
  Blockly.C.set_right_eye=function(a){var b=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_ATOMIC)||"0";return"rightRGB("+b+","+c+","+a+");\n"};Blockly.C.turnrighteyeoff=function(a){return"rightOff();\n"};Blockly.C.rightprevcolour=function(a){return"rightPrevCol();\n"};
  Blockly.C.hardwarestartup=function(a){a=Blockly.C.statementToCode(a,"do");Blockly.C.definitions_.setup='// Below is the "setup" function. It runs one time as soon as Wink turns on. You can add stuff\n// to this function if you want, but hardwareBegin() should always be the first code in the list.\nvoid setup(){\n  hardwareBegin();\n'+a+"}\n";return null};
  Blockly.C.loop=function(a){a=Blockly.C.statementToCode(a,"do");Blockly.C.definitions_.loop='// Below is the "loop" function. This is where you\'ll write most of your code. Whatever is included\n// inside the "loop" function will run over and over until Wink runs out of power or you turn him off.\nvoid loop(){\n'+a+"}\n";return null};
  Blockly.C.acceleratemotors=function(a){var b=Blockly.C.valueToCode(a,"startspeed",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"endspeed",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"duration",Blockly.C.ORDER_ATOMIC)||"0";return"accelerateMotors("+b+", "+c+", "+a+");\n"};Blockly.C.bestill=function(a){return"beStill();\n"};
  Blockly.C.motors=function(a){var b=Blockly.C.valueToCode(a,"leftspeed",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"rightspeed",Blockly.C.ORDER_ATOMIC)||"0";return"motors("+b+", "+a+");\n"};Blockly.C.spinleft=function(a){return"spinLeft("+(Blockly.C.valueToCode(a,"speed",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.spinright=function(a){return"spinRight("+(Blockly.C.valueToCode(a,"speed",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};
  Blockly.C.turn_by_values=function(a){var b=a.getFieldValue("direction"),c=a.getFieldValue("speed");a=a.getFieldValue("duration");switch(b){case "left":return"spinLeft("+c+");\ndelay("+a+");\nbeStill();\n";case "right":return"spinRight("+c+");\ndelay("+a+");\nbeStill();\n"}return["",Blockly.C.ORDER_NONE]};Blockly.C.buttonwait=function(a){return"waitForButton();\n"};Blockly.C.button_pressed=function(a){return["buttonPressed()",Blockly.C.ORDER_NONE]};
  Blockly.C.beepms=function(a){return"beep("+(Blockly.C.valueToCode(a,"beepms",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.beepon=function(a){return"beepOn();\n"};Blockly.C.beepoff=function(a){return"beepOff();\n"};
  Blockly.C.setirlight=function(a){var b=a.getFieldValue("LIGHT");a=a.getFieldValue("STATE");var c="HIGH";switch(b){case "HEADLIGHT":var d="Headlight";break;case "LINELEFTINNER":d="LineLeftInner";break;case "LINELEFTOUTER":d="LineLeftOuter";break;case "LINERIGHTINNER":d="LineRightInner";break;case "LINERIGHTOUTER":d="LineRightOuter"}switch(a){case "ON":c="HIGH";break;case "OFF":c="LOW"}return"digitalWrite("+d+", "+c+");\n"};
  Blockly.C.readsensor=function(a){switch(a.getFieldValue("LIGHT")){case "LINESENSELEFT":var b="LineSenseLeft";break;case "LINESENSERIGHT":b="LineSenseRight";break;case "AMBIENTSENSORLEFT":b="AmbientSenseLeft";break;case "AMBIENTSENSORCENTER":b="AmbientSenseCenter";break;case "AMBIENTSENSORRIGHT":b="AmbientSenseRight"}return["analogRead("+b+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.restart_ir=function(a){return"//Listen for 4 byte packets\nRxIRRestart(4);\n"};
  Blockly.C.is_ir_done=function(a){return["/*Check for completion of IR read*/\nIsIRDone()",Blockly.C.ORDER_NONE]};Blockly.C.ir_when=function(a){if(0==a.keyPressChecks)return"";for(var b="if(IsIRDone()){\n  int button = GetIRButton();\n",c=1;c<=a.keyPressChecks;++c){var d=1==c?"  if":"  else if",e=a.getFieldValue("BUTTON"+c),f=Blockly.C.statementToCode(a,"CHECK"+c);f=f.replace("\n","\n  ");b+=d+"(button == "+e+"){\n  "+f+"  RxIRRestart(4);\n  }\n"}return b+"  else{\n    RxIRRestart(4);\n  }\n}\n"};
  Blockly.C.ir_button=function(a){return[a.getFieldValue("BUTTONS"),Blockly.C.ORDER_ATOMIC]};Blockly.C.get_pressed_ir_button=function(){return["GetIRButton()",Blockly.C.ORDER_ATOMIC]};Blockly.C.lists={};Blockly.C.addReservedWords("Math");Blockly.C.lists_create_empty=function(a){Blockly.C.definitions_.include_list="#include <list>";return["std::list<int>()",Blockly.C.ORDER_ATOMIC]};Blockly.C.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=Blockly.C.valueToCode(a,"ADD"+c,Blockly.C.ORDER_NONE)||"null";b="["+b.join(", ")+"]";return[b,Blockly.C.ORDER_ATOMIC]};
  Blockly.C.lists_repeat=function(a){var b=Blockly.C.valueToCode(a,"ITEM",Blockly.C.ORDER_NONE)||"null";return["new List.filled("+(Blockly.C.valueToCode(a,"NUM",Blockly.C.ORDER_NONE)||"0")+", "+b+")",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.lists_length=function(a){return[(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"[]")+".length",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.lists_isEmpty=function(a){return[(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.lists_indexOf=function(a){var b="FIRST"==a.getFieldValue("END")?"indexOf":"lastIndexOf",c=Blockly.C.valueToCode(a,"FIND",Blockly.C.ORDER_NONE)||"''";return[(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+") + 1",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=Blockly.C.valueToCode(a,"AT",Blockly.C.ORDER_UNARY_PREFIX)||"1";a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"[]";if("FIRST"==c){if("GET"==b)return[a+".first",Blockly.C.ORDER_UNARY_POSTFIX];if("GET_REMOVE"==b)return[a+".removeAt(0)",Blockly.C.ORDER_UNARY_POSTFIX];if("REMOVE"==b)return a+".removeAt(0);\n"}else if("LAST"==c){if("GET"==b)return[a+".last",Blockly.C.ORDER_UNARY_POSTFIX];
  if("GET_REMOVE"==b)return[a+".removeLast()",Blockly.C.ORDER_UNARY_POSTFIX];if("REMOVE"==b)return a+".removeLast();\n"}else if("FROM_START"==c){d=Blockly.isNumber(d)?parseInt(d,10)-1:d+" - 1";if("GET"==b)return[a+"["+d+"]",Blockly.C.ORDER_UNARY_POSTFIX];if("GET_REMOVE"==b)return[a+".removeAt("+d+")",Blockly.C.ORDER_UNARY_POSTFIX];if("REMOVE"==b)return a+".removeAt("+d+");\n"}else if("FROM_END"==c){if("GET"==b)return c=Blockly.C.provideFunction_("lists_get_from_end",["dynamic "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+
  "(List myList, num x) {","  x = myList.length - x;","  return myList.removeAt(x);","}"]),[c+"("+a+", "+d+")",Blockly.C.ORDER_UNARY_POSTFIX];if("GET_REMOVE"==b||"REMOVE"==b){c=Blockly.C.provideFunction_("lists_remove_from_end",["dynamic "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList, num x) {","  x = myList.length - x;","  return myList.removeAt(x);","}"]);d=c+"("+a+", "+d+")";if("GET_REMOVE"==b)return[d,Blockly.C.ORDER_UNARY_POSTFIX];if("REMOVE"==b)return d+";\n"}}else if("RANDOM"==c){Blockly.C.definitions_.import_dart_math=
  "import 'dart:math' as Math;";c=Blockly.C.provideFunction_("lists_get_random_item",["dynamic "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList, bool remove) {","  int x = new Math.Random().nextInt(myList.length);","  if (remove) {","    return myList.removeAt(x);","  } else {","    return myList[x];","  }","}"]);d=c+"("+a+", "+("GET"!=b)+")";if("GET"==b||"GET_REMOVE"==b)return[d,Blockly.C.ORDER_UNARY_POSTFIX];if("REMOVE"==b)return d+";\n"}throw"Unhandled combination (lists_getIndex).";};
  Blockly.C.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))return"";var a=Blockly.C.variableDB_.getDistinctName("tmp_list",Blockly.Variables.NAME_TYPE),b="List "+a+" = "+c+";\n";c=a;return b}var c=Blockly.C.valueToCode(a,"LIST",Blockly.C.ORDER_UNARY_POSTFIX)||"[]",d=a.getFieldValue("MODE")||"GET",e=a.getFieldValue("WHERE")||"FROM_START",f=Blockly.C.valueToCode(a,"AT",Blockly.C.ORDER_ADDITIVE)||"1";a=Blockly.C.valueToCode(a,"TO",Blockly.C.ORDER_ASSIGNMENT)||"null";if("FIRST"==e){if("SET"==
  d)return c+"[0] = "+a+";\n";if("INSERT"==d)return c+".insert(0, "+a+");\n"}else if("LAST"==e){if("SET"==d)return e=b(),e+(c+"["+c+".length - 1] = "+a+";\n");if("INSERT"==d)return c+".add("+a+");\n"}else if("FROM_START"==e){f=Blockly.isNumber(f)?parseInt(f,10)-1:f+" - 1";if("SET"==d)return c+"["+f+"] = "+a+";\n";if("INSERT"==d)return c+".insert("+f+", "+a+");\n"}else if("FROM_END"==e){e=b();if("SET"==d)return e+(c+"["+c+".length - "+f+"] = "+a+";\n");if("INSERT"==d)return e+(c+".insert("+c+".length - "+
  f+", "+a+");\n")}else if("RANDOM"==e){Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;";e=b();f=Blockly.C.variableDB_.getDistinctName("tmp_x",Blockly.Variables.NAME_TYPE);e+="int "+f+" = new Math.Random().nextInt("+c+".length);";if("SET"==d)return e+(c+"["+f+"] = "+a+";\n");if("INSERT"==d)return e+(c+".insert("+f+", "+a+");\n")}throw"Unhandled combination (lists_setIndex).";};
  Blockly.C.lists_getSublist=function(a){var b=Blockly.C.valueToCode(a,"LIST",Blockly.C.ORDER_UNARY_POSTFIX)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=Blockly.C.valueToCode(a,"AT1",Blockly.C.ORDER_NONE)||"1";a=Blockly.C.valueToCode(a,"AT2",Blockly.C.ORDER_NONE)||"1";("FIRST"==c||"FROM_START"==c&&Blockly.isNumber(e))&&("LAST"==d||"FROM_START"==d&&Blockly.isNumber(a))?(e="FIRST"==c?0:parseInt(e,10)-1,"LAST"==d?b=b+".sublist("+e+")":(a=parseInt(a,10),b=b+".sublist("+e+", "+a+")")):
  b=Blockly.C.provideFunction_("lists_get_sublist",["List "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(list, where1, at1, where2, at2) {","  int getAt(where, at) {","    if (where == 'FROM_START') {","      at--;","    } else if (where == 'FROM_END') {","      at = list.length - at;","    } else if (where == 'FIRST') {","      at = 0;","    } else if (where == 'LAST') {","      at = list.length - 1;","    } else {","      throw 'Unhandled option (lists_getSublist).';","    }","    return at;","  }","  at1 = getAt(where1, at1);",
  "  at2 = getAt(where2, at2) + 1;","  return list.sublist(at1, at2);","}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.lists_split=function(a){var b=Blockly.C.valueToCode(a,"INPUT",Blockly.C.ORDER_UNARY_POSTFIX),c=Blockly.C.valueToCode(a,"DELIM",Blockly.C.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"==a)b||(b="''"),a="split";else if("JOIN"==a)b||(b="[]"),a="join";else throw"Unknown mode: "+a;return[b+"."+a+"("+c+")",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.ringo={};Blockly.C.hardwarestartup_ringo=function(a){a=Blockly.C.statementToCode(a,"do");Blockly.C.definitions_.setup='// Below is the "setup" function. It runs one time as soon as Wink turns on. You can add stuff\n// to this function if you want, but hardwareBegin() should always be the first code in the list.\nvoid setup(){\n\tHardwareBegin();\n'+a+"}\n";return null};Blockly.C.get_gyro_calibration_multiplier=function(a){return["GetGyroCalibrationMultiplier()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.begin_navigation=function(a){return"NavigationBegin();\n"};Blockly.C.simple_gyro_navigation=function(a){return"SimpleGyroNavigation();\n"};Blockly.C.simple_navigation=function(a){return"SimpleNavigation();\n"};Blockly.C.navigation_xy=function(a){var b=Blockly.C.valueToCode(a,"gyro_sensitivity",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"accel_sensitivity",Blockly.C.ORDER_ATOMIC)||"0";return"NavigationXY("+b+", "+a+");\n"};Blockly.C.calibrate_navigation_sensors=function(){return"CalibrateNavigationSensors();\n"};
  Blockly.C.zero_navigation=function(){return"ZeroNavigation();\n"};Blockly.C.pause_navigation=function(){return"PauseNavigation();\n"};Blockly.C.resume_navigation=function(){return"ResumeNavigation();\n"};Blockly.C.navigation_paused=function(){return["NavigationPaused()",Blockly.C.ORDER_ATOMIC]};Blockly.C.delay_with_navigation_ms=function(a){return"DelayWithNavigation("+Blockly.C.valueToCode(a,"milliseconds",Blockly.C.ORDER_ATOMIC)+");\n"};
  Blockly.C.delay_with_simple_navigation_ms=function(a){return"DelayWithSimpleNavigation("+Blockly.C.valueToCode(a,"milliseconds",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.present_heading=function(a){return["PresentHeading()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_degrees_x=function(a){return["GetDegreesX()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_degrees_per_second_z=function(a){return["GetDegreesPerSecond()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.get_degrees_per_second_x=function(a){return["GetDegreesPerSecondX()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_degrees_per_second_y=function(a){return["GetDegreesPerSecondY()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_degrees_to_stop=function(a){return["GetDegreesToStop()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_accel_x=function(a){return["GetAccelerationX()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_accel_y=function(a){return["GetAccelerationY()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.get_accel_z=function(a){return["GetAccelerationZ()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_accel_y_unzeroed=function(a){return["GetAccelerationYUnZeroed()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_vel_x=function(a){return["GetVelocityX()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_vel_y=function(a){return["GetVelocityY()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_pos_x=function(a){return["GetPositionX()",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_pos_y=function(a){return["GetPositionY()",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.is_stationary=function(a){return["IsStationary",Blockly.C.ORDER_ATOMIC]};Blockly.C.non_stationary_value=function(a){return["NonStationaryValue",Blockly.C.ORDER_ATOMIC]};Blockly.C.non_stationary_axis=function(a){return["NonStationaryAxis",Blockly.C.ORDER_ATOMIC]};Blockly.C.delay_with_navigation_seconds=function(a){return"DelayWithNavigationSeconds("+Blockly.C.valueToCode(a,"SECONDS",Blockly.C.ORDER_ATOMIC)+" * 1000);\n"};
  Blockly.C.delay_with_simple_navigation_seconds=function(a){return"DelayWithSimpleNavigation("+Blockly.C.valueToCode(a,"SECONDS",Blockly.C.ORDER_ATOMIC)+" * 1000);\n"};Blockly.C.min_turn=function(a){return["MinTurn("+(Blockly.C.valueToCode(a,"changeInDegrees",Blockly.C.ORDER_ATOMIC)||"0")+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.min_turn_to_heading=function(a){return["MinTurnToHeading("+(Blockly.C.valueToCode(a,"desiredHeading",Blockly.C.ORDER_ATOMIC)||"0")+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.vector_to_degrees=function(a){var b=Blockly.C.valueToCode(a,"xComponent",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"yComponent",Blockly.C.ORDER_ATOMIC)||"0";return["VectorToDegrees("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.set_pixel_rgb=function(a){var b=a.getFieldValue("PIXEL"),c=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_ATOMIC)||"0",d=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_ATOMIC)||"0";return"SetPixelRGB("+b+", "+c+", "+d+", "+a+");\n"};
  Blockly.C.set_pixel_rgb_colour=function(a){var b=a.getFieldValue("PIXEL"),c=a.getFieldValue("COLOUR")||"#000000";a=parseInt(c.substring(1,3),16);var d=parseInt(c.substring(3,5),16);c=parseInt(c.substring(5,7),16);return"SetPixelRGB("+b+", "+a+", "+d+", "+c+");\n"};
  Blockly.C.set_all_pixel_rgb=function(a){var b=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_ATOMIC)||"0";return"SetAllPixelsRGB( "+b+", "+c+", "+a+");\n"};Blockly.C.refresh_pixels=function(a){return"RefreshPixels();\n"};
  Blockly.C.set_all_pixel_rgb_colour=function(a){var b=a.getFieldValue("COLOUR")||"#000000";a=parseInt(b.substring(1,3),16);var c=parseInt(b.substring(3,5),16);b=parseInt(b.substring(5,7),16);return"SetAllPixelsRGB("+a+", "+c+", "+b+");\n"};Blockly.C.get_motor_max=function(a){return["MOTOR_MAX",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_left_motor=function(a){return["LeftMotor",Blockly.C.ORDER_ATOMIC]};Blockly.C.get_right_motor=function(a){return["RightMotor",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.motors_begin=function(a){return"MotorsBegin();\n"};Blockly.C.maintain_heading_reset=function(a){return"MaintainHeadingReset();\n"};Blockly.C.maintain_heading=function(a){var b=Blockly.C.valueToCode(a,"HEADING",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"SPEED",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"WIGGLE",Blockly.C.ORDER_ATOMIC)||"0";return"MaintainHeading("+b+", "+c+", "+a+");\n"};
  Blockly.C.drive_arc=function(a){var b=Blockly.C.valueToCode(a,"HEADING",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"LEFT_SPEED",Blockly.C.ORDER_ATOMIC)||"0",d=Blockly.C.valueToCode(a,"RIGHT_SPEED",Blockly.C.ORDER_ATOMIC)||"0",e=Blockly.C.valueToCode(a,"MAX_EXPECTED_TURN_TIME",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"MAX_EXPECTED_SKID_TIME",Blockly.C.ORDER_ATOMIC)||"0";return"DriveArc("+b+", "+c+", "+d+", "+e+", "+a+");\n"};
  Blockly.C.rotate_accurate=function(a){var b=Blockly.C.valueToCode(a,"HEADING",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"MAX_EXPECTED_TURN_TIME",Blockly.C.ORDER_ATOMIC)||"0";return"RotateAccurate("+b+", "+a+");\n"};Blockly.C.play_start_chirp=function(a){return"PlayStartChirp();\n"};Blockly.C.play_ack=function(a){return"PlayAck();\n"};Blockly.C.play_non_ack=function(a){return"PlayNonAck();\n"};Blockly.C.play_anger=function(a){return"PlayAnger();\n"};Blockly.C.play_boredom=function(a){return"PlayBoredom();\n"};
  Blockly.C.play_excited=function(a){return"PlayExcited();\n"};Blockly.C.play_chirp=function(a){var b=Blockly.C.valueToCode(a,"FREQUENCY",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"AMPLITUDE",Blockly.C.ORDER_ATOMIC)||"0";return"PlayChirp("+b+", "+a+");\n"};Blockly.C.off_chirp=function(a){return"OffChirp();\n"};Blockly.C.off_pixels=function(a){return"OffPixels();\n"};Blockly.C.off_pixel=function(a){return"OffPixel("+a.getFieldValue("PIXEL")+");\n"};Blockly.C.random_eyes=function(a){return"RandomEyes();\n"};
  Blockly.C.read_side_sensors=function(a){return"ReadSideSensors();\n"};Blockly.C.read_left_light_sensor=function(a){return["ReadLeftLightSensor()",Blockly.C.ORDER_ATOMIC]};Blockly.C.edge_lights_on=function(a){return"EdgeLightsOn();\n"};Blockly.C.edge_lights_off=function(a){return"EdgeLightsOff();\n"};Blockly.C.read_right_light_sensor=function(a){return["ReadRightLightSensor()",Blockly.C.ORDER_ATOMIC]};Blockly.C.reset_look_at_edge=function(a){return"ResetLookAtEdge();\n"};Blockly.C.look_at_edge=function(a){return"LookAtEdge();\n"};
  Blockly.C.look_for_edge=function(a){return["LookForEdge()",Blockly.C.ORDER_ATOMIC]};Blockly.C.read_edge_light_sensors=function(a){return"ReadEdgeLightSensors("+(Blockly.C.valueToCode(a,"AVERAGE",Blockly.C.ORDER_ATOMIC)||"0")+");\n"};Blockly.C.is_over_edge=function(a){return["IsOverEdge()",Blockly.C.ORDER_ATOMIC]};Blockly.C.switch_ambient_to_edge=function(a){return"SwitchAmbientToEdge();\n"};Blockly.C.switch_edge_to_ambient=function(a){return"SwitchEdgeToAmbient();\n"};
  Blockly.C.switch_button_to_pixels=function(a){return"SwitchButtonToPixels();\n"};Blockly.C.switch_pixels_to_button=function(a){return"SwitchPixelsToButton();\n"};Blockly.C.switch_motors_to_serial=function(a){return"SwitchMotorsToSerial();\n"};Blockly.C.ringo_button_pressed=function(a){return["ButtonPressed()",Blockly.C.ORDER_ATOMIC]};Blockly.C.heading_with_shortest_distance=function(a){return["HeadingWithShortestDistance("+(Blockly.C.valueToCode(a,"HEADING",Blockly.C.ORDER_ATOMIC)||"0")+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.procedures={};function getCType(a){switch(a){case "INTEGER":return"int";case "BOOLEAN":return"bool";case "FLOAT":return"float";case "STRING":return"String";case "CHARACTER":return"char";default:return"int"}}
  Blockly.C.procedures_defreturn=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.C.statementToCode(a,"STACK");Blockly.C.STATEMENT_PREFIX&&(c=Blockly.C.prefixLines(Blockly.C.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),Blockly.C.INDENT)+c);Blockly.C.INFINITE_LOOP_TRAP&&(c=Blockly.C.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=Blockly.C.valueToCode(a,"RETURN",Blockly.C.ORDER_NONE)||"";d&&(d="  return "+d+";\n");for(var e=d?"int":
  "void",f=[],g=0;g<a.arguments_.length;g++)f[g]="int "+Blockly.C.variableDB_.getName(a.arguments_[g],Blockly.Variables.NAME_TYPE);c=e+" "+b+"("+f.join(", ")+") {\n"+c+d+"}";c=Blockly.C.scrub_(a,c);Blockly.C.definitions_[b]=c;return null};Blockly.C.procedures_defnoreturn=Blockly.C.procedures_defreturn;
  Blockly.C.procedures_callreturn=function(a){for(var b=Blockly.C.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.C.valueToCode(a,"ARG"+d,Blockly.C.ORDER_NONE)||"0";return[b+"("+c.join(", ")+")",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.procedures_callnoreturn=function(a){for(var b=Blockly.C.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.C.valueToCode(a,"ARG"+d,Blockly.C.ORDER_NONE)||"0";return b+"("+c.join(", ")+");\n"};
  Blockly.C.procedures_ifreturn=function(a){var b="if ("+(Blockly.C.valueToCode(a,"CONDITION",Blockly.C.ORDER_NONE)||"false")+") {\n";a.hasReturnValue_?(a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_NONE)||"0",b+="  return "+a+";\n"):b+="  return;\n";return b+"}\n"};Blockly.C.procedures_ifreturn_typed=Blockly.C.procedures_ifreturn;Blockly.C.procedures_return_typed=function(a){return a.hasReturnValue_?"  return "+(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_NONE)||"0")+";\n":"  return;\n"};
  Blockly.C.procedures_defreturn_typed=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.C.statementToCode(a,"STACK");Blockly.C.STATEMENT_PREFIX&&(c=Blockly.C.prefixLines(Blockly.C.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),Blockly.C.INDENT)+c);Blockly.C.INFINITE_LOOP_TRAP&&(c=Blockly.C.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=Blockly.C.valueToCode(a,"RETURN",Blockly.C.ORDER_NONE)||"";d&&(d="  return "+d+";\n");for(var e=
  d?getCType(a.getFieldValue("TYPE")):"int",f=[],g=0;g<a.arguments_.length;g++){var h=getCType(a.workspace.getVariableType(a.arguments_[g]));f[g]=h+" "+Blockly.C.variableDB_.getName(a.arguments_[g],Blockly.Variables.NAME_TYPE)}c=e+" "+b+"("+f.join(", ")+") {\n"+c+d+"}";c=Blockly.C.scrub_(a,c);Blockly.C.functions_[b]=e+" "+b+" ("+f.join(", ")+");";Blockly.C.definitions_[b]=c;return null};Blockly.C.procedures_defnoreturn_typed=Blockly.C.procedures_defreturn_typed;
  Blockly.C.procedures_callreturn_typed=function(a){for(var b=Blockly.C.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.C.valueToCode(a,"ARG"+d,Blockly.C.ORDER_NONE)||"0";return[b+"("+c.join(", ")+")",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.procedures_callnoreturn_typed=Blockly.C.procedures_callnoreturn;
  Blockly.C.cast_block=function(a){var b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);a=a.getFieldValue("TYPE");return"STRING"===a?["new String("+b+")",Blockly.C.ORDER_NONE]:["("+getCType(a)+")("+b+")",Blockly.C.ORDER_NONE]};Blockly.C.procedures_return=function(a){return a.hasReturnValue_?"return "+(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_NONE)||"0")+";\n":"return;\n"};Blockly.C.math={};Blockly.C.addReservedWords("Math");Blockly.C.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));if(Infinity==a){a="double.INFINITY";var b=Blockly.C.ORDER_UNARY_POSTFIX}else-Infinity==a?(a="-double.INFINITY",b=Blockly.C.ORDER_UNARY_PREFIX):b=0>a?Blockly.C.ORDER_UNARY_PREFIX:Blockly.C.ORDER_ATOMIC;return[a,b]};
  Blockly.C.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.C.ORDER_ADDITIVE],MINUS:[" - ",Blockly.C.ORDER_ADDITIVE],MULTIPLY:[" * ",Blockly.C.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",Blockly.C.ORDER_MULTIPLICATIVE],POWER:[null,Blockly.C.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=Blockly.C.valueToCode(a,"A",b)||"0";a=Blockly.C.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:(Blockly.C.definitions_.import_dart_math="#include <math.h>",["pow("+d+", "+a+")",Blockly.C.ORDER_UNARY_POSTFIX])};
  Blockly.C.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"==b)return a=Blockly.C.valueToCode(a,"NUM",Blockly.C.ORDER_UNARY_PREFIX)||"0","-"==a[0]&&(a=" "+a),["-"+a,Blockly.C.ORDER_UNARY_PREFIX];Blockly.C.definitions_.import_dart_math="#include <math.h>";a="ABS"==b||"ROUND"==b.substring(0,5)?Blockly.C.valueToCode(a,"NUM",Blockly.C.ORDER_UNARY_POSTFIX)||"0":"SIN"==b||"COS"==b||"TAN"==b?Blockly.C.valueToCode(a,"NUM",Blockly.C.ORDER_MULTIPLICATIVE)||"0":Blockly.C.valueToCode(a,"NUM",Blockly.C.ORDER_NONE)||
  "0";switch(b){case "ABS":var c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "LN":c="log("+a+")";break;case "EXP":c="exp("+a+")";break;case "POW10":c="pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="ceil("+a+")";break;case "ROUNDDOWN":c="floor("+a+")";break;case "SIN":c="sin("+a+" / 180 * 3.14f)";break;case "COS":c="cos("+a+" / 180 * 3.14f)";break;case "TAN":c="tan("+a+" / 180 * 3.14f)"}if(c)return[c,Blockly.C.ORDER_UNARY_POSTFIX];switch(b){case "LOG10":c="log10("+
  a+")";break;case "ASIN":c="asin("+a+") / 3.14f * 180";break;case "ACOS":c="acos("+a+") / 3.14f * 180";break;case "ATAN":c="atan("+a+") / 3.14f * 180";break;default:throw"Unknown math operator: "+b;}return[c,Blockly.C.ORDER_MULTIPLICATIVE]};
  Blockly.C.math_constant=function(a){var b={PI:["3.14159265359f",Blockly.C.ORDER_UNARY_POSTFIX],E:["2.71828f",Blockly.C.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1.0f + sqrt(5.0f)) / 2.0f",Blockly.C.ORDER_MULTIPLICATIVE],SQRT2:["sqrt(2)",Blockly.C.ORDER_UNARY_POSTFIX],SQRT1_2:["sqrt(1.0f/2.0f)",Blockly.C.ORDER_UNARY_POSTFIX],INFINITY:["INFINITY",Blockly.C.ORDER_ATOMIC]};Blockly.C.definitions_.import_dart_math="#include <math.h>";a=a.getFieldValue("CONSTANT");return b[a]};
  Blockly.C.math_number_property=function(a){var b=Blockly.C.valueToCode(a,"NUMBER_TO_CHECK",Blockly.C.ORDER_MULTIPLICATIVE);if(!b)return["false",Blockly.Python.ORDER_ATOMIC];var c=a.getFieldValue("PROPERTY");if("PRIME"==c)return Blockly.C.definitions_.import_dart_math="#include <math.h>",[Blockly.C.provideFunction_("math_isPrime",["bool "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(n) {","  // https://en.wikipedia.org/wiki/Primality_test#Naive_methods","  if (n == 2 || n == 3) {","    return true;","  }",
  "  // False if n is null, negative, is 1, or not whole.","  // And false if n is divisible by 2 or 3.","  if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {","    return false;","  }","  // Check all the numbers of form 6k +/- 1, up to sqrt(n).","  for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {","    if (n % (x - 1) == 0 || n % (x + 1) == 0) {","      return false;","    }","  }","  return true;","}"])+"("+b+")",Blockly.C.ORDER_UNARY_POSTFIX];switch(c){case "EVEN":var d=b+" % 2 == 0";
  break;case "ODD":d=b+" % 2 == 1";break;case "WHOLE":d=b+" % 1 == 0";break;case "POSITIVE":d=b+" > 0";break;case "NEGATIVE":d=b+" < 0";break;case "DIVISIBLE_BY":a=Blockly.C.valueToCode(a,"DIVISOR",Blockly.C.ORDER_MULTIPLICATIVE);if(!a)return["false",Blockly.Python.ORDER_ATOMIC];d=b+" % "+a+" == 0"}return[d,Blockly.C.ORDER_EQUALITY]};
  Blockly.C.math_change=function(a){var b=Blockly.C.valueToCode(a,"DELTA",Blockly.C.ORDER_ADDITIVE)||"0";a=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return a+" = "+a+" + "+b+";\n"};Blockly.C.math_round=Blockly.C.math_single;Blockly.C.math_trig=Blockly.C.math_single;
  Blockly.C.math_on_list=function(a){var b=a.getFieldValue("OP");a=Blockly.C.valueToCode(a,"LIST",Blockly.C.ORDER_NONE)||"[]";switch(b){case "SUM":b=Blockly.C.provideFunction_("math_sum",["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  num sumVal = 0;","  myList.forEach((num entry) {sumVal += entry;});","  return sumVal;","}"]);b=b+"("+a+")";break;case "MIN":Blockly.C.definitions_.import_dart_math="#include <math.h>";b=Blockly.C.provideFunction_("math_min",["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+
  "(List myList) {","  if (myList.isEmpty) return null;","  num minVal = myList[0];","  myList.forEach((num entry) {minVal = Math.min(minVal, entry);});","  return minVal;","}"]);b=b+"("+a+")";break;case "MAX":Blockly.C.definitions_.import_dart_math="#include <math.h>";b=Blockly.C.provideFunction_("math_max",["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  if (myList.isEmpty) return null;","  num maxVal = myList[0];","  myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});",
  "  return maxVal;","}"]);b=b+"("+a+")";break;case "AVERAGE":b=Blockly.C.provideFunction_("math_average",["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  // First filter list for numbers only.","  List localList = new List.from(myList);","  localList.removeMatching((a) => a is! num);","  if (localList.isEmpty) return null;","  num sumVal = 0;","  localList.forEach((num entry) {sumVal += entry;});","  return sumVal / localList.length;","}"]);b=b+"("+a+")";break;case "MEDIAN":b=Blockly.C.provideFunction_("math_median",
  ["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  // First filter list for numbers only, then sort, then return middle value","  // or the average of two middle values if list has an even number of elements.","  List localList = new List.from(myList);","  localList.removeMatching((a) => a is! num);","  if (localList.isEmpty) return null;","  localList.sort((a, b) => (a - b));","  int index = localList.length ~/ 2;","  if (localList.length % 2 == 1) {","    return localList[index];",
  "  } else {","    return (localList[index - 1] + localList[index]) / 2;","  }","}"]);b=b+"("+a+")";break;case "MODE":Blockly.C.definitions_.import_dart_math="#include <math.h>";b=Blockly.C.provideFunction_("math_modes",["List "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List values) {","  List modes = [];","  List counts = [];","  int maxCount = 0;","  for (int i = 0; i < values.length; i++) {","    var value = values[i];","    bool found = false;","    int thisCount;","    for (int j = 0; j < counts.length; j++) {",
  "      if (counts[j][0] == value) {","        thisCount = ++counts[j][1];","        found = true;","        break;","      }","    }","    if (!found) {","      counts.add([value, 1]);","      thisCount = 1;","    }","    maxCount = Math.max(thisCount, maxCount);","  }","  for (int j = 0; j < counts.length; j++) {","    if (counts[j][1] == maxCount) {","        modes.add(counts[j][0]);","    }","  }","  return modes;","}"]);b=b+"("+a+")";break;case "STD_DEV":Blockly.C.definitions_.import_dart_math=
  "#include <math.h>";b=Blockly.C.provideFunction_("math_standard_deviation",["num "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  // First filter list for numbers only.","  List numbers = new List.from(myList);","  numbers.removeMatching((a) => a is! num);","  if (numbers.isEmpty) return null;","  num n = numbers.length;","  num sum = 0;","  numbers.forEach((x) => sum += x);","  num mean = sum / n;","  num sumSquare = 0;","  numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));",
  "  return Math.sqrt(sumSquare / n);","}"]);b=b+"("+a+")";break;case "RANDOM":Blockly.C.definitions_.import_dart_math="#include <math.h>";b=Blockly.C.provideFunction_("math_random_item",["dynamic "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {","  int x = new Math.Random().nextInt(myList.length);","  return myList[x];","}"]);b=b+"("+a+")";break;default:throw"Unknown operator: "+b;}return[b,Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.math_modulo=function(a){var b=Blockly.C.valueToCode(a,"DIVIDEND",Blockly.C.ORDER_MULTIPLICATIVE)||"0";a=Blockly.C.valueToCode(a,"DIVISOR",Blockly.C.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,Blockly.C.ORDER_MULTIPLICATIVE]};
  Blockly.C.math_constrain=function(a){Blockly.C.definitions_.import_dart_math="#include <math.h>";var b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_NONE)||"0",c=Blockly.C.valueToCode(a,"LOW",Blockly.C.ORDER_NONE)||"0";a=Blockly.C.valueToCode(a,"HIGH",Blockly.C.ORDER_NONE)||"double.INFINITY";return["min(max("+b+", "+c+"), "+a+")",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.math_random_int=function(a){Blockly.C.definitions_.import_dart_math="#include <math.h>";var b=Blockly.C.valueToCode(a,"FROM",Blockly.C.ORDER_NONE)||"0";a=Blockly.C.valueToCode(a,"TO",Blockly.C.ORDER_NONE)||"0";return[Blockly.C.provideFunction_("math_random_int",["int "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(int a, int b) {","  if (a > b) {","    // Swap a and b to ensure a is smaller.","    int c = a;","    a = b;","    b = c;","  }","  return (rand() % (b - a)) + a;","}"])+"("+b+", "+a+
  ")",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.math_random_float=function(a){Blockly.C.definitions_.import_dart_math="#include <math.h>";return["new Math.Random().nextDouble()",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.arduino={};Blockly.C.hardwarestartup_arduino=function(a){a=Blockly.C.statementToCode(a,"do");Blockly.C.definitions_.setup='// Below is the "setup" function. It runs one time as soon as the board turns on. You can add stuff\nvoid setup(){\n'+a+"}\n";return null};Blockly.C.delayseconds=function(a){return"delay("+(Blockly.C.valueToCode(a,"SECONDS",Blockly.C.ORDER_ATOMIC)||"0")+" * 1000);\n"};
  Blockly.C.delayms=function(a){return"delay( "+(Blockly.C.valueToCode(a,"MILLISECONDS",Blockly.C.ORDER_ATOMIC)||"0")+" );\n"};Blockly.C.delaymicroseconds=function(a){return"delayMicroseconds( "+(Blockly.C.valueToCode(a,"MICROSECONDS",Blockly.C.ORDER_ATOMIC)||"0")+" );\n"};Blockly.C.seconds=function(a){return["(millis() / 1000)",Blockly.C.ORDER_NONE]};Blockly.C.milliseconds=function(a){return["millis()",Blockly.C.ORDER_NONE]};Blockly.C.microseconds=function(a){return["micros()",Blockly.C.ORDER_NONE]};
  Blockly.C.high=function(a){return["HIGH",Blockly.C.ORDER_ATOMIC]};Blockly.C.low=function(a){return["LOW",Blockly.C.ORDER_ATOMIC]};Blockly.C.led_builtin=function(a){return["LED_BUILTIN",Blockly.C.ORDER_ATOMIC]};Blockly.C.pininput=function(a){var b=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)||"0";a=a.getFieldValue("MODE")||"0";return"pinMode("+b+", "+a+");\n"};
  Blockly.C.digitalwrite=function(a){var b=a.getFieldValue("VALUE")||"HIGH";return"digitalWrite("+Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)+", "+b+");\n"};Blockly.C.digital_read=function(a){return["digitalRead("+Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.analog_reference=function(a){return"analogReference("+a.getFieldValue("TYPE")+");\n"};
  Blockly.C.analog_read=function(a){return["analogRead("+Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.analog_write=function(a){var b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return"analogWrite("+Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)+", "+b+");\n"};
  Blockly.C.tone_pin_freq_duration=function(a){var b=Blockly.C.valueToCode(a,"FREQUENCY",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"DURATION",Blockly.C.ORDER_ATOMIC);return"tone("+c+", "+b+", "+a+");\n"};Blockly.C.tone_pin_freq=function(a){var b=Blockly.C.valueToCode(a,"FREQUENCY",Blockly.C.ORDER_ATOMIC)||"0";return"tone("+(Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)||"0")+", "+b+");\n"};
  Blockly.C.advanced_io_pulse_in=function(a){var b=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC);a=a.getFieldValue("VALUE");return["pulseIn("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.advanced_io_pulse_in_timeout=function(a){var b=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"TIMEOUT",Blockly.C.ORDER_ATOMIC)||"0";a=a.getFieldValue("VALUE");return["pulseIn("+b+", "+a+", "+c+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.advanced_io_pulse_in_long=function(a){var b=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)||"0";a=a.getFieldValue("VALUE");return["pulseInLong("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.advanced_io_pulse_in_long_timeout=function(a){var b=Blockly.C.valueToCode(a,"PIN",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"TIMEOUT",Blockly.C.ORDER_ATOMIC)||"0";a=a.getFieldValue("VALUE");return["pulseInLong("+b+", "+a+", "+c+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.advanced_io_shift_in=function(a){var b=Blockly.C.valueToCode(a,"DATA_PIN",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"CLOCK_PIN",Blockly.C.ORDER_ATOMIC)||"0";a=a.getFieldValue("BIT_ORDER");return["shiftIn("+b+", "+c+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.advanced_io_shift_out=function(a){var b=Blockly.C.valueToCode(a,"DATA_PIN",Blockly.C.ORDER_ATOMIC)||"0",c=Blockly.C.valueToCode(a,"CLOCK_PIN",Blockly.C.ORDER_ATOMIC)||"0",d=a.getFieldValue("BIT_ORDER");a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC)||"0";return["shiftOut("+b+", "+c+", "+d+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.random_seed=function(a){return"randomSeed("+Blockly.C.valueToCode(a,"SEED",Blockly.C.ORDER_ATOMIC)+");\n"};
  Blockly.C.random=function(a){var b=Blockly.C.valueToCode(a,"MIN",Blockly.C.ORDER_ATOMIC)||"0";a=Blockly.C.valueToCode(a,"MAX",Blockly.C.ORDER_ATOMIC);return["random("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_random_seed=function(a){return"randomSeed("+Blockly.C.valueToCode(a,"SEED",Blockly.C.ORDER_ATOMIC)+");\n"};
  Blockly.C.arduino_random=function(a){var b=Blockly.C.valueToCode(a,"MIN",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"MAX",Blockly.C.ORDER_ATOMIC);return["random("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.arduino_srand=function(a){return"srand("+Blockly.C.valueToCode(a,"SEED",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.bit=function(a){return["bit("+Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.bit_clear=function(a){var b=Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"POSITION",Blockly.C.ORDER_ATOMIC);return"bitClear("+b+", "+a+");\n"};Blockly.C.bit_set=function(a){var b=Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"POSITION",Blockly.C.ORDER_ATOMIC);return"bitSet("+b+", "+a+");\n"};
  Blockly.C.bit_write=function(a){var b=Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"POSITION",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC);return"bitWrite("+b+", "+c+", "+a+");\n"};Blockly.C.bit_read=function(a){var b=Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"POSITION",Blockly.C.ORDER_ATOMIC);return["bitRead("+b+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.high_byte=function(a){return["highByte("+Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};Blockly.C.low_byte=function(a){return["lowByte("+Blockly.C.valueToCode(a,"NUMBER",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.arduino_math_map=function(a){var b=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"FROM_LOW",Blockly.C.ORDER_ATOMIC),d=Blockly.C.valueToCode(a,"FROM_HIGH",Blockly.C.ORDER_ATOMIC),e=Blockly.C.valueToCode(a,"TO_LOW",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"TO_HIGH",Blockly.C.ORDER_ATOMIC);return["map("+b+", "+c+", "+d+", "+e+", "+a+")",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.char_input=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["'"+a.getFieldValue("TEXT")+"'",Blockly.C.ORDER_ATOMIC]};Blockly.C.char_to_lower=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["tolower("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_to_upper=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["toupper("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_alnum=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isalnum("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_is_alpha=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isalpha("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_cntrl=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["iscntrl("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_is_digit=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isdigit("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_graph=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isgraph("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_is_lower=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["islower("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_print=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isprint("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_is_punct=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["ispunct("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_space=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isspace("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};
  Blockly.C.char_is_upper=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isupper("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};Blockly.C.char_is_xdigit=function(a){Blockly.C.definitions_.import_c_type="#include <ctype.h>";return["isxdigit("+Blockly.C.valueToCode(a,"CHAR",Blockly.C.ORDER_ATOMIC)+")",Blockly.C.ORDER_FUNCTION_CALL]};/*
   DigiPen Institute of Technology 2018
  */
  Blockly.C.comments={};Blockly.C.comment_oneline=function(a){return"// "+a.getFieldValue("TEXT")+"\n"};Blockly.C.colour={};Blockly.C.addReservedWords("Math");Blockly.C.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.C.ORDER_ATOMIC]};
  Blockly.C.colour_random=function(a){Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;";return[Blockly.C.provideFunction_("colour_random",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"() {","  String hex = '0123456789abcdef';","  var rnd = new Math.Random();","  return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'","      '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'","      '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';","}"])+"()",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.colour_rgb=function(a){var b=Blockly.C.valueToCode(a,"RED",Blockly.C.ORDER_NONE)||0,c=Blockly.C.valueToCode(a,"GREEN",Blockly.C.ORDER_NONE)||0;a=Blockly.C.valueToCode(a,"BLUE",Blockly.C.ORDER_NONE)||0;Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;";return[Blockly.C.provideFunction_("colour_rgb",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {","  num rn = (Math.max(Math.min(r, 1), 0) * 255).round();","  String rs = rn.toInt().toRadixString(16);",
  "  rs = '0$rs';","  rs = rs.substring(rs.length - 2);","  num gn = (Math.max(Math.min(g, 1), 0) * 255).round();","  String gs = gn.toInt().toRadixString(16);","  gs = '0$gs';","  gs = gs.substring(gs.length - 2);","  num bn = (Math.max(Math.min(b, 1), 0) * 255).round();","  String bs = bn.toInt().toRadixString(16);","  bs = '0$bs';","  bs = bs.substring(bs.length - 2);","  return '#$rs$gs$bs';","}"])+"("+b+", "+c+", "+a+")",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.colour_blend=function(a){var b=Blockly.C.valueToCode(a,"COLOUR1",Blockly.C.ORDER_NONE)||"'#000000'",c=Blockly.C.valueToCode(a,"COLOUR2",Blockly.C.ORDER_NONE)||"'#000000'";a=Blockly.C.valueToCode(a,"RATIO",Blockly.C.ORDER_NONE)||.5;Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;";return[Blockly.C.provideFunction_("colour_blend",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(String c1, String c2, num ratio) {","  ratio = Math.max(Math.min(ratio, 1), 0);","  int r1 = int.parse('0x${c1.substring(1, 3)}');",
  "  int g1 = int.parse('0x${c1.substring(3, 5)}');","  int b1 = int.parse('0x${c1.substring(5, 7)}');","  int r2 = int.parse('0x${c2.substring(1, 3)}');","  int g2 = int.parse('0x${c2.substring(3, 5)}');","  int b2 = int.parse('0x${c2.substring(5, 7)}');","  num rn = (r1 * (1 - ratio) + r2 * ratio).round();","  String rs = rn.toInt().toRadixString(16);","  num gn = (g1 * (1 - ratio) + g2 * ratio).round();","  String gs = gn.toInt().toRadixString(16);","  num bn = (b1 * (1 - ratio) + b2 * ratio).round();",
  "  String bs = bn.toInt().toRadixString(16);","  rs = '0$rs';","  rs = rs.substring(rs.length - 2);","  gs = '0$gs';","  gs = gs.substring(gs.length - 2);","  bs = '0$bs';","  bs = bs.substring(bs.length - 2);","  return '#$rs$gs$bs';","}"])+"("+b+", "+c+", "+a+")",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.arduino_stepper={};
  Blockly.C.stepper=function(a){Blockly.C.definitions_.include_stepper="#include <Stepper.h>";var b=Blockly.C.valueToCode(a,"STEPS",Blockly.C.ORDER_ATOMIC),c=Blockly.C.valueToCode(a,"PIN1",Blockly.C.ORDER_ATOMIC),d=Blockly.C.valueToCode(a,"PIN2",Blockly.C.ORDER_ATOMIC),e=Blockly.C.valueToCode(a,"PIN3",Blockly.C.ORDER_ATOMIC);a=Blockly.C.valueToCode(a,"PIN4",Blockly.C.ORDER_ATOMIC);Blockly.C.definitions_.stepper_create="Stepper stepper = Stepper("+b+","+c+","+d+","+e+","+a+");\n";return""};
  Blockly.C.stepper_set_speed=function(a){Blockly.C.definitions_.include_stepper="#include <Stepper.h>";return"stepper.setSpeed("+Blockly.C.valueToCode(a,"SPEED",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.stepper_steps=function(a){Blockly.C.definitions_.include_stepper="#include <Stepper.h>";Blockly.C.valueToCode(a,"STEPPER",Blockly.C.ORDER_ATOMIC);return"stepper.step("+Blockly.C.valueToCode(a,"STEPS",Blockly.C.ORDER_ATOMIC)+");\n"};Blockly.C.loops={};
  Blockly.C.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):Blockly.C.valueToCode(a,"TIMES",Blockly.C.ORDER_ASSIGNMENT)||"0",c=Blockly.C.statementToCode(a,"DO");c=Blockly.C.addLoopTrap(c,a.id);a="";var d=Blockly.C.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.C.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),a+="int "+e+" = "+b+";\n");return a+("for (int "+
  d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.C.controls_repeat=Blockly.C.controls_repeat_ext;Blockly.C.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.C.valueToCode(a,"BOOL",b?Blockly.C.ORDER_UNARY_PREFIX:Blockly.C.ORDER_NONE)||"false",d=Blockly.C.statementToCode(a,"DO");d=Blockly.C.addLoopTrap(d,a.id);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
  Blockly.C.controls_for=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.C.valueToCode(a,"FROM",Blockly.C.ORDER_ASSIGNMENT)||"0",d=Blockly.C.valueToCode(a,"TO",Blockly.C.ORDER_ASSIGNMENT)||"0",e=Blockly.C.valueToCode(a,"BY",Blockly.C.ORDER_ASSIGNMENT)||"1",f=Blockly.C.statementToCode(a,"DO");f=Blockly.C.addLoopTrap(f,a.id);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&Blockly.isNumber(e)){var g=parseFloat(c)<=parseFloat(d);a="for ("+b+" = "+
  c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.C.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="int "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.C.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),a+="int "+c+" = "+d+";\n"),d=Blockly.C.variableDB_.getDistinctName(b+"_inc",Blockly.Variables.NAME_TYPE),
  a+="int "+d+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+(Blockly.C.INDENT+d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+";\n     "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+";\n     "+b+" += "+d+") {\n"+f+"}\n";return a};
  Blockly.C.controls_forEach=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.C.valueToCode(a,"LIST",Blockly.C.ORDER_ASSIGNMENT)||"std::list()",d=Blockly.C.statementToCode(a,"DO");d=Blockly.C.addLoopTrap(d,a.id);return"for (auto "+b+" : "+c+") {\n"+d+"}\n"};Blockly.C.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw"Unknown flow statement.";};/*
  
   ( All content copyright DigiPen Institute of Technology 2016
  */
  Blockly.C.texts={};Blockly.C.addReservedWords("Html,Math");Blockly.C.text=function(a){return[Blockly.C.quote_(a.getFieldValue("TEXT")),Blockly.C.ORDER_ATOMIC]};
  Blockly.C.text_join=function(a){if(0==a.itemCount_)return["''",Blockly.C.ORDER_ATOMIC];if(1==a.itemCount_)return[(Blockly.C.valueToCode(a,"ADD0",Blockly.C.ORDER_UNARY_POSTFIX)||"''")+".toString()",Blockly.C.ORDER_UNARY_POSTFIX];var b=Array(a.itemCount_);for(var c=0;c<a.itemCount_;c++)b[c]=Blockly.C.valueToCode(a,"ADD"+c,Blockly.C.ORDER_NONE)||"''";b="["+b.join(",")+"].join()";return[b,Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.text_append=function(a){var b=Blockly.C.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_UNARY_POSTFIX)||"''";return b+" = ["+b+", "+a+"].join();\n"};Blockly.C.text_length=function(a){return["strlen( "+(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||'""')+" )",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.text_isEmpty=function(a){return[(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"''")+".isEmpty",Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.text_indexOf=function(a){var b="FIRST"==a.getFieldValue("END")?"indexOf":"lastIndexOf",c=Blockly.C.valueToCode(a,"FIND",Blockly.C.ORDER_NONE)||"''";return[(Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"''")+"."+b+"("+c+") + 1",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=Blockly.C.valueToCode(a,"AT",Blockly.C.ORDER_NONE)||"1";a=Blockly.C.valueToCode(a,"VALUE",Blockly.C.ORDER_UNARY_POSTFIX)||"''";switch(b){case "FIRST":return[a+"[0]",Blockly.C.ORDER_UNARY_POSTFIX];case "FROM_START":return c=c.match(/^-?\d+$/)?parseInt(c,10)-1:c+" - 1",[a+"["+c+"]",Blockly.C.ORDER_UNARY_POSTFIX];case "LAST":c=1;case "FROM_END":return b=Blockly.C.provideFunction_("text_get_from_end",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+
  "(String text, num x) {","  return text[text.length - x];","}"]),[b+"("+a+", "+c+")",Blockly.C.ORDER_UNARY_POSTFIX];case "RANDOM":return Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;",b=Blockly.C.provideFunction_("text_random_letter",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(String text) {","  int x = new Math.Random().nextInt(text.length);","  return text[x];","}"]),[b+"("+a+")",Blockly.C.ORDER_UNARY_POSTFIX]}throw"Unhandled option (text_charAt).";};
  Blockly.C.text_getSubstring=function(a){var b=Blockly.C.valueToCode(a,"STRING",Blockly.C.ORDER_UNARY_POSTFIX)||"''",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=Blockly.C.valueToCode(a,"AT1",Blockly.C.ORDER_NONE)||"1";a=Blockly.C.valueToCode(a,"AT2",Blockly.C.ORDER_NONE)||"1";return["FIRST"==c&&"LAST"==d?b:Blockly.C.provideFunction_("text_get_substring",["function "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(text, where1, at1, where2, at2) {","  function getAt(where, at) {","    if (where == 'FROM_START') {",
  "      at--;","    } else if (where == 'FROM_END') {","      at = text.length - at;","    } else if (where == 'FIRST') {","      at = 0;","    } else if (where == 'LAST') {","      at = text.length - 1;","    } else {","      throw 'Unhandled option (text_getSubstring).';","    }","    return at;","  }","  at1 = getAt(where1, at1);","  at2 = getAt(where2, at2) + 1;","  return text.substring(at1, at2);","}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")",Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];b?(a=Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_UNARY_POSTFIX)||"''",a+=b):(b=Blockly.C.provideFunction_("text_toTitleCase",["String "+Blockly.C.FUNCTION_NAME_PLACEHOLDER_+"(String str) {","  RegExp exp = new RegExp(r'\\b');","  List<String> list = str.split(exp);","  final title = new StringBuffer();","  for (String part in list) {","    if (part.length > 0) {",
  "      title.write(part[0].toUpperCase());","      if (part.length > 0) {","        title.write(part.substring(1).toLowerCase());","      }","    }","  }","  return title.toString();","}"]),a=Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_NONE)||"''",a=b+"("+a+")");return[a,Blockly.C.ORDER_UNARY_POSTFIX]};
  Blockly.C.text_trim=function(a){var b={LEFT:".replaceFirst(new RegExp(r'^\\s+'), '')",RIGHT:".replaceFirst(new RegExp(r'\\s+$'), '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_UNARY_POSTFIX)||"''")+b,Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.text_print=function(a){return"print("+(Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_NONE)||"''")+");\n"};
  Blockly.C.text_prompt_ext=function(a){Blockly.C.definitions_.import_dart_html="import 'dart:html' as Html;";var b="Html.window.prompt("+(a.getField("TEXT")?Blockly.C.quote_(a.getFieldValue("TEXT")):Blockly.C.valueToCode(a,"TEXT",Blockly.C.ORDER_NONE)||"''")+", '')";"NUMBER"==a.getFieldValue("TYPE")&&(Blockly.C.definitions_.import_dart_math="import 'dart:math' as Math;",b="Math.parseDouble("+b+")");return[b,Blockly.C.ORDER_UNARY_POSTFIX]};Blockly.C.text_prompt=Blockly.C.text_prompt_ext;
  Blockly.C.escape_characters=function(a){return["'\\"+a.getFieldValue("CHAR")+"'",Blockly.C.ORDER_ATOMIC]};