blockly 9.3.2 → 10.0.0-beta.0

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.
Files changed (160) hide show
  1. package/README.md +9 -7
  2. package/blockly.min.js +1304 -1404
  3. package/blockly_compressed.js +1057 -1099
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +120 -136
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +59 -32
  8. package/core/block_dragger.d.ts +2 -2
  9. package/core/block_svg.d.ts +38 -67
  10. package/core/blockly.d.ts +18 -112
  11. package/core/browser_events.d.ts +1 -2
  12. package/core/bubble_dragger.d.ts +1 -2
  13. package/core/{bubble.d.ts → bubble_old.d.ts} +3 -7
  14. package/core/bubbles/bubble.d.ts +174 -0
  15. package/core/bubbles/mini_workspace_bubble.d.ts +80 -0
  16. package/core/bubbles/text_bubble.d.ts +35 -0
  17. package/core/bubbles/textinput_bubble.d.ts +89 -0
  18. package/core/bump_objects.d.ts +6 -4
  19. package/core/connection.d.ts +19 -9
  20. package/core/connection_db.d.ts +4 -4
  21. package/core/contextmenu.d.ts +1 -2
  22. package/core/events/events.d.ts +1 -4
  23. package/core/events/events_abstract.d.ts +0 -6
  24. package/core/events/events_block_base.d.ts +0 -6
  25. package/core/events/events_block_change.d.ts +0 -6
  26. package/core/events/events_block_create.d.ts +0 -6
  27. package/core/events/events_block_delete.d.ts +0 -6
  28. package/core/events/events_block_drag.d.ts +0 -6
  29. package/core/events/events_block_move.d.ts +21 -7
  30. package/core/events/events_bubble_open.d.ts +0 -6
  31. package/core/events/events_click.d.ts +0 -6
  32. package/core/events/events_comment_base.d.ts +0 -6
  33. package/core/events/events_comment_change.d.ts +0 -6
  34. package/core/events/events_comment_create.d.ts +0 -6
  35. package/core/events/events_comment_move.d.ts +0 -6
  36. package/core/events/events_marker_move.d.ts +0 -6
  37. package/core/events/events_selected.d.ts +0 -6
  38. package/core/events/events_theme_change.d.ts +0 -6
  39. package/core/events/events_toolbox_item_select.d.ts +0 -6
  40. package/core/events/events_trashcan_open.d.ts +0 -6
  41. package/core/events/events_var_base.d.ts +0 -6
  42. package/core/events/events_var_create.d.ts +0 -6
  43. package/core/events/events_var_delete.d.ts +0 -6
  44. package/core/events/events_var_rename.d.ts +0 -6
  45. package/core/events/events_viewport.d.ts +0 -6
  46. package/core/events/utils.d.ts +1 -1
  47. package/core/events/workspace_events.d.ts +1 -16
  48. package/core/field.d.ts +31 -5
  49. package/core/field_checkbox.d.ts +1 -1
  50. package/core/field_colour.d.ts +0 -2
  51. package/core/field_dropdown.d.ts +11 -13
  52. package/core/field_image.d.ts +5 -5
  53. package/core/field_input.d.ts +9 -2
  54. package/core/field_label.d.ts +3 -1
  55. package/core/field_number.d.ts +4 -4
  56. package/core/field_variable.d.ts +5 -5
  57. package/core/flyout_base.d.ts +23 -25
  58. package/core/flyout_button.d.ts +9 -9
  59. package/core/flyout_horizontal.d.ts +1 -1
  60. package/core/flyout_vertical.d.ts +1 -1
  61. package/core/generator.d.ts +15 -2
  62. package/core/gesture.d.ts +58 -41
  63. package/core/icons/comment_icon.d.ts +108 -0
  64. package/core/icons/exceptions.d.ts +14 -0
  65. package/core/icons/icon.d.ts +38 -0
  66. package/core/icons/icon_types.d.ts +22 -0
  67. package/core/icons/mutator_icon.d.ts +90 -0
  68. package/core/icons/registry.d.ts +23 -0
  69. package/core/icons/warning_icon.d.ts +67 -0
  70. package/core/icons.d.ts +12 -0
  71. package/core/inputs/dummy_input.d.ts +20 -0
  72. package/core/{input.d.ts → inputs/input.d.ts} +20 -13
  73. package/core/{input_types.d.ts → inputs/input_types.d.ts} +2 -1
  74. package/core/inputs/statement_input.d.ts +22 -0
  75. package/core/inputs/value_input.d.ts +20 -0
  76. package/core/interfaces/i_block_dragger.d.ts +1 -1
  77. package/core/interfaces/i_bounded_element.d.ts +2 -1
  78. package/core/interfaces/i_bubble.d.ts +2 -14
  79. package/core/interfaces/i_has_bubble.d.ts +14 -0
  80. package/core/interfaces/i_icon.d.ts +75 -0
  81. package/core/interfaces/i_serializable.d.ts +24 -0
  82. package/core/keyboard_nav/ast_node.d.ts +15 -15
  83. package/core/keyboard_nav/basic_cursor.d.ts +2 -2
  84. package/core/keyboard_nav/marker.d.ts +2 -2
  85. package/core/main.d.ts +0 -10
  86. package/core/marker_manager.d.ts +0 -1
  87. package/core/names.d.ts +4 -4
  88. package/core/options.d.ts +3 -3
  89. package/core/procedures.d.ts +1 -4
  90. package/core/registry.d.ts +5 -0
  91. package/core/render_management.d.ts +9 -1
  92. package/core/rendered_connection.d.ts +7 -7
  93. package/core/renderers/common/block_rendering.d.ts +0 -10
  94. package/core/renderers/common/constants.d.ts +5 -7
  95. package/core/renderers/common/drawer.d.ts +7 -2
  96. package/core/renderers/common/info.d.ts +1 -4
  97. package/core/renderers/common/marker_svg.d.ts +4 -4
  98. package/core/renderers/common/renderer.d.ts +0 -9
  99. package/core/renderers/geras/highlighter.d.ts +1 -1
  100. package/core/renderers/geras/info.d.ts +1 -1
  101. package/core/renderers/geras/measurables/inline_input.d.ts +1 -1
  102. package/core/renderers/geras/measurables/statement_input.d.ts +1 -1
  103. package/core/renderers/geras/renderer.d.ts +1 -1
  104. package/core/renderers/measurables/external_value_input.d.ts +1 -1
  105. package/core/renderers/measurables/field.d.ts +1 -1
  106. package/core/renderers/measurables/icon.d.ts +5 -1
  107. package/core/renderers/measurables/inline_input.d.ts +1 -1
  108. package/core/renderers/measurables/input_connection.d.ts +1 -1
  109. package/core/renderers/measurables/statement_input.d.ts +1 -1
  110. package/core/renderers/zelos/constants.d.ts +2 -2
  111. package/core/renderers/zelos/info.d.ts +2 -2
  112. package/core/renderers/zelos/marker_svg.d.ts +3 -3
  113. package/core/renderers/zelos/measurables/inputs.d.ts +1 -1
  114. package/core/renderers/zelos/path_object.d.ts +3 -3
  115. package/core/scrollbar.d.ts +0 -2
  116. package/core/scrollbar_pair.d.ts +0 -2
  117. package/core/serialization/blocks.d.ts +3 -3
  118. package/core/serialization/exceptions.d.ts +11 -0
  119. package/core/shortcut_registry.d.ts +2 -2
  120. package/core/theme_manager.d.ts +0 -1
  121. package/core/touch.d.ts +0 -43
  122. package/core/trashcan.d.ts +19 -21
  123. package/core/utils/dom.d.ts +2 -2
  124. package/core/utils/object.d.ts +0 -25
  125. package/core/utils/rect.d.ts +2 -0
  126. package/core/utils/style.d.ts +0 -12
  127. package/core/utils/svg_math.d.ts +0 -8
  128. package/core/utils/xml.d.ts +15 -22
  129. package/core/utils.d.ts +0 -138
  130. package/core/widgetdiv.d.ts +5 -0
  131. package/core/workspace.d.ts +9 -3
  132. package/core/workspace_comment.d.ts +3 -3
  133. package/core/workspace_comment_svg.d.ts +31 -44
  134. package/core/workspace_dragger.d.ts +1 -4
  135. package/core/workspace_svg.d.ts +13 -50
  136. package/core/xml.d.ts +0 -12
  137. package/core-browser.js +0 -1
  138. package/core.js +0 -1
  139. package/dart_compressed.js +124 -159
  140. package/dart_compressed.js.map +1 -1
  141. package/javascript_compressed.js +127 -169
  142. package/javascript_compressed.js.map +1 -1
  143. package/lua_compressed.js +119 -142
  144. package/lua_compressed.js.map +1 -1
  145. package/msg/constants.d.ts +1 -3
  146. package/msg/msg.d.ts +1 -2
  147. package/msg/qqq.d.ts +1 -3
  148. package/msg/synonyms.d.ts +1 -3
  149. package/package.json +12 -13
  150. package/php_compressed.js +131 -161
  151. package/php_compressed.js.map +1 -1
  152. package/python_compressed.js +118 -149
  153. package/python_compressed.js.map +1 -1
  154. package/core/comment.d.ts +0 -115
  155. package/core/events/events_ui.d.ts +0 -40
  156. package/core/icon.d.ts +0 -89
  157. package/core/mutator.d.ts +0 -142
  158. package/core/renderers/common/debug.d.ts +0 -29
  159. package/core/renderers/common/debugger.d.ts +0 -117
  160. package/core/warning.d.ts +0 -53
