forked from google/blockly
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dart_compressed.js
117 lines (114 loc) · 44.2 KB
/
dart_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
// Do not edit this file; automatically generated.
/* eslint-disable */
;(function(root, factory) {
if (typeof define === 'function' && define.amd) { // AMD
define(["./blockly_compressed.js"], factory);
} else if (typeof exports === 'object') { // Node.js
module.exports = factory(require("./blockly_compressed.js"));
} else { // Browser
var factoryExports = factory(root.Blockly);
root.Blockly.Dart = factoryExports;
}
}(this, function(__parent__) {
var $=__parent__.__namespace__;
var module$contents$Blockly$Dart_Dart=new $.module$exports$Blockly$Generator.Generator("Dart");module$contents$Blockly$Dart_Dart.addReservedWords("assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError");
module$contents$Blockly$Dart_Dart.ORDER_ATOMIC=0;module$contents$Blockly$Dart_Dart.ORDER_UNARY_POSTFIX=1;module$contents$Blockly$Dart_Dart.ORDER_UNARY_PREFIX=2;module$contents$Blockly$Dart_Dart.ORDER_MULTIPLICATIVE=3;module$contents$Blockly$Dart_Dart.ORDER_ADDITIVE=4;module$contents$Blockly$Dart_Dart.ORDER_SHIFT=5;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_AND=6;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_XOR=7;module$contents$Blockly$Dart_Dart.ORDER_BITWISE_OR=8;
module$contents$Blockly$Dart_Dart.ORDER_RELATIONAL=9;module$contents$Blockly$Dart_Dart.ORDER_EQUALITY=10;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_AND=11;module$contents$Blockly$Dart_Dart.ORDER_LOGICAL_OR=12;module$contents$Blockly$Dart_Dart.ORDER_IF_NULL=13;module$contents$Blockly$Dart_Dart.ORDER_CONDITIONAL=14;module$contents$Blockly$Dart_Dart.ORDER_CASCADE=15;module$contents$Blockly$Dart_Dart.ORDER_ASSIGNMENT=16;module$contents$Blockly$Dart_Dart.ORDER_NONE=99;
module$contents$Blockly$Dart_Dart.isInitialized=!1;
module$contents$Blockly$Dart_Dart.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);for(var b=[],c=(0,$.module$exports$Blockly$Variables.allDeveloperVariables)(a),d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$exports$Blockly$Names.NameType.DEVELOPER_VARIABLE));
a=(0,$.module$exports$Blockly$Variables.allUsedVarModels)(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.module$exports$Blockly$Names.NameType.VARIABLE));b.length&&(this.definitions_.variables="var "+b.join(", ")+";");this.isInitialized=!0};
module$contents$Blockly$Dart_Dart.finish=function(a){a&&(a=this.prefixLines(a,this.INDENT));a="main() {\n"+a+"}";var b=[],c=[],d;for(d in this.definitions_){var e=this.definitions_[d];e.match(/^import\s/)?b.push(e):c.push(e)}a=Object.getPrototypeOf(this).finish.call(this,a);this.isInitialized=!1;this.nameDB_.reset();return(b.join("\n")+"\n\n"+c.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+a};module$contents$Blockly$Dart_Dart.scrubNakedValue=function(a){return a+";\n"};
module$contents$Blockly$Dart_Dart.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return"'"+a+"'"};module$contents$Blockly$Dart_Dart.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
module$contents$Blockly$Dart_Dart.scrub_=function(a,b,c){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=(0,$.module$exports$Blockly$utils$string.wrap)(e,this.COMMENT_WRAP-3),d=a.getProcedureDef?d+this.prefixLines(e+"\n","/// "):d+this.prefixLines(e+"\n","// "));for(var f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$exports$Blockly$inputTypes.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&
(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};
module$contents$Blockly$Dart_Dart.getAdjusted=function(a,b,c,d,e){c=c||0;e=e||this.ORDER_NONE;a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g;if(c)var h=g=this.ORDER_ADDITIVE;else d?h=g=this.ORDER_UNARY_PREFIX:g=e;a=this.valueToCode(a,b,g)||f;(0,$.module$exports$Blockly$utils$string.isNumber)(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(0<c?a=a+" + "+c:0>c&&(a=a+" - "+-c),d&&(a=c?"-("+a+")":"-"+a),h=Math.floor(h),e=Math.floor(e),h&&e>=h&&(a="("+a+")"));return a};
$.Blockly.Dart=module$contents$Blockly$Dart_Dart;var module$exports$Blockly$Dart$variables={};$.Blockly.Dart.variables_get=function(a){return[$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.variables_set=function(a){var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";return $.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Dart$variablesDynamic={};$.Blockly.Dart.variables_get_dynamic=$.Blockly.Dart.variables_get;$.Blockly.Dart.variables_set_dynamic=$.Blockly.Dart.variables_set;var module$exports$Blockly$Dart$texts={};$.Blockly.Dart.addReservedWords("Html,Math");$.Blockly.Dart.text=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("TEXT")),$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.text_multiline=function(a){a=$.Blockly.Dart.multiline_quote_(a.getFieldValue("TEXT"));var b=-1!==a.indexOf("+")?$.Blockly.Dart.ORDER_ADDITIVE:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
$.Blockly.Dart.text_join=function(a){switch(a.itemCount_){case 0:return["''",$.Blockly.Dart.ORDER_ATOMIC];case 1:return[($.Blockly.Dart.valueToCode(a,"ADD0",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".toString()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];default:for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"''";return["["+b.join(",")+"].join()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}};
$.Blockly.Dart.text_append=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);a=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";return b+" = ["+b+", "+a+"].join();\n"};$.Blockly.Dart.text_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=$.Blockly.Dart.valueToCode(a,"VALUE","FIRST"===b||"FROM_START"===b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";switch(b){case "FIRST":return[c+"[0]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "FROM_START":return a=$.Blockly.Dart.getAdjusted(a,"AT"),[c+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "LAST":case "FROM_END":return a=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("text_get_from_end",
"\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, num x) {\n return text[text.length - x];\n}\n")+"("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];case "RANDOM":return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",[$.Blockly.Dart.provideFunction_("text_random_letter","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text) {\n int x = new Math.Random().nextInt(text.length);\n return text[x];\n}\n")+"("+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).");
};
$.Blockly.Dart.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1"),c=a.getFieldValue("WHERE2"),d="FROM_END"!==b&&"FROM_START"===c,e=$.Blockly.Dart.valueToCode(a,"STRING",d?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";if("FIRST"===b&&"LAST"===c)return[e,$.Blockly.Dart.ORDER_NONE];if(e.match(/^'?\w+'?$/)||d){switch(b){case "FROM_START":b=$.Blockly.Dart.getAdjusted(a,"AT1");break;case "FROM_END":b=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);b=
e+".length - "+b;break;case "FIRST":b="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(c){case "FROM_START":var f=$.Blockly.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":f=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.ORDER_ADDITIVE);f=e+".length - "+f;break;case "LAST":break;default:throw Error("Unhandled option (text_getSubstring).");}c="LAST"===c?e+".substring("+b+")":e+".substring("+b+", "+f+")"}else f=$.Blockly.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,
"AT2"),c=$.Blockly.Dart.provideFunction_("text_get_substring","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String text, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = text.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = text.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (text_getSubstring).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return text.substring(at1, at2);\n}\n")+
"("+e+", '"+b+"', "+f+", '"+c+"', "+a+")";return[c,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=$.Blockly.Dart.valueToCode(a,"TEXT",b?$.Blockly.Dart.ORDER_UNARY_POSTFIX:$.Blockly.Dart.ORDER_NONE)||"''";return[b?a+b:$.Blockly.Dart.provideFunction_("text_toTitleCase","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String str) {\n RegExp exp = new RegExp(r'\\b');\n List<String> list = str.split(exp);\n final title = new StringBuffer();\n for (String part in list) {\n if (part.length > 0) {\n title.write(part[0].toUpperCase());\n if (part.length > 0) {\n title.write(part.substring(1).toLowerCase());\n }\n }\n }\n return title.toString();\n}\n")+"("+
a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.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.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_print=function(a){return"print("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+");\n"};
$.Blockly.Dart.text_prompt_ext=function(a){$.Blockly.Dart.definitions_.import_dart_html="import 'dart:html' as Html;";var b="Html.window.prompt("+(a.getField("TEXT")?$.Blockly.Dart.quote_(a.getFieldValue("TEXT")):$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''")+", '')";"NUMBER"===a.getFieldValue("TYPE")&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",b="Math.parseDouble("+b+")");return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_prompt=$.Blockly.Dart.text_prompt_ext;
$.Blockly.Dart.text_count=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"SUB",$.Blockly.Dart.ORDER_NONE)||"''";return[$.Blockly.Dart.provideFunction_("text_count","\nint "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String haystack, String needle) {\n if (needle.length == 0) {\n return haystack.length + 1;\n }\n int index = 0;\n int count = 0;\n while (index != -1) {\n index = haystack.indexOf(needle, index);\n if (index != -1) {\n count++;\n index += needle.length;\n }\n }\n return count;\n}\n")+"("+
b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.text_replace=function(a){var b=$.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''",c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"''";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"''";return[b+".replaceAll("+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.text_reverse=function(a){return["new String.fromCharCodes("+($.Blockly.Dart.valueToCode(a,"TEXT",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"''")+".runes.toList().reversed)",$.Blockly.Dart.ORDER_UNARY_PREFIX]};var module$exports$Blockly$Dart$procedures={};
$.Blockly.Dart.procedures_defreturn=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));c&&(c=$.Blockly.Dart.prefixLines(c,$.Blockly.Dart.INDENT));var d="";$.Blockly.Dart.INFINITE_LOOP_TRAP&&(d=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.INFINITE_LOOP_TRAP,
a),$.Blockly.Dart.INDENT));var e=$.Blockly.Dart.statementToCode(a,"STACK"),f=$.Blockly.Dart.valueToCode(a,"RETURN",$.Blockly.Dart.ORDER_NONE)||"",g="";e&&f&&(g=c);f&&(f=$.Blockly.Dart.INDENT+"return "+f+";\n");for(var h=f?"dynamic":"void",k=[],l=a.getVars(),m=0;m<l.length;m++)k[m]=$.Blockly.Dart.nameDB_.getName(l[m],$.module$exports$Blockly$Names.NameType.VARIABLE);c=h+" "+b+"("+k.join(", ")+") {\n"+c+d+e+g+f+"}";c=$.Blockly.Dart.scrub_(a,c);$.Blockly.Dart.definitions_["%"+b]=c;return null};
$.Blockly.Dart.procedures_defnoreturn=$.Blockly.Dart.procedures_defreturn;$.Blockly.Dart.procedures_callreturn=function(a){for(var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=[],d=a.getVars(),e=0;e<d.length;e++)c[e]=$.Blockly.Dart.valueToCode(a,"ARG"+e,$.Blockly.Dart.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.procedures_callnoreturn=function(a){return $.Blockly.Dart.procedures_callreturn(a)[0]+";\n"};
$.Blockly.Dart.procedures_ifreturn=function(a){var b="if ("+($.Blockly.Dart.valueToCode(a,"CONDITION",$.Blockly.Dart.ORDER_NONE)||"false")+") {\n";$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT));a.hasReturnValue_?(a=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"null",b+=$.Blockly.Dart.INDENT+"return "+a+";\n"):b+=$.Blockly.Dart.INDENT+"return;\n";return b+"}\n"};var module$exports$Blockly$Dart$math={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.math_number=function(a){a=Number(a.getFieldValue("NUM"));if(Infinity===a){a="double.infinity";var b=$.Blockly.Dart.ORDER_UNARY_POSTFIX}else-Infinity===a?(a="-double.infinity",b=$.Blockly.Dart.ORDER_UNARY_PREFIX):b=0>a?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_ATOMIC;return[a,b]};
$.Blockly.Dart.math_arithmetic=function(a){var b={ADD:[" + ",$.Blockly.Dart.ORDER_ADDITIVE],MINUS:[" - ",$.Blockly.Dart.ORDER_ADDITIVE],MULTIPLY:[" * ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",$.Blockly.Dart.ORDER_MULTIPLICATIVE],POWER:[null,$.Blockly.Dart.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=$.Blockly.Dart.valueToCode(a,"A",b)||"0";a=$.Blockly.Dart.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",
["Math.pow("+d+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX])};
$.Blockly.Dart.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"===b)return a=$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_PREFIX)||"0","-"===a[0]&&(a=" "+a),["-"+a,$.Blockly.Dart.ORDER_UNARY_PREFIX];$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a="ABS"===b||"ROUND"===b.substring(0,5)?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"0":"SIN"===b||"COS"===b||"TAN"===b?$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||
"0":$.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_NONE)||"0";switch(b){case "ABS":var c=a+".abs()";break;case "ROOT":c="Math.sqrt("+a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c=a+".round()";break;case "ROUNDUP":c=a+".ceil()";break;case "ROUNDDOWN":c=a+".floor()";break;case "SIN":c="Math.sin("+a+" / 180 * Math.pi)";break;case "COS":c="Math.cos("+a+" / 180 * Math.pi)";break;case "TAN":c="Math.tan("+
a+" / 180 * Math.pi)"}if(c)return[c,$.Blockly.Dart.ORDER_UNARY_POSTFIX];switch(b){case "LOG10":c="Math.log("+a+") / Math.log(10)";break;case "ASIN":c="Math.asin("+a+") / Math.pi * 180";break;case "ACOS":c="Math.acos("+a+") / Math.pi * 180";break;case "ATAN":c="Math.atan("+a+") / Math.pi * 180";break;default:throw Error("Unknown math operator: "+b);}return[c,$.Blockly.Dart.ORDER_MULTIPLICATIVE]};
$.Blockly.Dart.math_constant=function(a){var b={PI:["Math.pi",$.Blockly.Dart.ORDER_UNARY_POSTFIX],E:["Math.e",$.Blockly.Dart.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",$.Blockly.Dart.ORDER_MULTIPLICATIVE],SQRT2:["Math.sqrt2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",$.Blockly.Dart.ORDER_UNARY_POSTFIX],INFINITY:["double.infinity",$.Blockly.Dart.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&($.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;");
return b[a]};
$.Blockly.Dart.math_number_property=function(a){var b={EVEN:[" % 2 == 0",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],ODD:[" % 2 == 1",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],WHOLE:[" % 1 == 0",$.Blockly.Dart.ORDER_MULTIPLICATIVE,$.Blockly.Dart.ORDER_EQUALITY],POSITIVE:[" > 0",$.Blockly.Dart.ORDER_RELATIONAL,$.Blockly.Dart.ORDER_RELATIONAL],NEGATIVE:[" < 0",$.Blockly.Dart.ORDER_RELATIONAL,$.Blockly.Dart.ORDER_RELATIONAL],DIVISIBLE_BY:[null,$.Blockly.Dart.ORDER_MULTIPLICATIVE,
$.Blockly.Dart.ORDER_EQUALITY],PRIME:[null,$.Blockly.Dart.ORDER_NONE,$.Blockly.Dart.ORDER_UNARY_POSTFIX]},c=a.getFieldValue("PROPERTY");b=$.$jscomp.makeIterator(b[c]);var d=b.next().value,e=b.next().value;b=b.next().value;e=$.Blockly.Dart.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",a=$.Blockly.Dart.provideFunction_("math_isPrime","\nbool "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is null, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n")+
"("+e+")";else if("DIVISIBLE_BY"===c){a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["false",$.Blockly.Dart.ORDER_ATOMIC];a=e+" % "+a+" == 0"}else a=e+d;return[a,b]};$.Blockly.Dart.math_change=function(a){var b=$.Blockly.Dart.valueToCode(a,"DELTA",$.Blockly.Dart.ORDER_ADDITIVE)||"0";a=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};
$.Blockly.Dart.math_round=$.Blockly.Dart.math_single;$.Blockly.Dart.math_trig=$.Blockly.Dart.math_single;
$.Blockly.Dart.math_on_list=function(a){var b=a.getFieldValue("OP");a=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]";switch(b){case "SUM":b=$.Blockly.Dart.provideFunction_("math_sum","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n num sumVal = 0;\n myList.forEach((num entry) {sumVal += entry;});\n return sumVal;\n}\n")+"("+a+")";break;case "MIN":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_min",
"\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num minVal = myList[0];\n myList.forEach((num entry) {minVal = Math.min(minVal, entry);});\n return minVal;\n}\n")+"("+a+")";break;case "MAX":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_max","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List<num> myList) {\n if (myList.isEmpty) return null;\n num maxVal = myList[0];\n myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});\n return maxVal;\n}\n")+
"("+a+")";break;case "AVERAGE":b=$.Blockly.Dart.provideFunction_("math_mean","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n num sumVal = 0;\n localList.forEach((var entry) {sumVal += entry;});\n return sumVal / localList.length;\n}\n")+"("+a+")";break;case "MEDIAN":b=$.Blockly.Dart.provideFunction_("math_median",
"\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only, then sort, then return middle value\n // or the average of two middle values if list has an even number of elements.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n localList.sort((a, b) => (a - b));\n int index = localList.length ~/ 2;\n if (localList.length % 2 == 1) {\n return localList[index];\n } else {\n return (localList[index - 1] + localList[index]) / 2;\n }\n}\n")+
"("+a+")";break;case "MODE":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_modes","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List values) {\n List modes = [];\n List counts = [];\n int maxCount = 0;\n for (int i = 0; i < values.length; i++) {\n var value = values[i];\n bool found = false;\n int thisCount;\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][0] == value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.add([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][1] == maxCount) {\n modes.add(counts[j][0]);\n }\n }\n return modes;\n}\n")+
"("+a+")";break;case "STD_DEV":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_standard_deviation","\nnum "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n // First filter list for numbers only.\n List numbers = new List.from(myList);\n numbers.removeWhere((a) => a is! num);\n if (numbers.isEmpty) return null;\n num n = numbers.length;\n num sum = 0;\n numbers.forEach((x) => sum += x);\n num mean = sum / n;\n num sumSquare = 0;\n numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));\n return Math.sqrt(sumSquare / n);\n}\n")+
"("+a+")";break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";b=$.Blockly.Dart.provideFunction_("math_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List myList) {\n int x = new Math.Random().nextInt(myList.length);\n return myList[x];\n}\n")+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.math_modulo=function(a){var b=$.Blockly.Dart.valueToCode(a,"DIVIDEND",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";a=$.Blockly.Dart.valueToCode(a,"DIVISOR",$.Blockly.Dart.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,$.Blockly.Dart.ORDER_MULTIPLICATIVE]};
$.Blockly.Dart.math_constrain=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_NONE)||"0",c=$.Blockly.Dart.valueToCode(a,"LOW",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"HIGH",$.Blockly.Dart.ORDER_NONE)||"double.infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.math_random_int=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_NONE)||"0";a=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_NONE)||"0";return[$.Blockly.Dart.provideFunction_("math_random_int","\nint "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num a, num b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n num c = a;\n a = b;\n b = c;\n }\n return new Math.Random().nextInt(b - a + 1) + a;\n}\n")+
"("+b+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.math_random_float=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return["new Math.Random().nextDouble()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.math_atan2=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";var b=$.Blockly.Dart.valueToCode(a,"X",$.Blockly.Dart.ORDER_NONE)||"0";return["Math.atan2("+($.Blockly.Dart.valueToCode(a,"Y",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+") / Math.pi * 180",$.Blockly.Dart.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Dart$loops={};
$.Blockly.Dart.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):$.Blockly.Dart.valueToCode(a,"TIMES",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0";var c=$.Blockly.Dart.statementToCode(a,"DO");c=$.Blockly.Dart.addLoopTrap(c,a);a="";var d=$.Blockly.Dart.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(b)||(e=$.Blockly.Dart.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),
a+="var "+e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.Dart.controls_repeat=$.Blockly.Dart.controls_repeat_ext;$.Blockly.Dart.controls_whileUntil=function(a){var b="UNTIL"===a.getFieldValue("MODE"),c=$.Blockly.Dart.valueToCode(a,"BOOL",b?$.Blockly.Dart.ORDER_UNARY_PREFIX:$.Blockly.Dart.ORDER_NONE)||"false",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
$.Blockly.Dart.controls_for=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"FROM",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",d=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_ASSIGNMENT)||"0",e=$.Blockly.Dart.valueToCode(a,"BY",$.Blockly.Dart.ORDER_ASSIGNMENT)||"1",f=$.Blockly.Dart.statementToCode(a,"DO");f=$.Blockly.Dart.addLoopTrap(f,a);if((0,$.module$exports$Blockly$utils$string.isNumber)(c)&&
(0,$.module$exports$Blockly$utils$string.isNumber)(d)&&(0,$.module$exports$Blockly$utils$string.isNumber)(e)){var g=Number(c)<=Number(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(Number(e));a=(1===b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(c)||(g=$.Blockly.Dart.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+g+" = "+c+";\n"),c=d,
d.match(/^\w+$/)||(0,$.module$exports$Blockly$utils$string.isNumber)(d)||(c=$.Blockly.Dart.nameDB_.getDistinctName(b+"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="var "+c+" = "+d+";\n"),d=$.Blockly.Dart.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="num "+d+" = ",a=(0,$.module$exports$Blockly$utils$string.isNumber)(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+($.Blockly.Dart.INDENT+d+" = -"+d+";\n"),a+="}\n",
a+="for ("+b+" = "+g+"; "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+"; "+b+" += "+d+") {\n"+f+"}\n";return a};$.Blockly.Dart.controls_forEach=function(a){var b=$.Blockly.Dart.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),c=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_ASSIGNMENT)||"[]",d=$.Blockly.Dart.statementToCode(a,"DO");d=$.Blockly.Dart.addLoopTrap(d,a);return"for (var "+b+" in "+c+") {\n"+d+"}\n"};
$.Blockly.Dart.controls_flow_statements=function(a){var b="";$.Blockly.Dart.STATEMENT_PREFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));$.Blockly.Dart.STATEMENT_SUFFIX&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a));if($.Blockly.Dart.STATEMENT_PREFIX){var c=a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,c))}switch(a.getFieldValue("FLOW")){case "BREAK":return b+"break;\n";case "CONTINUE":return b+"continue;\n"}throw Error("Unknown flow statement.");
};var module$exports$Blockly$Dart$logic={};
$.Blockly.Dart.controls_if=function(a){var b=0,c="";$.Blockly.Dart.STATEMENT_PREFIX&&(c+=$.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_PREFIX,a));do{var d=$.Blockly.Dart.valueToCode(a,"IF"+b,$.Blockly.Dart.ORDER_NONE)||"false";var e=$.Blockly.Dart.statementToCode(a,"DO"+b);$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e);c+=(0<b?"else ":"")+"if ("+d+") {\n"+e+"}";b++}while(a.getInput("IF"+b));if(a.getInput("ELSE")||
$.Blockly.Dart.STATEMENT_SUFFIX)e=$.Blockly.Dart.statementToCode(a,"ELSE"),$.Blockly.Dart.STATEMENT_SUFFIX&&(e=$.Blockly.Dart.prefixLines($.Blockly.Dart.injectId($.Blockly.Dart.STATEMENT_SUFFIX,a),$.Blockly.Dart.INDENT)+e),c+=" else {\n"+e+"}";return c+"\n"};$.Blockly.Dart.controls_ifelse=$.Blockly.Dart.controls_if;
$.Blockly.Dart.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="===b||"!="===b?$.Blockly.Dart.ORDER_EQUALITY:$.Blockly.Dart.ORDER_RELATIONAL,d=$.Blockly.Dart.valueToCode(a,"A",c)||"0";a=$.Blockly.Dart.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
$.Blockly.Dart.logic_operation=function(a){var b="AND"===a.getFieldValue("OP")?"&&":"||",c="&&"===b?$.Blockly.Dart.ORDER_LOGICAL_AND:$.Blockly.Dart.ORDER_LOGICAL_OR,d=$.Blockly.Dart.valueToCode(a,"A",c);a=$.Blockly.Dart.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.Dart.logic_negate=function(a){var b=$.Blockly.Dart.ORDER_UNARY_PREFIX;return["!"+($.Blockly.Dart.valueToCode(a,"BOOL",b)||"true"),b]};
$.Blockly.Dart.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"true":"false",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.logic_null=function(a){return["null",$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.logic_ternary=function(a){var b=$.Blockly.Dart.valueToCode(a,"IF",$.Blockly.Dart.ORDER_CONDITIONAL)||"false",c=$.Blockly.Dart.valueToCode(a,"THEN",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";a=$.Blockly.Dart.valueToCode(a,"ELSE",$.Blockly.Dart.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,$.Blockly.Dart.ORDER_CONDITIONAL]};var module$exports$Blockly$Dart$lists={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.lists_create_empty=function(a){return["[]",$.Blockly.Dart.ORDER_ATOMIC]};$.Blockly.Dart.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=$.Blockly.Dart.valueToCode(a,"ADD"+c,$.Blockly.Dart.ORDER_NONE)||"null";return["["+b.join(", ")+"]",$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.lists_repeat=function(a){var b=$.Blockly.Dart.valueToCode(a,"ITEM",$.Blockly.Dart.ORDER_NONE)||"null";return["new List.filled("+($.Blockly.Dart.valueToCode(a,"NUM",$.Blockly.Dart.ORDER_NONE)||"0")+", "+b+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.lists_length=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".length",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_isEmpty=function(a){return[($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+".isEmpty",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"indexOf":"lastIndexOf",c=$.Blockly.Dart.valueToCode(a,"FIND",$.Blockly.Dart.ORDER_NONE)||"''";b=($.Blockly.Dart.valueToCode(a,"VALUE",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",$.Blockly.Dart.ORDER_ADDITIVE]:[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_getIndex=function(a){function b(){var f=$.Blockly.Dart.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),g="List "+f+" = "+e+";\n";e=f;return g}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Dart.valueToCode(a,"VALUE","RANDOM"===d||"FROM_END"===d?$.Blockly.Dart.ORDER_NONE:$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]";if(("RANDOM"!==d||"REMOVE"!==c)&&"FROM_END"!==d||e.match(/^\w+$/))switch(d){case "FIRST":if("GET"===
c)return[e+".first",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeAt(0)",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt(0);\n";break;case "LAST":if("GET"===c)return[e+".last",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c)return[e+".removeLast()",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeLast();\n";break;case "FROM_START":a=$.Blockly.Dart.getAdjusted(a,"AT");if("GET"===c)return[e+"["+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[e+".removeAt("+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return e+".removeAt("+a+");\n";break;case "FROM_END":a=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);if("GET"===c)return[e+"["+e+".length - "+a+"]",$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("GET_REMOVE"===c||"REMOVE"===c){a=e+".removeAt("+e+".length - "+a+")";if("GET_REMOVE"===c)return[a,$.Blockly.Dart.ORDER_UNARY_POSTFIX];if("REMOVE"===c)return a+";\n"}break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math=
"import 'dart:math' as Math;";if("REMOVE"===c)return c=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),"int "+c+" = new Math.Random().nextInt("+e+".length);\n"+(e+".removeAt("+c+");\n");if("GET"===c)return[$.Blockly.Dart.provideFunction_("lists_get_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list[x];\n}\n")+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return[$.Blockly.Dart.provideFunction_("lists_remove_random_item","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list.removeAt(x);\n}\n")+"("+e+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}else{if("RANDOM"===d)return $.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;",c=b(),a=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE),
c+("int "+a+" = new Math.Random().nextInt("+e+".length);\n")+(e+".removeAt("+a+");\n");if("REMOVE"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE),b()+(e+".removeAt("+e+".length - "+c+");\n");if("GET"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_get_from_end","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list[x];\n}\n")+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX];
if("GET_REMOVE"===c)return c=$.Blockly.Dart.getAdjusted(a,"AT",1),[$.Blockly.Dart.provideFunction_("lists_remove_from_end","\ndynamic "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List my_list, num x) {\n x = my_list.length - x;\n return my_list.removeAt(x);\n}\n")+"("+e+", "+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).");};
$.Blockly.Dart.lists_setIndex=function(a){function b(){if(e.match(/^\w+$/))return"";var g=$.Blockly.Dart.nameDB_.getDistinctName("tmp_list",$.module$exports$Blockly$Names.NameType.VARIABLE),h="List "+g+" = "+e+";\n";e=g;return h}var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]",f=$.Blockly.Dart.valueToCode(a,"TO",$.Blockly.Dart.ORDER_ASSIGNMENT)||"null";switch(d){case "FIRST":if("SET"===c)return e+
"[0] = "+f+";\n";if("INSERT"===c)return e+".insert(0, "+f+");\n";break;case "LAST":if("SET"===c)return b()+(e+"["+e+".length - 1] = "+f+";\n");if("INSERT"===c)return e+".add("+f+");\n";break;case "FROM_START":a=$.Blockly.Dart.getAdjusted(a,"AT");if("SET"===c)return e+"["+a+"] = "+f+";\n";if("INSERT"===c)return e+".insert("+a+", "+f+");\n";break;case "FROM_END":a=$.Blockly.Dart.getAdjusted(a,"AT",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);d=b();if("SET"===c)return d+(e+"["+e+".length - "+a+"] = "+f+";\n");
if("INSERT"===c)return d+(e+".insert("+e+".length - "+a+", "+f+");\n");break;case "RANDOM":$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";a=b();d=$.Blockly.Dart.nameDB_.getDistinctName("tmp_x",$.module$exports$Blockly$Names.NameType.VARIABLE);a+="int "+d+" = new Math.Random().nextInt("+e+".length);\n";if("SET"===c)return a+(e+"["+d+"] = "+f+";\n");if("INSERT"===c)return a+(e+".insert("+d+", "+f+");\n")}throw Error("Unhandled combination (lists_setIndex).");};
$.Blockly.Dart.lists_getSublist=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_UNARY_POSTFIX)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2");if(b.match(/^\w+$/)||"FROM_END"!==c&&"FROM_START"===d){switch(c){case "FROM_START":c=$.Blockly.Dart.getAdjusted(a,"AT1");break;case "FROM_END":c=$.Blockly.Dart.getAdjusted(a,"AT1",1,!1,$.Blockly.Dart.ORDER_ADDITIVE);c=b+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");
}switch(d){case "FROM_START":var e=$.Blockly.Dart.getAdjusted(a,"AT2",1);break;case "FROM_END":e=$.Blockly.Dart.getAdjusted(a,"AT2",0,!1,$.Blockly.Dart.ORDER_ADDITIVE);e=b+".length - "+e;break;case "LAST":break;default:throw Error("Unhandled option (lists_getSublist).");}b="LAST"===d?b+".sublist("+c+")":b+".sublist("+c+", "+e+")"}else e=$.Blockly.Dart.getAdjusted(a,"AT1"),a=$.Blockly.Dart.getAdjusted(a,"AT2"),b=$.Blockly.Dart.provideFunction_("lists_get_sublist","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+
"(List list, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = list.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = list.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (lists_getSublist).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return list.sublist(at1, at2);\n}\n")+
"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")";return[b,$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_sort=function(a){var b=$.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]",c="1"===a.getFieldValue("DIRECTION")?1:-1;a=a.getFieldValue("TYPE");return[$.Blockly.Dart.provideFunction_("lists_sort","\nList "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(List list, String type, int direction) {\n var compareFuncs = {\n 'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),\n 'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),\n 'IGNORE_CASE':\n (a, b) => direction *\n a.toString().toLowerCase().compareTo(b.toString().toLowerCase())\n };\n list = new List.from(list);\n var compare = compareFuncs[type];\n list.sort(compare);\n return list;\n}\n")+"("+
b+', "'+a+'", '+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};$.Blockly.Dart.lists_split=function(a){var b=$.Blockly.Dart.valueToCode(a,"INPUT",$.Blockly.Dart.ORDER_UNARY_POSTFIX),c=$.Blockly.Dart.valueToCode(a,"DELIM",$.Blockly.Dart.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"===a)b||(b="''"),a="split";else if("JOIN"===a)b||(b="[]"),a="join";else throw Error("Unknown mode: "+a);return[b+"."+a+"("+c+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.lists_reverse=function(a){return["new List.from("+($.Blockly.Dart.valueToCode(a,"LIST",$.Blockly.Dart.ORDER_NONE)||"[]")+".reversed)",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$colour={};$.Blockly.Dart.addReservedWords("Math");$.Blockly.Dart.colour_picker=function(a){return[$.Blockly.Dart.quote_(a.getFieldValue("COLOUR")),$.Blockly.Dart.ORDER_ATOMIC]};
$.Blockly.Dart.colour_random=function(a){$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_random","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"() {\n String hex = '0123456789abcdef';\n var rnd = new Math.Random();\n return '#${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}'\n '${hex[rnd.nextInt(16)]}${hex[rnd.nextInt(16)]}';\n}\n")+"()",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.colour_rgb=function(a){var b=$.Blockly.Dart.valueToCode(a,"RED",$.Blockly.Dart.ORDER_NONE)||0,c=$.Blockly.Dart.valueToCode(a,"GREEN",$.Blockly.Dart.ORDER_NONE)||0;a=$.Blockly.Dart.valueToCode(a,"BLUE",$.Blockly.Dart.ORDER_NONE)||0;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_rgb","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(num r, num g, num b) {\n num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();\n String rs = rn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();\n String gs = gn.toInt().toRadixString(16);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();\n String bs = bn.toInt().toRadixString(16);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};
$.Blockly.Dart.colour_blend=function(a){var b=$.Blockly.Dart.valueToCode(a,"COLOUR1",$.Blockly.Dart.ORDER_NONE)||"'#000000'",c=$.Blockly.Dart.valueToCode(a,"COLOUR2",$.Blockly.Dart.ORDER_NONE)||"'#000000'";a=$.Blockly.Dart.valueToCode(a,"RATIO",$.Blockly.Dart.ORDER_NONE)||.5;$.Blockly.Dart.definitions_.import_dart_math="import 'dart:math' as Math;";return[$.Blockly.Dart.provideFunction_("colour_blend","\nString "+$.Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_+"(String c1, String c2, num ratio) {\n ratio = Math.max(Math.min(ratio, 1), 0);\n int r1 = int.parse('0x${c1.substring(1, 3)}');\n int g1 = int.parse('0x${c1.substring(3, 5)}');\n int b1 = int.parse('0x${c1.substring(5, 7)}');\n int r2 = int.parse('0x${c2.substring(1, 3)}');\n int g2 = int.parse('0x${c2.substring(3, 5)}');\n int b2 = int.parse('0x${c2.substring(5, 7)}');\n num rn = (r1 * (1 - ratio) + r2 * ratio).round();\n String rs = rn.toInt().toRadixString(16);\n num gn = (g1 * (1 - ratio) + g2 * ratio).round();\n String gs = gn.toInt().toRadixString(16);\n num bn = (b1 * (1 - ratio) + b2 * ratio).round();\n String bs = bn.toInt().toRadixString(16);\n rs = '0$rs';\n rs = rs.substring(rs.length - 2);\n gs = '0$gs';\n gs = gs.substring(gs.length - 2);\n bs = '0$bs';\n bs = bs.substring(bs.length - 2);\n return '#$rs$gs$bs';\n}\n")+
"("+b+", "+c+", "+a+")",$.Blockly.Dart.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Dart$all={};
$.Blockly.Dart.__namespace__=$;
return $.Blockly.Dart;
}));
//# sourceMappingURL=dart_compressed.js.map