2022-01-03 14:02:41 +00:00
// Do not edit this file; automatically generated.
2021-01-16 14:07:51 +00:00
/* eslint-disable */
; ( function ( root , factory ) {
if ( typeof define === 'function' && define . amd ) { // AMD
2022-01-03 14:02:41 +00:00
define ( [ "./blockly_compressed.js" ] , factory ) ;
2021-01-16 14:07:51 +00:00
} else if ( typeof exports === 'object' ) { // Node.js
2022-01-03 14:02:41 +00:00
module . exports = factory ( require ( "./blockly_compressed.js" ) ) ;
2021-01-16 14:07:51 +00:00
} else { // Browser
2022-06-07 11:14:29 +00:00
var factoryExports = factory ( root . Blockly ) ;
2022-11-16 13:57:00 +00:00
root . Blockly . JavaScript = factoryExports . javascriptGenerator ;
root . Blockly . JavaScript . _ _namespace _ _ = factoryExports . _ _namespace _ _ ;
2021-01-16 14:07:51 +00:00
}
2022-06-07 11:14:29 +00:00
} ( this , function ( _ _parent _ _ ) {
var $ = _ _parent _ _ . _ _namespace _ _ ;
2022-11-16 13:57:00 +00:00
var module$exports$Blockly$JavaScript = { } , module$contents$Blockly$JavaScript _Variables = $ . module$build$src$core$variables , module$contents$Blockly$JavaScript _objectUtils = $ . module$build$src$core$utils$object , module$contents$Blockly$JavaScript _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$JavaScript _Generator = $ . Generator$$module$build$src$core$generator , module$contents$Blockly$JavaScript _inputTypes = $ . module$build$src$core$input _types . inputTypes , module$contents$Blockly$JavaScript _Names =
$ . module$build$src$core$names . Names , module$contents$Blockly$JavaScript _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$JavaScript . javascriptGenerator = new $ . Generator$$module$build$src$core$generator ( "JavaScript" ) ;
module$exports$Blockly$JavaScript . javascriptGenerator . addReservedWords ( "break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments," + Object . getOwnPropertyNames ( globalThis ) . join ( "," ) ) ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC = 0 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NEW = 1.1 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER = 1.2 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL = 2 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _INCREMENT = 3 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DECREMENT = 3 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _BITWISE _NOT = 4.1 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _UNARY _PLUS = 4.2 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _UNARY _NEGATION = 4.3 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT = 4.4 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _TYPEOF = 4.5 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _VOID = 4.6 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DELETE = 4.7 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _AWAIT = 4.8 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EXPONENTIATION = 5 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MULTIPLICATION = 5.1 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION = 5.2 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS = 5.3 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION = 6.1 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION = 6.2 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _BITWISE _SHIFT = 7 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL = 8 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _IN = 8 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _INSTANCEOF = 8 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY = 9 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _BITWISE _AND = 10 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _BITWISE _XOR = 11 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _BITWISE _OR = 12 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _AND = 13 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _OR = 14 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _CONDITIONAL = 15 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT = 16 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _YIELD = 17 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _COMMA = 18 ; module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE = 99 ;
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _OVERRIDES = [ [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ,
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MULTIPLICATION , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MULTIPLICATION ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ] ,
[ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _AND , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _AND ] , [ module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _OR , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _OR ] ] ; module$exports$Blockly$JavaScript . javascriptGenerator . isInitialized = ! 1 ;
module$exports$Blockly$JavaScript . javascriptGenerator . init = function ( a ) { Object . getPrototypeOf ( this ) . init . call ( this ) ; 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 ] , $ . NameType$$module$build$src$core$names . DEVELOPER _VARIABLE ) ) ;
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 ) ) ; b . length && ( this . definitions _ . variables = "var " + b . join ( ", " ) + ";" ) ; this . isInitialized = ! 0 } ;
module$exports$Blockly$JavaScript . javascriptGenerator . finish = function ( a ) { const b = $ . module$build$src$core$utils$object . values ( this . definitions _ ) ; a = Object . getPrototypeOf ( this ) . finish . call ( this , a ) ; this . isInitialized = ! 1 ; this . nameDB _ . reset ( ) ; return b . join ( "\n\n" ) + "\n\n\n" + a } ; module$exports$Blockly$JavaScript . javascriptGenerator . scrubNakedValue = function ( a ) { return a + ";\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . quote _ = function ( a ) { a = a . replace ( /\\/g , "\\\\" ) . replace ( /\n/g , "\\\n" ) . replace ( /'/g , "\\'" ) ; return "'" + a + "'" } ; module$exports$Blockly$JavaScript . javascriptGenerator . multiline _quote _ = function ( a ) { return a . split ( /\n/g ) . map ( this . quote _ ) . join ( " + '\\n' +\n" ) } ;
module$exports$Blockly$JavaScript . javascriptGenerator . 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 && a . nextConnection . targetBlock ( ) ; c = c ? "" : this . blockToCode ( a ) ; return d + b + c } ;
module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted = function ( a , b , c , d , e ) { c = c || 0 ; e = e || this . ORDER _NONE ; a . workspace . options . oneBasedIndex && c -- ; const f = a . workspace . options . oneBasedIndex ? "1" : "0" ; let g , h = e ; 0 < c ? g = h = this . ORDER _ADDITION : 0 > c ? g = h = this . ORDER _SUBTRACTION : d && ( g = h = this . ORDER _UNARY _NEGATION ) ; a = this . valueToCode ( a , b , h ) || f ; $ . module$build$src$core$utils$string . isNumber ( a ) ? ( a = Number ( a ) + c , d && ( a = - a ) ) : ( 0 < c ? a = a + " + " + c : 0 > c && ( a = a + " - " + - c ) , d && ( a = c ? "-(" + a + ")" : "-" + a ) , g = Math . floor ( g ) , e = Math . floor ( e ) ,
g && e >= g && ( a = "(" + a + ")" ) ) ; return a } ; var module$exports$Blockly$JavaScript$variables = { } , module$contents$Blockly$JavaScript$variables _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$JavaScript . javascriptGenerator . variables _get = function ( a ) { return [ module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . variables _set = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "0" ; return module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) + " = " + b + ";\n" } ; var module$exports$Blockly$JavaScript$variablesDynamic = { } ; module$exports$Blockly$JavaScript . javascriptGenerator . variables _get _dynamic = module$exports$Blockly$JavaScript . javascriptGenerator . variables _get ; module$exports$Blockly$JavaScript . javascriptGenerator . variables _set _dynamic = module$exports$Blockly$JavaScript . javascriptGenerator . variables _set ; var module$exports$Blockly$JavaScript$texts = { } , module$contents$Blockly$JavaScript$texts _NameType = $ . NameType$$module$build$src$core$names , module$contents$Blockly$JavaScript$texts _strRegExp = /^\s*'([^']|\\')*'\s*$/ , module$contents$Blockly$JavaScript$texts _forceString = function ( a ) { return module$contents$Blockly$JavaScript$texts _strRegExp . test ( a ) ? [ a , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] : [ "String(" + a + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ,
module$contents$Blockly$JavaScript$texts _getSubstringIndex = function ( a , b , c ) { return "FIRST" === b ? "0" : "FROM_END" === b ? a + ".length - 1 - " + c : "LAST" === b ? a + ".length - 1" : c } ; module$exports$Blockly$JavaScript . javascriptGenerator . text = function ( a ) { return [ module$exports$Blockly$JavaScript . javascriptGenerator . quote _ ( a . getFieldValue ( "TEXT" ) ) , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _multiline = function ( a ) { a = module$exports$Blockly$JavaScript . javascriptGenerator . multiline _quote _ ( a . getFieldValue ( "TEXT" ) ) ; const b = - 1 !== a . indexOf ( "+" ) ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ; return [ a , b ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _join = function ( a ) { switch ( a . itemCount _ ) { case 0 : return [ "''" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] ; case 1 : return a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ADD0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" , module$contents$Blockly$JavaScript$texts _forceString ( a ) ; case 2 : var b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ADD0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
"''" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ADD1" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; return [ module$contents$Blockly$JavaScript$texts _forceString ( b ) [ 0 ] + " + " + module$contents$Blockly$JavaScript$texts _forceString ( a ) [ 0 ] , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ] ; default : b = Array ( a . itemCount _ ) ; for ( let c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ADD" + c , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
"''" ; return [ "[" + b . join ( "," ) + "].join('')" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _append = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; return b + " += " + module$contents$Blockly$JavaScript$texts _forceString ( a ) [ 0 ] + ";\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _length = function ( a ) { return [ ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "''" ) + ".length" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _isEmpty = function ( a ) { return [ "!" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "''" ) + ".length" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _indexOf = function ( a ) { var b = "FIRST" === a . getFieldValue ( "END" ) ? "indexOf" : "lastIndexOf" ; const c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "FIND" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; b = ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "''" ) + "." + b + "(" + c + ")" ; return a . workspace . options . oneBasedIndex ?
[ b + " + 1" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ] : [ b , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _charAt = function ( a ) { const b = a . getFieldValue ( "WHERE" ) || "FROM_START" , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , "RANDOM" === b ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "''" ; switch ( b ) { case "FIRST" : return [ c + ".charAt(0)" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; case "LAST" : return [ c + ".slice(-1)" ,
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; case "FROM_START" : return a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT" ) , [ c + ".charAt(" + a + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; case "FROM_END" : return a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT" , 1 , ! 0 ) , [ c + ".slice(" + a + ").charAt(0)" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; case "RANDOM" : return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "textRandomLetter" ,
`
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( text ) {
var x = Math . floor ( Math . random ( ) * text . length ) ;
return text [ x ] ;
}
` )+"("+c+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).");};
module$exports$Blockly$JavaScript . javascriptGenerator . text _getSubstring = function ( a ) { var b = a . getFieldValue ( "WHERE1" ) , c = a . getFieldValue ( "WHERE2" ) , d = "FROM_END" !== b && "LAST" !== b && "FROM_END" !== c && "LAST" !== c , e = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "STRING" , d ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; if ( "FIRST" === b && "LAST" === c ) return [ e , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ] ;
if ( e . match ( /^'?\w+'?$/ ) || d ) { switch ( b ) { case "FROM_START" : b = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" ) ; break ; case "FROM_END" : b = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" , 1 , ! 1 , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ) ; b = e + ".length - " + b ; break ; case "FIRST" : b = "0" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)." ) ; } switch ( c ) { case "FROM_START" : c = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a ,
"AT2" , 1 ) ; break ; case "FROM_END" : c = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT2" , 0 , ! 1 , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ) ; c = e + ".length - " + c ; break ; case "LAST" : c = e + ".length" ; break ; default : throw Error ( "Unhandled option (text_getSubstring)." ) ; } e = e + ".slice(" + b + ", " + c + ")" } else { d = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" ) ; a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT2" ) ; const f = { FIRST : "First" ,
LAST : "Last" , FROM _START : "FromStart" , FROM _END : "FromEnd" } ; e = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "subsequence" + f [ b ] + f [ c ] , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( sequence$ { "FROM_END" === b || "FROM_START" === b ? ", at1" : "" } $ { "FROM_END" === c || "FROM_START" === c ? ", at2" : "" } ) {
var start = $ { module$contents$Blockly$JavaScript$texts _getSubstringIndex ( "sequence" , b , "at1" ) } ;
var end = $ { module$contents$Blockly$JavaScript$texts _getSubstringIndex ( "sequence" , c , "at2" ) } + 1 ;
return sequence . slice ( start , end ) ;
}
` )+"("+e+("FROM_END"===b||"FROM_START"===b?", "+d:"")+("FROM_END"===c||"FROM_START"===c?", "+a:"")+")"}return[e,module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . text _changeCase = function ( a ) { const b = { UPPERCASE : ".toUpperCase()" , LOWERCASE : ".toLowerCase()" , TITLECASE : null } [ a . getFieldValue ( "CASE" ) ] ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , b ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; return [ b ? a + b : module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "textToTitleCase" ,
`
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( str ) {
return str . replace ( /\\S+/g ,
function ( txt ) { return txt [ 0 ] . toUpperCase ( ) + txt . substring ( 1 ) . toLowerCase ( ) ; } ) ;
}
` )+"("+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module $ exports $ Blockly $ JavaScript.javascriptGenerator.text_trim=function(a){const b={LEFT:".replace(/^[ \\ s \\ xa0]+/, '')",RIGHT:".replace(/[ \\ s \\ xa0]+ $ /, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+b,module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . text _print = function ( a ) { return "window.alert(" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ) + ");\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _prompt _ext = function ( a ) { let b = "window.prompt(" + ( a . getField ( "TEXT" ) ? module$exports$Blockly$JavaScript . javascriptGenerator . quote _ ( a . getFieldValue ( "TEXT" ) ) : module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ) + ")" ; "NUMBER" === a . getFieldValue ( "TYPE" ) && ( b = "Number(" + b + ")" ) ; return [ b , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _prompt = module$exports$Blockly$JavaScript . javascriptGenerator . text _prompt _ext ;
module$exports$Blockly$JavaScript . javascriptGenerator . text _count = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "SUB" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "textCount" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( haystack , needle ) {
if ( needle . length === 0 ) {
return haystack . length + 1 ;
} else {
return haystack . split ( needle ) . length - 1 ;
}
}
` )+"("+b+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . text _replace = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TEXT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TO" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
"''" ; return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "textReplace" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( haystack , needle , replacement ) {
needle = needle . replace ( /([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g , '\\\\$1' )
. replace ( /\\x08/g , '\\\\x08' ) ;
return haystack . replace ( new RegExp ( needle , 'g' ) , replacement ) ;
}
` )+"("+b+", "+c+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module $ exports $ Blockly $ JavaScript.javascriptGenerator.text_reverse=function(a){return[(module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"TEXT",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_MEMBER)||"''")+".split('').reverse().join('')",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module $ exports $ Blockly $ JavaScript $ procedures={},module $ contents $ Blockly $ JavaScript $ procedures_NameType= $ .NameType $ $ module $ build $ src $ core $ names;
module$exports$Blockly$JavaScript . javascriptGenerator . procedures _defreturn = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "NAME" ) , $ . NameType$$module$build$src$core$names . PROCEDURE ) ; var c = "" ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX && ( c += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX , a ) ) ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX &&
( c += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX , a ) ) ; c && ( c = module$exports$Blockly$JavaScript . javascriptGenerator . prefixLines ( c , module$exports$Blockly$JavaScript . javascriptGenerator . INDENT ) ) ; let d = "" ; module$exports$Blockly$JavaScript . javascriptGenerator . INFINITE _LOOP _TRAP && ( d = module$exports$Blockly$JavaScript . javascriptGenerator . prefixLines ( module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . INFINITE _LOOP _TRAP ,
a ) , module$exports$Blockly$JavaScript . javascriptGenerator . INDENT ) ) ; const e = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "STACK" ) ; let f = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "RETURN" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "" , g = "" ; e && f && ( g = c ) ; f && ( f = module$exports$Blockly$JavaScript . javascriptGenerator . INDENT + "return " + f + ";\n" ) ; const h = [ ] , k = a . getVars ( ) ; for ( let l = 0 ; l < k . length ; l ++ ) h [ l ] = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( k [ l ] ,
$ . NameType$$module$build$src$core$names . VARIABLE ) ; c = "async function " + b + "(" + h . join ( ", " ) + ") {\n" + c + d + e + g + f + "}" ; c = module$exports$Blockly$JavaScript . javascriptGenerator . scrub _ ( a , c ) ; module$exports$Blockly$JavaScript . javascriptGenerator . definitions _ [ "%" + b ] = c ; return null } ; module$exports$Blockly$JavaScript . javascriptGenerator . procedures _defnoreturn = module$exports$Blockly$JavaScript . javascriptGenerator . procedures _defreturn ;
module$exports$Blockly$JavaScript . javascriptGenerator . procedures _callreturn = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . 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$JavaScript . javascriptGenerator . valueToCode ( a , "ARG" + e , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "null" ; return [ 'await ' + b + "(" + c . join ( ", " ) + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . procedures _callnoreturn = function ( a ) { return module$exports$Blockly$JavaScript . javascriptGenerator . procedures _callreturn ( a ) [ 0 ] + ";\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . procedures _ifreturn = function ( a ) { let b = "if (" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "CONDITION" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "false" ) + ") {\n" ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX && ( b += module$exports$Blockly$JavaScript . javascriptGenerator . prefixLines ( module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX ,
a ) , module$exports$Blockly$JavaScript . javascriptGenerator . INDENT ) ) ; a . hasReturnValue _ ? ( a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "null" , b += module$exports$Blockly$JavaScript . javascriptGenerator . INDENT + "return " + a + ";\n" ) : b += module$exports$Blockly$JavaScript . javascriptGenerator . INDENT + "return;\n" ; return b + "}\n" } ; var module$exports$Blockly$JavaScript$math = { } , module$contents$Blockly$JavaScript$math _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$JavaScript . javascriptGenerator . math _number = function ( a ) { a = Number ( a . getFieldValue ( "NUM" ) ) ; return [ a , 0 <= a ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _UNARY _NEGATION ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _arithmetic = function ( a ) { var b = { ADD : [ " + " , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ] , MINUS : [ " - " , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ] , MULTIPLY : [ " * " , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MULTIPLICATION ] , DIVIDE : [ " / " , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION ] , POWER : [ null , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ] } [ a . getFieldValue ( "OP" ) ] ;
const c = b [ 0 ] ; b = b [ 1 ] ; const d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "A" , b ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "B" , b ) || "0" ; return c ? [ d + c + a , b ] : [ "Math.pow(" + d + ", " + a + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _single = function ( a ) { const b = a . getFieldValue ( "OP" ) ; let c ; if ( "NEG" === b ) return a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "NUM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _UNARY _NEGATION ) || "0" , "-" === a [ 0 ] && ( a = " " + a ) , [ "-" + a , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _UNARY _NEGATION ] ; a = "SIN" === b || "COS" === b || "TAN" === b ? module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "NUM" ,
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION ) || "0" : module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "NUM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ; switch ( b ) { case "ABS" : c = "Math.abs(" + a + ")" ; break ; case "ROOT" : c = "Math.sqrt(" + a + ")" ; break ; case "LN" : c = "Math.log(" + a + ")" ; break ; case "EXP" : c = "Math.exp(" + a + ")" ; break ; case "POW10" : c = "Math.pow(10," + a + ")" ; break ; case "ROUND" : c = "Math.round(" + a + ")" ; break ; case "ROUNDUP" : c = "Math.ceil(" + a + ")" ; break ;
case "ROUNDDOWN" : c = "Math.floor(" + a + ")" ; break ; case "SIN" : c = "Math.sin(" + a + " / 180 * Math.PI)" ; break ; case "COS" : c = "Math.cos(" + a + " / 180 * Math.PI)" ; break ; case "TAN" : c = "Math.tan(" + a + " / 180 * Math.PI)" } if ( c ) return [ c , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; switch ( b ) { case "LOG10" : c = "Math.log(" + a + ") / Math.log(10)" ; break ; case "ASIN" : c = "Math.asin(" + a + ") / Math.PI * 180" ; break ; case "ACOS" : c = "Math.acos(" + a + ") / Math.PI * 180" ; break ; case "ATAN" : c = "Math.atan(" + a + ") / Math.PI * 180" ;
break ; default : throw Error ( "Unknown math operator: " + b ) ; } return [ c , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _constant = function ( a ) { return { PI : [ "Math.PI" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] , E : [ "Math.E" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] , GOLDEN _RATIO : [ "(1 + Math.sqrt(5)) / 2" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION ] , SQRT2 : [ "Math.SQRT2" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] , SQRT1 _2 : [ "Math.SQRT1_2" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ,
INFINITY : [ "Infinity" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } [ a . getFieldValue ( "CONSTANT" ) ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _number _property = function ( a ) { var b = { EVEN : [ " % 2 === 0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY ] , ODD : [ " % 2 === 1" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY ] , WHOLE : [ " % 1 === 0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY ] ,
POSITIVE : [ " > 0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL ] , NEGATIVE : [ " < 0" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL ] , DIVISIBLE _BY : [ null , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY ] , PRIME : [ null , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ,
module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ; const c = a . getFieldValue ( "PROPERTY" ) , [ d , e , f ] = b [ c ] ; b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "NUMBER_TO_CHECK" , e ) || "0" ; "PRIME" === c ? a = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "mathIsPrime" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( n ) {
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
if ( n == 2 || n == 3 ) {
return true ;
}
// False if n is NaN, negative, is 1, or not whole.
// And false if n is divisible by 2 or 3.
if ( isNaN ( n ) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0 ) {
return false ;
}
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
for ( var x = 6 ; x <= Math . sqrt ( n ) + 1 ; x += 6 ) {
if ( n % ( x - 1 ) === 0 || n % ( x + 1 ) === 0 ) {
return false ;
}
}
return true ;
}
` )+"("+b+")":"DIVISIBLE_BY"===c?(a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"DIVISOR",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_MODULUS)||"0",a=b+" % "+a+" === 0"):a=b+d;return[a,f]};
module$exports$Blockly$JavaScript . javascriptGenerator . math _change = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "DELTA" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; return a + " = (typeof " + a + " === 'number' ? " + a + " : 0) + " + b + ";\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _round = module$exports$Blockly$JavaScript . javascriptGenerator . math _single ; module$exports$Blockly$JavaScript . javascriptGenerator . math _trig = module$exports$Blockly$JavaScript . javascriptGenerator . math _single ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _on _list = function ( a ) { var b = a . getFieldValue ( "OP" ) ; switch ( b ) { case "SUM" : a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ; a += ".reduce(function(x, y) {return x + y;}, 0)" ; break ; case "MIN" : a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "[]" ; a = "Math.min.apply(null, " +
a + ")" ; break ; case "MAX" : a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "[]" ; a = "Math.max.apply(null, " + a + ")" ; break ; case "AVERAGE" : b = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "mathMean" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( myList ) {
return myList . reduce ( function ( x , y ) { return x + y ; } , 0 ) / myList . length ;
}
` );a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"LIST",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MEDIAN":b=module $ exports $ Blockly $ JavaScript.javascriptGenerator.provideFunction_("mathMedian", `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( myList ) {
var localList = myList . filter ( function ( x ) { return typeof x === 'number' ; } ) ;
if ( ! localList . length ) return null ;
localList . sort ( function ( a , b ) { return b - a ; } ) ;
if ( localList . length % 2 === 0 ) {
return ( localList [ localList . length / 2 - 1 ] + localList [ localList . length / 2 ] ) / 2 ;
} else {
return localList [ ( localList . length - 1 ) / 2 ] ;
}
}
` );a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"LIST",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "MODE":b=module $ exports $ Blockly $ JavaScript.javascriptGenerator.provideFunction_("mathModes", `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( values ) {
var modes = [ ] ;
var counts = [ ] ;
var maxCount = 0 ;
for ( var i = 0 ; i < values . length ; i ++ ) {
var value = values [ i ] ;
var found = false ;
var thisCount ;
for ( var j = 0 ; j < counts . length ; j ++ ) {
if ( counts [ j ] [ 0 ] === value ) {
thisCount = ++ counts [ j ] [ 1 ] ;
found = true ;
break ;
}
}
if ( ! found ) {
counts . push ( [ value , 1 ] ) ;
thisCount = 1 ;
}
maxCount = Math . max ( thisCount , maxCount ) ;
}
for ( var j = 0 ; j < counts . length ; j ++ ) {
if ( counts [ j ] [ 1 ] === maxCount ) {
modes . push ( counts [ j ] [ 0 ] ) ;
}
}
return modes ;
}
` );a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"LIST",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "STD_DEV":b=module $ exports $ Blockly $ JavaScript.javascriptGenerator.provideFunction_("mathStandardDeviation", `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( numbers ) {
var n = numbers . length ;
if ( ! n ) return null ;
var mean = numbers . reduce ( function ( x , y ) { return x + y ; } ) / n ;
var variance = 0 ;
for ( var j = 0 ; j < n ; j ++ ) {
variance += Math . pow ( numbers [ j ] - mean , 2 ) ;
}
variance = variance / n ;
return Math . sqrt ( variance ) ;
}
` );a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"LIST",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;case "RANDOM":b=module $ exports $ Blockly $ JavaScript.javascriptGenerator.provideFunction_("mathRandomList", `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( list ) {
var x = Math . floor ( Math . random ( ) * list . length ) ;
return list [ x ] ;
}
` );a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"LIST",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw Error("Unknown operator: "+b);}return[a,module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . math _modulo = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "DIVIDEND" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "DIVISOR" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS ) || "0" ; return [ b + " % " + a , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MODULUS ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _constrain = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LOW" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "HIGH" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
"Infinity" ; return [ "Math.min(Math.max(" + b + ", " + c + "), " + a + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . math _random _int = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TO" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ; return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "mathRandomInt" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( a , b ) {
if ( a > b ) {
// Swap a and b to ensure a is smaller.
var c = a ;
a = b ;
b = c ;
}
return Math . floor ( Math . random ( ) * ( b - a + 1 ) + a ) ;
}
` )+"("+b+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};module $ exports $ Blockly $ JavaScript.javascriptGenerator.math_random_float=function(a){return["Math.random()",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . math _atan2 = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "X" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ; return [ "Math.atan2(" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "Y" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "0" ) + ", " + b + ") / Math.PI * 180" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _DIVISION ] } ; var module$exports$Blockly$JavaScript$loops = { } , module$contents$Blockly$JavaScript$loops _stringUtils = $ . module$build$src$core$utils$string , module$contents$Blockly$JavaScript$loops _NameType = $ . NameType$$module$build$src$core$names ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _repeat _ext = function ( a ) { let b ; b = a . getField ( "TIMES" ) ? String ( Number ( a . getFieldValue ( "TIMES" ) ) ) : module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TIMES" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "0" ; let c = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "DO" ) ; c = module$exports$Blockly$JavaScript . javascriptGenerator . addLoopTrap ( c , a ) ; a = "" ; const d = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( "count" ,
$ . NameType$$module$build$src$core$names . VARIABLE ) ; let e = b ; b . match ( /^\w+$/ ) || $ . module$build$src$core$utils$string . isNumber ( b ) || ( e = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( "repeat_end" , $ . NameType$$module$build$src$core$names . VARIABLE ) , a += "var " + e + " = " + b + ";\n" ) ; return a + ( "for (var " + d + " = 0; " + d + " < " + e + "; " + d + "++) {\n" + c + "}\n" ) } ; module$exports$Blockly$JavaScript . javascriptGenerator . controls _repeat = module$exports$Blockly$JavaScript . javascriptGenerator . controls _repeat _ext ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _whileUntil = function ( a ) { const b = "UNTIL" === a . getFieldValue ( "MODE" ) ; let c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "BOOL" , b ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "false" , d = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "DO" ) ; d = module$exports$Blockly$JavaScript . javascriptGenerator . addLoopTrap ( d ,
a ) ; b && ( c = "!" + c ) ; return "while (" + c + ") {\n" + d + "}\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _for = function ( a ) { var b = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "FROM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "0" , d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TO" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) ||
"0" ; const e = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "BY" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "1" ; let f = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "DO" ) ; f = module$exports$Blockly$JavaScript . javascriptGenerator . addLoopTrap ( f , a ) ; 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 ) ) { var g = Number ( c ) <= Number ( d ) ; a =
"for (" + b + " = " + c + "; " + b + ( g ? " <= " : " >= " ) + d + "; " + b ; b = Math . abs ( Number ( e ) ) ; a = 1 === b ? a + ( g ? "++" : "--" ) : a + ( ( g ? " += " : " -= " ) + b ) ; a += ") {\n" + f + "}\n" } else a = "" , g = c , c . match ( /^\w+$/ ) || $ . module$build$src$core$utils$string . isNumber ( c ) || ( g = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( b + "_start" , $ . NameType$$module$build$src$core$names . VARIABLE ) , a += "var " + g + " = " + c + ";\n" ) , c = d , d . match ( /^\w+$/ ) || $ . module$build$src$core$utils$string . isNumber ( d ) || ( c = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( b +
"_end" , $ . NameType$$module$build$src$core$names . VARIABLE ) , a += "var " + c + " = " + d + ";\n" ) , d = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( b + "_inc" , $ . NameType$$module$build$src$core$names . VARIABLE ) , a += "var " + d + " = " , a = $ . module$build$src$core$utils$string . isNumber ( e ) ? a + ( Math . abs ( e ) + ";\n" ) : a + ( "Math.abs(" + e + ");\n" ) , a += "if (" + g + " > " + c + ") {\n" , a += module$exports$Blockly$JavaScript . javascriptGenerator . INDENT + d + " = -" + d + ";\n" , a = a + "}\nfor (" + ( b + " = " + g + "; " + d + " >= 0 ? " + b + " <= " +
c + " : " + b + " >= " + c + "; " + b + " += " + d + ") {\n" + f + "}\n" ) ; return a } ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _forEach = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getName ( a . getFieldValue ( "VAR" ) , $ . NameType$$module$build$src$core$names . VARIABLE ) ; var c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "[]" ; let d = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "DO" ) ; d = module$exports$Blockly$JavaScript . javascriptGenerator . addLoopTrap ( d ,
a ) ; a = "" ; let e = c ; c . match ( /^\w+$/ ) || ( e = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( b + "_list" , $ . NameType$$module$build$src$core$names . VARIABLE ) , a += "var " + e + " = " + c + ";\n" ) ; c = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( b + "_index" , $ . NameType$$module$build$src$core$names . VARIABLE ) ; d = module$exports$Blockly$JavaScript . javascriptGenerator . INDENT + b + " = " + e + "[" + c + "];\n" + d ; return a + ( "for (var " + c + " in " + e + ") {\n" + d + "}\n" ) } ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _flow _statements = function ( a ) { let b = "" ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX && ( b += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX , a ) ) ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX && ( b += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX ,
a ) ) ; if ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX ) { const c = a . getSurroundLoop ( ) ; c && ! c . suppressPrefixSuffix && ( b += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . 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$JavaScript$logic = { } ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _if = function ( a ) { var b = 0 ; let c = "" ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX && ( c += module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _PREFIX , a ) ) ; do { const d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "IF" + b , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "false" ; let e = module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a ,
"DO" + b ) ; module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX && ( e = module$exports$Blockly$JavaScript . javascriptGenerator . prefixLines ( module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX , a ) , module$exports$Blockly$JavaScript . javascriptGenerator . INDENT ) + e ) ; c += ( 0 < b ? " else " : "" ) + "if (" + d + ") {\n" + e + "}" ; b ++ } while ( a . getInput ( "IF" + b ) ) ; if ( a . getInput ( "ELSE" ) || module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX ) b =
module$exports$Blockly$JavaScript . javascriptGenerator . statementToCode ( a , "ELSE" ) , module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX && ( b = module$exports$Blockly$JavaScript . javascriptGenerator . prefixLines ( module$exports$Blockly$JavaScript . javascriptGenerator . injectId ( module$exports$Blockly$JavaScript . javascriptGenerator . STATEMENT _SUFFIX , a ) , module$exports$Blockly$JavaScript . javascriptGenerator . INDENT ) + b ) , c += " else {\n" + b + "}" ; return c + "\n" } ;
module$exports$Blockly$JavaScript . javascriptGenerator . controls _ifelse = module$exports$Blockly$JavaScript . javascriptGenerator . controls _if ;
module$exports$Blockly$JavaScript . javascriptGenerator . logic _compare = function ( a ) { const b = { EQ : "==" , NEQ : "!=" , LT : "<" , LTE : "<=" , GT : ">" , GTE : ">=" } [ a . getFieldValue ( "OP" ) ] , c = "==" === b || "!=" === b ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _EQUALITY : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _RELATIONAL , d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "A" , c ) || "0" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "B" , c ) || "0" ; return [ d + " " + b +
" " + a , c ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . logic _operation = function ( a ) { const b = "AND" === a . getFieldValue ( "OP" ) ? "&&" : "||" , c = "&&" === b ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _AND : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _OR ; let d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "A" , c ) ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "B" , c ) ; if ( d || a ) { const e = "&&" === b ? "true" : "false" ; d || ( d = e ) ; a || ( a = e ) } else a =
d = "false" ; return [ d + " " + b + " " + a , c ] } ; module$exports$Blockly$JavaScript . javascriptGenerator . logic _negate = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT ; return [ "!" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "BOOL" , b ) || "true" ) , b ] } ; module$exports$Blockly$JavaScript . javascriptGenerator . logic _boolean = function ( a ) { return [ "TRUE" === a . getFieldValue ( "BOOL" ) ? "true" : "false" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . logic _null = function ( a ) { return [ "null" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . logic _ternary = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "IF" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _CONDITIONAL ) || "false" , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "THEN" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _CONDITIONAL ) || "null" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ELSE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _CONDITIONAL ) ||
"null" ; return [ b + " ? " + c + " : " + a , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _CONDITIONAL ] } ; var module$exports$Blockly$JavaScript$lists = { } , module$contents$Blockly$JavaScript$lists _NameType = $ . NameType$$module$build$src$core$names ; module$exports$Blockly$JavaScript . javascriptGenerator . lists _create _empty = function ( a ) { return [ "[]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _create _with = function ( a ) { const b = Array ( a . itemCount _ ) ; for ( let c = 0 ; c < a . itemCount _ ; c ++ ) b [ c ] = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "ADD" + c , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "null" ; return [ "[" + b . join ( ", " ) + "]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _repeat = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "listsRepeat" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( value , n ) {
var array = [ ] ;
for ( var i = 0 ; i < n ; i ++ ) {
array [ i ] = value ;
}
return array ;
}
` ),c=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"ITEM",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"null";a=module $ exports $ Blockly $ JavaScript.javascriptGenerator.valueToCode(a,"NUM",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . lists _length = function ( a ) { return [ ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ) + ".length" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _isEmpty = function ( a ) { return [ "!" + ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ) + ".length" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _LOGICAL _NOT ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _indexOf = function ( a ) { var b = "FIRST" === a . getFieldValue ( "END" ) ? "indexOf" : "lastIndexOf" ; const c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "FIND" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; b = ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ) + "." + b + "(" + c + ")" ; return a . workspace . options . oneBasedIndex ?
[ b + " + 1" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ADDITION ] : [ b , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _getIndex = function ( a ) { const b = a . getFieldValue ( "MODE" ) || "GET" , c = a . getFieldValue ( "WHERE" ) || "FROM_START" ; var d = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "VALUE" , "RANDOM" === c ? module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE : module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ; switch ( c ) { case "FIRST" : if ( "GET" === b ) return [ d + "[0]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ;
if ( "GET_REMOVE" === b ) return [ d + ".shift()" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ; if ( "REMOVE" === b ) return d + ".shift();\n" ; break ; case "LAST" : if ( "GET" === b ) return [ d + ".slice(-1)[0]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".pop()" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ; if ( "REMOVE" === b ) return d + ".pop();\n" ; break ; case "FROM_START" : a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a ,
"AT" ) ; if ( "GET" === b ) return [ d + "[" + a + "]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ] ; if ( "GET_REMOVE" === b ) return [ d + ".splice(" + a + ", 1)[0]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".splice(" + a + ", 1);\n" ; break ; case "FROM_END" : a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT" , 1 , ! 0 ) ; if ( "GET" === b ) return [ d + ".slice(" + a + ")[0]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; if ( "GET_REMOVE" ===
b ) return [ d + ".splice(" + a + ", 1)[0]" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] ; if ( "REMOVE" === b ) return d + ".splice(" + a + ", 1);" ; break ; case "RANDOM" : d = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "listsGetRandomItem" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( list , remove ) {
var x = Math . floor ( Math . random ( ) * list . length ) ;
if ( remove ) {
return list . splice ( x , 1 ) [ 0 ] ;
} else {
return list [ x ] ;
}
}
` )+"("+d+", "+("GET"!==b)+")";if("GET"===b||"GET_REMOVE"===b)return[d,module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL];if("REMOVE"===b)return d+"; \n "}throw Error("Unhandled combination (lists_getIndex).");};
module$exports$Blockly$JavaScript . javascriptGenerator . lists _setIndex = function ( a ) { function b ( ) { if ( c . match ( /^\w+$/ ) ) return "" ; const g = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( "tmpList" , $ . NameType$$module$build$src$core$names . VARIABLE ) , h = "var " + g + " = " + c + ";\n" ; c = g ; return h } let c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" ; const d = a . getFieldValue ( "MODE" ) || "GET" ;
var e = a . getFieldValue ( "WHERE" ) || "FROM_START" ; const f = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "TO" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ASSIGNMENT ) || "null" ; switch ( e ) { case "FIRST" : if ( "SET" === d ) return c + "[0] = " + f + ";\n" ; if ( "INSERT" === d ) return c + ".unshift(" + f + ");\n" ; break ; case "LAST" : if ( "SET" === d ) return b ( ) + ( c + "[" + c + ".length - 1] = " + f + ";\n" ) ; if ( "INSERT" === d ) return c + ".push(" + f + ");\n" ; break ; case "FROM_START" : a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a ,
"AT" ) ; if ( "SET" === d ) return c + "[" + a + "] = " + f + ";\n" ; if ( "INSERT" === d ) return c + ".splice(" + a + ", 0, " + f + ");\n" ; break ; case "FROM_END" : a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT" , 1 , ! 1 , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ) ; e = b ( ) ; if ( "SET" === d ) return e + ( c + "[" + c + ".length - " + a + "] = " + f + ";\n" ) ; if ( "INSERT" === d ) return e + ( c + ".splice(" + c + ".length - " + a + ", 0, " + f + ");\n" ) ; break ; case "RANDOM" : a = b ( ) ; e = module$exports$Blockly$JavaScript . javascriptGenerator . nameDB _ . getDistinctName ( "tmpX" ,
$ . NameType$$module$build$src$core$names . VARIABLE ) ; a += "var " + e + " = Math.floor(Math.random() * " + c + ".length);\n" ; if ( "SET" === d ) return a + ( c + "[" + e + "] = " + f + ";\n" ) ; if ( "INSERT" === d ) return a + ( c + ".splice(" + e + ", 0, " + f + ");\n" ) } throw Error ( "Unhandled combination (lists_setIndex)." ) ; } ; var module$contents$Blockly$JavaScript$lists _getSubstringIndex = function ( a , b , c ) { return "FIRST" === b ? "0" : "FROM_END" === b ? a + ".length - 1 - " + c : "LAST" === b ? a + ".length - 1" : c } ;
module$exports$Blockly$JavaScript . javascriptGenerator . lists _getSublist = function ( a ) { var b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) || "[]" , c = a . getFieldValue ( "WHERE1" ) , d = a . getFieldValue ( "WHERE2" ) ; if ( "FIRST" === c && "LAST" === d ) b += ".slice(0)" ; else if ( b . match ( /^\w+$/ ) || "FROM_END" !== c && "FROM_START" === d ) { switch ( c ) { case "FROM_START" : c = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" ) ;
break ; case "FROM_END" : c = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" , 1 , ! 1 , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ) ; c = b + ".length - " + c ; break ; case "FIRST" : c = "0" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)." ) ; } switch ( d ) { case "FROM_START" : d = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT2" , 1 ) ; break ; case "FROM_END" : d = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT2" , 0 , ! 1 , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _SUBTRACTION ) ;
d = b + ".length - " + d ; break ; case "LAST" : d = b + ".length" ; break ; default : throw Error ( "Unhandled option (lists_getSublist)." ) ; } b = b + ".slice(" + c + ", " + d + ")" } else { const e = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT1" ) ; a = module$exports$Blockly$JavaScript . javascriptGenerator . getAdjusted ( a , "AT2" ) ; const f = { FIRST : "First" , LAST : "Last" , FROM _START : "FromStart" , FROM _END : "FromEnd" } ; b = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "subsequence" + f [ c ] + f [ d ] , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( sequence$ { "FROM_END" === c || "FROM_START" === c ? ", at1" : "" } $ { "FROM_END" === d || "FROM_START" === d ? ", at2" : "" } ) {
var start = $ { module$contents$Blockly$JavaScript$lists _getSubstringIndex ( "sequence" , c , "at1" ) } ;
var end = $ { module$contents$Blockly$JavaScript$lists _getSubstringIndex ( "sequence" , d , "at2" ) } + 1 ;
return sequence . slice ( start , end ) ;
}
` )+"("+b+("FROM_END"===c||"FROM_START"===c?", "+e:"")+("FROM_END"===d||"FROM_START"===d?", "+a:"")+")"}return[b,module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . lists _sort = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ) || "[]" , c = "1" === a . getFieldValue ( "DIRECTION" ) ? 1 : - 1 ; a = a . getFieldValue ( "TYPE" ) ; const d = module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "listsGetSortCompare" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( type , direction ) {
var compareFuncs = {
'NUMERIC' : function ( a , b ) {
return Number ( a ) - Number ( b ) ; } ,
'TEXT' : function ( a , b ) {
return a . toString ( ) > b . toString ( ) ? 1 : - 1 ; } ,
'IGNORE_CASE' : function ( a , b ) {
return a . toString ( ) . toLowerCase ( ) > b . toString ( ) . toLowerCase ( ) ? 1 : - 1 ; } ,
} ;
var compare = compareFuncs [ type ] ;
return function ( a , b ) { return compare ( a , b ) * direction ; } ;
}
` );return[b+".slice().sort("+d+'("'+a+'", '+c+"))",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . lists _split = function ( a ) { let b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "INPUT" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _MEMBER ) ; const c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "DELIM" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "''" ; a = a . getFieldValue ( "MODE" ) ; if ( "SPLIT" === a ) b || ( b = "''" ) , a = "split" ; else if ( "JOIN" === a ) b || ( b = "[]" ) , a = "join" ; else throw Error ( "Unknown mode: " +
a ) ; return [ b + "." + a + "(" + c + ")" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ; module$exports$Blockly$JavaScript . javascriptGenerator . lists _reverse = function ( a ) { return [ ( module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "LIST" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ) || "[]" ) + ".slice().reverse()" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _FUNCTION _CALL ] } ; var module$exports$Blockly$JavaScript$colour = { } ; module$exports$Blockly$JavaScript . javascriptGenerator . colour _picker = function ( a ) { return [ module$exports$Blockly$JavaScript . javascriptGenerator . quote _ ( a . getFieldValue ( "COLOUR" ) ) , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _ATOMIC ] } ; module$exports$Blockly$JavaScript . javascriptGenerator . colour _random = function ( a ) { return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "colourRandom" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( ) {
var num = Math . floor ( Math . random ( ) * Math . pow ( 2 , 24 ) ) ;
return '#' + ( '00000' + num . toString ( 16 ) ) . substr ( - 6 ) ;
}
` )+"()",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . colour _rgb = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "RED" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || 0 , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "GREEN" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || 0 ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "BLUE" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
0 ; return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "colourRgb" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( r , g , b ) {
r = Math . max ( Math . min ( Number ( r ) , 100 ) , 0 ) * 2.55 ;
g = Math . max ( Math . min ( Number ( g ) , 100 ) , 0 ) * 2.55 ;
b = Math . max ( Math . min ( Number ( b ) , 100 ) , 0 ) * 2.55 ;
r = ( '0' + ( Math . round ( r ) || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
g = ( '0' + ( Math . round ( g ) || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
b = ( '0' + ( Math . round ( b ) || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
return '#' + r + g + b ;
}
` )+"("+b+", "+c+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};
module$exports$Blockly$JavaScript . javascriptGenerator . colour _blend = function ( a ) { const b = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "COLOUR1" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "'#000000'" , c = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "COLOUR2" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) || "'#000000'" ; a = module$exports$Blockly$JavaScript . javascriptGenerator . valueToCode ( a , "RATIO" , module$exports$Blockly$JavaScript . javascriptGenerator . ORDER _NONE ) ||
. 5 ; return [ module$exports$Blockly$JavaScript . javascriptGenerator . provideFunction _ ( "colourBlend" , `
function $ { module$exports$Blockly$JavaScript . javascriptGenerator . FUNCTION _NAME _PLACEHOLDER _ } ( c1 , c2 , ratio ) {
ratio = Math . max ( Math . min ( Number ( ratio ) , 1 ) , 0 ) ;
var r1 = parseInt ( c1 . substring ( 1 , 3 ) , 16 ) ;
var g1 = parseInt ( c1 . substring ( 3 , 5 ) , 16 ) ;
var b1 = parseInt ( c1 . substring ( 5 , 7 ) , 16 ) ;
var r2 = parseInt ( c2 . substring ( 1 , 3 ) , 16 ) ;
var g2 = parseInt ( c2 . substring ( 3 , 5 ) , 16 ) ;
var b2 = parseInt ( c2 . substring ( 5 , 7 ) , 16 ) ;
var r = Math . round ( r1 * ( 1 - ratio ) + r2 * ratio ) ;
var g = Math . round ( g1 * ( 1 - ratio ) + g2 * ratio ) ;
var b = Math . round ( b1 * ( 1 - ratio ) + b2 * ratio ) ;
r = ( '0' + ( r || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
g = ( '0' + ( g || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
b = ( '0' + ( b || 0 ) . toString ( 16 ) ) . slice ( - 2 ) ;
return '#' + r + g + b ;
}
` )+"("+b+", "+c+", "+a+")",module $ exports $ Blockly $ JavaScript.javascriptGenerator.ORDER_FUNCTION_CALL]};var module $ exports $ Blockly $ JavaScript $ all=module $ exports $ Blockly $ JavaScript;
module$exports$Blockly$JavaScript . _ _namespace _ _ = $ ;
return module$exports$Blockly$JavaScript ;
2021-01-16 14:07:51 +00:00
} ) ) ;
//# sourceMappingURL=javascript_compressed.js.map