@@ -6,36 +6,28 @@
6
6
  define(["./blockly_compressed.js"], factory);
7
7
  } else if (typeof exports === 'object') { // Node.js
8
8
  module.exports = factory(require("./blockly_compressed.js"));
9
- } else { // Browser
10
- var factoryExports = factory(root.Blockly);
11
- root.Blockly.Python = factoryExports.pythonGenerator;
12
- root.Blockly.Python.__namespace__ = factoryExports.__namespace__;
9
+ } else { // Script
10
+ root.python = factory(root.Blockly);
11
+ root.Blockly.Python = root.python.pythonGenerator;
13
12
  }
14
13
  }(this, function(__parent__) {
15
14
  var $=__parent__.__namespace__;
16
- var module$exports$Blockly$Python={},module$contents$Blockly$Python_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python_Variables=$.module$build$src$core$variables,module$contents$Blockly$Python_CodeGenerator=$.CodeGenerator$$module$build$src$core$generator,module$contents$Blockly$Python_inputTypes=$.module$build$src$core$input_types.inputTypes,module$contents$Blockly$Python_Names=$.module$build$src$core$names.Names,module$contents$Blockly$Python_NameType=$.NameType$$module$build$src$core$names;
17
- module$exports$Blockly$Python.pythonGenerator=new $.CodeGenerator$$module$build$src$core$generator("Python");module$exports$Blockly$Python.pythonGenerator.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");
18
- module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC=0;module$exports$Blockly$Python.pythonGenerator.ORDER_COLLECTION=1;module$exports$Blockly$Python.pythonGenerator.ORDER_STRING_CONVERSION=1;module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER=2.1;module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL=2.2;module$exports$Blockly$Python.pythonGenerator.ORDER_EXPONENTIATION=3;module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN=4;
19
- module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_NOT=4;module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE=5;module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE=6;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_SHIFT=7;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_AND=8;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_XOR=9;module$exports$Blockly$Python.pythonGenerator.ORDER_BITWISE_OR=10;
20
- module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL=11;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT=12;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND=13;module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR=14;module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL=15;module$exports$Blockly$Python.pythonGenerator.ORDER_LAMBDA=16;module$exports$Blockly$Python.pythonGenerator.ORDER_NONE=99;
21
- module$exports$Blockly$Python.pythonGenerator.ORDER_OVERRIDES=[[module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],[module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER,module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],[module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER,
22
- module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND],[module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR,module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR]];
23
- module$exports$Blockly$Python.pythonGenerator.isInitialized=!1;
24
- module$exports$Blockly$Python.pythonGenerator.init=function(a){Object.getPrototypeOf(this).init.call(this);this.PASS=this.INDENT+"pass\n";this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$build$src$core$names.Names(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);const b=[];var c=$.module$build$src$core$variables.allDeveloperVariables(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.module$build$src$core$names.Names.DEVELOPER_VARIABLE_TYPE)+
25
- " = None");a=$.module$build$src$core$variables.allUsedVarModels(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE)+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0};
26
- module$exports$Blockly$Python.pythonGenerator.finish=function(a){const b=[],c=[];for(let d in this.definitions_){const e=this.definitions_[d];e.match(/^(from\s+\S+\s+)?import\s+\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$exports$Blockly$Python.pythonGenerator.scrubNakedValue=function(a){return a+"\n"};
27
- module$exports$Blockly$Python.pythonGenerator.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n");let b="'";-1!==a.indexOf("'")&&(-1===a.indexOf('"')?b='"':a=a.replace(/'/g,"\\'"));return b+a+b};module$exports$Blockly$Python.pythonGenerator.multiline_quote_=function(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")};
28
- module$exports$Blockly$Python.pythonGenerator.scrub_=function(a,b,c){let d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();e&&(e=$.module$build$src$core$utils$string.wrap(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","# "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.module$build$src$core$input_types.inputTypes.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"# "))}a=a.nextConnection&&
29
- a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c};module$exports$Blockly$Python.pythonGenerator.getAdjustedInt=function(a,b,c,d){c=c||0;a.workspace.options.oneBasedIndex&&c--;const e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?this.ORDER_ADDITIVE:this.ORDER_NONE)||e;$.module$build$src$core$utils$string.isNumber(a)?(a=parseInt(a,10)+c,d&&(a=-a)):(a=0<c?"int("+a+" + "+c+")":0>c?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a};var module$exports$Blockly$Python$colour={};module$exports$Blockly$Python.pythonGenerator.colour_picker=function(a){return[module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("COLOUR")),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};module$exports$Blockly$Python.pythonGenerator.colour_random=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
30
- module$exports$Blockly$Python.pythonGenerator.colour_rgb=function(a){const b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("colour_rgb",`
31
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b):
15
+ var Order$$module$build$src$generators$python={ATOMIC:0,COLLECTION:1,STRING_CONVERSION:1,MEMBER:2.1,FUNCTION_CALL:2.2,EXPONENTIATION:3,UNARY_SIGN:4,BITWISE_NOT:4,MULTIPLICATIVE:5,ADDITIVE:6,BITWISE_SHIFT:7,BITWISE_AND:8,BITWISE_XOR:9,BITWISE_OR:10,RELATIONAL:11,LOGICAL_NOT:12,LOGICAL_AND:13,LOGICAL_OR:14,CONDITIONAL:15,LAMBDA:16,NONE:99},PythonGenerator$$module$build$src$generators$python=class extends $.CodeGenerator$$module$build$src$core$generator{constructor(a){super(null!=a?a:"Python");this.ORDER_OVERRIDES=
16
+ [[Order$$module$build$src$generators$python.FUNCTION_CALL,Order$$module$build$src$generators$python.MEMBER],[Order$$module$build$src$generators$python.FUNCTION_CALL,Order$$module$build$src$generators$python.FUNCTION_CALL],[Order$$module$build$src$generators$python.MEMBER,Order$$module$build$src$generators$python.MEMBER],[Order$$module$build$src$generators$python.MEMBER,Order$$module$build$src$generators$python.FUNCTION_CALL],[Order$$module$build$src$generators$python.LOGICAL_NOT,Order$$module$build$src$generators$python.LOGICAL_NOT],
17
+ [Order$$module$build$src$generators$python.LOGICAL_AND,Order$$module$build$src$generators$python.LOGICAL_AND],[Order$$module$build$src$generators$python.LOGICAL_OR,Order$$module$build$src$generators$python.LOGICAL_OR]];this.isInitialized=!1;for(const b in Order$$module$build$src$generators$python)this["ORDER_"+b]=Order$$module$build$src$generators$python[b];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);
18
+ 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);const b=[];var 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);
19
+ for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.NameType$$module$build$src$core$names.VARIABLE)+" = None");this.definitions_.variables=b.join("\n");this.isInitialized=!0}finish(a){const b=[],c=[];for(let d in this.definitions_){const 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+
20
+ "\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n");let b="'";-1!==a.indexOf("'")&&(-1===a.indexOf('"')?b='"':a=a.replace(/'/g,"\\'"));return b+a+b}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(a,b,c){let 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===
21
+ $.inputTypes$$module$build$src$core$inputs$input_types.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,d){c=c||0;a.workspace.options.oneBasedIndex&&c--;const e=a.workspace.options.oneBasedIndex?"1":"0";a=this.valueToCode(a,b,c?this.ORDER_ADDITIVE:this.ORDER_NONE)||e;$.isNumber$$module$build$src$core$utils$string(a)?(a=parseInt(a,
22
+ 10)+c,d&&(a=-a)):(a=0<c?"int("+a+" + "+c+")":0>c?"int("+a+" - "+-c+")":"int("+a+")",d&&(a="-"+a));return a}},pythonGenerator$$module$build$src$generators$python=new PythonGenerator$$module$build$src$generators$python,module$build$src$generators$python={};module$build$src$generators$python.Order=Order$$module$build$src$generators$python;module$build$src$generators$python.PythonGenerator=PythonGenerator$$module$build$src$generators$python;module$build$src$generators$python.pythonGenerator=pythonGenerator$$module$build$src$generators$python;pythonGenerator$$module$build$src$generators$python.forBlock.colour_picker=function(a,b){return[b.quote_(a.getFieldValue("COLOUR")),Order$$module$build$src$generators$python.ATOMIC]};pythonGenerator$$module$build$src$generators$python.forBlock.colour_random=function(a,b){b.definitions_.import_random="import random";return["'#%06x' % random.randint(0, 2**24 - 1)",Order$$module$build$src$generators$python.FUNCTION_CALL]};
23
+ pythonGenerator$$module$build$src$generators$python.forBlock.colour_rgb=function(a,b){const c=b.provideFunction_("colour_rgb",`
24
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(r, g, b):
32
25
  r = round(min(100, max(0, r)) * 2.55)
33
26
  g = round(min(100, max(0, g)) * 2.55)
34
27
  b = round(min(100, max(0, b)) * 2.55)
35
28
  return '#%02x%02x%02x' % (r, g, b)
36
- `),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RED",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0,d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"GREEN",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BLUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
37
- module$exports$Blockly$Python.pythonGenerator.colour_blend=function(a){const b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("colour_blend",`
38
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):
29
+ `),d=b.valueToCode(a,"RED",Order$$module$build$src$generators$python.NONE)||0,e=b.valueToCode(a,"GREEN",Order$$module$build$src$generators$python.NONE)||0;a=b.valueToCode(a,"BLUE",Order$$module$build$src$generators$python.NONE)||0;return[c+"("+d+", "+e+", "+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.colour_blend=function(a,b){const c=b.provideFunction_("colour_blend",`
30
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):
39
31
  r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)
40
32
  g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)
41
33
  b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)
@@ -44,39 +36,35 @@ def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(
44
36
  g = round(g1 * (1 - ratio) + g2 * ratio)
45
37
  b = round(b1 * (1 - ratio) + b2 * ratio)
46
38
  return '#%02x%02x%02x' % (r, g, b)
47
- `),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"COLOUR1",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"'#000000'",d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"COLOUR2",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"'#000000'";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RATIO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$lists={},module$contents$Blockly$Python$lists_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$lists_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.lists_create_empty=function(a){return["[]",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
48
- module$exports$Blockly$Python.pythonGenerator.lists_create_with=function(a){const b=Array(a.itemCount_);for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";return["["+b.join(", ")+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
49
- module$exports$Blockly$Python.pythonGenerator.lists_repeat=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ITEM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";return["["+b+"] * "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
50
- module$exports$Blockly$Python.pythonGenerator.lists_length=function(a){return["len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
51
- module$exports$Blockly$Python.pythonGenerator.lists_isEmpty=function(a){return["not len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};
52
- module$exports$Blockly$Python.pythonGenerator.lists_indexOf=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FIND",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";let d=" -1",e="",f=" - 1";a.workspace.options.oneBasedIndex&&(d=" 0",e=" + 1",f="");return[("FIRST"===a.getFieldValue("END")?module$exports$Blockly$Python.pythonGenerator.provideFunction_("first_index",
53
- `
54
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
55
- try: index = my_list.index(elem)${e}
56
- except: index =${d}
39
+ `),d=b.valueToCode(a,"COLOUR1",Order$$module$build$src$generators$python.NONE)||"'#000000'",e=b.valueToCode(a,"COLOUR2",Order$$module$build$src$generators$python.NONE)||"'#000000'";a=b.valueToCode(a,"RATIO",Order$$module$build$src$generators$python.NONE)||0;return[c+"("+d+", "+e+", "+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};var module$build$src$generators$python$colour={};pythonGenerator$$module$build$src$generators$python.forBlock.lists_create_empty=function(a,b){return["[]",Order$$module$build$src$generators$python.ATOMIC]};pythonGenerator$$module$build$src$generators$python.forBlock.lists_create_with=function(a,b){const 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.NONE)||"None";return["["+c.join(", ")+"]",Order$$module$build$src$generators$python.ATOMIC]};
40
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_repeat=function(a,b){const c=b.valueToCode(a,"ITEM",Order$$module$build$src$generators$python.NONE)||"None";a=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python.MULTIPLICATIVE)||"0";return["["+c+"] * "+a,Order$$module$build$src$generators$python.MULTIPLICATIVE]};
41
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_length=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"[]")+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.lists_isEmpty=function(a,b){return["not len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"[]")+")",Order$$module$build$src$generators$python.LOGICAL_NOT]};
42
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_indexOf=function(a,b){const c=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python.NONE)||"[]",d=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"''";let e=" -1",f="",g=" - 1";a.workspace.options.oneBasedIndex&&(e=" 0",f=" + 1",g="");return[("FIRST"===a.getFieldValue("END")?b.provideFunction_("first_index",`
43
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
44
+ try: index = my_list.index(elem)${f}
45
+ except: index =${e}
57
46
  return index
58
- `):module$exports$Blockly$Python.pythonGenerator.provideFunction_("last_index",`
59
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
60
- try: index = len(my_list) - my_list[::-1].index(elem)${f}
61
- except: index =${d}
47
+ `):b.provideFunction_("last_index",`
48
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
49
+ try: index = len(my_list) - my_list[::-1].index(elem)${g}
50
+ except: index =${e}
62
51
  return index
63
- `))+"("+c+", "+b+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
64
- module$exports$Blockly$Python.pythonGenerator.lists_getIndex=function(a){const b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START";var d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE","RANDOM"===c?module$exports$Blockly$Python.pythonGenerator.ORDER_NONE:module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";switch(c){case "FIRST":if("GET"===b)return[d+"[0]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+
65
- ".pop(0)",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop(0)\n";break;case "LAST":if("GET"===b)return[d+"[-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop()",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop()\n";break;case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT");if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];
66
- if("GET_REMOVE"===b)return[d+".pop("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0);if("GET"===b)return[d+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];if("GET_REMOVE"===b)return[d+".pop("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+".pop("+a+")\n";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random=
67
- "import random";if("GET"===b)return["random.choice("+d+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];d=module$exports$Blockly$Python.pythonGenerator.provideFunction_("lists_remove_random_item",`
68
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
52
+ `))+"("+d+", "+c+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
53
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_getIndex=function(a,b){const c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START";var e=b.valueToCode(a,"VALUE","RANDOM"===d?Order$$module$build$src$generators$python.NONE:Order$$module$build$src$generators$python.MEMBER)||"[]";switch(d){case "FIRST":if("GET"===c)return[e+"[0]",Order$$module$build$src$generators$python.MEMBER];if("GET_REMOVE"===c)return[e+".pop(0)",Order$$module$build$src$generators$python.FUNCTION_CALL];
54
+ if("REMOVE"===c)return e+".pop(0)\n";break;case "LAST":if("GET"===c)return[e+"[-1]",Order$$module$build$src$generators$python.MEMBER];if("GET_REMOVE"===c)return[e+".pop()",Order$$module$build$src$generators$python.FUNCTION_CALL];if("REMOVE"===c)return e+".pop()\n";break;case "FROM_START":a=b.getAdjustedInt(a,"AT");if("GET"===c)return[e+"["+a+"]",Order$$module$build$src$generators$python.MEMBER];if("GET_REMOVE"===c)return[e+".pop("+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL];if("REMOVE"===
55
+ c)return e+".pop("+a+")\n";break;case "FROM_END":a=b.getAdjustedInt(a,"AT",1,!0);if("GET"===c)return[e+"["+a+"]",Order$$module$build$src$generators$python.MEMBER];if("GET_REMOVE"===c)return[e+".pop("+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL];if("REMOVE"===c)return e+".pop("+a+")\n";break;case "RANDOM":b.definitions_.import_random="import random";if("GET"===c)return["random.choice("+e+")",Order$$module$build$src$generators$python.FUNCTION_CALL];e=b.provideFunction_("lists_remove_random_item",
56
+ `
57
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
69
58
  x = int(random.random() * len(myList))
70
59
  return myList.pop(x)
71
- `)+"("+d+")";if("GET_REMOVE"===b)return[d,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+"\n"}throw Error("Unhandled combination (lists_getIndex).");};
72
- module$exports$Blockly$Python.pythonGenerator.lists_setIndex=function(a){let b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";const c=a.getFieldValue("MODE")||"GET";var d=a.getFieldValue("WHERE")||"FROM_START";const e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";switch(d){case "FIRST":if("SET"===c)return b+"[0] = "+e+"\n";if("INSERT"===
73
- c)return b+".insert(0, "+e+")\n";break;case "LAST":if("SET"===c)return b+"[-1] = "+e+"\n";if("INSERT"===c)return b+".append("+e+")\n";break;case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT");if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+e+")\n";break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0);if("SET"===c)return b+"["+a+"] = "+e+"\n";if("INSERT"===c)return b+".insert("+a+", "+
74
- e+")\n";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";b.match(/^\w+$/)?a="":(a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("tmp_list",$.NameType$$module$build$src$core$names.VARIABLE),d=a+" = "+b+"\n",b=a,a=d);d=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("tmp_x",$.NameType$$module$build$src$core$names.VARIABLE);a+=d+" = int(random.random() * len("+b+"))\n";if("SET"===c)return a+(b+"["+
75
- d+"] = "+e+"\n");if("INSERT"===c)return a+(b+".insert("+d+", "+e+")\n")}throw Error("Unhandled combination (lists_setIndex).");};
76
- module$exports$Blockly$Python.pythonGenerator.lists_getSublist=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"[]";var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2");switch(c){case "FROM_START":c=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1");0===c&&(c="");break;case "FROM_END":c=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1",1,!0);break;
77
- case "FIRST":c="";break;default:throw Error("Unhandled option (lists_getSublist)");}switch(d){case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",0,!0);$.module$build$src$core$utils$string.isNumber(String(a))?0===a&&(a=""):(module$exports$Blockly$Python.pythonGenerator.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (lists_getSublist)");
78
- }return[b+"["+c+" : "+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.lists_sort=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]",c=a.getFieldValue("TYPE");a="1"===a.getFieldValue("DIRECTION")?"False":"True";return[module$exports$Blockly$Python.pythonGenerator.provideFunction_("lists_sort",`
79
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
60
+ `)+"("+e+")";if("GET_REMOVE"===c)return[e,Order$$module$build$src$generators$python.FUNCTION_CALL];if("REMOVE"===c)return e+"\n"}throw Error("Unhandled combination (lists_getIndex).");};
61
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_setIndex=function(a,b){let c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.MEMBER)||"[]";const d=a.getFieldValue("MODE")||"GET";var e=a.getFieldValue("WHERE")||"FROM_START";const f=b.valueToCode(a,"TO",Order$$module$build$src$generators$python.NONE)||"None";switch(e){case "FIRST":if("SET"===d)return c+"[0] = "+f+"\n";if("INSERT"===d)return c+".insert(0, "+f+")\n";break;case "LAST":if("SET"===d)return c+"[-1] = "+
62
+ f+"\n";if("INSERT"===d)return c+".append("+f+")\n";break;case "FROM_START":b=b.getAdjustedInt(a,"AT");if("SET"===d)return c+"["+b+"] = "+f+"\n";if("INSERT"===d)return c+".insert("+b+", "+f+")\n";break;case "FROM_END":b=b.getAdjustedInt(a,"AT",1,!0);if("SET"===d)return c+"["+b+"] = "+f+"\n";if("INSERT"===d)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",$.NameType$$module$build$src$core$names.VARIABLE),
63
+ 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("SET"===d)return a+(c+"["+b+"] = "+f+"\n");if("INSERT"===d)return a+(c+".insert("+b+", "+f+")\n")}throw Error("Unhandled combination (lists_setIndex).");};
64
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_getSublist=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.MEMBER)||"[]";var d=a.getFieldValue("WHERE1");const e=a.getFieldValue("WHERE2");switch(d){case "FROM_START":d=b.getAdjustedInt(a,"AT1");0===d&&(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,
65
+ "AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?0===a&&(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.MEMBER]};
66
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_sort=function(a,b){const c=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.NONE)||"[]",d=a.getFieldValue("TYPE");a="1"===a.getFieldValue("DIRECTION")?"False":"True";return[b.provideFunction_("lists_sort",`
67
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
80
68
  def try_float(s):
81
69
  try:
82
70
  return float(s)
@@ -90,53 +78,45 @@ def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(
90
78
  key_func = key_funcs[type]
91
79
  list_cpy = list(my_list)
92
80
  return sorted(list_cpy, key=key_func, reverse=reverse)
93
- `)+"("+b+', "'+c+'", '+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
94
- module$exports$Blockly$Python.pythonGenerator.lists_split=function(a){var b=a.getFieldValue("MODE");if("SPLIT"===b)b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''",a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE),a=b+".split("+a+")";else if("JOIN"===b)b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"INPUT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||
95
- "[]",a=(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELIM",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+".join("+b+")";else throw Error("Unknown mode: "+b);return[a,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
96
- module$exports$Blockly$Python.pythonGenerator.lists_reverse=function(a){return["list(reversed("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]")+"))",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};var module$exports$Blockly$Python$logic={};
97
- module$exports$Blockly$Python.pythonGenerator.controls_if=function(a){let b=0,c="",d,e;module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(c+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));do e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"IF"+b,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False",d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO"+b)||module$exports$Blockly$Python.pythonGenerator.PASS,
98
- module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT)+d),c+=(0===b?"if ":"elif ")+e+":\n"+d,b++;while(a.getInput("IF"+b));if(a.getInput("ELSE")||module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX)d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,
99
- "ELSE")||module$exports$Blockly$Python.pythonGenerator.PASS,module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT)+d),c+="else:\n"+d;return c};module$exports$Blockly$Python.pythonGenerator.controls_ifelse=module$exports$Blockly$Python.pythonGenerator.controls_if;
100
- module$exports$Blockly$Python.pythonGenerator.logic_compare=function(a){const b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",c)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
101
- module$exports$Blockly$Python.pythonGenerator.logic_operation=function(a){const b="AND"===a.getFieldValue("OP")?"and":"or",c="and"===b?module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_AND:module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_OR;let d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",c);a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",c);if(d||a){const e="and"===b?"True":"False";d||(d=e);a||(a=e)}else a=d="False";return[d+" "+b+" "+a,
102
- c]};module$exports$Blockly$Python.pythonGenerator.logic_negate=function(a){return["not "+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BOOL",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT)||"True"),module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};module$exports$Blockly$Python.pythonGenerator.logic_boolean=function(a){return["TRUE"===a.getFieldValue("BOOL")?"True":"False",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
103
- module$exports$Blockly$Python.pythonGenerator.logic_null=function(a){return["None",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
104
- module$exports$Blockly$Python.pythonGenerator.logic_ternary=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"IF",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"False",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"THEN",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"None";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ELSE",module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL)||"None";
105
- return[c+" if "+b+" else "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_CONDITIONAL]};var module$exports$Blockly$Python$loops={},module$contents$Blockly$Python$loops_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$loops_NameType=$.NameType$$module$build$src$core$names;
106
- module$exports$Blockly$Python.pythonGenerator.controls_repeat_ext=function(a){let b;b=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),10)):module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TIMES",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";b=$.module$build$src$core$utils$string.isNumber(b)?parseInt(b,10):"int("+b+")";let c=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");c=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(c,a)||
107
- module$exports$Blockly$Python.pythonGenerator.PASS;return"for "+module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("count",$.NameType$$module$build$src$core$names.VARIABLE)+" in range("+b+"):\n"+c};module$exports$Blockly$Python.pythonGenerator.controls_repeat=module$exports$Blockly$Python.pythonGenerator.controls_repeat_ext;
108
- module$exports$Blockly$Python.pythonGenerator.controls_whileUntil=function(a){const b="UNTIL"===a.getFieldValue("MODE");let c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"BOOL",b?module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT:module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False",d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(d,a)||module$exports$Blockly$Python.pythonGenerator.PASS;
109
- b&&(c="not "+c);return"while "+c+":\n"+d};
110
- module$exports$Blockly$Python.pythonGenerator.controls_for=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",e=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,
111
- "BY",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"1";let f=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");f=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(f,a)||module$exports$Blockly$Python.pythonGenerator.PASS;let g="";const h=function(){return module$exports$Blockly$Python.pythonGenerator.provideFunction_("upRange",`
112
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
81
+ `)+"("+c+', "'+d+'", '+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
82
+ pythonGenerator$$module$build$src$generators$python.forBlock.lists_split=function(a,b){var c=a.getFieldValue("MODE");if("SPLIT"===c)c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python.MEMBER)||"''",a=b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python.NONE),a=c+".split("+a+")";else if("JOIN"===c)c=b.valueToCode(a,"INPUT",Order$$module$build$src$generators$python.NONE)||"[]",a=(b.valueToCode(a,"DELIM",Order$$module$build$src$generators$python.MEMBER)||"''")+".join("+c+
83
+ ")";else throw Error("Unknown mode: "+c);return[a,Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.lists_reverse=function(a,b){return["list(reversed("+(b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.NONE)||"[]")+"))",Order$$module$build$src$generators$python.FUNCTION_CALL]};var module$build$src$generators$python$lists={};pythonGenerator$$module$build$src$generators$python.forBlock.controls_if=function(a,b){let c=0,d="",e,f;b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do f=b.valueToCode(a,"IF"+c,Order$$module$build$src$generators$python.NONE)||"False",e=b.statementToCode(a,"DO"+c)||b.PASS,b.STATEMENT_SUFFIX&&(e=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+e),d+=(0===c?"if ":"elif ")+f+":\n"+e,c++;while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)e=b.statementToCode(a,"ELSE")||
84
+ b.PASS,b.STATEMENT_SUFFIX&&(e=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+e),d+="else:\n"+e;return d};pythonGenerator$$module$build$src$generators$python.forBlock.controls_ifelse=pythonGenerator$$module$build$src$generators$python.forBlock.controls_if;
85
+ pythonGenerator$$module$build$src$generators$python.forBlock.logic_compare=function(a,b){const c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=Order$$module$build$src$generators$python.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]};
86
+ pythonGenerator$$module$build$src$generators$python.forBlock.logic_operation=function(a,b){const c="AND"===a.getFieldValue("OP")?"and":"or",d="and"===c?Order$$module$build$src$generators$python.LOGICAL_AND:Order$$module$build$src$generators$python.LOGICAL_OR;let e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b="and"===c?"True":"False",e||(e=b),a||(a=b)):a=e="False";return[e+" "+c+" "+a,d]};
87
+ pythonGenerator$$module$build$src$generators$python.forBlock.logic_negate=function(a,b){return["not "+(b.valueToCode(a,"BOOL",Order$$module$build$src$generators$python.LOGICAL_NOT)||"True"),Order$$module$build$src$generators$python.LOGICAL_NOT]};pythonGenerator$$module$build$src$generators$python.forBlock.logic_boolean=function(a,b){return["TRUE"===a.getFieldValue("BOOL")?"True":"False",Order$$module$build$src$generators$python.ATOMIC]};
88
+ pythonGenerator$$module$build$src$generators$python.forBlock.logic_null=function(a,b){return["None",Order$$module$build$src$generators$python.ATOMIC]};
89
+ pythonGenerator$$module$build$src$generators$python.forBlock.logic_ternary=function(a,b){const c=b.valueToCode(a,"IF",Order$$module$build$src$generators$python.CONDITIONAL)||"False",d=b.valueToCode(a,"THEN",Order$$module$build$src$generators$python.CONDITIONAL)||"None";a=b.valueToCode(a,"ELSE",Order$$module$build$src$generators$python.CONDITIONAL)||"None";return[d+" if "+c+" else "+a,Order$$module$build$src$generators$python.CONDITIONAL]};var module$build$src$generators$python$logic={};pythonGenerator$$module$build$src$generators$python.forBlock.controls_repeat_ext=function(a,b){let c;c=a.getField("TIMES")?String(parseInt(a.getFieldValue("TIMES"),10)):b.valueToCode(a,"TIMES",Order$$module$build$src$generators$python.NONE)||"0";c=$.isNumber$$module$build$src$core$utils$string(c)?parseInt(c,10):"int("+c+")";let 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"+
90
+ d};pythonGenerator$$module$build$src$generators$python.forBlock.controls_repeat=pythonGenerator$$module$build$src$generators$python.forBlock.controls_repeat_ext;
91
+ pythonGenerator$$module$build$src$generators$python.forBlock.controls_whileUntil=function(a,b){const c="UNTIL"===a.getFieldValue("MODE");let d=b.valueToCode(a,"BOOL",c?Order$$module$build$src$generators$python.LOGICAL_NOT:Order$$module$build$src$generators$python.NONE)||"False",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;c&&(d="not "+d);return"while "+d+":\n"+e};
92
+ pythonGenerator$$module$build$src$generators$python.forBlock.controls_for=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);var d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python.NONE)||"0",e=b.valueToCode(a,"TO",Order$$module$build$src$generators$python.NONE)||"0",f=b.valueToCode(a,"BY",Order$$module$build$src$generators$python.NONE)||"1";let g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a)||b.PASS;let h="";const k=function(){return b.provideFunction_("upRange",
93
+ `
94
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
113
95
  while start <= stop:
114
96
  yield start
115
97
  start += abs(step)
116
- `)},k=function(){return module$exports$Blockly$Python.pythonGenerator.provideFunction_("downRange",`
117
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
98
+ `)},l=function(){return b.provideFunction_("downRange",`
99
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
118
100
  while start >= stop:
119
101
  yield start
120
102
  start -= abs(step)
121
- `)};a=function(l,m,n){return"("+l+" <= "+m+") and "+h()+"("+l+", "+m+", "+n+") or "+k()+"("+l+", "+m+", "+n+")"};if($.module$build$src$core$utils$string.isNumber(c)&&$.module$build$src$core$utils$string.isNumber(d)&&$.module$build$src$core$utils$string.isNumber(e))c=Number(c),d=Number(d),e=Math.abs(Number(e)),0===c%1&&0===d%1&&0===e%1?(c<=d?(d++,a=0===c&&1===e?d:c+", "+d,1!==e&&(a+=", "+e)):(d--,a=c+", "+d+", -"+e),a="range("+a+")"):(a=c<d?h():k(),a+="("+c+", "+d+", "+e+")");else{const l=function(m,
122
- n){$.module$build$src$core$utils$string.isNumber(m)?m=Number(m):m.match(/^\w+$/)||(n=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName(b+n,$.NameType$$module$build$src$core$names.VARIABLE),g+=n+" = "+m+"\n",m=n);return m};c=l(c,"_start");d=l(d,"_end");e=l(e,"_inc");"number"===typeof c&&"number"===typeof d?(a=c<d?h():k(),a+="("+c+", "+d+", "+e+")"):a=a(c,d,e)}return g+="for "+b+" in "+a+":\n"+f};
123
- module$exports$Blockly$Python.pythonGenerator.controls_forEach=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL)||"[]";let d=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"DO");d=module$exports$Blockly$Python.pythonGenerator.addLoopTrap(d,a)||module$exports$Blockly$Python.pythonGenerator.PASS;
124
- return"for "+b+" in "+c+":\n"+d};
125
- module$exports$Blockly$Python.pythonGenerator.controls_flow_statements=function(a){let b="";module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a));if(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX){const c=
126
- a.getSurroundLoop();c&&!c.suppressPrefixSuffix&&(b+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.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$Python$math={},module$contents$Blockly$Python$math_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.addReservedWords("math,random,Number");
127
- module$exports$Blockly$Python.pythonGenerator.math_number=function(a){a=Number(a.getFieldValue("NUM"));let b;Infinity===a?(a='float("inf")',b=module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL):-Infinity===a?(a='-float("inf")',b=module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN):b=0>a?module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN:module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC;return[a,b]};
128
- module$exports$Blockly$Python.pythonGenerator.math_arithmetic=function(a){var b={ADD:[" + ",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE],MINUS:[" - ",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],POWER:[" ** ",module$exports$Blockly$Python.pythonGenerator.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")];
129
- const c=b[0];b=b[1];const d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"A",b)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
130
- module$exports$Blockly$Python.pythonGenerator.math_single=function(a){const b=a.getFieldValue("OP");let c;if("NEG"===b)return c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN)||"0",["-"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_UNARY_SIGN];module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";a="SIN"===b||"COS"===b||"TAN"===b?module$exports$Blockly$Python.pythonGenerator.valueToCode(a,
131
- "NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0":module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";switch(b){case "ABS":c="math.fabs("+a+")";break;case "ROOT":c="math.sqrt("+a+")";break;case "LN":c="math.log("+a+")";break;case "LOG10":c="math.log10("+a+")";break;case "EXP":c="math.exp("+a+")";break;case "POW10":c="math.pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c=
132
- "math.ceil("+a+")";break;case "ROUNDDOWN":c="math.floor("+a+")";break;case "SIN":c="math.sin("+a+" / 180.0 * math.pi)";break;case "COS":c="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":c="math.tan("+a+" / 180.0 * math.pi)"}if(c)return[c,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL];switch(b){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: "+
133
- b);}return[c,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
134
- module$exports$Blockly$Python.pythonGenerator.math_constant=function(a){const b={PI:["math.pi",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],E:["math.e",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER],
135
- INFINITY:["float('inf')",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&(module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math");return b[a]};
136
- module$exports$Blockly$Python.pythonGenerator.math_number_property=function(a){var b={EVEN:[" % 2 == 0",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],
137
- POSITIVE:[" > 0",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE,module$exports$Blockly$Python.pythonGenerator.ORDER_RELATIONAL],PRIME:[null,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE,
138
- module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};const c=a.getFieldValue("PROPERTY"),[d,e,f]=b[c];b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"NUMBER_TO_CHECK",e)||"0";if("PRIME"===c)module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math",module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number",a=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_isPrime",`
139
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(n):
103
+ `)};a=function(n,m,p){return"("+n+" <= "+m+") and "+k()+"("+n+", "+m+", "+p+") or "+l()+"("+n+", "+m+", "+p+")"};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)),0===d%1&&0===e%1&&0===f%1?(d<=e?(e++,a=0===d&&1===f?e:d+", "+e,1!==f&&(a+=", "+f)):(e--,a=d+", "+e+", -"+f),a="range("+a+")"):(a=d<e?k():l(),a+="("+d+", "+e+", "+f+")");else{const n=function(m,
104
+ p){$.isNumber$$module$build$src$core$utils$string(m)?m=Number(m):m.match(/^\w+$/)||(p=b.nameDB_.getDistinctName(c+p,$.NameType$$module$build$src$core$names.VARIABLE),h+=p+" = "+m+"\n",m=p);return m};d=n(d,"_start");e=n(e,"_end");f=n(f,"_inc");"number"===typeof d&&"number"===typeof e?(a=d<e?k():l(),a+="("+d+", "+e+", "+f+")"):a=a(d,e,f)}return h+="for "+c+" in "+a+":\n"+g};
105
+ pythonGenerator$$module$build$src$generators$python.forBlock.controls_forEach=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),d=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.RELATIONAL)||"[]";let e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a)||b.PASS;return"for "+c+" in "+d+":\n"+e};
106
+ pythonGenerator$$module$build$src$generators$python.forBlock.controls_flow_statements=function(a,b){let 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){const 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.");};
107
+ var module$build$src$generators$python$loops={};pythonGenerator$$module$build$src$generators$python.addReservedWords("math,random,Number");
108
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_number=function(a,b){a=Number(a.getFieldValue("NUM"));Infinity===a?(a='float("inf")',b=Order$$module$build$src$generators$python.FUNCTION_CALL):-Infinity===a?(a='-float("inf")',b=Order$$module$build$src$generators$python.UNARY_SIGN):b=0>a?Order$$module$build$src$generators$python.UNARY_SIGN:Order$$module$build$src$generators$python.ATOMIC;return[a,b]};
109
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_arithmetic=function(a,b){var c={ADD:[" + ",Order$$module$build$src$generators$python.ADDITIVE],MINUS:[" - ",Order$$module$build$src$generators$python.ADDITIVE],MULTIPLY:[" * ",Order$$module$build$src$generators$python.MULTIPLICATIVE],DIVIDE:[" / ",Order$$module$build$src$generators$python.MULTIPLICATIVE],POWER:[" ** ",Order$$module$build$src$generators$python.EXPONENTIATION]}[a.getFieldValue("OP")];const d=c[0];c=c[1];const e=b.valueToCode(a,
110
+ "A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return[e+d+a,c]};
111
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_single=function(a,b){const c=a.getFieldValue("OP");let d;if("NEG"===c)return d=b.valueToCode(a,"NUM",Order$$module$build$src$generators$python.UNARY_SIGN)||"0",["-"+d,Order$$module$build$src$generators$python.UNARY_SIGN];b.definitions_.import_math="import math";a="SIN"===c||"COS"===c||"TAN"===c?b.valueToCode(a,"NUM",Order$$module$build$src$generators$python.MULTIPLICATIVE)||"0":b.valueToCode(a,"NUM",Order$$module$build$src$generators$python.NONE)||
112
+ "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)";break;case "COS":d="math.cos("+a+" / 180.0 * math.pi)";break;case "TAN":d="math.tan("+
113
+ a+" / 180.0 * math.pi)"}if(d)return[d,Order$$module$build$src$generators$python.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.MULTIPLICATIVE]};
114
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_constant=function(a,b){const c={PI:["math.pi",Order$$module$build$src$generators$python.MEMBER],E:["math.e",Order$$module$build$src$generators$python.MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Order$$module$build$src$generators$python.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Order$$module$build$src$generators$python.MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",Order$$module$build$src$generators$python.MEMBER],INFINITY:["float('inf')",Order$$module$build$src$generators$python.ATOMIC]};
115
+ a=a.getFieldValue("CONSTANT");"INFINITY"!==a&&(b.definitions_.import_math="import math");return c[a]};
116
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_number_property=function(a,b){var c={EVEN:[" % 2 == 0",Order$$module$build$src$generators$python.MULTIPLICATIVE,Order$$module$build$src$generators$python.RELATIONAL],ODD:[" % 2 == 1",Order$$module$build$src$generators$python.MULTIPLICATIVE,Order$$module$build$src$generators$python.RELATIONAL],WHOLE:[" % 1 == 0",Order$$module$build$src$generators$python.MULTIPLICATIVE,Order$$module$build$src$generators$python.RELATIONAL],POSITIVE:[" > 0",
117
+ Order$$module$build$src$generators$python.RELATIONAL,Order$$module$build$src$generators$python.RELATIONAL],NEGATIVE:[" < 0",Order$$module$build$src$generators$python.RELATIONAL,Order$$module$build$src$generators$python.RELATIONAL],DIVISIBLE_BY:[null,Order$$module$build$src$generators$python.MULTIPLICATIVE,Order$$module$build$src$generators$python.RELATIONAL],PRIME:[null,Order$$module$build$src$generators$python.NONE,Order$$module$build$src$generators$python.FUNCTION_CALL]};const d=a.getFieldValue("PROPERTY"),
118
+ [e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";if("PRIME"===d)b.definitions_.import_math="import math",b.definitions_.from_numbers_import_Number="from numbers import Number",a=b.provideFunction_("math_isPrime",`
119
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(n):
140
120
  # https://en.wikipedia.org/wiki/Primality_test#Naive_methods
141
121
  # If n is not a number but a string, try parsing it.
142
122
  if not isinstance(n, Number):
@@ -154,25 +134,24 @@ def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(
154
134
  if n % (x - 1) == 0 or n % (x + 1) == 0:
155
135
  return False
156
136
  return True
157
- `)+"("+b+")";else if("DIVISIBLE_BY"===c){a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";if("0"===a)return["False",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC];a=b+" % "+a+" == 0"}else a=b+d;return[a,f]};
158
- module$exports$Blockly$Python.pythonGenerator.math_change=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DELTA",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE)||"0";a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = ("+a+" if isinstance("+
159
- a+", Number) else 0) + "+b+"\n"};module$exports$Blockly$Python.pythonGenerator.math_round=module$exports$Blockly$Python.pythonGenerator.math_single;module$exports$Blockly$Python.pythonGenerator.math_trig=module$exports$Blockly$Python.pythonGenerator.math_single;
160
- module$exports$Blockly$Python.pythonGenerator.math_on_list=function(a){var b=a.getFieldValue("OP");a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LIST",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"[]";switch(b){case "SUM":b="sum("+a+")";break;case "MIN":b="min("+a+")";break;case "MAX":b="max("+a+")";break;case "AVERAGE":module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_mean",
161
- `
162
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
137
+ `)+"("+c+")";else if("DIVISIBLE_BY"===d){a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$python.MULTIPLICATIVE)||"0";if("0"===a)return["False",Order$$module$build$src$generators$python.ATOMIC];a=c+" % "+a+" == 0"}else a=c+e;return[a,g]};
138
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_change=function(a,b){b.definitions_.from_numbers_import_Number="from numbers import Number";const c=b.valueToCode(a,"DELTA",Order$$module$build$src$generators$python.ADDITIVE)||"0";a=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);return a+" = ("+a+" if isinstance("+a+", Number) else 0) + "+c+"\n"};pythonGenerator$$module$build$src$generators$python.forBlock.math_round=pythonGenerator$$module$build$src$generators$python.forBlock.math_single;
139
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_trig=pythonGenerator$$module$build$src$generators$python.forBlock.math_single;
140
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_on_list=function(a,b){const c=a.getFieldValue("OP");a=b.valueToCode(a,"LIST",Order$$module$build$src$generators$python.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",`
141
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
163
142
  localList = [e for e in myList if isinstance(e, Number)]
164
143
  if not localList: return
165
144
  return float(sum(localList)) / len(localList)
166
- `)+"("+a+")";break;case "MEDIAN":module$exports$Blockly$Python.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_median",`
167
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
145
+ `)+"("+a+")";break;case "MEDIAN":b.definitions_.from_numbers_import_Number="from numbers import Number";b=b.provideFunction_("math_median",`
146
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(myList):
168
147
  localList = sorted([e for e in myList if isinstance(e, Number)])
169
148
  if not localList: return
170
149
  if len(localList) % 2 == 0:
171
150
  return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0
172
151
  else:
173
152
  return localList[(len(localList) - 1) // 2]
174
- `)+"("+a+")";break;case "MODE":b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_modes",`
175
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(some_list):
153
+ `)+"("+a+")";break;case "MODE":b=b.provideFunction_("math_modes",`
154
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(some_list):
176
155
  modes = []
177
156
  # Using a lists of [item, count] to keep count rather than dict
178
157
  # to avoid "unhashable" errors when the counted item is itself a list or dict.
@@ -191,63 +170,53 @@ def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(
191
170
  if item_count == maxCount:
192
171
  modes.append(counted_item)
193
172
  return modes
194
- `)+"("+a+")";break;case "STD_DEV":module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("math_standard_deviation",`
195
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers):
173
+ `)+"("+a+")";break;case "STD_DEV":b.definitions_.import_math="import math";b=b.provideFunction_("math_standard_deviation",`
174
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(numbers):
196
175
  n = len(numbers)
197
176
  if n == 0: return
198
177
  mean = float(sum(numbers)) / n
199
178
  variance = sum((x - mean) ** 2 for x in numbers) / n
200
179
  return math.sqrt(variance)
201
- `)+"("+a+")";break;case "RANDOM":module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";b="random.choice("+a+")";break;default:throw Error("Unknown operator: "+b);}return[b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
202
- module$exports$Blockly$Python.pythonGenerator.math_modulo=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVIDEND",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"DIVISOR",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};
203
- module$exports$Blockly$Python.pythonGenerator.math_constrain=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"LOW",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"HIGH",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"float('inf')";return["min(max("+
204
- b+", "+c+"), "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
205
- module$exports$Blockly$Python.pythonGenerator.math_random_int=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return["random.randint("+b+", "+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
206
- module$exports$Blockly$Python.pythonGenerator.math_random_float=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random";return["random.random()",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
207
- module$exports$Blockly$Python.pythonGenerator.math_atan2=function(a){module$exports$Blockly$Python.pythonGenerator.definitions_.import_math="import math";const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"X",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return["math.atan2("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"Y",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0")+", "+b+") / math.pi * 180",module$exports$Blockly$Python.pythonGenerator.ORDER_MULTIPLICATIVE]};var module$exports$Blockly$Python$procedures={},module$contents$Blockly$Python$procedures_Variables=$.module$build$src$core$variables,module$contents$Blockly$Python$procedures_NameType=$.NameType$$module$build$src$core$names;
208
- module$exports$Blockly$Python.pythonGenerator.procedures_defreturn=function(a){var b=[],c=a.workspace,d=$.module$build$src$core$variables.allUsedVarModels(c)||[];for(let m=0,n;n=d[m];m++){var e=n.name;-1===a.getVars().indexOf(e)&&b.push(module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(e,$.NameType$$module$build$src$core$names.VARIABLE))}c=$.module$build$src$core$variables.allDeveloperVariables(c);for(d=0;d<c.length;d++)b.push(module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(c[d],
209
- $.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));c=b.length?module$exports$Blockly$Python.pythonGenerator.INDENT+"global "+b.join(", ")+"\n":"";b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);d="";module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX&&(d+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_PREFIX,a));module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&
210
- (d+=module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a));d&&(d=module$exports$Blockly$Python.pythonGenerator.prefixLines(d,module$exports$Blockly$Python.pythonGenerator.INDENT));e="";module$exports$Blockly$Python.pythonGenerator.INFINITE_LOOP_TRAP&&(e=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.INFINITE_LOOP_TRAP,a),
211
- module$exports$Blockly$Python.pythonGenerator.INDENT));let f=module$exports$Blockly$Python.pythonGenerator.statementToCode(a,"STACK"),g=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"RETURN",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"",h="";f&&g&&(h=d);g?g=module$exports$Blockly$Python.pythonGenerator.INDENT+"return "+g+"\n":f||(f=module$exports$Blockly$Python.pythonGenerator.PASS);const k=[],l=a.getVars();for(let m=0;m<l.length;m++)k[m]=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(l[m],
212
- $.NameType$$module$build$src$core$names.VARIABLE);c="def "+b+"("+k.join(", ")+"):\n"+c+d+e+f+h+g;c=module$exports$Blockly$Python.pythonGenerator.scrub_(a,c);module$exports$Blockly$Python.pythonGenerator.definitions_["%"+b]=c;return null};module$exports$Blockly$Python.pythonGenerator.procedures_defnoreturn=module$exports$Blockly$Python.pythonGenerator.procedures_defreturn;
213
- module$exports$Blockly$Python.pythonGenerator.procedures_callreturn=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),c=[],d=a.getVars();for(let e=0;e<d.length;e++)c[e]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ARG"+e,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None";return[b+"("+c.join(", ")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
214
- module$exports$Blockly$Python.pythonGenerator.procedures_callnoreturn=function(a){return module$exports$Blockly$Python.pythonGenerator.procedures_callreturn(a)[0]+"\n"};
215
- module$exports$Blockly$Python.pythonGenerator.procedures_ifreturn=function(a){let b="if "+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"CONDITION",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"False")+":\n";module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX&&(b+=module$exports$Blockly$Python.pythonGenerator.prefixLines(module$exports$Blockly$Python.pythonGenerator.injectId(module$exports$Blockly$Python.pythonGenerator.STATEMENT_SUFFIX,a),module$exports$Blockly$Python.pythonGenerator.INDENT));
216
- a.hasReturnValue_?(a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"None",b+=module$exports$Blockly$Python.pythonGenerator.INDENT+"return "+a+"\n"):b+=module$exports$Blockly$Python.pythonGenerator.INDENT+"return\n";return b};var module$exports$Blockly$Python$texts={},module$contents$Blockly$Python$texts_stringUtils=$.module$build$src$core$utils$string,module$contents$Blockly$Python$texts_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.text=function(a){return[module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("TEXT")),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
217
- module$exports$Blockly$Python.pythonGenerator.text_multiline=function(a){a=module$exports$Blockly$Python.pythonGenerator.multiline_quote_(a.getFieldValue("TEXT"));const b=-1!==a.indexOf("+")?module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE:module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC;return[a,b]};
218
- var module$contents$Blockly$Python$texts_strRegExp=/^\s*'([^']|\\')*'\s*$/,module$contents$Blockly$Python$texts_forceString=function(a){return module$contents$Blockly$Python$texts_strRegExp.test(a)?[a,module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]:["str("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
219
- module$exports$Blockly$Python.pythonGenerator.text_join=function(a){switch(a.itemCount_){case 0:return["''",module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC];case 1:return a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''",module$contents$Blockly$Python$texts_forceString(a);case 2:var b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD0",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||
220
- "''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD1",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[module$contents$Blockly$Python$texts_forceString(b)[0]+" + "+module$contents$Blockly$Python$texts_forceString(a)[0],module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE];default:b=[];for(let c=0;c<a.itemCount_;c++)b[c]=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"ADD"+c,module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";
221
- a=module$exports$Blockly$Python.pythonGenerator.nameDB_.getDistinctName("x",$.NameType$$module$build$src$core$names.VARIABLE);return["''.join([str("+a+") for "+a+" in ["+b.join(", ")+"]])",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]}};
222
- module$exports$Blockly$Python.pythonGenerator.text_append=function(a){const b=module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return b+" = str("+b+") + "+module$contents$Blockly$Python$texts_forceString(a)[0]+"\n"};
223
- module$exports$Blockly$Python.pythonGenerator.text_length=function(a){return["len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
224
- module$exports$Blockly$Python.pythonGenerator.text_isEmpty=function(a){return["not len("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")",module$exports$Blockly$Python.pythonGenerator.ORDER_LOGICAL_NOT]};
225
- module$exports$Blockly$Python.pythonGenerator.text_indexOf=function(a){var b="FIRST"===a.getFieldValue("END")?"find":"rfind";const c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FIND",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";b=(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+"."+b+"("+c+")";return a.workspace.options.oneBasedIndex?[b+" + 1",module$exports$Blockly$Python.pythonGenerator.ORDER_ADDITIVE]:
226
- [b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
227
- module$exports$Blockly$Python.pythonGenerator.text_charAt=function(a){const b=a.getFieldValue("WHERE")||"FROM_START",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE","RANDOM"===b?module$exports$Blockly$Python.pythonGenerator.ORDER_NONE:module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";switch(b){case "FIRST":return[c+"[0]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "LAST":return[c+"[-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];
228
- case "FROM_START":return a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT"),[c+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "FROM_END":return a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT",1,!0),[c+"["+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER];case "RANDOM":return module$exports$Blockly$Python.pythonGenerator.definitions_.import_random="import random",[module$exports$Blockly$Python.pythonGenerator.provideFunction_("text_random_letter",
229
- `
230
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(text):
180
+ `)+"("+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.FUNCTION_CALL]};
181
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_modulo=function(a,b){const c=b.valueToCode(a,"DIVIDEND",Order$$module$build$src$generators$python.MULTIPLICATIVE)||"0";a=b.valueToCode(a,"DIVISOR",Order$$module$build$src$generators$python.MULTIPLICATIVE)||"0";return[c+" % "+a,Order$$module$build$src$generators$python.MULTIPLICATIVE]};
182
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_constrain=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"0",d=b.valueToCode(a,"LOW",Order$$module$build$src$generators$python.NONE)||"0";a=b.valueToCode(a,"HIGH",Order$$module$build$src$generators$python.NONE)||"float('inf')";return["min(max("+c+", "+d+"), "+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
183
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_random_int=function(a,b){b.definitions_.import_random="import random";const c=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python.NONE)||"0";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$python.NONE)||"0";return["random.randint("+c+", "+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
184
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_random_float=function(a,b){b.definitions_.import_random="import random";return["random.random()",Order$$module$build$src$generators$python.FUNCTION_CALL]};
185
+ pythonGenerator$$module$build$src$generators$python.forBlock.math_atan2=function(a,b){b.definitions_.import_math="import math";const c=b.valueToCode(a,"X",Order$$module$build$src$generators$python.NONE)||"0";return["math.atan2("+(b.valueToCode(a,"Y",Order$$module$build$src$generators$python.NONE)||"0")+", "+c+") / math.pi * 180",Order$$module$build$src$generators$python.MULTIPLICATIVE]};var module$build$src$generators$python$math={};pythonGenerator$$module$build$src$generators$python.forBlock.procedures_defreturn=function(a,b){var c=[],d=a.workspace,e=$.allUsedVarModels$$module$build$src$core$variables(d)||[];for(let m=0,p;p=e[m];m++){var f=p.name;-1===a.getVars().indexOf(f)&&c.push(b.nameDB_.getName(f,$.NameType$$module$build$src$core$names.VARIABLE))}d=$.allDeveloperVariables$$module$build$src$core$variables(d);for(e=0;e<d.length;e++)c.push(b.nameDB_.getName(d[e],$.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));
186
+ d=c.length?b.INDENT+"global "+c.join(", ")+"\n":"";c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE);e="";b.STATEMENT_PREFIX&&(e+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(e+=b.injectId(b.STATEMENT_SUFFIX,a));e&&(e=b.prefixLines(e,b.INDENT));f="";b.INFINITE_LOOP_TRAP&&(f=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));let g=b.statementToCode(a,"STACK"),h=b.valueToCode(a,"RETURN",Order$$module$build$src$generators$python.NONE)||
187
+ "",k="";g&&h&&(k=e);h?h=b.INDENT+"return "+h+"\n":g||(g=b.PASS);const l=[],n=a.getVars();for(let m=0;m<n.length;m++)l[m]=b.nameDB_.getName(n[m],$.NameType$$module$build$src$core$names.VARIABLE);d="def "+c+"("+l.join(", ")+"):\n"+d+e+f+g+k+h;d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null};pythonGenerator$$module$build$src$generators$python.forBlock.procedures_defnoreturn=pythonGenerator$$module$build$src$generators$python.forBlock.procedures_defreturn;
188
+ pythonGenerator$$module$build$src$generators$python.forBlock.procedures_callreturn=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("NAME"),$.NameType$$module$build$src$core$names.PROCEDURE),d=[],e=a.getVars();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,Order$$module$build$src$generators$python.NONE)||"None";return[c+"("+d.join(", ")+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
189
+ pythonGenerator$$module$build$src$generators$python.forBlock.procedures_callnoreturn=function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+"\n"};
190
+ pythonGenerator$$module$build$src$generators$python.forBlock.procedures_ifreturn=function(a,b){let c="if "+(b.valueToCode(a,"CONDITION",Order$$module$build$src$generators$python.NONE)||"False")+":\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"None",c+=b.INDENT+"return "+a+"\n"):c+=b.INDENT+"return\n";return c};var module$build$src$generators$python$procedures={};pythonGenerator$$module$build$src$generators$python.forBlock.text=function(a,b){return[b.quote_(a.getFieldValue("TEXT")),Order$$module$build$src$generators$python.ATOMIC]};pythonGenerator$$module$build$src$generators$python.forBlock.text_multiline=function(a,b){a=b.multiline_quote_(a.getFieldValue("TEXT"));b=-1!==a.indexOf("+")?Order$$module$build$src$generators$python.ADDITIVE:Order$$module$build$src$generators$python.ATOMIC;return[a,b]};
191
+ 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.ATOMIC]:["str("+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
192
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_join=function(a,b){switch(a.itemCount_){case 0:return["''",Order$$module$build$src$generators$python.ATOMIC];case 1:return a=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python.NONE)||"''",forceString$$module$build$src$generators$python$text(a);case 2:var c=b.valueToCode(a,"ADD0",Order$$module$build$src$generators$python.NONE)||"''";a=b.valueToCode(a,"ADD1",Order$$module$build$src$generators$python.NONE)||"''";return[forceString$$module$build$src$generators$python$text(c)[0]+
193
+ " + "+forceString$$module$build$src$generators$python$text(a)[0],Order$$module$build$src$generators$python.ADDITIVE];default:c=[];for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,Order$$module$build$src$generators$python.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.FUNCTION_CALL]}};
194
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_append=function(a,b){const c=b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE);a=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.NONE)||"''";return c+" = str("+c+") + "+forceString$$module$build$src$generators$python$text(a)[0]+"\n"};
195
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_length=function(a,b){return["len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"''")+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.text_isEmpty=function(a,b){return["not len("+(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"''")+")",Order$$module$build$src$generators$python.LOGICAL_NOT]};
196
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_indexOf=function(a,b){const c="FIRST"===a.getFieldValue("END")?"find":"rfind",d=b.valueToCode(a,"FIND",Order$$module$build$src$generators$python.NONE)||"''";b=(b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.MEMBER)||"''")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",Order$$module$build$src$generators$python.ADDITIVE]:[b,Order$$module$build$src$generators$python.FUNCTION_CALL]};
197
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_charAt=function(a,b){const c=a.getFieldValue("WHERE")||"FROM_START",d=b.valueToCode(a,"VALUE","RANDOM"===c?Order$$module$build$src$generators$python.NONE:Order$$module$build$src$generators$python.MEMBER)||"''";switch(c){case "FIRST":return[d+"[0]",Order$$module$build$src$generators$python.MEMBER];case "LAST":return[d+"[-1]",Order$$module$build$src$generators$python.MEMBER];case "FROM_START":return a=b.getAdjustedInt(a,"AT"),[d+"["+
198
+ a+"]",Order$$module$build$src$generators$python.MEMBER];case "FROM_END":return a=b.getAdjustedInt(a,"AT",1,!0),[d+"["+a+"]",Order$$module$build$src$generators$python.MEMBER];case "RANDOM":return b.definitions_.import_random="import random",[b.provideFunction_("text_random_letter",`
199
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(text):
231
200
  x = int(random.random() * len(text))
232
201
  return text[x]
233
- `)+"("+c+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
234
- module$exports$Blockly$Python.pythonGenerator.text_getSubstring=function(a){var b=a.getFieldValue("WHERE1");const c=a.getFieldValue("WHERE2"),d=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"STRING",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";switch(b){case "FROM_START":b=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1");0===b&&(b="");break;case "FROM_END":b=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":b=
235
- "";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(c){case "FROM_START":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",1);break;case "FROM_END":a=module$exports$Blockly$Python.pythonGenerator.getAdjustedInt(a,"AT2",0,!0);$.module$build$src$core$utils$string.isNumber(String(a))?0===a&&(a=""):(module$exports$Blockly$Python.pythonGenerator.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case "LAST":a="";break;default:throw Error("Unhandled option (text_getSubstring)");
236
- }return[d+"["+b+" : "+a+"]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.text_changeCase=function(a){const b={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
237
- module$exports$Blockly$Python.pythonGenerator.text_trim=function(a){const b={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
238
- module$exports$Blockly$Python.pythonGenerator.text_print=function(a){return"print("+(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''")+")\n"};module$exports$Blockly$Python.pythonGenerator.text_prompt_ext=function(a){var b=module$exports$Blockly$Python.pythonGenerator.provideFunction_("text_prompt",`
239
- def ${module$exports$Blockly$Python.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg):
202
+ `)+"("+d+")",Order$$module$build$src$generators$python.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
203
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_getSubstring=function(a,b){var c=a.getFieldValue("WHERE1");const d=a.getFieldValue("WHERE2"),e=b.valueToCode(a,"STRING",Order$$module$build$src$generators$python.MEMBER)||"''";switch(c){case "FROM_START":c=b.getAdjustedInt(a,"AT1");0===c&&(c="");break;case "FROM_END":c=b.getAdjustedInt(a,"AT1",1,!0);break;case "FIRST":c="";break;default:throw Error("Unhandled option (text_getSubstring)");}switch(d){case "FROM_START":a=b.getAdjustedInt(a,
204
+ "AT2",1);break;case "FROM_END":a=b.getAdjustedInt(a,"AT2",0,!0);$.isNumber$$module$build$src$core$utils$string(String(a))?0===a&&(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.MEMBER]};
205
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_changeCase=function(a,b){const c={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[a.getFieldValue("CASE")];return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.MEMBER)||"''")+c,Order$$module$build$src$generators$python.FUNCTION_CALL]};
206
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_trim=function(a,b){const c={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.MEMBER)||"''")+c,Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.text_print=function(a,b){return"print("+(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.NONE)||"''")+")\n"};
207
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_prompt_ext=function(a,b){var c=b.provideFunction_("text_prompt",`
208
+ def ${b.FUNCTION_NAME_PLACEHOLDER_}(msg):
240
209
  try:
241
210
  return raw_input(msg)
242
211
  except NameError:
243
212
  return input(msg)
244
- `);let c;c=a.getField("TEXT")?module$exports$Blockly$Python.pythonGenerator.quote_(a.getFieldValue("TEXT")):module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";b=b+"("+c+")";"NUMBER"===a.getFieldValue("TYPE")&&(b="float("+b+")");return[b,module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};module$exports$Blockly$Python.pythonGenerator.text_prompt=module$exports$Blockly$Python.pythonGenerator.text_prompt_ext;
245
- module$exports$Blockly$Python.pythonGenerator.text_count=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"SUB",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[b+".count("+a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_FUNCTION_CALL]};
246
- module$exports$Blockly$Python.pythonGenerator.text_replace=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''",c=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"FROM",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";a=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TO",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"''";return[b+".replace("+c+", "+
247
- a+")",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};module$exports$Blockly$Python.pythonGenerator.text_reverse=function(a){return[(module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"TEXT",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER)||"''")+"[::-1]",module$exports$Blockly$Python.pythonGenerator.ORDER_MEMBER]};var module$exports$Blockly$Python$variables={},module$contents$Blockly$Python$variables_NameType=$.NameType$$module$build$src$core$names;module$exports$Blockly$Python.pythonGenerator.variables_get=function(a){return[module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),module$exports$Blockly$Python.pythonGenerator.ORDER_ATOMIC]};
248
- module$exports$Blockly$Python.pythonGenerator.variables_set=function(a){const b=module$exports$Blockly$Python.pythonGenerator.valueToCode(a,"VALUE",module$exports$Blockly$Python.pythonGenerator.ORDER_NONE)||"0";return module$exports$Blockly$Python.pythonGenerator.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+b+"\n"};var module$exports$Blockly$Python$variablesDynamic={};module$exports$Blockly$Python.pythonGenerator.variables_get_dynamic=module$exports$Blockly$Python.pythonGenerator.variables_get;module$exports$Blockly$Python.pythonGenerator.variables_set_dynamic=module$exports$Blockly$Python.pythonGenerator.variables_set;var module$exports$Blockly$Python$all=module$exports$Blockly$Python;
249
- module$exports$Blockly$Python.__namespace__=$;
250
- return module$exports$Blockly$Python;
213
+ `);b=a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.NONE)||"''";c=c+"("+b+")";"NUMBER"===a.getFieldValue("TYPE")&&(c="float("+c+")");return[c,Order$$module$build$src$generators$python.FUNCTION_CALL]};pythonGenerator$$module$build$src$generators$python.forBlock.text_prompt=pythonGenerator$$module$build$src$generators$python.forBlock.text_prompt_ext;
214
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_count=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.MEMBER)||"''";a=b.valueToCode(a,"SUB",Order$$module$build$src$generators$python.NONE)||"''";return[c+".count("+a+")",Order$$module$build$src$generators$python.FUNCTION_CALL]};
215
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_replace=function(a,b){const c=b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.MEMBER)||"''",d=b.valueToCode(a,"FROM",Order$$module$build$src$generators$python.NONE)||"''";a=b.valueToCode(a,"TO",Order$$module$build$src$generators$python.NONE)||"''";return[c+".replace("+d+", "+a+")",Order$$module$build$src$generators$python.MEMBER]};
216
+ pythonGenerator$$module$build$src$generators$python.forBlock.text_reverse=function(a,b){return[(b.valueToCode(a,"TEXT",Order$$module$build$src$generators$python.MEMBER)||"''")+"[::-1]",Order$$module$build$src$generators$python.MEMBER]};var module$build$src$generators$python$text={};pythonGenerator$$module$build$src$generators$python.forBlock.variables_get=function(a,b){return[b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE),Order$$module$build$src$generators$python.ATOMIC]};
217
+ pythonGenerator$$module$build$src$generators$python.forBlock.variables_set=function(a,b){const c=b.valueToCode(a,"VALUE",Order$$module$build$src$generators$python.NONE)||"0";return b.nameDB_.getName(a.getFieldValue("VAR"),$.NameType$$module$build$src$core$names.VARIABLE)+" = "+c+"\n"};var module$build$src$generators$python$variables={};pythonGenerator$$module$build$src$generators$python.forBlock.variables_get_dynamic=pythonGenerator$$module$build$src$generators$python.forBlock.variables_get;pythonGenerator$$module$build$src$generators$python.forBlock.variables_set_dynamic=pythonGenerator$$module$build$src$generators$python.forBlock.variables_set;var module$build$src$generators$python$variables_dynamic={};var module$build$src$generators$python$all={};module$build$src$generators$python$all.Order=Order$$module$build$src$generators$python;module$build$src$generators$python$all.PythonGenerator=PythonGenerator$$module$build$src$generators$python;module$build$src$generators$python$all.pythonGenerator=pythonGenerator$$module$build$src$generators$python;
218
+ module$build$src$generators$python$all.__namespace__=$;
219
+ return module$build$src$generators$python$all;
251
220
  }));
252
221
 
253
222