blockly 13.0.0-beta.7 → 13.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,78 +12,45 @@
12
12
  }
13
13
  }(this, function(__parent__) {
14
14
  var $=__parent__.__namespace__;
15
- var lists_create_empty$$module$build$src$generators$python$lists=function(a,b){return["[]",Order$$module$build$src$generators$python$python_generator.ATOMIC]},lists_create_with$$module$build$src$generators$python$lists=function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$python$python_generator.NONE)||"None";return["["+c.join(", ")+"]",Order$$module$build$src$generators$python$python_generator.ATOMIC]},lists_repeat$$module$build$src$generators$python$lists=
16
- function(a,b){var c=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$python$python_generator.NONE)||"None";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0";return["["+c+"] * "+a,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},lists_length$$module$build$src$generators$python$lists=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+")",
17
- Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_isEmpty$$module$build$src$generators$python$lists=function(a,b){return["not len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+")",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},lists_indexOf$$module$build$src$generators$python$lists=function(a,b){var c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python$python_generator.NONE)||
18
- "[]",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''",e=" -1",f="",g=" - 1";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1",g="");return[(a.getFieldValue("END")==="FIRST"?b.provideFunction_("first_index",`
19
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
20
- try: index = my_list.index(elem)${f}
21
- except: index =${e}
22
- return index
23
- `):b.provideFunction_("last_index",`
24
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
25
- try: index = len(my_list) - my_list[::-1].index(elem)${g}
26
- except: index =${e}
27
- return index
28
- `))+"("+d+", "+c+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_getIndex$$module$build$src$generators$python$lists=function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",d==="RANDOM"?Order$$module$build$src$generators$python$python_generator.NONE:Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]";switch(d){case "FIRST":if(c==="GET")return[e+"[0]",Order$$module$build$src$generators$python$python_generator.MEMBER];
29
- if(c==="GET_REMOVE")return[e+".pop(0)",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop(0)\n";break;case "LAST":if(c==="GET")return[e+"[-1]",Order$$module$build$src$generators$python$python_generator.MEMBER];if(c==="GET_REMOVE")return[e+".pop()",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop()\n";break;case "FROM_START":a=b.getAdjustedInt(a,"AT");if(c==="GET")return[e+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];
30
- if(c==="GET_REMOVE")return[e+".pop("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "FROM_END":a=b.getAdjustedInt(a,"AT",1,!0);if(c==="GET")return[e+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];if(c==="GET_REMOVE")return[e+".pop("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "RANDOM":b.definitions_.import_random=
31
- "import random";if(c==="GET")return["random.choice("+e+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];e=b.provideFunction_("lists_remove_random_item",`
32
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
33
- x = int(random.random() * len(myList))
34
- return myList.pop(x)
35
- `)+"("+e+")";if(c==="GET_REMOVE")return[e,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];if(c==="REMOVE")return e+"\n"}throw Error("Unhandled combination (lists_getIndex).");},lists_setIndex$$module$build$src$generators$python$lists=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]",d=a.getFieldValue("MODE")||"GET",e=a.getFieldValue("WHERE")||"FROM_START",f=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||
36
- "None";switch(e){case "FIRST":if(d==="SET")return c+"[0] = "+f+"\n";if(d==="INSERT")return c+".insert(0, "+f+")\n";break;case "LAST":if(d==="SET")return c+"[-1] = "+f+"\n";if(d==="INSERT")return c+".append("+f+")\n";break;case "FROM_START":b=b.getAdjustedInt(a,"AT");if(d==="SET")return c+"["+b+"] = "+f+"\n";if(d==="INSERT")return c+".insert("+b+", "+f+")\n";break;case "FROM_END":b=b.getAdjustedInt(a,"AT",1,!0);if(d==="SET")return c+"["+b+"] = "+f+"\n";if(d==="INSERT")return c+".insert("+b+", "+f+
37
- ")\n";break;case "RANDOM":b.definitions_.import_random="import random";c.match(/^\w+$/)?a="":(a=b.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),e=a+" = "+c+"\n",c=a,a=e);b=b.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);a+=b+" = int(random.random() * len("+c+"))\n";if(d==="SET")return a+(c+"["+b+"] = "+f+"\n");if(d==="INSERT")return a+(c+".insert("+b+", "+f+")\n")}throw Error("Unhandled combination (lists_setIndex).");},lists_getSublist$$module$build$src$generators$python$lists=
38
- function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.MEMBER)||"[]",d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2");switch(d){case "FROM_START":d=b.getAdjustedInt(a,"AT1");d===0&&(d="");break;case "FROM_END":d=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":d="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(e){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?
39
- a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");}return[c+"["+d+" : "+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER]},lists_sort$$module$build$src$generators$python$lists=function(a,b){var c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]",d=a.getFieldValue("TYPE");a=a.getFieldValue("DIRECTION")==="1"?"False":"True";
40
- return[b.provideFunction_("lists_sort",`
41
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
42
- def try_float(s):
43
- try:
44
- return float(s)
45
- except:
46
- return 0
47
- key_funcs = {
48
- "NUMERIC": try_float,
49
- "TEXT": str,
50
- "IGNORE_CASE": lambda s: str(s).lower()
51
- }
52
- key_func = key_funcs[type]
53
- list_cpy = list(my_list)
54
- return sorted(list_cpy, key=key_func, reverse=reverse)
55
- `)+"("+c+', "'+d+'", '+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_split$$module$build$src$generators$python$lists=function(a,b){var c=a.getFieldValue("MODE");if(c==="SPLIT")c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''",a=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python$python_generator.NONE),a=c+".split("+a+")";else if(c==="JOIN")c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python$python_generator.NONE)||
56
- "[]",a=(b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+".join("+c+")";else throw Error("Unknown mode: "+c);return[a,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},lists_reverse$$module$build$src$generators$python$lists=function(a,b){return["list(reversed("+(b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]")+"))",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},
57
- controls_if$$module$build$src$generators$python$logic=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{var e=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$python$python_generator.NONE)||"False";var f=b.statementToCode(a,"DO"+c)||b.PASS;b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c===0?"if ":"elif ")+e+":\n"+f;c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)f=a.getInput("ELSE")?b.statementToCode(a,
58
- "ELSE")||b.PASS:b.PASS,b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f),d+="else:\n"+f;return d},logic_compare$$module$build$src$generators$python$logic=function(a,b){var c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=Order$$module$build$src$generators$python$python_generator.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]},logic_operation$$module$build$src$generators$python$logic=function(a,
59
- b){var c=a.getFieldValue("OP")==="AND"?"and":"or",d=c==="and"?Order$$module$build$src$generators$python$python_generator.LOGICAL_AND:Order$$module$build$src$generators$python$python_generator.LOGICAL_OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="and"?"True":"False",e||(e=b),a||(a=b)):a=e="False";return[e+" "+c+" "+a,d]},logic_negate$$module$build$src$generators$python$logic=function(a,b){return["not "+(b.valueToCode(a,"BOOL",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT)||
60
- "True"),Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},logic_boolean$$module$build$src$generators$python$logic=function(a,b){return[a.getFieldValue("BOOL")==="TRUE"?"True":"False",Order$$module$build$src$generators$python$python_generator.ATOMIC]},logic_null$$module$build$src$generators$python$logic=function(a,b){return["None",Order$$module$build$src$generators$python$python_generator.ATOMIC]},logic_ternary$$module$build$src$generators$python$logic=function(a,b){var c=b.valueToCode(a,
61
- "IF",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"False",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"None";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$python$python_generator.CONDITIONAL)||"None";return[d+" if "+c+" else "+a,Order$$module$build$src$generators$python$python_generator.CONDITIONAL]},controls_repeat_ext$$module$build$src$generators$python$loops=function(a,b){var c=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),
62
- 10)):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$python$python_generator.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"int("+c+")";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a)||b.PASS;return"for "+b.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" in range("+c+"):\n"+d},controls_whileUntil$$module$build$src$generators$python$loops=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",
63
- c?Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT:Order$$module$build$src$generators$python$python_generator.NONE)||"False",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;c&&(d="not "+d);return"while "+d+":\n"+e},controls_for$$module$build$src$generators$python$loops=function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"0",e=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||
64
- "0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$python$python_generator.NONE)||"1",g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a)||b.PASS;var h="";a=function(){return b.provideFunction_("upRange",`
65
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
66
- while start <= stop:
67
- yield start
68
- start += abs(step)
69
- `)};var k=function(){return b.provideFunction_("downRange",`
15
+ var ur=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{var e=b.valueToCode(a,"IF"+c,U.NONE)||"False";var f=b.statementToCode(a,"DO"+c)||b.PASS;b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c===0?"if ":"elif ")+e+":\n"+f;c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)f=a.getInput("ELSE")?b.statementToCode(a,"ELSE")||b.PASS:b.PASS,b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,
16
+ a),b.INDENT)+f),d+="else:\n"+f;return d},vr=function(a,b){var c=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),10)):b.valueToCode(a,"TIMES",U.NONE)||"0";c=$.df(c)?parseInt(c,10):"int("+c+")";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a)||b.PASS;return"for "+b.nameDB_.getDistinctName("count",$.P.VARIABLE)+" in range("+c+"):\n"+d},wr=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG"){var d=b.valueToCode(a,"NUM",U.UNARY_SIGN)||"0";return["-"+d,U.UNARY_SIGN]}b.definitions_.import_math=
17
+ "import math";a=c==="SIN"||c==="COS"||c==="TAN"?b.valueToCode(a,"NUM",U.MULTIPLICATIVE)||"0":b.valueToCode(a,"NUM",U.NONE)||"0";switch(c){case "ABS":d="math.fabs("+a+")";break;case "ROOT":d="math.sqrt("+a+")";break;case "LN":d="math.log("+a+")";break;case "LOG10":d="math.log10("+a+")";break;case "EXP":d="math.exp("+a+")";break;case "POW10":d="math.pow(10,"+a+")";break;case "ROUND":d="round("+a+")";break;case "ROUNDUP":d="math.ceil("+a+")";break;case "ROUNDDOWN":d="math.floor("+a+")";break;case "SIN":d=
18
+ "math.sin("+a+" / 180.0 * math.pi)";break;case "COS":d="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":d="math.tan("+a+" / 180.0 * math.pi)"}if(d)return[d,U.FUNCTION_CALL];switch(c){case "ASIN":d="math.asin("+a+") / math.pi * 180";break;case "ACOS":d="math.acos("+a+") / math.pi * 180";break;case "ATAN":d="math.atan("+a+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,U.MULTIPLICATIVE]},xr=function(a,b){var c=[],d=a.workspace,e=$.Ad(d)||[];for(var f of e)e=
19
+ f.getName(),a.getVarModels().includes(f)||c.push(b.getVariableName(e));d=$.Bd(d);for(f=0;f<d.length;f++)c.push(b.nameDB_.getName(d[f],$.P.DEVELOPER_VARIABLE));d=c.length?b.INDENT+"global "+c.join(", ")+"\n":"";c=b.getProcedureName(a.getFieldValue("NAME"));f="";b.STATEMENT_PREFIX&&(f+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(f+=b.injectId(b.STATEMENT_SUFFIX,a));f&&(f=b.prefixLines(f,b.INDENT));e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var g=
20
+ "";a.getInput("STACK")&&(g=b.statementToCode(a,"STACK"));var k="";a.getInput("RETURN")&&(k=b.valueToCode(a,"RETURN",U.NONE)||"");var m="";g&&k&&(m=f);k?k=b.INDENT+"return "+k+"\n":g||(g=b.PASS);var z=[],E=a.getVarModels();for(let G=0;G<E.length;G++)z[G]=b.getVariableName(E[G].getId());d="def "+c+"("+z.join(", ")+"):\n"+d+f+e+g+m+k;d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},zr=function(a){return yr.test(a)?[a,U.ATOMIC]:["str("+a+")",U.FUNCTION_CALL]},Ar=function(a,b){var c=b.provideFunction_("text_prompt",
21
+ `
22
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(msg):
23
+ try:
24
+ return raw_input(msg)
25
+ except NameError:
26
+ return input(msg)
27
+ `);b=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",U.NONE)||"''";c=c+"("+b+")";a.getFieldValue("TYPE")==="NUMBER"&&(c="float("+c+")");return[c,U.FUNCTION_CALL]},Br=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),U.ATOMIC]},Cr=function(a,b){var c=b.valueToCode(a,"VALUE",U.NONE)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+"\n"},U,Dr=U||(U={});Dr[Dr.ATOMIC=0]="ATOMIC";Dr[Dr.COLLECTION=1]="COLLECTION";Dr[Dr.STRING_CONVERSION=1]="STRING_CONVERSION";
28
+ Dr[Dr.MEMBER=2.1]="MEMBER";Dr[Dr.FUNCTION_CALL=2.2]="FUNCTION_CALL";Dr[Dr.EXPONENTIATION=3]="EXPONENTIATION";Dr[Dr.UNARY_SIGN=4]="UNARY_SIGN";Dr[Dr.BITWISE_NOT=4]="BITWISE_NOT";Dr[Dr.MULTIPLICATIVE=5]="MULTIPLICATIVE";Dr[Dr.ADDITIVE=6]="ADDITIVE";Dr[Dr.BITWISE_SHIFT=7]="BITWISE_SHIFT";Dr[Dr.BITWISE_AND=8]="BITWISE_AND";Dr[Dr.BITWISE_XOR=9]="BITWISE_XOR";Dr[Dr.BITWISE_OR=10]="BITWISE_OR";Dr[Dr.RELATIONAL=11]="RELATIONAL";Dr[Dr.LOGICAL_NOT=12]="LOGICAL_NOT";Dr[Dr.LOGICAL_AND=13]="LOGICAL_AND";
29
+ Dr[Dr.LOGICAL_OR=14]="LOGICAL_OR";Dr[Dr.CONDITIONAL=15]="CONDITIONAL";Dr[Dr.LAMBDA=16]="LAMBDA";Dr[Dr.NONE=99]="NONE";
30
+ var Er=class extends $.Ip{constructor(a="Python"){super(a);this.ORDER_OVERRIDES=[[U.FUNCTION_CALL,U.MEMBER],[U.FUNCTION_CALL,U.FUNCTION_CALL],[U.MEMBER,U.MEMBER],[U.MEMBER,U.FUNCTION_CALL],[U.LOGICAL_NOT,U.LOGICAL_NOT],[U.LOGICAL_AND,U.LOGICAL_AND],[U.LOGICAL_OR,U.LOGICAL_OR]];this.PASS="";this.isInitialized=!1;for(let b in U)a=U[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip")}init(a){super.init(a);this.PASS=
31
+ this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.aj(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);var b=[],c=$.Bd(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.aj.DEVELOPER_VARIABLE_TYPE)+" = None");a=$.Ad(a);for(c=0;c<a.length;c++)b.push(this.getVariableName(a[c].getId())+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0}finish(a){var b=
32
+ [],c=[];for(let d in this.definitions_){let e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}a=super.finish(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}scrubNakedValue(a){return a+"\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n");var b="'";a.includes("'")&&(a.includes('"')?a=a.replace(/'/g,"\\'"):b='"');return b+a+b}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(a,
33
+ b,c=!1){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.cf(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.he.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}getAdjustedInt(a,b,c=0,d=!1){a.workspace.options.oneBasedIndex&&
34
+ c--;var e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?U.ADDITIVE:U.NONE)||e;$.df(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(a=c>0?"int("+a+" + "+c+")":c<0?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a}};var Fr={};Fr.controls_if=ur;Fr.controls_ifelse=ur;Fr.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"True":"False",U.ATOMIC]};Fr.logic_compare=function(a,b){var c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=U.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]};Fr.logic_negate=function(a,b){return["not "+(b.valueToCode(a,"BOOL",U.LOGICAL_NOT)||"True"),U.LOGICAL_NOT]};
35
+ Fr.logic_null=function(){return["None",U.ATOMIC]};Fr.logic_operation=function(a,b){var c=a.getFieldValue("OP")==="AND"?"and":"or",d=c==="and"?U.LOGICAL_AND:U.LOGICAL_OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="and"?"True":"False",e||(e=b),a||(a=b)):a=e="False";return[e+" "+c+" "+a,d]};
36
+ Fr.logic_ternary=function(a,b){var c=b.valueToCode(a,"IF",U.CONDITIONAL)||"False",d=b.valueToCode(a,"THEN",U.CONDITIONAL)||"None";a=b.valueToCode(a,"ELSE",U.CONDITIONAL)||"None";return[d+" if "+c+" else "+a,U.CONDITIONAL]};var Gr={controls_flow_statements:function(a,b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break\n";case "CONTINUE":return c+"continue\n"}throw Error("Unknown flow statement.");},controls_for:function(a,b){function c(){return b.provideFunction_("downRange",
37
+ `
70
38
  def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
71
39
  while start >= stop:
72
40
  yield start
73
41
  start -= abs(step)
74
- `)};if($.isNumber$$module$build$src$core$utils$string(d)&&$.isNumber$$module$build$src$core$utils$string(e)&&$.isNumber$$module$build$src$core$utils$string(f))d=Number(d),e=Number(e),f=Math.abs(Number(f)),d%1===0&&e%1===0&&f%1===0?(d<=e?(e++,a=d===0&&f===1?e:d+", "+e,f!==1&&(a+=", "+f)):(e--,a=d+", "+e+", -"+f),a="range("+a+")"):(a=d<e?a():k(),a+="("+d+", "+e+", "+f+")");else{let l=function(m,n){$.isNumber$$module$build$src$core$utils$string(m)?m=String(Number(m)):m.match(/^\w+$/)||(n=b.nameDB_.getDistinctName(c+
75
- n,$.NameType$$module$build$src$core$names.VARIABLE),h+=n+" = "+m+"\n",m=n);return m};d=l(d,"_start");e=l(e,"_end");f=l(f,"_inc");typeof d==="number"&&typeof e==="number"?(a=d<e?a():k(),a+="("+d+", "+e+", "+f+")"):a="("+d+" <= "+e+") and "+a()+"("+d+", "+e+", "+f+") or "+k()+"("+d+", "+e+", "+f+")"}return h+="for "+c+" in "+a+":\n"+g},controls_forEach$$module$build$src$generators$python$loops=function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.RELATIONAL)||
76
- "[]",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;return"for "+c+" in "+d+":\n"+e},controls_flow_statements$$module$build$src$generators$python$loops=function(a,b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break\n";case "CONTINUE":return c+
77
- "continue\n"}throw Error("Unknown flow statement.");},math_number$$module$build$src$generators$python$math=function(a,b){a=Number(a.getFieldValue("NUM"));return a===Infinity?['float("inf")',Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]:a===-Infinity?['-float("inf")',Order$$module$build$src$generators$python$python_generator.UNARY_SIGN]:[String(a),a<0?Order$$module$build$src$generators$python$python_generator.UNARY_SIGN:Order$$module$build$src$generators$python$python_generator.ATOMIC]},
78
- math_arithmetic$$module$build$src$generators$python$math=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$python$python_generator.ADDITIVE],MINUS:[" - ",Order$$module$build$src$generators$python$python_generator.ADDITIVE],MULTIPLY:[" * ",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],DIVIDE:[" / ",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],POWER:[" ** ",Order$$module$build$src$generators$python$python_generator.EXPONENTIATION]}[a.getFieldValue("OP")],
79
- d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_single$$module$build$src$generators$python$math=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG"){var d=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.UNARY_SIGN)||"0";return["-"+d,Order$$module$build$src$generators$python$python_generator.UNARY_SIGN]}b.definitions_.import_math="import math";a=c==="SIN"||c==="COS"||c==="TAN"?b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||
80
- "0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$python$python_generator.NONE)||"0";switch(c){case "ABS":d="math.fabs("+a+")";break;case "ROOT":d="math.sqrt("+a+")";break;case "LN":d="math.log("+a+")";break;case "LOG10":d="math.log10("+a+")";break;case "EXP":d="math.exp("+a+")";break;case "POW10":d="math.pow(10,"+a+")";break;case "ROUND":d="round("+a+")";break;case "ROUNDUP":d="math.ceil("+a+")";break;case "ROUNDDOWN":d="math.floor("+a+")";break;case "SIN":d="math.sin("+a+" / 180.0 * math.pi)";
81
- break;case "COS":d="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":d="math.tan("+a+" / 180.0 * math.pi)"}if(d)return[d,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL];switch(c){case "ASIN":d="math.asin("+a+") / math.pi * 180";break;case "ACOS":d="math.acos("+a+") / math.pi * 180";break;case "ATAN":d="math.atan("+a+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},
82
- math_constant$$module$build$src$generators$python$math=function(a,b){var c={PI:["math.pi",Order$$module$build$src$generators$python$python_generator.MEMBER],E:["math.e",Order$$module$build$src$generators$python$python_generator.MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Order$$module$build$src$generators$python$python_generator.MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",Order$$module$build$src$generators$python$python_generator.MEMBER],
83
- INFINITY:["float('inf')",Order$$module$build$src$generators$python$python_generator.ATOMIC]};a=a.getFieldValue("CONSTANT");a!=="INFINITY"&&(b.definitions_.import_math="import math");return c[a]},math_number_property$$module$build$src$generators$python$math=function(a,b){var c={EVEN:[" % 2 == 0",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],ODD:[" % 2 == 1",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,
84
- Order$$module$build$src$generators$python$python_generator.RELATIONAL],WHOLE:[" % 1 == 0",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],POSITIVE:[" > 0",Order$$module$build$src$generators$python$python_generator.RELATIONAL,Order$$module$build$src$generators$python$python_generator.RELATIONAL],NEGATIVE:[" < 0",Order$$module$build$src$generators$python$python_generator.RELATIONAL,Order$$module$build$src$generators$python$python_generator.RELATIONAL],
85
- DIVISIBLE_BY:[null,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE,Order$$module$build$src$generators$python$python_generator.RELATIONAL],PRIME:[null,Order$$module$build$src$generators$python$python_generator.NONE,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if(d==="PRIME")b.definitions_.import_math="import math",b.definitions_.from_numbers_import_Number="from numbers import Number",
86
- a=b.provideFunction_("math_isPrime",`
42
+ `)}function d(){return b.provideFunction_("upRange",`
43
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
44
+ while start <= stop:
45
+ yield start
46
+ start += abs(step)
47
+ `)}var e=b.getVariableName(a.getFieldValue("VAR")),f=b.valueToCode(a,"FROM",U.NONE)||"0",g=b.valueToCode(a,"TO",U.NONE)||"0",k=b.valueToCode(a,"BY",U.NONE)||"1",m=b.statementToCode(a,"DO");m=b.addLoopTrap(m,a)||b.PASS;var z="";$.df(f)&&$.df(g)&&$.df(k)?(f=Number(f),g=Number(g),k=Math.abs(Number(k)),f%1===0&&g%1===0&&k%1===0?(f<=g?(g++,a=f===0&&k===1?g:f+", "+g,k!==1&&(a+=", "+k)):(g--,a=f+", "+g+", -"+k),a="range("+a+")"):(a=f<g?d():c(),a+="("+f+", "+g+", "+k+")")):(a=function(E,G){$.df(E)?E=String(Number(E)):
48
+ E.match(/^\w+$/)||(G=b.nameDB_.getDistinctName(e+G,$.P.VARIABLE),z+=G+" = "+E+"\n",E=G);return E},f=a(f,"_start"),g=a(g,"_end"),k=a(k,"_inc"),typeof f==="number"&&typeof g==="number"?(a=f<g?d():c(),a+="("+f+", "+g+", "+k+")"):a="("+f+" <= "+g+") and "+d()+"("+f+", "+g+", "+k+") or "+c()+"("+f+", "+g+", "+k+")");return z+="for "+e+" in "+a+":\n"+m},controls_forEach:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,"LIST",U.RELATIONAL)||"[]",e=b.statementToCode(a,"DO");
49
+ e=b.addLoopTrap(e,a)||b.PASS;return"for "+c+" in "+d+":\n"+e}};Gr.controls_repeat=vr;Gr.controls_repeat_ext=vr;Gr.controls_whileUntil=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",c?U.LOGICAL_NOT:U.NONE)||"False",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;c&&(d="not "+d);return"while "+d+":\n"+e};var Hr={math_arithmetic:function(a,b){var c={ADD:[" + ",U.ADDITIVE],MINUS:[" - ",U.ADDITIVE],MULTIPLY:[" * ",U.MULTIPLICATIVE],DIVIDE:[" / ",U.MULTIPLICATIVE],POWER:[" ** ",U.EXPONENTIATION]}[a.getFieldValue("OP")],d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]},math_atan2:function(a,b){b.definitions_.import_math="import math";var c=b.valueToCode(a,"X",U.NONE)||"0";return["math.atan2("+(b.valueToCode(a,"Y",U.NONE)||"0")+", "+c+") / math.pi * 180",U.MULTIPLICATIVE]},
50
+ math_change:function(a,b){b.definitions_.from_numbers_import_Number="from numbers import Number";var c=b.valueToCode(a,"DELTA",U.ADDITIVE)||"0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = ("+a+" if isinstance("+a+", Number) else 0) + "+c+"\n"},math_constant:function(a,b){var c={PI:["math.pi",U.MEMBER],E:["math.e",U.MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",U.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",U.MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",U.MEMBER],INFINITY:["float('inf')",U.ATOMIC]};
51
+ a=a.getFieldValue("CONSTANT");a!=="INFINITY"&&(b.definitions_.import_math="import math");return c[a]},math_constrain:function(a,b){var c=b.valueToCode(a,"VALUE",U.NONE)||"0",d=b.valueToCode(a,"LOW",U.NONE)||"0";a=b.valueToCode(a,"HIGH",U.NONE)||"float('inf')";return["min(max("+c+", "+d+"), "+a+")",U.FUNCTION_CALL]},math_modulo:function(a,b){var c=b.valueToCode(a,"DIVIDEND",U.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",U.MULTIPLICATIVE)||"0";return[c+" % "+a,U.MULTIPLICATIVE]},math_number:function(a){a=
52
+ Number(a.getFieldValue("NUM"));return a===Infinity?['float("inf")',U.FUNCTION_CALL]:a===-Infinity?['-float("inf")',U.UNARY_SIGN]:[String(a),a<0?U.UNARY_SIGN:U.ATOMIC]},math_number_property:function(a,b){var c={EVEN:[" % 2 == 0",U.MULTIPLICATIVE,U.RELATIONAL],ODD:[" % 2 == 1",U.MULTIPLICATIVE,U.RELATIONAL],WHOLE:[" % 1 == 0",U.MULTIPLICATIVE,U.RELATIONAL],POSITIVE:[" > 0",U.RELATIONAL,U.RELATIONAL],NEGATIVE:[" < 0",U.RELATIONAL,U.RELATIONAL],DIVISIBLE_BY:[null,U.MULTIPLICATIVE,U.RELATIONAL],PRIME:[null,
53
+ U.NONE,U.FUNCTION_CALL]},d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if(d==="PRIME")b.definitions_.import_math="import math",b.definitions_.from_numbers_import_Number="from numbers import Number",a=b.provideFunction_("math_isPrime",`
87
54
  def ${b.FUNCTION_NAME_PLACEHOLDER_}(n):
88
55
  # https://en.wikipedia.org/wiki/Primality_test#Naive_methods
89
56
  # If n is not a number but a string, try parsing it.
@@ -102,9 +69,7 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(n):
102
69
  if n % (x - 1) == 0 or n % (x + 1) == 0:
103
70
  return False
104
71
  return True
105
- `)+"("+c+")";else if(d==="DIVISIBLE_BY"){a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0";if(a==="0")return["False",Order$$module$build$src$generators$python$python_generator.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]},math_change$$module$build$src$generators$python$math=function(a,b){b.definitions_.from_numbers_import_Number="from numbers import Number";var c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$python$python_generator.ADDITIVE)||
106
- "0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = ("+a+" if isinstance("+a+", Number) else 0) + "+c+"\n"},math_on_list$$module$build$src$generators$python$math=function(a,b){var c=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python$python_generator.NONE)||"[]";switch(c){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":b.definitions_.from_numbers_import_Number="from numbers import Number";
107
- b=b.provideFunction_("math_mean",`
72
+ `)+"("+c+")";else if(d==="DIVISIBLE_BY"){a=b.valueToCode(a,"DIVISOR",U.MULTIPLICATIVE)||"0";if(a==="0")return["False",U.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]},math_on_list:function(a,b){var c=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",U.NONE)||"[]";switch(c){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":b.definitions_.from_numbers_import_Number="from numbers import Number";b=b.provideFunction_("math_mean",`
108
73
  def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
109
74
  localList = [e for e in myList if isinstance(e, Number)]
110
75
  if not localList: return
@@ -144,64 +109,58 @@ def ${b.FUNCTION_NAME_PLACEHOLDER_}(numbers):
144
109
  mean = float(sum(numbers)) / n
145
110
  variance = sum((x - mean) ** 2 for x in numbers) / n
146
111
  return math.sqrt(variance)
147
- `)+"("+a+")";break;case "RANDOM":b.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+c);}return[b,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},math_modulo$$module$build$src$generators$python$math=function(a,b){var c=b.valueToCode(a,"DIVIDEND",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE)||
148
- "0";return[c+" % "+a,Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},math_constrain$$module$build$src$generators$python$math=function(a,b){var c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"0",d=b.valueToCode(a,"LOW",Order$$module$build$src$generators$python$python_generator.NONE)||"0";a=b.valueToCode(a,"HIGH",Order$$module$build$src$generators$python$python_generator.NONE)||"float('inf')";return["min(max("+c+", "+d+"), "+a+
149
- ")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},math_random_int$$module$build$src$generators$python$math=function(a,b){b.definitions_.import_random="import random";var c=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"0";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||"0";return["random.randint("+c+", "+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},math_random_float$$module$build$src$generators$python$math=
150
- function(a,b){b.definitions_.import_random="import random";return["random.random()",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},math_atan2$$module$build$src$generators$python$math=function(a,b){b.definitions_.import_math="import math";var c=b.valueToCode(a,"X",Order$$module$build$src$generators$python$python_generator.NONE)||"0";return["math.atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$python$python_generator.NONE)||"0")+", "+c+") / math.pi * 180",
151
- Order$$module$build$src$generators$python$python_generator.MULTIPLICATIVE]},procedures_defreturn$$module$build$src$generators$python$procedures=function(a,b){var c=[],d=a.workspace,e=$.allUsedVarModels$$module$build$src$core$variables(d)||[];for(var f of e)e=f.getName(),a.getVarModels().includes(f)||c.push(b.getVariableName(e));d=$.allDeveloperVariables$$module$build$src$core$variables(d);for(f=0;f<d.length;f++)c.push(b.nameDB_.getName(d[f],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
152
- d=c.length?b.INDENT+"global "+c.join(", ")+"\n":"";c=b.getProcedureName(a.getFieldValue("NAME"));f="";b.STATEMENT_PREFIX&&(f+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(f+=b.injectId(b.STATEMENT_SUFFIX,a));f&&(f=b.prefixLines(f,b.INDENT));e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var g="";a.getInput("STACK")&&(g=b.statementToCode(a,"STACK"));var h="";a.getInput("RETURN")&&(h=b.valueToCode(a,"RETURN",Order$$module$build$src$generators$python$python_generator.NONE)||
153
- "");var k="";g&&h&&(k=f);h?h=b.INDENT+"return "+h+"\n":g||(g=b.PASS);var l=[],m=a.getVarModels();for(let n=0;n<m.length;n++)l[n]=b.getVariableName(m[n].getId());d="def "+c+"("+l.join(", ")+"):\n"+d+f+e+g+k+h;d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},procedures_callreturn$$module$build$src$generators$python$procedures=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$python$python_generator.NONE)||
154
- "None";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},procedures_callnoreturn$$module$build$src$generators$python$procedures=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"},procedures_ifreturn$$module$build$src$generators$python$procedures=function(a,b){var c="if "+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$python$python_generator.NONE)||"False")+":\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,
155
- a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"None",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c},text$$module$build$src$generators$python$text=function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Order$$module$build$src$generators$python$python_generator.ATOMIC]},text_join$$module$build$src$generators$python$text=function(a,b){switch(a.itemCount_){case 0:return["''",Order$$module$build$src$generators$python$python_generator.ATOMIC];
156
- case 1:return a=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python$python_generator.NONE)||"''",forceString$$module$build$src$generators$python$text(a);case 2:var c=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$python$python_generator.NONE)||"''";return[forceString$$module$build$src$generators$python$text(c)[0]+" + "+forceString$$module$build$src$generators$python$text(a)[0],Order$$module$build$src$generators$python$python_generator.ADDITIVE];
157
- default:c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.nameDB_.getDistinctName("x",$.NameType$$module$build$src$core$names.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+c.join(", ")+"]])",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]}},text_append$$module$build$src$generators$python$text=function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",
158
- Order$$module$build$src$generators$python$python_generator.NONE)||"''";return c+" = str("+c+") + "+forceString$$module$build$src$generators$python$text(a)[0]+"\n"},text_length$$module$build$src$generators$python$text=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_isEmpty$$module$build$src$generators$python$text=function(a,b){return["not len("+
159
- (b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")",Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT]},text_indexOf$$module$build$src$generators$python$text=function(a,b){var c=a.getFieldValue("END")==="FIRST"?"find":"rfind",d=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python$python_generator.NONE)||"''";b=(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+"."+c+"("+
160
- d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$python$python_generator.ADDITIVE]:[b,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_charAt$$module$build$src$generators$python$text=function(a,b){var c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE",c==="RANDOM"?Order$$module$build$src$generators$python$python_generator.NONE:Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";switch(c){case "FIRST":return[d+
161
- "[0]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "LAST":return[d+"[-1]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "FROM_START":return a=b.getAdjustedInt(a,"AT"),[d+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "FROM_END":return a=b.getAdjustedInt(a,"AT",1,!0),[d+"["+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER];case "RANDOM":return b.definitions_.import_random="import random",
162
- [b.provideFunction_("text_random_letter",`
112
+ `)+"("+a+")";break;case "RANDOM":b.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+c);}return[b,U.FUNCTION_CALL]},math_random_float:function(a,b){b.definitions_.import_random="import random";return["random.random()",U.FUNCTION_CALL]},math_random_int:function(a,b){b.definitions_.import_random="import random";var c=b.valueToCode(a,"FROM",U.NONE)||"0";a=b.valueToCode(a,"TO",U.NONE)||"0";return["random.randint("+c+", "+a+")",U.FUNCTION_CALL]}};
113
+ Hr.math_round=wr;Hr.math_single=wr;Hr.math_trig=wr;var Ir={procedures_callnoreturn:function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"},procedures_callreturn:function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,U.NONE)||"None";return[c+"("+d.join(", ")+")",U.FUNCTION_CALL]}};Ir.procedures_defnoreturn=xr;Ir.procedures_defreturn=xr;
114
+ Ir.procedures_ifreturn=function(a,b){var c="if "+(b.valueToCode(a,"CONDITION",U.NONE)||"False")+":\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",U.NONE)||"None",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c};var yr=/^\s*'([^']|\\')*'\s*$/,Jr={text:function(a,b){return[b.quote_(a.getFieldValue("TEXT")),U.ATOMIC]},text_append:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",U.NONE)||"''";return c+" = str("+c+") + "+zr(a)[0]+"\n"},text_changeCase:function(a,b){var c={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(b.valueToCode(a,"TEXT",U.MEMBER)||"''")+c,U.FUNCTION_CALL]},text_charAt:function(a,b){var c=a.getFieldValue("WHERE")||
115
+ "FROM_START",d=b.valueToCode(a,"VALUE",c==="RANDOM"?U.NONE:U.MEMBER)||"''";switch(c){case "FIRST":return[d+"[0]",U.MEMBER];case "LAST":return[d+"[-1]",U.MEMBER];case "FROM_START":return a=b.getAdjustedInt(a,"AT"),[d+"["+a+"]",U.MEMBER];case "FROM_END":return a=b.getAdjustedInt(a,"AT",1,!0),[d+"["+a+"]",U.MEMBER];case "RANDOM":return b.definitions_.import_random="import random",[b.provideFunction_("text_random_letter",`
163
116
  def ${b.FUNCTION_NAME_PLACEHOLDER_}(text):
164
117
  x = int(random.random() * len(text))
165
118
  return text[x]
166
- `)+"("+d+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");},text_getSubstring$$module$build$src$generators$python$text=function(a,b){var c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=b.valueToCode(a,"STRING",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";switch(c){case "FROM_START":c=b.getAdjustedInt(a,"AT1");c===0&&(c="");break;case "FROM_END":c=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":c=
167
- "";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(d){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");}return[e+"["+c+" : "+a+"]",Order$$module$build$src$generators$python$python_generator.MEMBER]},
168
- text_changeCase$$module$build$src$generators$python$text=function(a,b){var c={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_trim$$module$build$src$generators$python$text=function(a,b){var c={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,
169
- "TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_print$$module$build$src$generators$python$text=function(a,b){return"print("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.NONE)||"''")+")\n"},text_prompt_ext$$module$build$src$generators$python$text=function(a,b){var c=b.provideFunction_("text_prompt",`
170
- def ${b.FUNCTION_NAME_PLACEHOLDER_}(msg):
171
- try:
172
- return raw_input(msg)
173
- except NameError:
174
- return input(msg)
175
- `);b=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.NONE)||"''";c=c+"("+b+")";a.getFieldValue("TYPE")==="NUMBER"&&(c="float("+c+")");return[c,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_count$$module$build$src$generators$python$text=function(a,b){var c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$python$python_generator.NONE)||
176
- "''";return[c+".count("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_replace$$module$build$src$generators$python$text=function(a,b){var c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python$python_generator.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$python$python_generator.NONE)||"''";return[c+".replace("+d+", "+a+")",Order$$module$build$src$generators$python$python_generator.MEMBER]},
177
- text_reverse$$module$build$src$generators$python$text=function(a,b){return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python$python_generator.MEMBER)||"''")+"[::-1]",Order$$module$build$src$generators$python$python_generator.MEMBER]},variables_get$$module$build$src$generators$python$variables=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),Order$$module$build$src$generators$python$python_generator.ATOMIC]},variables_set$$module$build$src$generators$python$variables=
178
- function(a,b){var c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python$python_generator.NONE)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+"\n"},Order$$module$build$src$generators$python$python_generator;
179
- (function(a){a[a.ATOMIC=0]="ATOMIC";a[a.COLLECTION=1]="COLLECTION";a[a.STRING_CONVERSION=1]="STRING_CONVERSION";a[a.MEMBER=2.1]="MEMBER";a[a.FUNCTION_CALL=2.2]="FUNCTION_CALL";a[a.EXPONENTIATION=3]="EXPONENTIATION";a[a.UNARY_SIGN=4]="UNARY_SIGN";a[a.BITWISE_NOT=4]="BITWISE_NOT";a[a.MULTIPLICATIVE=5]="MULTIPLICATIVE";a[a.ADDITIVE=6]="ADDITIVE";a[a.BITWISE_SHIFT=7]="BITWISE_SHIFT";a[a.BITWISE_AND=8]="BITWISE_AND";a[a.BITWISE_XOR=9]="BITWISE_XOR";a[a.BITWISE_OR=10]="BITWISE_OR";a[a.RELATIONAL=11]="RELATIONAL";
180
- a[a.LOGICAL_NOT=12]="LOGICAL_NOT";a[a.LOGICAL_AND=13]="LOGICAL_AND";a[a.LOGICAL_OR=14]="LOGICAL_OR";a[a.CONDITIONAL=15]="CONDITIONAL";a[a.LAMBDA=16]="LAMBDA";a[a.NONE=99]="NONE"})(Order$$module$build$src$generators$python$python_generator||(Order$$module$build$src$generators$python$python_generator={}));
181
- var PythonGenerator$$module$build$src$generators$python$python_generator=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a="Python"){super(a);this.ORDER_OVERRIDES=[[Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL,Order$$module$build$src$generators$python$python_generator.MEMBER],[Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL],[Order$$module$build$src$generators$python$python_generator.MEMBER,
182
- Order$$module$build$src$generators$python$python_generator.MEMBER],[Order$$module$build$src$generators$python$python_generator.MEMBER,Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL],[Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT,Order$$module$build$src$generators$python$python_generator.LOGICAL_NOT],[Order$$module$build$src$generators$python$python_generator.LOGICAL_AND,Order$$module$build$src$generators$python$python_generator.LOGICAL_AND],[Order$$module$build$src$generators$python$python_generator.LOGICAL_OR,
183
- Order$$module$build$src$generators$python$python_generator.LOGICAL_OR]];this.PASS="";this.isInitialized=!1;for(let b in Order$$module$build$src$generators$python$python_generator)a=Order$$module$build$src$generators$python$python_generator[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip")}init(a){super.init(a);
184
- this.PASS=this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.Names$$module$build$src$core$names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);var b=[],c=$.allDeveloperVariables$$module$build$src$core$variables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE)+" = None");a=$.allUsedVarModels$$module$build$src$core$variables(a);
185
- for(c=0;c<a.length;c++)b.push(this.getVariableName(a[c].getId())+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0}finish(a){var b=[],c=[];for(let d in this.definitions_){let e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\S+/)?b.push(e):c.push(e)}a=super.finish(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}scrubNakedValue(a){return a+"\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,
186
- "\\\n");var b="'";a.includes("'")&&(a.includes('"')?a=a.replace(/'/g,"\\'"):b='"');return b+a+b}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(a,b,c=!1){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.wrap$$module$build$src$core$utils$string(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.inputTypes$$module$build$src$core$inputs$input_types.VALUE&&
187
- (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}getAdjustedInt(a,b,c=0,d=!1){a.workspace.options.oneBasedIndex&&c--;var e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?Order$$module$build$src$generators$python$python_generator.ADDITIVE:Order$$module$build$src$generators$python$python_generator.NONE)||e;$.isNumber$$module$build$src$core$utils$string(a)?
188
- (a=parseInt(a,10)+c,d&&(a=-a)):(a=c>0?"int("+a+" + "+c+")":c<0?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a}},module$build$src$generators$python$python_generator={};module$build$src$generators$python$python_generator.Order=Order$$module$build$src$generators$python$python_generator;module$build$src$generators$python$python_generator.PythonGenerator=PythonGenerator$$module$build$src$generators$python$python_generator;var module$build$src$generators$python$lists={};module$build$src$generators$python$lists.lists_create_empty=lists_create_empty$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_create_with=lists_create_with$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_getIndex=lists_getIndex$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_getSublist=lists_getSublist$$module$build$src$generators$python$lists;
189
- module$build$src$generators$python$lists.lists_indexOf=lists_indexOf$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_isEmpty=lists_isEmpty$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_length=lists_length$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_repeat=lists_repeat$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_reverse=lists_reverse$$module$build$src$generators$python$lists;
190
- module$build$src$generators$python$lists.lists_setIndex=lists_setIndex$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_sort=lists_sort$$module$build$src$generators$python$lists;module$build$src$generators$python$lists.lists_split=lists_split$$module$build$src$generators$python$lists;var controls_ifelse$$module$build$src$generators$python$logic=controls_if$$module$build$src$generators$python$logic,module$build$src$generators$python$logic={};module$build$src$generators$python$logic.controls_if=controls_if$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.controls_ifelse=controls_if$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_boolean=logic_boolean$$module$build$src$generators$python$logic;
191
- module$build$src$generators$python$logic.logic_compare=logic_compare$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_negate=logic_negate$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_null=logic_null$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_operation=logic_operation$$module$build$src$generators$python$logic;module$build$src$generators$python$logic.logic_ternary=logic_ternary$$module$build$src$generators$python$logic;var controls_repeat$$module$build$src$generators$python$loops=controls_repeat_ext$$module$build$src$generators$python$loops,module$build$src$generators$python$loops={};module$build$src$generators$python$loops.controls_flow_statements=controls_flow_statements$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_for=controls_for$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_forEach=controls_forEach$$module$build$src$generators$python$loops;
192
- module$build$src$generators$python$loops.controls_repeat=controls_repeat_ext$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_repeat_ext=controls_repeat_ext$$module$build$src$generators$python$loops;module$build$src$generators$python$loops.controls_whileUntil=controls_whileUntil$$module$build$src$generators$python$loops;var math_round$$module$build$src$generators$python$math=math_single$$module$build$src$generators$python$math,math_trig$$module$build$src$generators$python$math=math_single$$module$build$src$generators$python$math,module$build$src$generators$python$math={};module$build$src$generators$python$math.math_arithmetic=math_arithmetic$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_atan2=math_atan2$$module$build$src$generators$python$math;
193
- module$build$src$generators$python$math.math_change=math_change$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_constant=math_constant$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_constrain=math_constrain$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_modulo=math_modulo$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_number=math_number$$module$build$src$generators$python$math;
194
- module$build$src$generators$python$math.math_number_property=math_number_property$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_on_list=math_on_list$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_random_float=math_random_float$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_random_int=math_random_int$$module$build$src$generators$python$math;
195
- module$build$src$generators$python$math.math_round=math_single$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_single=math_single$$module$build$src$generators$python$math;module$build$src$generators$python$math.math_trig=math_single$$module$build$src$generators$python$math;var procedures_defnoreturn$$module$build$src$generators$python$procedures=procedures_defreturn$$module$build$src$generators$python$procedures,module$build$src$generators$python$procedures={};module$build$src$generators$python$procedures.procedures_callnoreturn=procedures_callnoreturn$$module$build$src$generators$python$procedures;module$build$src$generators$python$procedures.procedures_callreturn=procedures_callreturn$$module$build$src$generators$python$procedures;
196
- module$build$src$generators$python$procedures.procedures_defnoreturn=procedures_defreturn$$module$build$src$generators$python$procedures;module$build$src$generators$python$procedures.procedures_defreturn=procedures_defreturn$$module$build$src$generators$python$procedures;module$build$src$generators$python$procedures.procedures_ifreturn=procedures_ifreturn$$module$build$src$generators$python$procedures;var strRegExp$$module$build$src$generators$python$text=/^\s*'([^']|\\')*'\s*$/,forceString$$module$build$src$generators$python$text=function(a){return strRegExp$$module$build$src$generators$python$text.test(a)?[a,Order$$module$build$src$generators$python$python_generator.ATOMIC]:["str("+a+")",Order$$module$build$src$generators$python$python_generator.FUNCTION_CALL]},text_prompt$$module$build$src$generators$python$text=text_prompt_ext$$module$build$src$generators$python$text,module$build$src$generators$python$text=
197
- {};module$build$src$generators$python$text.text=text$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_append=text_append$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_changeCase=text_changeCase$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_charAt=text_charAt$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_count=text_count$$module$build$src$generators$python$text;
198
- module$build$src$generators$python$text.text_getSubstring=text_getSubstring$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_indexOf=text_indexOf$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_isEmpty=text_isEmpty$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_join=text_join$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_length=text_length$$module$build$src$generators$python$text;
199
- module$build$src$generators$python$text.text_print=text_print$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_prompt=text_prompt_ext$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_prompt_ext=text_prompt_ext$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_replace=text_replace$$module$build$src$generators$python$text;module$build$src$generators$python$text.text_reverse=text_reverse$$module$build$src$generators$python$text;
200
- module$build$src$generators$python$text.text_trim=text_trim$$module$build$src$generators$python$text;var module$build$src$generators$python$variables={};module$build$src$generators$python$variables.variables_get=variables_get$$module$build$src$generators$python$variables;module$build$src$generators$python$variables.variables_set=variables_set$$module$build$src$generators$python$variables;var module$build$src$generators$python$variables_dynamic={};module$build$src$generators$python$variables_dynamic.variables_get_dynamic=variables_get$$module$build$src$generators$python$variables;module$build$src$generators$python$variables_dynamic.variables_set_dynamic=variables_set$$module$build$src$generators$python$variables;var pythonGenerator$$module$build$src$generators$python=new PythonGenerator$$module$build$src$generators$python$python_generator;pythonGenerator$$module$build$src$generators$python.addReservedWords("math,random,Number");
201
- var generators$$module$build$src$generators$python=Object.assign({},module$build$src$generators$python$lists,module$build$src$generators$python$logic,module$build$src$generators$python$loops,module$build$src$generators$python$math,module$build$src$generators$python$procedures,module$build$src$generators$python$text,module$build$src$generators$python$variables,module$build$src$generators$python$variables_dynamic);
202
- for(let a in generators$$module$build$src$generators$python)pythonGenerator$$module$build$src$generators$python.forBlock[a]=generators$$module$build$src$generators$python[a];var module$build$src$generators$python={};module$build$src$generators$python.Order=Order$$module$build$src$generators$python$python_generator;module$build$src$generators$python.PythonGenerator=PythonGenerator$$module$build$src$generators$python$python_generator;module$build$src$generators$python.pythonGenerator=pythonGenerator$$module$build$src$generators$python;
203
- module$build$src$generators$python.__namespace__=$;
204
- return module$build$src$generators$python;
119
+ `)+"("+d+")",U.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");},text_count:function(a,b){var c=b.valueToCode(a,"TEXT",U.MEMBER)||"''";a=b.valueToCode(a,"SUB",U.NONE)||"''";return[c+".count("+a+")",U.FUNCTION_CALL]},text_getSubstring:function(a,b){var c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=b.valueToCode(a,"STRING",U.MEMBER)||"''";switch(c){case "FROM_START":c=b.getAdjustedInt(a,"AT1");c===0&&(c="");break;case "FROM_END":c=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":c=
120
+ "";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(d){case "FROM_START":a=b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.df(String(a))?a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");}return[e+"["+c+" : "+a+"]",U.MEMBER]},text_indexOf:function(a,b){var c=a.getFieldValue("END")==="FIRST"?"find":"rfind",d=b.valueToCode(a,
121
+ "FIND",U.NONE)||"''";b=(b.valueToCode(a,"VALUE",U.MEMBER)||"''")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",U.ADDITIVE]:[b,U.FUNCTION_CALL]},text_isEmpty:function(a,b){return["not len("+(b.valueToCode(a,"VALUE",U.NONE)||"''")+")",U.LOGICAL_NOT]},text_join:function(a,b){switch(a.itemCount_){case 0:return["''",U.ATOMIC];case 1:return a=b.valueToCode(a,"ADD0",U.NONE)||"''",zr(a);case 2:var c=b.valueToCode(a,"ADD0",U.NONE)||"''";a=b.valueToCode(a,"ADD1",U.NONE)||"''";return[zr(c)[0]+
122
+ " + "+zr(a)[0],U.ADDITIVE];default:c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,U.NONE)||"''";a=b.nameDB_.getDistinctName("x",$.P.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+c.join(", ")+"]])",U.FUNCTION_CALL]}},text_length:function(a,b){return["len("+(b.valueToCode(a,"VALUE",U.NONE)||"''")+")",U.FUNCTION_CALL]},text_print:function(a,b){return"print("+(b.valueToCode(a,"TEXT",U.NONE)||"''")+")\n"}};Jr.text_prompt=Ar;Jr.text_prompt_ext=Ar;
123
+ Jr.text_replace=function(a,b){var c=b.valueToCode(a,"TEXT",U.MEMBER)||"''",d=b.valueToCode(a,"FROM",U.NONE)||"''";a=b.valueToCode(a,"TO",U.NONE)||"''";return[c+".replace("+d+", "+a+")",U.MEMBER]};Jr.text_reverse=function(a,b){return[(b.valueToCode(a,"TEXT",U.MEMBER)||"''")+"[::-1]",U.MEMBER]};Jr.text_trim=function(a,b){var c={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,"TEXT",U.MEMBER)||"''")+c,U.FUNCTION_CALL]};var Kr={};Kr.variables_get=Br;Kr.variables_set=Cr;var Lr={};Lr.variables_get_dynamic=Br;Lr.variables_set_dynamic=Cr;var Mr=new Er;Mr.addReservedWords("math,random,Number");
124
+ var Nr=Object.assign({},{lists_create_empty:function(){return["[]",U.ATOMIC]},lists_create_with:function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,U.NONE)||"None";return["["+c.join(", ")+"]",U.ATOMIC]},lists_getIndex:function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",d==="RANDOM"?U.NONE:U.MEMBER)||"[]";switch(d){case "FIRST":if(c==="GET")return[e+"[0]",U.MEMBER];if(c==="GET_REMOVE")return[e+
125
+ ".pop(0)",U.FUNCTION_CALL];if(c==="REMOVE")return e+".pop(0)\n";break;case "LAST":if(c==="GET")return[e+"[-1]",U.MEMBER];if(c==="GET_REMOVE")return[e+".pop()",U.FUNCTION_CALL];if(c==="REMOVE")return e+".pop()\n";break;case "FROM_START":a=b.getAdjustedInt(a,"AT");if(c==="GET")return[e+"["+a+"]",U.MEMBER];if(c==="GET_REMOVE")return[e+".pop("+a+")",U.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "FROM_END":a=b.getAdjustedInt(a,"AT",1,!0);if(c==="GET")return[e+"["+a+"]",U.MEMBER];
126
+ if(c==="GET_REMOVE")return[e+".pop("+a+")",U.FUNCTION_CALL];if(c==="REMOVE")return e+".pop("+a+")\n";break;case "RANDOM":b.definitions_.import_random="import random";if(c==="GET")return["random.choice("+e+")",U.FUNCTION_CALL];e=b.provideFunction_("lists_remove_random_item",`
127
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
128
+ x = int(random.random() * len(myList))
129
+ return myList.pop(x)
130
+ `)+"("+e+")";if(c==="GET_REMOVE")return[e,U.FUNCTION_CALL];if(c==="REMOVE")return e+"\n"}throw Error("Unhandled combination (lists_getIndex).");},lists_getSublist:function(a,b){var c=b.valueToCode(a,"LIST",U.MEMBER)||"[]",d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2");switch(d){case "FROM_START":d=b.getAdjustedInt(a,"AT1");d===0&&(d="");break;case "FROM_END":d=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":d="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(e){case "FROM_START":a=
131
+ b.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.df(String(a))?a===0&&(a=""):(b.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");}return[c+"["+d+" : "+a+"]",U.MEMBER]},lists_indexOf:function(a,b){var c=b.valueToCode(a,"FIND",U.NONE)||"[]",d=b.valueToCode(a,"VALUE",U.NONE)||"''",e=" -1",f="",g=" - 1";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1",g="");return[(a.getFieldValue("END")===
132
+ "FIRST"?b.provideFunction_("first_index",`
133
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
134
+ try: index = my_list.index(elem)${f}
135
+ except: index =${e}
136
+ return index
137
+ `):b.provideFunction_("last_index",`
138
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
139
+ try: index = len(my_list) - my_list[::-1].index(elem)${g}
140
+ except: index =${e}
141
+ return index
142
+ `))+"("+d+", "+c+")",U.FUNCTION_CALL]},lists_isEmpty:function(a,b){return["not len("+(b.valueToCode(a,"VALUE",U.NONE)||"[]")+")",U.LOGICAL_NOT]},lists_length:function(a,b){return["len("+(b.valueToCode(a,"VALUE",U.NONE)||"[]")+")",U.FUNCTION_CALL]},lists_repeat:function(a,b){var c=b.valueToCode(a,"ITEM",U.NONE)||"None";a=b.valueToCode(a,"NUM",U.MULTIPLICATIVE)||"0";return["["+c+"] * "+a,U.MULTIPLICATIVE]},lists_reverse:function(a,b){return["list(reversed("+(b.valueToCode(a,"LIST",U.NONE)||"[]")+"))",
143
+ U.FUNCTION_CALL]},lists_setIndex:function(a,b){var c=b.valueToCode(a,"LIST",U.MEMBER)||"[]",d=a.getFieldValue("MODE")||"GET",e=a.getFieldValue("WHERE")||"FROM_START",f=b.valueToCode(a,"TO",U.NONE)||"None";switch(e){case "FIRST":if(d==="SET")return c+"[0] = "+f+"\n";if(d==="INSERT")return c+".insert(0, "+f+")\n";break;case "LAST":if(d==="SET")return c+"[-1] = "+f+"\n";if(d==="INSERT")return c+".append("+f+")\n";break;case "FROM_START":b=b.getAdjustedInt(a,"AT");if(d==="SET")return c+"["+b+"] = "+f+
144
+ "\n";if(d==="INSERT")return c+".insert("+b+", "+f+")\n";break;case "FROM_END":b=b.getAdjustedInt(a,"AT",1,!0);if(d==="SET")return c+"["+b+"] = "+f+"\n";if(d==="INSERT")return c+".insert("+b+", "+f+")\n";break;case "RANDOM":b.definitions_.import_random="import random";c.match(/^\w+$/)?a="":(a=b.nameDB_.getDistinctName("tmp_list",$.P.VARIABLE),e=a+" = "+c+"\n",c=a,a=e);b=b.nameDB_.getDistinctName("tmp_x",$.P.VARIABLE);a+=b+" = int(random.random() * len("+c+"))\n";if(d==="SET")return a+(c+"["+b+"] = "+
145
+ f+"\n");if(d==="INSERT")return a+(c+".insert("+b+", "+f+")\n")}throw Error("Unhandled combination (lists_setIndex).");},lists_sort:function(a,b){var c=b.valueToCode(a,"LIST",U.NONE)||"[]",d=a.getFieldValue("TYPE");a=a.getFieldValue("DIRECTION")==="1"?"False":"True";return[b.provideFunction_("lists_sort",`
146
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
147
+ def try_float(s):
148
+ try:
149
+ return float(s)
150
+ except:
151
+ return 0
152
+ key_funcs = {
153
+ "NUMERIC": try_float,
154
+ "TEXT": str,
155
+ "IGNORE_CASE": lambda s: str(s).lower()
156
+ }
157
+ key_func = key_funcs[type]
158
+ list_cpy = list(my_list)
159
+ return sorted(list_cpy, key=key_func, reverse=reverse)
160
+ `)+"("+c+', "'+d+'", '+a+")",U.FUNCTION_CALL]},lists_split:function(a,b){var c=a.getFieldValue("MODE");if(c==="SPLIT")c=b.valueToCode(a,"INPUT",U.MEMBER)||"''",a=b.valueToCode(a,"DELIM",U.NONE),a=c+".split("+a+")";else if(c==="JOIN")c=b.valueToCode(a,"INPUT",U.NONE)||"[]",a=(b.valueToCode(a,"DELIM",U.MEMBER)||"''")+".join("+c+")";else throw Error("Unknown mode: "+c);return[a,U.FUNCTION_CALL]}},Fr,Gr,Hr,Ir,Jr,Kr,Lr);for(let a in Nr)Mr.forBlock[a]=Nr[a];var Or={};Or.Order=U;Or.PythonGenerator=Er;
161
+ Or.pythonGenerator=Mr;$.__chunk_python=Or;
162
+ $.__chunk_python.__namespace__=$;
163
+ return $.__chunk_python;
205
164
  }));
206
165
 
207
166