2021-01-16 14:07:51 +00:00
// Do not edit this file; automatically generated by gulp.
/* eslint-disable */
; ( function ( root , factory ) {
if ( typeof define === 'function' && define . amd ) { // AMD
define ( [ ] , factory ) ;
} else if ( typeof exports === 'object' ) { // Node.js
module . exports = factory ( ) ;
} else { // Browser
root . Blockly = factory ( ) ;
}
} ( this , function ( ) {
2021-05-19 13:38:55 +00:00
'use strict' ; var Blockly = { connectionTypes : { INPUT _VALUE : 1 , OUTPUT _VALUE : 2 , NEXT _STATEMENT : 3 , PREVIOUS _STATEMENT : 4 } } ; Blockly . constants = { } ; Blockly . LINE _MODE _MULTIPLIER = 40 ; Blockly . PAGE _MODE _MULTIPLIER = 125 ; Blockly . DRAG _RADIUS = 5 ; Blockly . FLYOUT _DRAG _RADIUS = 10 ; Blockly . SNAP _RADIUS = 28 ; Blockly . CONNECTING _SNAP _RADIUS = Blockly . SNAP _RADIUS ; Blockly . CURRENT _CONNECTION _PREFERENCE = 8 ; Blockly . BUMP _DELAY = 250 ; Blockly . BUMP _RANDOMNESS = 10 ; Blockly . COLLAPSE _CHARS = 30 ; Blockly . LONGPRESS = 750 ; Blockly . SOUND _LIMIT = 100 ; Blockly . DRAG _STACK = ! 0 ; Blockly . HSV _SATURATION = . 45 ; Blockly . HSV _VALUE = . 65 ; Blockly . SPRITE = { width : 96 , height : 124 , url : "sprites.png" } ;
Blockly . constants . ALIGN = { LEFT : - 1 , CENTRE : 0 , RIGHT : 1 } ; Blockly . DRAG _NONE = 0 ; Blockly . DRAG _STICKY = 1 ; Blockly . DRAG _BEGIN = 1 ; Blockly . DRAG _FREE = 2 ; Blockly . OPPOSITE _TYPE = [ ] ; Blockly . OPPOSITE _TYPE [ Blockly . connectionTypes . INPUT _VALUE ] = Blockly . connectionTypes . OUTPUT _VALUE ; Blockly . OPPOSITE _TYPE [ Blockly . connectionTypes . OUTPUT _VALUE ] = Blockly . connectionTypes . INPUT _VALUE ; Blockly . OPPOSITE _TYPE [ Blockly . connectionTypes . NEXT _STATEMENT ] = Blockly . connectionTypes . PREVIOUS _STATEMENT ;
2021-09-18 14:29:06 +00:00
Blockly . OPPOSITE _TYPE [ Blockly . connectionTypes . PREVIOUS _STATEMENT ] = Blockly . connectionTypes . NEXT _STATEMENT ; Blockly . VARIABLE _CATEGORY _NAME = "VARIABLE" ; Blockly . VARIABLE _DYNAMIC _CATEGORY _NAME = "VARIABLE_DYNAMIC" ; Blockly . PROCEDURE _CATEGORY _NAME = "PROCEDURE" ; Blockly . RENAME _VARIABLE _ID = "RENAME_VARIABLE_ID" ; Blockly . DELETE _VARIABLE _ID = "DELETE_VARIABLE_ID" ; Blockly . constants . COLLAPSED _INPUT _NAME = "_TEMP_COLLAPSED_INPUT" ; Blockly . constants . COLLAPSED _FIELD _NAME = "_TEMP_COLLAPSED_FIELD" ; Blockly . utils = { } ; Blockly . utils . global = function ( ) { return "object" === typeof self ? self : "object" === typeof window ? window : "object" === typeof global ? global : this } ( ) ; Blockly . Msg = { } ; Blockly . utils . global . Blockly || ( Blockly . utils . global . Blockly = { } ) ; Blockly . utils . global . Blockly . Msg || ( Blockly . utils . global . Blockly . Msg = Blockly . Msg ) ; Blockly . utils . colour = { } ;
2021-01-16 14:07:51 +00:00
Blockly . utils . colour . parse = function ( a ) { a = String ( a ) . toLowerCase ( ) . trim ( ) ; var b = Blockly . utils . colour . names [ a ] ; if ( b ) return b ; b = "0x" == a . substring ( 0 , 2 ) ? "#" + a . substring ( 2 ) : a ; b = "#" == b [ 0 ] ? b : "#" + b ; if ( /^#[0-9a-f]{6}$/ . test ( b ) ) return b ; if ( /^#[0-9a-f]{3}$/ . test ( b ) ) return [ "#" , b [ 1 ] , b [ 1 ] , b [ 2 ] , b [ 2 ] , b [ 3 ] , b [ 3 ] ] . join ( "" ) ; var c = a . match ( /^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/ ) ; return c && ( a = Number ( c [ 1 ] ) , b = Number ( c [ 2 ] ) , c = Number ( c [ 3 ] ) , 0 <= a && 256 > a && 0 <= b && 256 > b && 0 <= c && 256 > c ) ? Blockly . utils . colour . rgbToHex ( a , b ,
c ) : null } ; Blockly . utils . colour . rgbToHex = function ( a , b , c ) { b = a << 16 | b << 8 | c ; return 16 > a ? "#" + ( 16777216 | b ) . toString ( 16 ) . substr ( 1 ) : "#" + b . toString ( 16 ) } ; Blockly . utils . colour . hexToRgb = function ( a ) { a = Blockly . utils . colour . parse ( a ) ; if ( ! a ) return [ 0 , 0 , 0 ] ; a = parseInt ( a . substr ( 1 ) , 16 ) ; return [ a >> 16 , a >> 8 & 255 , a & 255 ] } ;
Blockly . utils . colour . hsvToHex = function ( a , b , c ) { var d = 0 , e = 0 , f = 0 ; if ( 0 == b ) f = e = d = c ; else { var g = Math . floor ( a / 60 ) , h = a / 60 - g ; a = c * ( 1 - b ) ; var k = c * ( 1 - b * h ) ; b = c * ( 1 - b * ( 1 - h ) ) ; switch ( g ) { case 1 : d = k ; e = c ; f = a ; break ; case 2 : d = a ; e = c ; f = b ; break ; case 3 : d = a ; e = k ; f = c ; break ; case 4 : d = b ; e = a ; f = c ; break ; case 5 : d = c ; e = a ; f = k ; break ; case 6 : case 0 : d = c , e = b , f = a } } return Blockly . utils . colour . rgbToHex ( Math . floor ( d ) , Math . floor ( e ) , Math . floor ( f ) ) } ;
Blockly . utils . colour . blend = function ( a , b , c ) { a = Blockly . utils . colour . parse ( a ) ; if ( ! a ) return null ; b = Blockly . utils . colour . parse ( b ) ; if ( ! b ) return null ; a = Blockly . utils . colour . hexToRgb ( a ) ; b = Blockly . utils . colour . hexToRgb ( b ) ; return Blockly . utils . colour . rgbToHex ( Math . round ( b [ 0 ] + c * ( a [ 0 ] - b [ 0 ] ) ) , Math . round ( b [ 1 ] + c * ( a [ 1 ] - b [ 1 ] ) ) , Math . round ( b [ 2 ] + c * ( a [ 2 ] - b [ 2 ] ) ) ) } ;
Blockly . utils . colour . names = { aqua : "#00ffff" , black : "#000000" , blue : "#0000ff" , fuchsia : "#ff00ff" , gray : "#808080" , green : "#008000" , lime : "#00ff00" , maroon : "#800000" , navy : "#000080" , olive : "#808000" , purple : "#800080" , red : "#ff0000" , silver : "#c0c0c0" , teal : "#008080" , white : "#ffffff" , yellow : "#ffff00" } ; Blockly . utils . Coordinate = function ( a , b ) { this . x = a ; this . y = b } ; Blockly . utils . Coordinate . equals = function ( a , b ) { return a == b ? ! 0 : a && b ? a . x == b . x && a . y == b . y : ! 1 } ; Blockly . utils . Coordinate . distance = function ( a , b ) { var c = a . x - b . x ; a = a . y - b . y ; return Math . sqrt ( c * c + a * a ) } ; Blockly . utils . Coordinate . magnitude = function ( a ) { return Math . sqrt ( a . x * a . x + a . y * a . y ) } ; Blockly . utils . Coordinate . difference = function ( a , b ) { return new Blockly . utils . Coordinate ( a . x - b . x , a . y - b . y ) } ;
2021-09-18 14:29:06 +00:00
Blockly . utils . Coordinate . sum = function ( a , b ) { return new Blockly . utils . Coordinate ( a . x + b . x , a . y + b . y ) } ; Blockly . utils . Coordinate . prototype . clone = function ( ) { return new Blockly . utils . Coordinate ( this . x , this . y ) } ; Blockly . utils . Coordinate . prototype . scale = function ( a ) { this . x *= a ; this . y *= a ; return this } ; Blockly . utils . Coordinate . prototype . translate = function ( a , b ) { this . x += a ; this . y += b ; return this } ; Blockly . utils . Rect = function ( a , b , c , d ) { this . top = a ; this . bottom = b ; this . left = c ; this . right = d } ; Blockly . utils . Rect . prototype . contains = function ( a , b ) { return a >= this . left && a <= this . right && b >= this . top && b <= this . bottom } ; Blockly . utils . Rect . prototype . intersects = function ( a ) { return ! ( this . left > a . right || this . right < a . left || this . top > a . bottom || this . bottom < a . top ) } ; Blockly . utils . string = { } ; Blockly . utils . string . startsWith = function ( a , b ) { return 0 == a . lastIndexOf ( b , 0 ) } ; Blockly . utils . string . shortestStringLength = function ( a ) { return a . length ? a . reduce ( function ( b , c ) { return b . length < c . length ? b : c } ) . length : 0 } ;
2021-01-16 14:07:51 +00:00
Blockly . utils . string . commonWordPrefix = function ( a , b ) { if ( ! a . length ) return 0 ; if ( 1 == a . length ) return a [ 0 ] . length ; var c = 0 ; b = b || Blockly . utils . string . shortestStringLength ( a ) ; for ( var d = 0 ; d < b ; d ++ ) { for ( var e = a [ 0 ] [ d ] , f = 1 ; f < a . length ; f ++ ) if ( e != a [ f ] [ d ] ) return c ; " " == e && ( c = d + 1 ) } for ( f = 1 ; f < a . length ; f ++ ) if ( ( e = a [ f ] [ d ] ) && " " != e ) return c ; return b } ;
Blockly . utils . string . commonWordSuffix = function ( a , b ) { if ( ! a . length ) return 0 ; if ( 1 == a . length ) return a [ 0 ] . length ; var c = 0 ; b = b || Blockly . utils . string . shortestStringLength ( a ) ; for ( var d = 0 ; d < b ; d ++ ) { for ( var e = a [ 0 ] . substr ( - d - 1 , 1 ) , f = 1 ; f < a . length ; f ++ ) if ( e != a [ f ] . substr ( - d - 1 , 1 ) ) return c ; " " == e && ( c = d + 1 ) } for ( f = 1 ; f < a . length ; f ++ ) if ( ( e = a [ f ] . charAt ( a [ f ] . length - d - 1 ) ) && " " != e ) return c ; return b } ; Blockly . utils . string . wrap = function ( a , b ) { a = a . split ( "\n" ) ; for ( var c = 0 ; c < a . length ; c ++ ) a [ c ] = Blockly . utils . string . wrapLine _ ( a [ c ] , b ) ; return a . join ( "\n" ) } ;
Blockly . utils . string . wrapLine _ = function ( a , b ) { if ( a . length <= b ) return a ; for ( var c = a . trim ( ) . split ( /\s+/ ) , d = 0 ; d < c . length ; d ++ ) c [ d ] . length > b && ( b = c [ d ] . length ) ; d = - Infinity ; var e = 1 ; do { var f = d ; var g = a ; a = [ ] ; var h = c . length / e , k = 1 ; for ( d = 0 ; d < c . length - 1 ; d ++ ) k < ( d + 1.5 ) / h ? ( k ++ , a [ d ] = ! 0 ) : a [ d ] = ! 1 ; a = Blockly . utils . string . wrapMutate _ ( c , a , b ) ; d = Blockly . utils . string . wrapScore _ ( c , a , b ) ; a = Blockly . utils . string . wrapToText _ ( c , a ) ; e ++ } while ( d > f ) ; return g } ;
Blockly . utils . string . wrapScore _ = function ( a , b , c ) { for ( var d = [ 0 ] , e = [ ] , f = 0 ; f < a . length ; f ++ ) d [ d . length - 1 ] += a [ f ] . length , ! 0 === b [ f ] ? ( d . push ( 0 ) , e . push ( a [ f ] . charAt ( a [ f ] . length - 1 ) ) ) : ! 1 === b [ f ] && d [ d . length - 1 ] ++ ; a = Math . max . apply ( Math , d ) ; for ( f = b = 0 ; f < d . length ; f ++ ) b -= 2 * Math . pow ( Math . abs ( c - d [ f ] ) , 1.5 ) , b -= Math . pow ( a - d [ f ] , 1.5 ) , - 1 != ".?!" . indexOf ( e [ f ] ) ? b += c / 3 : - 1 != ",;)]}" . indexOf ( e [ f ] ) && ( b += c / 4 ) ; 1 < d . length && d [ d . length - 1 ] <= d [ d . length - 2 ] && ( b += . 5 ) ; return b } ;
Blockly . utils . string . wrapMutate _ = function ( a , b , c ) { for ( var d = Blockly . utils . string . wrapScore _ ( a , b , c ) , e , f = 0 ; f < b . length - 1 ; f ++ ) if ( b [ f ] != b [ f + 1 ] ) { var g = [ ] . concat ( b ) ; g [ f ] = ! g [ f ] ; g [ f + 1 ] = ! g [ f + 1 ] ; var h = Blockly . utils . string . wrapScore _ ( a , g , c ) ; h > d && ( d = h , e = g ) } return e ? Blockly . utils . string . wrapMutate _ ( a , e , c ) : b } ; Blockly . utils . string . wrapToText _ = function ( a , b ) { for ( var c = [ ] , d = 0 ; d < a . length ; d ++ ) c . push ( a [ d ] ) , void 0 !== b [ d ] && c . push ( b [ d ] ? "\n" : " " ) ; return c . join ( "" ) } ; Blockly . utils . Size = function ( a , b ) { this . width = a ; this . height = b } ; Blockly . utils . Size . equals = function ( a , b ) { return a == b ? ! 0 : a && b ? a . width == b . width && a . height == b . height : ! 1 } ; Blockly . utils . style = { } ; Blockly . utils . style . getSize = function ( a ) { if ( "none" != Blockly . utils . style . getStyle _ ( a , "display" ) ) return Blockly . utils . style . getSizeWithDisplay _ ( a ) ; var b = a . style , c = b . display , d = b . visibility , e = b . position ; b . visibility = "hidden" ; b . position = "absolute" ; b . display = "inline" ; var f = a . offsetWidth ; a = a . offsetHeight ; b . display = c ; b . position = e ; b . visibility = d ; return new Blockly . utils . Size ( f , a ) } ; Blockly . utils . style . getSizeWithDisplay _ = function ( a ) { return new Blockly . utils . Size ( a . offsetWidth , a . offsetHeight ) } ;
Blockly . utils . style . getStyle _ = function ( a , b ) { return Blockly . utils . style . getComputedStyle ( a , b ) || Blockly . utils . style . getCascadedStyle ( a , b ) || a . style && a . style [ b ] } ; Blockly . utils . style . getComputedStyle = function ( a , b ) { return document . defaultView && document . defaultView . getComputedStyle && ( a = document . defaultView . getComputedStyle ( a , null ) ) ? a [ b ] || a . getPropertyValue ( b ) || "" : "" } ; Blockly . utils . style . getCascadedStyle = function ( a , b ) { return a . currentStyle ? a . currentStyle [ b ] : null } ;
Blockly . utils . style . getPageOffset = function ( a ) { var b = new Blockly . utils . Coordinate ( 0 , 0 ) ; a = a . getBoundingClientRect ( ) ; var c = document . documentElement ; c = new Blockly . utils . Coordinate ( window . pageXOffset || c . scrollLeft , window . pageYOffset || c . scrollTop ) ; b . x = a . left + c . x ; b . y = a . top + c . y ; return b } ; Blockly . utils . style . getViewportPageOffset = function ( ) { var a = document . body , b = document . documentElement ; return new Blockly . utils . Coordinate ( a . scrollLeft || b . scrollLeft , a . scrollTop || b . scrollTop ) } ;
Blockly . utils . style . setElementShown = function ( a , b ) { a . style . display = b ? "" : "none" } ; Blockly . utils . style . isRightToLeft = function ( a ) { return "rtl" == Blockly . utils . style . getStyle _ ( a , "direction" ) } ;
Blockly . utils . style . getBorderBox = function ( a ) { var b = Blockly . utils . style . getComputedStyle ( a , "borderLeftWidth" ) , c = Blockly . utils . style . getComputedStyle ( a , "borderRightWidth" ) , d = Blockly . utils . style . getComputedStyle ( a , "borderTopWidth" ) ; a = Blockly . utils . style . getComputedStyle ( a , "borderBottomWidth" ) ; return { top : parseFloat ( d ) , right : parseFloat ( c ) , bottom : parseFloat ( a ) , left : parseFloat ( b ) } } ;
Blockly . utils . style . scrollIntoContainerView = function ( a , b , c ) { a = Blockly . utils . style . getContainerOffsetToScrollInto ( a , b , c ) ; b . scrollLeft = a . x ; b . scrollTop = a . y } ;
Blockly . utils . style . getContainerOffsetToScrollInto = function ( a , b , c ) { var d = Blockly . utils . style . getPageOffset ( a ) , e = Blockly . utils . style . getPageOffset ( b ) , f = Blockly . utils . style . getBorderBox ( b ) , g = d . x - e . x - f . left ; d = d . y - e . y - f . top ; e = Blockly . utils . style . getSizeWithDisplay _ ( a ) ; a = b . clientWidth - e . width ; e = b . clientHeight - e . height ; f = b . scrollLeft ; b = b . scrollTop ; c ? ( f += g - a / 2 , b += d - e / 2 ) : ( f += Math . min ( g , Math . max ( g - a , 0 ) ) , b += Math . min ( d , Math . max ( d - e , 0 ) ) ) ; return new Blockly . utils . Coordinate ( f , b ) } ; Blockly . utils . userAgent = { } ;
( function ( a ) { function b ( d ) { return - 1 != c . indexOf ( d . toUpperCase ( ) ) } Blockly . utils . userAgent . raw = a ; var c = Blockly . utils . userAgent . raw . toUpperCase ( ) ; Blockly . utils . userAgent . IE = b ( "Trident" ) || b ( "MSIE" ) ; Blockly . utils . userAgent . EDGE = b ( "Edge" ) ; Blockly . utils . userAgent . JAVA _FX = b ( "JavaFX" ) ; Blockly . utils . userAgent . CHROME = ( b ( "Chrome" ) || b ( "CriOS" ) ) && ! Blockly . utils . userAgent . EDGE ; Blockly . utils . userAgent . WEBKIT = b ( "WebKit" ) && ! Blockly . utils . userAgent . EDGE ; Blockly . utils . userAgent . GECKO = b ( "Gecko" ) && ! Blockly . utils . userAgent . WEBKIT &&
2021-09-18 14:29:06 +00:00
! Blockly . utils . userAgent . IE && ! Blockly . utils . userAgent . EDGE ; Blockly . utils . userAgent . ANDROID = b ( "Android" ) ; a = Blockly . utils . global . navigator && Blockly . utils . global . navigator . maxTouchPoints ; Blockly . utils . userAgent . IPAD = b ( "iPad" ) || b ( "Macintosh" ) && 0 < a ; Blockly . utils . userAgent . IPOD = b ( "iPod" ) ; Blockly . utils . userAgent . IPHONE = b ( "iPhone" ) && ! Blockly . utils . userAgent . IPAD && ! Blockly . utils . userAgent . IPOD ; Blockly . utils . userAgent . MAC = b ( "Macintosh" ) ; Blockly . utils . userAgent . TABLET = Blockly . utils . userAgent . IPAD || Blockly . utils . userAgent . ANDROID &&
! b ( "Mobile" ) || b ( "Silk" ) ; Blockly . utils . userAgent . MOBILE = ! Blockly . utils . userAgent . TABLET && ( Blockly . utils . userAgent . IPOD || Blockly . utils . userAgent . IPHONE || Blockly . utils . userAgent . ANDROID || b ( "IEMobile" ) ) } ) ( Blockly . utils . global . navigator && Blockly . utils . global . navigator . userAgent || "" ) ; Blockly . utils . noEvent = function ( a ) { a . preventDefault ( ) ; a . stopPropagation ( ) } ; Blockly . utils . isTargetInput = function ( a ) { return "textarea" == a . target . type || "text" == a . target . type || "number" == a . target . type || "email" == a . target . type || "password" == a . target . type || "search" == a . target . type || "tel" == a . target . type || "url" == a . target . type || a . target . isContentEditable || a . target . dataset && "true" == a . target . dataset . isTextInput } ;
2021-01-16 14:07:51 +00:00
Blockly . utils . getRelativeXY = function ( a ) { var b = new Blockly . utils . Coordinate ( 0 , 0 ) , c = a . getAttribute ( "x" ) ; c && ( b . x = parseInt ( c , 10 ) ) ; if ( c = a . getAttribute ( "y" ) ) b . y = parseInt ( c , 10 ) ; if ( c = ( c = a . getAttribute ( "transform" ) ) && c . match ( Blockly . utils . getRelativeXY . XY _REGEX _ ) ) b . x += Number ( c [ 1 ] ) , c [ 3 ] && ( b . y += Number ( c [ 3 ] ) ) ; ( a = a . getAttribute ( "style" ) ) && - 1 < a . indexOf ( "translate" ) && ( a = a . match ( Blockly . utils . getRelativeXY . XY _STYLE _REGEX _ ) ) && ( b . x += Number ( a [ 1 ] ) , a [ 3 ] && ( b . y += Number ( a [ 3 ] ) ) ) ; return b } ;
Blockly . utils . getInjectionDivXY _ = function ( a ) { for ( var b = 0 , c = 0 ; a ; ) { var d = Blockly . utils . getRelativeXY ( a ) ; b += d . x ; c += d . y ; if ( - 1 != ( " " + ( a . getAttribute ( "class" ) || "" ) + " " ) . indexOf ( " injectionDiv " ) ) break ; a = a . parentNode } return new Blockly . utils . Coordinate ( b , c ) } ; Blockly . utils . getRelativeXY . XY _REGEX _ = /translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/ ; Blockly . utils . getRelativeXY . XY _STYLE _REGEX _ = /transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/ ;
Blockly . utils . isRightButton = function ( a ) { return a . ctrlKey && Blockly . utils . userAgent . MAC ? ! 0 : 2 == a . button } ; Blockly . utils . mouseToSvg = function ( a , b , c ) { var d = b . createSVGPoint ( ) ; d . x = a . clientX ; d . y = a . clientY ; c || ( c = b . getScreenCTM ( ) . inverse ( ) ) ; return d . matrixTransform ( c ) } ;
Blockly . utils . getScrollDeltaPixels = function ( a ) { switch ( a . deltaMode ) { default : return { x : a . deltaX , y : a . deltaY } ; case 1 : return { x : a . deltaX * Blockly . LINE _MODE _MULTIPLIER , y : a . deltaY * Blockly . LINE _MODE _MULTIPLIER } ; case 2 : return { x : a . deltaX * Blockly . PAGE _MODE _MULTIPLIER , y : a . deltaY * Blockly . PAGE _MODE _MULTIPLIER } } } ; Blockly . utils . tokenizeInterpolation = function ( a ) { return Blockly . utils . tokenizeInterpolation _ ( a , ! 0 ) } ;
Blockly . utils . replaceMessageReferences = function ( a ) { if ( "string" != typeof a ) return a ; a = Blockly . utils . tokenizeInterpolation _ ( a , ! 1 ) ; return a . length ? String ( a [ 0 ] ) : "" } ; Blockly . utils . checkMessageReferences = function ( a ) { for ( var b = ! 0 , c = Blockly . Msg , d = a . match ( /%{BKY_[A-Z]\w*}/ig ) , e = 0 ; e < d . length ; e ++ ) { var f = d [ e ] . toUpperCase ( ) ; void 0 == c [ f . slice ( 6 , - 1 ) ] && ( console . warn ( "No message string for " + d [ e ] + " in " + a ) , b = ! 1 ) } return b } ;
Blockly . utils . tokenizeInterpolation _ = function ( a , b ) { var c = [ ] , d = a . split ( "" ) ; d . push ( "" ) ; var e = 0 ; a = [ ] ; for ( var f = null , g = 0 ; g < d . length ; g ++ ) { var h = d [ g ] ; 0 == e ? "%" == h ? ( ( h = a . join ( "" ) ) && c . push ( h ) , a . length = 0 , e = 1 ) : a . push ( h ) : 1 == e ? "%" == h ? ( a . push ( h ) , e = 0 ) : b && "0" <= h && "9" >= h ? ( e = 2 , f = h , ( h = a . join ( "" ) ) && c . push ( h ) , a . length = 0 ) : "{" == h ? e = 3 : ( a . push ( "%" , h ) , e = 0 ) : 2 == e ? "0" <= h && "9" >= h ? f += h : ( c . push ( parseInt ( f , 10 ) ) , g -- , e = 0 ) : 3 == e && ( "" == h ? ( a . splice ( 0 , 0 , "%{" ) , g -- , e = 0 ) : "}" != h ? a . push ( h ) : ( e = a . join ( "" ) , /[A-Z]\w*/i . test ( e ) ? ( h = e . toUpperCase ( ) ,
( h = Blockly . utils . string . startsWith ( h , "BKY_" ) ? h . substring ( 4 ) : null ) && h in Blockly . Msg ? ( e = Blockly . Msg [ h ] , "string" == typeof e ? Array . prototype . push . apply ( c , Blockly . utils . tokenizeInterpolation _ ( e , b ) ) : b ? c . push ( String ( e ) ) : c . push ( e ) ) : c . push ( "%{" + e + "}" ) ) : c . push ( "%{" + e + "}" ) , e = a . length = 0 ) ) } ( h = a . join ( "" ) ) && c . push ( h ) ; b = [ ] ; for ( g = a . length = 0 ; g < c . length ; ++ g ) "string" == typeof c [ g ] ? a . push ( c [ g ] ) : ( ( h = a . join ( "" ) ) && b . push ( h ) , a . length = 0 , b . push ( c [ g ] ) ) ; ( h = a . join ( "" ) ) && b . push ( h ) ; a . length = 0 ; return b } ;
Blockly . utils . genUid = function ( ) { for ( var a = Blockly . utils . genUid . soup _ . length , b = [ ] , c = 0 ; 20 > c ; c ++ ) b [ c ] = Blockly . utils . genUid . soup _ . charAt ( Math . random ( ) * a ) ; return b . join ( "" ) } ; Blockly . utils . genUid . soup _ = "!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ;
Blockly . utils . is3dSupported = function ( ) { if ( void 0 !== Blockly . utils . is3dSupported . cached _ ) return Blockly . utils . is3dSupported . cached _ ; if ( ! Blockly . utils . global . getComputedStyle ) return ! 1 ; var a = document . createElement ( "p" ) , b = "none" , c = { webkitTransform : "-webkit-transform" , OTransform : "-o-transform" , msTransform : "-ms-transform" , MozTransform : "-moz-transform" , transform : "transform" } ; document . body . insertBefore ( a , null ) ; for ( var d in c ) if ( void 0 !== a . style [ d ] ) { a . style [ d ] = "translate3d(1px,1px,1px)" ; b = Blockly . utils . global . getComputedStyle ( a ) ;
if ( ! b ) return document . body . removeChild ( a ) , ! 1 ; b = b . getPropertyValue ( c [ d ] ) } document . body . removeChild ( a ) ; Blockly . utils . is3dSupported . cached _ = "none" !== b ; return Blockly . utils . is3dSupported . cached _ } ; Blockly . utils . runAfterPageLoad = function ( a ) { if ( "object" != typeof document ) throw Error ( "Blockly.utils.runAfterPageLoad() requires browser document." ) ; if ( "complete" == document . readyState ) a ( ) ; else var b = setInterval ( function ( ) { "complete" == document . readyState && ( clearInterval ( b ) , a ( ) ) } , 10 ) } ;
Blockly . utils . getViewportBBox = function ( ) { var a = Blockly . utils . style . getViewportPageOffset ( ) ; return new Blockly . utils . Rect ( a . y , document . documentElement . clientHeight + a . y , a . x , document . documentElement . clientWidth + a . x ) } ; Blockly . utils . arrayRemove = function ( a , b ) { b = a . indexOf ( b ) ; if ( - 1 == b ) return ! 1 ; a . splice ( b , 1 ) ; return ! 0 } ;
Blockly . utils . getDocumentScroll = function ( ) { var a = document . documentElement , b = window ; return Blockly . utils . userAgent . IE && b . pageYOffset != a . scrollTop ? new Blockly . utils . Coordinate ( a . scrollLeft , a . scrollTop ) : new Blockly . utils . Coordinate ( b . pageXOffset || a . scrollLeft , b . pageYOffset || a . scrollTop ) } ; Blockly . utils . getBlockTypeCounts = function ( a , b ) { var c = Object . create ( null ) , d = a . getDescendants ( ! 0 ) ; b && ( a = a . getNextBlock ( ) ) && ( a = d . indexOf ( a ) , d . splice ( a , d . length - a ) ) ; for ( a = 0 ; b = d [ a ] ; a ++ ) c [ b . type ] ? c [ b . type ] ++ : c [ b . type ] = 1 ; return c } ;
Blockly . utils . screenToWsCoordinates = function ( a , b ) { var c = b . x ; b = b . y ; var d = a . getInjectionDiv ( ) . getBoundingClientRect ( ) ; c = new Blockly . utils . Coordinate ( c - d . left , b - d . top ) ; b = a . getOriginOffsetInPixels ( ) ; return Blockly . utils . Coordinate . difference ( c , b ) . scale ( 1 / a . scale ) } ;
2021-05-19 13:38:55 +00:00
Blockly . utils . parseBlockColour = function ( a ) { var b = "string" == typeof a ? Blockly . utils . replaceMessageReferences ( a ) : a , c = Number ( b ) ; if ( ! isNaN ( c ) && 0 <= c && 360 >= c ) return { hue : c , hex : Blockly . utils . colour . hsvToHex ( c , Blockly . HSV _SATURATION , 255 * Blockly . HSV _VALUE ) } ; if ( c = Blockly . utils . colour . parse ( b ) ) return { hue : null , hex : c } ; c = 'Invalid colour: "' + b + '"' ; a != b && ( c += ' (from "' + a + '")' ) ; throw Error ( c ) ; } ; Blockly . Touch = { } ; Blockly . Touch . TOUCH _ENABLED = "ontouchstart" in Blockly . utils . global || ! ! ( Blockly . utils . global . document && document . documentElement && "ontouchstart" in document . documentElement ) || ! ( ! Blockly . utils . global . navigator || ! Blockly . utils . global . navigator . maxTouchPoints && ! Blockly . utils . global . navigator . msMaxTouchPoints ) ; Blockly . Touch . touchIdentifier _ = null ; Blockly . Touch . TOUCH _MAP = { } ;
Blockly . utils . global . PointerEvent ? Blockly . Touch . TOUCH _MAP = { mousedown : [ "pointerdown" ] , mouseenter : [ "pointerenter" ] , mouseleave : [ "pointerleave" ] , mousemove : [ "pointermove" ] , mouseout : [ "pointerout" ] , mouseover : [ "pointerover" ] , mouseup : [ "pointerup" , "pointercancel" ] , touchend : [ "pointerup" ] , touchcancel : [ "pointercancel" ] } : Blockly . Touch . TOUCH _ENABLED && ( Blockly . Touch . TOUCH _MAP = { mousedown : [ "touchstart" ] , mousemove : [ "touchmove" ] , mouseup : [ "touchend" , "touchcancel" ] } ) ; Blockly . longPid _ = 0 ;
Blockly . longStart = function ( a , b ) { Blockly . longStop _ ( ) ; a . changedTouches && 1 != a . changedTouches . length || ( Blockly . longPid _ = setTimeout ( function ( ) { a . changedTouches && ( a . button = 2 , a . clientX = a . changedTouches [ 0 ] . clientX , a . clientY = a . changedTouches [ 0 ] . clientY ) ; b && b . handleRightClick ( a ) } , Blockly . LONGPRESS ) ) } ; Blockly . longStop _ = function ( ) { Blockly . longPid _ && ( clearTimeout ( Blockly . longPid _ ) , Blockly . longPid _ = 0 ) } ; Blockly . Touch . clearTouchIdentifier = function ( ) { Blockly . Touch . touchIdentifier _ = null } ;
Blockly . Touch . shouldHandleEvent = function ( a ) { return ! Blockly . Touch . isMouseOrTouchEvent ( a ) || Blockly . Touch . checkTouchIdentifier ( a ) } ; Blockly . Touch . getTouchIdentifierFromEvent = function ( a ) { return void 0 != a . pointerId ? a . pointerId : a . changedTouches && a . changedTouches [ 0 ] && void 0 !== a . changedTouches [ 0 ] . identifier && null !== a . changedTouches [ 0 ] . identifier ? a . changedTouches [ 0 ] . identifier : "mouse" } ;
Blockly . Touch . checkTouchIdentifier = function ( a ) { var b = Blockly . Touch . getTouchIdentifierFromEvent ( a ) ; return void 0 !== Blockly . Touch . touchIdentifier _ && null !== Blockly . Touch . touchIdentifier _ ? Blockly . Touch . touchIdentifier _ == b : "mousedown" == a . type || "touchstart" == a . type || "pointerdown" == a . type ? ( Blockly . Touch . touchIdentifier _ = b , ! 0 ) : ! 1 } ; Blockly . Touch . setClientFromTouch = function ( a ) { if ( Blockly . utils . string . startsWith ( a . type , "touch" ) ) { var b = a . changedTouches [ 0 ] ; a . clientX = b . clientX ; a . clientY = b . clientY } } ;
Blockly . Touch . isMouseOrTouchEvent = function ( a ) { return Blockly . utils . string . startsWith ( a . type , "touch" ) || Blockly . utils . string . startsWith ( a . type , "mouse" ) || Blockly . utils . string . startsWith ( a . type , "pointer" ) } ; Blockly . Touch . isTouchEvent = function ( a ) { return Blockly . utils . string . startsWith ( a . type , "touch" ) || Blockly . utils . string . startsWith ( a . type , "pointer" ) } ;
Blockly . Touch . splitEventByTouches = function ( a ) { var b = [ ] ; if ( a . changedTouches ) for ( var c = 0 ; c < a . changedTouches . length ; c ++ ) b [ c ] = { type : a . type , changedTouches : [ a . changedTouches [ c ] ] , target : a . target , stopPropagation : function ( ) { a . stopPropagation ( ) } , preventDefault : function ( ) { a . preventDefault ( ) } } ; else b . push ( a ) ; return b } ; Blockly . browserEvents = { } ;
Blockly . browserEvents . conditionalBind = function ( a , b , c , d , e , f ) { var g = ! 1 , h = function ( p ) { var q = ! e ; p = Blockly . Touch . splitEventByTouches ( p ) ; for ( var t = 0 , r ; r = p [ t ] ; t ++ ) if ( ! q || Blockly . Touch . shouldHandleEvent ( r ) ) Blockly . Touch . setClientFromTouch ( r ) , c ? d . call ( c , r ) : d ( r ) , g = ! 0 } , k = [ ] ; if ( Blockly . utils . global . PointerEvent && b in Blockly . Touch . TOUCH _MAP ) for ( var l = 0 , m ; m = Blockly . Touch . TOUCH _MAP [ b ] [ l ] ; l ++ ) a . addEventListener ( m , h , ! 1 ) , k . push ( [ a , m , h ] ) ; else if ( a . addEventListener ( b , h , ! 1 ) , k . push ( [ a , b , h ] ) , b in Blockly . Touch . TOUCH _MAP ) { var n =
function ( p ) { h ( p ) ; var q = ! f ; g && q && p . preventDefault ( ) } ; for ( l = 0 ; m = Blockly . Touch . TOUCH _MAP [ b ] [ l ] ; l ++ ) a . addEventListener ( m , n , ! 1 ) , k . push ( [ a , m , n ] ) } return k } ;
Blockly . browserEvents . bind = function ( a , b , c , d ) { var e = function ( l ) { c ? d . call ( c , l ) : d ( l ) } , f = [ ] ; if ( Blockly . utils . global . PointerEvent && b in Blockly . Touch . TOUCH _MAP ) for ( var g = 0 , h ; h = Blockly . Touch . TOUCH _MAP [ b ] [ g ] ; g ++ ) a . addEventListener ( h , e , ! 1 ) , f . push ( [ a , h , e ] ) ; else if ( a . addEventListener ( b , e , ! 1 ) , f . push ( [ a , b , e ] ) , b in Blockly . Touch . TOUCH _MAP ) { var k = function ( l ) { if ( l . changedTouches && 1 == l . changedTouches . length ) { var m = l . changedTouches [ 0 ] ; l . clientX = m . clientX ; l . clientY = m . clientY } e ( l ) ; l . preventDefault ( ) } ; for ( g = 0 ; h = Blockly . Touch . TOUCH _MAP [ b ] [ g ] ; g ++ ) a . addEventListener ( h ,
2021-09-18 14:29:06 +00:00
k , ! 1 ) , f . push ( [ a , h , k ] ) } return f } ; Blockly . browserEvents . unbind = function ( a ) { for ( ; a . length ; ) { var b = a . pop ( ) , c = b [ 2 ] ; b [ 0 ] . removeEventListener ( b [ 1 ] , c , ! 1 ) } return c } ; Blockly . ComponentManager = function ( ) { this . componentData _ = Object . create ( null ) ; this . capabilityToComponentIds _ = Object . create ( null ) } ;
Blockly . ComponentManager . prototype . addComponent = function ( a , b ) { var c = a . component . id ; if ( ! b && this . componentData _ [ c ] ) throw Error ( 'Plugin "' + c + '" with capabilities "' + this . componentData _ [ c ] . capabilities + '" already added.' ) ; this . componentData _ [ c ] = a ; b = [ ] ; for ( var d = 0 ; d < a . capabilities . length ; d ++ ) { var e = String ( a . capabilities [ d ] ) . toLowerCase ( ) ; b . push ( e ) ; void 0 === this . capabilityToComponentIds _ [ e ] ? this . capabilityToComponentIds _ [ e ] = [ c ] : this . capabilityToComponentIds _ [ e ] . push ( c ) } this . componentData _ [ c ] . capabilities =
b } ; Blockly . ComponentManager . prototype . removeComponent = function ( a ) { var b = this . componentData _ [ a ] ; if ( b ) { for ( var c = 0 ; c < b . capabilities . length ; c ++ ) { var d = String ( b . capabilities [ c ] ) . toLowerCase ( ) ; this . capabilityToComponentIds _ [ d ] . splice ( this . capabilityToComponentIds _ [ d ] . indexOf ( a ) , 1 ) } delete this . componentData _ [ a ] } } ;
Blockly . ComponentManager . prototype . addCapability = function ( a , b ) { if ( ! this . getComponent ( a ) ) throw Error ( 'Cannot add capability, "' + b + '". Plugin "' + a + '" has not been added to the ComponentManager' ) ; this . hasCapability ( a , b ) ? console . warn ( 'Plugin "' + a + 'already has capability "' + b + '"' ) : ( b = String ( b ) . toLowerCase ( ) , this . componentData _ [ a ] . capabilities . push ( b ) , this . capabilityToComponentIds _ [ b ] . push ( a ) ) } ;
Blockly . ComponentManager . prototype . removeCapability = function ( a , b ) { if ( ! this . getComponent ( a ) ) throw Error ( 'Cannot remove capability, "' + b + '". Plugin "' + a + '" has not been added to the ComponentManager' ) ; this . hasCapability ( a , b ) ? ( b = String ( b ) . toLowerCase ( ) , this . componentData _ [ a ] . capabilities . splice ( this . componentData _ [ a ] . capabilities . indexOf ( b ) , 1 ) , this . capabilityToComponentIds _ [ b ] . splice ( this . capabilityToComponentIds _ [ b ] . indexOf ( a ) , 1 ) ) : console . warn ( 'Plugin "' + a + "doesn't have capability \"" + b + '" to remove' ) } ;
Blockly . ComponentManager . prototype . hasCapability = function ( a , b ) { b = String ( b ) . toLowerCase ( ) ; return - 1 !== this . componentData _ [ a ] . capabilities . indexOf ( b ) } ; Blockly . ComponentManager . prototype . getComponent = function ( a ) { return this . componentData _ [ a ] && this . componentData _ [ a ] . component } ;
Blockly . ComponentManager . prototype . getComponents = function ( a , b ) { a = String ( a ) . toLowerCase ( ) ; a = this . capabilityToComponentIds _ [ a ] ; if ( ! a ) return [ ] ; var c = [ ] ; if ( b ) { var d = [ ] , e = this . componentData _ ; a . forEach ( function ( f ) { d . push ( e [ f ] ) } ) ; d . sort ( function ( f , g ) { return f . weight - g . weight } ) ; d . forEach ( function ( f ) { c . push ( f . component ) } ) } else e = this . componentData _ , a . forEach ( function ( f ) { c . push ( e [ f ] . component ) } ) ; return c } ; Blockly . ComponentManager . Capability = function ( a ) { this . name _ = a } ;
Blockly . ComponentManager . Capability . prototype . toString = function ( ) { return this . name _ } ; Blockly . ComponentManager . Capability . POSITIONABLE = new Blockly . ComponentManager . Capability ( "positionable" ) ; Blockly . ComponentManager . Capability . DRAG _TARGET = new Blockly . ComponentManager . Capability ( "drag_target" ) ; Blockly . ComponentManager . Capability . DELETE _AREA = new Blockly . ComponentManager . Capability ( "delete_area" ) ; Blockly . ComponentManager . Capability . AUTOHIDEABLE = new Blockly . ComponentManager . Capability ( "autohideable" ) ; Blockly . utils . Svg = function ( a ) { this . tagName _ = a } ; Blockly . utils . Svg . prototype . toString = function ( ) { return this . tagName _ } ; Blockly . utils . Svg . ANIMATE = new Blockly . utils . Svg ( "animate" ) ; Blockly . utils . Svg . CIRCLE = new Blockly . utils . Svg ( "circle" ) ; Blockly . utils . Svg . CLIPPATH = new Blockly . utils . Svg ( "clipPath" ) ; Blockly . utils . Svg . DEFS = new Blockly . utils . Svg ( "defs" ) ; Blockly . utils . Svg . FECOMPOSITE = new Blockly . utils . Svg ( "feComposite" ) ; Blockly . utils . Svg . FECOMPONENTTRANSFER = new Blockly . utils . Svg ( "feComponentTransfer" ) ;
Blockly . utils . Svg . FEFLOOD = new Blockly . utils . Svg ( "feFlood" ) ; Blockly . utils . Svg . FEFUNCA = new Blockly . utils . Svg ( "feFuncA" ) ; Blockly . utils . Svg . FEGAUSSIANBLUR = new Blockly . utils . Svg ( "feGaussianBlur" ) ; Blockly . utils . Svg . FEPOINTLIGHT = new Blockly . utils . Svg ( "fePointLight" ) ; Blockly . utils . Svg . FESPECULARLIGHTING = new Blockly . utils . Svg ( "feSpecularLighting" ) ; Blockly . utils . Svg . FILTER = new Blockly . utils . Svg ( "filter" ) ; Blockly . utils . Svg . FOREIGNOBJECT = new Blockly . utils . Svg ( "foreignObject" ) ; Blockly . utils . Svg . G = new Blockly . utils . Svg ( "g" ) ;
Blockly . utils . Svg . IMAGE = new Blockly . utils . Svg ( "image" ) ; Blockly . utils . Svg . LINE = new Blockly . utils . Svg ( "line" ) ; Blockly . utils . Svg . PATH = new Blockly . utils . Svg ( "path" ) ; Blockly . utils . Svg . PATTERN = new Blockly . utils . Svg ( "pattern" ) ; Blockly . utils . Svg . POLYGON = new Blockly . utils . Svg ( "polygon" ) ; Blockly . utils . Svg . RECT = new Blockly . utils . Svg ( "rect" ) ; Blockly . utils . Svg . SVG = new Blockly . utils . Svg ( "svg" ) ; Blockly . utils . Svg . TEXT = new Blockly . utils . Svg ( "text" ) ; Blockly . utils . Svg . TSPAN = new Blockly . utils . Svg ( "tspan" ) ; Blockly . utils . dom = { } ; Blockly . utils . dom . SVG _NS = "http://www.w3.org/2000/svg" ; Blockly . utils . dom . HTML _NS = "http://www.w3.org/1999/xhtml" ; Blockly . utils . dom . XLINK _NS = "http://www.w3.org/1999/xlink" ; Blockly . utils . dom . NodeType = { ELEMENT _NODE : 1 , TEXT _NODE : 3 , COMMENT _NODE : 8 , DOCUMENT _POSITION _CONTAINED _BY : 16 } ; Blockly . utils . dom . cacheWidths _ = null ; Blockly . utils . dom . cacheReference _ = 0 ; Blockly . utils . dom . canvasContext _ = null ;
Blockly . utils . dom . createSvgElement = function ( a , b , c ) { a = document . createElementNS ( Blockly . utils . dom . SVG _NS , String ( a ) ) ; for ( var d in b ) a . setAttribute ( d , b [ d ] ) ; document . body . runtimeStyle && ( a . runtimeStyle = a . currentStyle = a . style ) ; c && c . appendChild ( a ) ; return a } ; Blockly . utils . dom . addClass = function ( a , b ) { var c = a . getAttribute ( "class" ) || "" ; if ( - 1 != ( " " + c + " " ) . indexOf ( " " + b + " " ) ) return ! 1 ; c && ( c += " " ) ; a . setAttribute ( "class" , c + b ) ; return ! 0 } ;
Blockly . utils . dom . removeClasses = function ( a , b ) { b = b . split ( " " ) ; for ( var c = 0 ; c < b . length ; c ++ ) Blockly . utils . dom . removeClass ( a , b [ c ] ) } ; Blockly . utils . dom . removeClass = function ( a , b ) { var c = a . getAttribute ( "class" ) ; if ( - 1 == ( " " + c + " " ) . indexOf ( " " + b + " " ) ) return ! 1 ; c = c . split ( /\s+/ ) ; for ( var d = 0 ; d < c . length ; d ++ ) c [ d ] && c [ d ] != b || ( c . splice ( d , 1 ) , d -- ) ; c . length ? a . setAttribute ( "class" , c . join ( " " ) ) : a . removeAttribute ( "class" ) ; return ! 0 } ;
Blockly . utils . dom . hasClass = function ( a , b ) { return - 1 != ( " " + a . getAttribute ( "class" ) + " " ) . indexOf ( " " + b + " " ) } ; Blockly . utils . dom . removeNode = function ( a ) { return a && a . parentNode ? a . parentNode . removeChild ( a ) : null } ; Blockly . utils . dom . insertAfter = function ( a , b ) { var c = b . nextSibling ; b = b . parentNode ; if ( ! b ) throw Error ( "Reference node has no parent." ) ; c ? b . insertBefore ( a , c ) : b . appendChild ( a ) } ; Blockly . utils . dom . containsNode = function ( a , b ) { return ! ! ( a . compareDocumentPosition ( b ) & Blockly . utils . dom . NodeType . DOCUMENT _POSITION _CONTAINED _BY ) } ;
Blockly . utils . dom . setCssTransform = function ( a , b ) { a . style . transform = b ; a . style [ "-webkit-transform" ] = b } ; Blockly . utils . dom . startTextWidthCache = function ( ) { Blockly . utils . dom . cacheReference _ ++ ; Blockly . utils . dom . cacheWidths _ || ( Blockly . utils . dom . cacheWidths _ = Object . create ( null ) ) } ; Blockly . utils . dom . stopTextWidthCache = function ( ) { Blockly . utils . dom . cacheReference _ -- ; Blockly . utils . dom . cacheReference _ || ( Blockly . utils . dom . cacheWidths _ = null ) } ;
Blockly . utils . dom . getTextWidth = function ( a ) { var b = a . textContent + "\n" + a . className . baseVal , c ; if ( Blockly . utils . dom . cacheWidths _ && ( c = Blockly . utils . dom . cacheWidths _ [ b ] ) ) return c ; try { c = Blockly . utils . userAgent . IE || Blockly . utils . userAgent . EDGE ? a . getBBox ( ) . width : a . getComputedTextLength ( ) } catch ( d ) { return 8 * a . textContent . length } Blockly . utils . dom . cacheWidths _ && ( Blockly . utils . dom . cacheWidths _ [ b ] = c ) ; return c } ;
Blockly . utils . dom . getFastTextWidth = function ( a , b , c , d ) { return Blockly . utils . dom . getFastTextWidthWithSizeString ( a , b + "pt" , c , d ) } ;
Blockly . utils . dom . getFastTextWidthWithSizeString = function ( a , b , c , d ) { var e = a . textContent ; a = e + "\n" + a . className . baseVal ; var f ; if ( Blockly . utils . dom . cacheWidths _ && ( f = Blockly . utils . dom . cacheWidths _ [ a ] ) ) return f ; Blockly . utils . dom . canvasContext _ || ( f = document . createElement ( "canvas" ) , f . className = "blocklyComputeCanvas" , document . body . appendChild ( f ) , Blockly . utils . dom . canvasContext _ = f . getContext ( "2d" ) ) ; Blockly . utils . dom . canvasContext _ . font = c + " " + b + " " + d ; f = Blockly . utils . dom . canvasContext _ . measureText ( e ) . width ; Blockly . utils . dom . cacheWidths _ &&
( Blockly . utils . dom . cacheWidths _ [ a ] = f ) ; return f } ;
Blockly . utils . dom . measureFontMetrics = function ( a , b , c , d ) { var e = document . createElement ( "span" ) ; e . style . font = c + " " + b + " " + d ; e . textContent = a ; a = document . createElement ( "div" ) ; a . style . width = "1px" ; a . style . height = "0px" ; b = document . createElement ( "div" ) ; b . setAttribute ( "style" , "position: fixed; top: 0; left: 0; display: flex;" ) ; b . appendChild ( e ) ; b . appendChild ( a ) ; document . body . appendChild ( b ) ; try { c = { } , b . style . alignItems = "baseline" , c . baseline = a . offsetTop - e . offsetTop , b . style . alignItems = "flex-end" , c . height = a . offsetTop -
e . offsetTop } finally { document . body . removeChild ( b ) } return c } ; Blockly . utils . math = { } ; Blockly . utils . math . toRadians = function ( a ) { return a * Math . PI / 180 } ; Blockly . utils . math . toDegrees = function ( a ) { return 180 * a / Math . PI } ; Blockly . utils . math . clamp = function ( a , b , c ) { if ( c < a ) { var d = c ; c = a ; a = d } return Math . max ( a , Math . min ( b , c ) ) } ; Blockly . DropDownDiv = function ( ) { } ; Blockly . DropDownDiv . boundsElement _ = null ; Blockly . DropDownDiv . owner _ = null ; Blockly . DropDownDiv . positionToField _ = null ; Blockly . DropDownDiv . ARROW _SIZE = 16 ; Blockly . DropDownDiv . BORDER _SIZE = 1 ; Blockly . DropDownDiv . ARROW _HORIZONTAL _PADDING = 12 ; Blockly . DropDownDiv . PADDING _Y = 16 ; Blockly . DropDownDiv . ANIMATION _TIME = . 25 ; Blockly . DropDownDiv . animateOutTimer _ = null ; Blockly . DropDownDiv . onHide _ = null ; Blockly . DropDownDiv . rendererClassName _ = "" ; Blockly . DropDownDiv . themeClassName _ = "" ;
Blockly . DropDownDiv . createDom = function ( ) { if ( ! Blockly . DropDownDiv . DIV _ ) { var a = document . createElement ( "div" ) ; a . className = "blocklyDropDownDiv" ; ( Blockly . parentContainer || document . body ) . appendChild ( a ) ; Blockly . DropDownDiv . DIV _ = a ; var b = document . createElement ( "div" ) ; b . className = "blocklyDropDownContent" ; a . appendChild ( b ) ; Blockly . DropDownDiv . content _ = b ; b = document . createElement ( "div" ) ; b . className = "blocklyDropDownArrow" ; a . appendChild ( b ) ; Blockly . DropDownDiv . arrow _ = b ; Blockly . DropDownDiv . DIV _ . style . opacity = 0 ; Blockly . DropDownDiv . DIV _ . style . transition =
"transform " + Blockly . DropDownDiv . ANIMATION _TIME + "s, opacity " + Blockly . DropDownDiv . ANIMATION _TIME + "s" ; a . addEventListener ( "focusin" , function ( ) { Blockly . utils . dom . addClass ( a , "blocklyFocused" ) } ) ; a . addEventListener ( "focusout" , function ( ) { Blockly . utils . dom . removeClass ( a , "blocklyFocused" ) } ) } } ; Blockly . DropDownDiv . setBoundsElement = function ( a ) { Blockly . DropDownDiv . boundsElement _ = a } ; Blockly . DropDownDiv . getContentDiv = function ( ) { return Blockly . DropDownDiv . content _ } ;
Blockly . DropDownDiv . clearContent = function ( ) { Blockly . DropDownDiv . content _ . textContent = "" ; Blockly . DropDownDiv . content _ . style . width = "" } ; Blockly . DropDownDiv . setColour = function ( a , b ) { Blockly . DropDownDiv . DIV _ . style . backgroundColor = a ; Blockly . DropDownDiv . DIV _ . style . borderColor = b } ; Blockly . DropDownDiv . showPositionedByBlock = function ( a , b , c , d ) { return Blockly . DropDownDiv . showPositionedByRect _ ( Blockly . DropDownDiv . getScaledBboxOfBlock _ ( b ) , a , c , d ) } ;
Blockly . DropDownDiv . showPositionedByField = function ( a , b , c ) { Blockly . DropDownDiv . positionToField _ = ! 0 ; return Blockly . DropDownDiv . showPositionedByRect _ ( Blockly . DropDownDiv . getScaledBboxOfField _ ( a ) , a , b , c ) } ; Blockly . DropDownDiv . getScaledBboxOfBlock _ = function ( a ) { var b = a . getSvgRoot ( ) , c = b . getBBox ( ) , d = a . workspace . scale ; a = c . height * d ; c = c . width * d ; b = Blockly . utils . style . getPageOffset ( b ) ; return new Blockly . utils . Rect ( b . y , b . y + a , b . x , b . x + c ) } ;
Blockly . DropDownDiv . getScaledBboxOfField _ = function ( a ) { a = a . getScaledBBox ( ) ; return new Blockly . utils . Rect ( a . top , a . bottom , a . left , a . right ) } ; Blockly . DropDownDiv . showPositionedByRect _ = function ( a , b , c , d ) { var e = a . left + ( a . right - a . left ) / 2 , f = a . bottom ; a = a . top ; d && ( a += d ) ; d = b . getSourceBlock ( ) ; for ( var g = d . workspace ; g . options . parentWorkspace ; ) g = g . options . parentWorkspace ; Blockly . DropDownDiv . setBoundsElement ( g . getParentSvg ( ) . parentNode ) ; return Blockly . DropDownDiv . show ( b , d . RTL , e , f , e , a , c ) } ;
Blockly . DropDownDiv . show = function ( a , b , c , d , e , f , g ) { Blockly . DropDownDiv . owner _ = a ; Blockly . DropDownDiv . onHide _ = g || null ; a = Blockly . DropDownDiv . DIV _ ; a . style . direction = b ? "rtl" : "ltr" ; b = Blockly . getMainWorkspace ( ) ; Blockly . DropDownDiv . rendererClassName _ = b . getRenderer ( ) . getClassName ( ) ; Blockly . DropDownDiv . themeClassName _ = b . getTheme ( ) . getClassName ( ) ; Blockly . utils . dom . addClass ( a , Blockly . DropDownDiv . rendererClassName _ ) ; Blockly . utils . dom . addClass ( a , Blockly . DropDownDiv . themeClassName _ ) ; return Blockly . DropDownDiv . positionInternal _ ( c ,
d , e , f ) } ; Blockly . DropDownDiv . getBoundsInfo _ = function ( ) { var a = Blockly . utils . style . getPageOffset ( Blockly . DropDownDiv . boundsElement _ ) , b = Blockly . utils . style . getSize ( Blockly . DropDownDiv . boundsElement _ ) ; return { left : a . x , right : a . x + b . width , top : a . y , bottom : a . y + b . height , width : b . width , height : b . height } } ;
Blockly . DropDownDiv . getPositionMetrics _ = function ( a , b , c , d ) { var e = Blockly . DropDownDiv . getBoundsInfo _ ( ) , f = Blockly . utils . style . getSize ( Blockly . DropDownDiv . DIV _ ) ; return b + f . height < e . bottom ? Blockly . DropDownDiv . getPositionBelowMetrics _ ( a , b , e , f ) : d - f . height > e . top ? Blockly . DropDownDiv . getPositionAboveMetrics _ ( c , d , e , f ) : b + f . height < document . documentElement . clientHeight ? Blockly . DropDownDiv . getPositionBelowMetrics _ ( a , b , e , f ) : d - f . height > document . documentElement . clientTop ? Blockly . DropDownDiv . getPositionAboveMetrics _ ( c ,
d , e , f ) : Blockly . DropDownDiv . getPositionTopOfPageMetrics _ ( a , e , f ) } ; Blockly . DropDownDiv . getPositionBelowMetrics _ = function ( a , b , c , d ) { a = Blockly . DropDownDiv . getPositionX ( a , c . left , c . right , d . width ) ; return { initialX : a . divX , initialY : b , finalX : a . divX , finalY : b + Blockly . DropDownDiv . PADDING _Y , arrowX : a . arrowX , arrowY : - ( Blockly . DropDownDiv . ARROW _SIZE / 2 + Blockly . DropDownDiv . BORDER _SIZE ) , arrowAtTop : ! 0 , arrowVisible : ! 0 } } ;
Blockly . DropDownDiv . getPositionAboveMetrics _ = function ( a , b , c , d ) { a = Blockly . DropDownDiv . getPositionX ( a , c . left , c . right , d . width ) ; return { initialX : a . divX , initialY : b - d . height , finalX : a . divX , finalY : b - d . height - Blockly . DropDownDiv . PADDING _Y , arrowX : a . arrowX , arrowY : d . height - 2 * Blockly . DropDownDiv . BORDER _SIZE - Blockly . DropDownDiv . ARROW _SIZE / 2 , arrowAtTop : ! 1 , arrowVisible : ! 0 } } ;
Blockly . DropDownDiv . getPositionTopOfPageMetrics _ = function ( a , b , c ) { a = Blockly . DropDownDiv . getPositionX ( a , b . left , b . right , c . width ) ; return { initialX : a . divX , initialY : 0 , finalX : a . divX , finalY : 0 , arrowAtTop : null , arrowX : null , arrowY : null , arrowVisible : ! 1 } } ;
Blockly . DropDownDiv . getPositionX = function ( a , b , c , d ) { var e = a ; a = Blockly . utils . math . clamp ( b , a - d / 2 , c - d ) ; e -= Blockly . DropDownDiv . ARROW _SIZE / 2 ; b = Blockly . DropDownDiv . ARROW _HORIZONTAL _PADDING ; d = Blockly . utils . math . clamp ( b , e - a , d - b - Blockly . DropDownDiv . ARROW _SIZE ) ; return { arrowX : d , divX : a } } ; Blockly . DropDownDiv . isVisible = function ( ) { return ! ! Blockly . DropDownDiv . owner _ } ;
Blockly . DropDownDiv . hideIfOwner = function ( a , b ) { return Blockly . DropDownDiv . owner _ === a ? ( b ? Blockly . DropDownDiv . hideWithoutAnimation ( ) : Blockly . DropDownDiv . hide ( ) , ! 0 ) : ! 1 } ;
Blockly . DropDownDiv . hide = function ( ) { var a = Blockly . DropDownDiv . DIV _ ; a . style . transform = "translate(0, 0)" ; a . style . opacity = 0 ; Blockly . DropDownDiv . animateOutTimer _ = setTimeout ( function ( ) { Blockly . DropDownDiv . hideWithoutAnimation ( ) } , 1E3 * Blockly . DropDownDiv . ANIMATION _TIME ) ; Blockly . DropDownDiv . onHide _ && ( Blockly . DropDownDiv . onHide _ ( ) , Blockly . DropDownDiv . onHide _ = null ) } ;
Blockly . DropDownDiv . hideWithoutAnimation = function ( ) { if ( Blockly . DropDownDiv . isVisible ( ) ) { Blockly . DropDownDiv . animateOutTimer _ && clearTimeout ( Blockly . DropDownDiv . animateOutTimer _ ) ; var a = Blockly . DropDownDiv . DIV _ ; a . style . transform = "" ; a . style . left = "" ; a . style . top = "" ; a . style . opacity = 0 ; a . style . display = "none" ; a . style . backgroundColor = "" ; a . style . borderColor = "" ; Blockly . DropDownDiv . onHide _ && ( Blockly . DropDownDiv . onHide _ ( ) , Blockly . DropDownDiv . onHide _ = null ) ; Blockly . DropDownDiv . clearContent ( ) ; Blockly . DropDownDiv . owner _ =
null ; Blockly . DropDownDiv . rendererClassName _ && ( Blockly . utils . dom . removeClass ( a , Blockly . DropDownDiv . rendererClassName _ ) , Blockly . DropDownDiv . rendererClassName _ = "" ) ; Blockly . DropDownDiv . themeClassName _ && ( Blockly . utils . dom . removeClass ( a , Blockly . DropDownDiv . themeClassName _ ) , Blockly . DropDownDiv . themeClassName _ = "" ) ; Blockly . getMainWorkspace ( ) . markFocused ( ) } } ;
Blockly . DropDownDiv . positionInternal _ = function ( a , b , c , d ) { a = Blockly . DropDownDiv . getPositionMetrics _ ( a , b , c , d ) ; a . arrowVisible ? ( Blockly . DropDownDiv . arrow _ . style . display = "" , Blockly . DropDownDiv . arrow _ . style . transform = "translate(" + a . arrowX + "px," + a . arrowY + "px) rotate(45deg)" , Blockly . DropDownDiv . arrow _ . setAttribute ( "class" , a . arrowAtTop ? "blocklyDropDownArrow blocklyArrowTop" : "blocklyDropDownArrow blocklyArrowBottom" ) ) : Blockly . DropDownDiv . arrow _ . style . display = "none" ; b = Math . floor ( a . initialX ) ; c = Math . floor ( a . initialY ) ;
d = Math . floor ( a . finalX ) ; var e = Math . floor ( a . finalY ) , f = Blockly . DropDownDiv . DIV _ ; f . style . left = b + "px" ; f . style . top = c + "px" ; f . style . display = "block" ; f . style . opacity = 1 ; f . style . transform = "translate(" + ( d - b ) + "px," + ( e - c ) + "px)" ; return ! ! a . arrowAtTop } ;
Blockly . DropDownDiv . repositionForWindowResize = function ( ) { if ( Blockly . DropDownDiv . owner _ ) { var a = Blockly . DropDownDiv . owner _ , b = a . getSourceBlock ( ) ; a = Blockly . DropDownDiv . positionToField _ ? Blockly . DropDownDiv . getScaledBboxOfField _ ( a ) : Blockly . DropDownDiv . getScaledBboxOfBlock _ ( b ) ; b = a . left + ( a . right - a . left ) / 2 ; Blockly . DropDownDiv . positionInternal _ ( b , a . bottom , b , a . top ) } else Blockly . DropDownDiv . hide ( ) } ; Blockly . registry = { } ; Blockly . registry . typeMap _ = Object . create ( null ) ; Blockly . registry . DEFAULT = "default" ; Blockly . registry . Type = function ( a ) { this . name _ = a } ; Blockly . registry . Type . prototype . toString = function ( ) { return this . name _ } ; Blockly . registry . Type . CONNECTION _CHECKER = new Blockly . registry . Type ( "connectionChecker" ) ; Blockly . registry . Type . CURSOR = new Blockly . registry . Type ( "cursor" ) ; Blockly . registry . Type . EVENT = new Blockly . registry . Type ( "event" ) ; Blockly . registry . Type . FIELD = new Blockly . registry . Type ( "field" ) ;
2021-05-19 13:38:55 +00:00
Blockly . registry . Type . RENDERER = new Blockly . registry . Type ( "renderer" ) ; Blockly . registry . Type . TOOLBOX = new Blockly . registry . Type ( "toolbox" ) ; Blockly . registry . Type . THEME = new Blockly . registry . Type ( "theme" ) ; Blockly . registry . Type . TOOLBOX _ITEM = new Blockly . registry . Type ( "toolboxItem" ) ; Blockly . registry . Type . FLYOUTS _VERTICAL _TOOLBOX = new Blockly . registry . Type ( "flyoutsVerticalToolbox" ) ; Blockly . registry . Type . FLYOUTS _HORIZONTAL _TOOLBOX = new Blockly . registry . Type ( "flyoutsHorizontalToolbox" ) ;
2021-09-18 14:29:06 +00:00
Blockly . registry . Type . METRICS _MANAGER = new Blockly . registry . Type ( "metricsManager" ) ; Blockly . registry . Type . BLOCK _DRAGGER = new Blockly . registry . Type ( "blockDragger" ) ;
2021-05-19 13:38:55 +00:00
Blockly . registry . register = function ( a , b , c , d ) { if ( ! ( a instanceof Blockly . registry . Type ) && "string" != typeof a || "" == String ( a ) . trim ( ) ) throw Error ( 'Invalid type "' + a + '". The type must be a non-empty string or a Blockly.registry.Type.' ) ; a = String ( a ) . toLowerCase ( ) ; if ( "string" != typeof b || "" == b . trim ( ) ) throw Error ( 'Invalid name "' + b + '". The name must be a non-empty string.' ) ; b = b . toLowerCase ( ) ; if ( ! c ) throw Error ( "Can not register a null value" ) ; var e = Blockly . registry . typeMap _ [ a ] ; e || ( e = Blockly . registry . typeMap _ [ a ] =
2021-09-18 14:29:06 +00:00
Object . create ( null ) ) ; Blockly . registry . validate _ ( a , c ) ; if ( ! d && e [ b ] ) throw Error ( 'Name "' + b + '" with type "' + a + '" already registered.' ) ; e [ b ] = c } ; Blockly . registry . validate _ = function ( a , b ) { switch ( a ) { case String ( Blockly . registry . Type . FIELD ) : if ( "function" != typeof b . fromJson ) throw Error ( 'Type "' + a + '" must have a fromJson function' ) ; } } ;
2021-05-19 13:38:55 +00:00
Blockly . registry . unregister = function ( a , b ) { a = String ( a ) . toLowerCase ( ) ; b = b . toLowerCase ( ) ; var c = Blockly . registry . typeMap _ [ a ] ; c && c [ b ] ? delete Blockly . registry . typeMap _ [ a ] [ b ] : console . warn ( "Unable to unregister [" + b + "][" + a + "] from the registry." ) } ;
Blockly . registry . getItem _ = function ( a , b , c ) { a = String ( a ) . toLowerCase ( ) ; b = b . toLowerCase ( ) ; var d = Blockly . registry . typeMap _ [ a ] ; if ( ! d || ! d [ b ] ) { b = "Unable to find [" + b + "][" + a + "] in the registry." ; if ( c ) throw Error ( b + " You must require or register a " + a + " plugin." ) ; console . warn ( b ) ; return null } return d [ b ] } ; Blockly . registry . hasItem = function ( a , b ) { a = String ( a ) . toLowerCase ( ) ; b = b . toLowerCase ( ) ; return ( a = Blockly . registry . typeMap _ [ a ] ) ? ! ! a [ b ] : ! 1 } ;
Blockly . registry . getClass = function ( a , b , c ) { return Blockly . registry . getItem _ ( a , b , c ) } ; Blockly . registry . getObject = function ( a , b , c ) { return Blockly . registry . getItem _ ( a , b , c ) } ; Blockly . registry . getClassFromOptions = function ( a , b , c ) { b = b . plugins [ a . toString ( ) ] || Blockly . registry . DEFAULT ; return "function" == typeof b ? b : Blockly . registry . getClass ( a , b , c ) } ; Blockly . Events = { } ; Blockly . Events . group _ = "" ; Blockly . Events . recordUndo = ! 0 ; Blockly . Events . disabled _ = 0 ; Blockly . Events . CREATE = "create" ; Blockly . Events . BLOCK _CREATE = Blockly . Events . CREATE ; Blockly . Events . DELETE = "delete" ; Blockly . Events . BLOCK _DELETE = Blockly . Events . DELETE ; Blockly . Events . CHANGE = "change" ; Blockly . Events . BLOCK _CHANGE = Blockly . Events . CHANGE ; Blockly . Events . MOVE = "move" ; Blockly . Events . BLOCK _MOVE = Blockly . Events . MOVE ; Blockly . Events . VAR _CREATE = "var_create" ; Blockly . Events . VAR _DELETE = "var_delete" ;
2021-01-16 14:07:51 +00:00
Blockly . Events . VAR _RENAME = "var_rename" ; Blockly . Events . UI = "ui" ; Blockly . Events . BLOCK _DRAG = "drag" ; Blockly . Events . SELECTED = "selected" ; Blockly . Events . CLICK = "click" ; Blockly . Events . MARKER _MOVE = "marker_move" ; Blockly . Events . BUBBLE _OPEN = "bubble_open" ; Blockly . Events . TRASHCAN _OPEN = "trashcan_open" ; Blockly . Events . TOOLBOX _ITEM _SELECT = "toolbox_item_select" ; Blockly . Events . THEME _CHANGE = "theme_change" ; Blockly . Events . VIEWPORT _CHANGE = "viewport_change" ; Blockly . Events . COMMENT _CREATE = "comment_create" ;
Blockly . Events . COMMENT _DELETE = "comment_delete" ; Blockly . Events . COMMENT _CHANGE = "comment_change" ; Blockly . Events . COMMENT _MOVE = "comment_move" ; Blockly . Events . FINISHED _LOADING = "finished_loading" ; Blockly . Events . BUMP _EVENTS = [ Blockly . Events . BLOCK _CREATE , Blockly . Events . BLOCK _MOVE , Blockly . Events . COMMENT _CREATE , Blockly . Events . COMMENT _MOVE ] ; Blockly . Events . FIRE _QUEUE _ = [ ] ; Blockly . Events . fire = function ( a ) { Blockly . Events . isEnabled ( ) && ( Blockly . Events . FIRE _QUEUE _ . length || setTimeout ( Blockly . Events . fireNow _ , 0 ) , Blockly . Events . FIRE _QUEUE _ . push ( a ) ) } ;
Blockly . Events . fireNow _ = function ( ) { for ( var a = Blockly . Events . filter ( Blockly . Events . FIRE _QUEUE _ , ! 0 ) , b = Blockly . Events . FIRE _QUEUE _ . length = 0 , c ; c = a [ b ] ; b ++ ) if ( c . workspaceId ) { var d = Blockly . Workspace . getById ( c . workspaceId ) ; d && d . fireChangeListener ( c ) } } ;
Blockly . Events . filter = function ( a , b ) { a = a . slice ( ) ; b || a . reverse ( ) ; for ( var c = [ ] , d = Object . create ( null ) , e = 0 , f ; f = a [ e ] ; e ++ ) if ( ! f . isNull ( ) ) { var g = [ f . isUiEvent ? Blockly . Events . UI : f . type , f . blockId , f . workspaceId ] . join ( " " ) , h = d [ g ] , k = h ? h . event : null ; if ( ! h ) d [ g ] = { event : f , index : e } , c . push ( f ) ; else if ( f . type == Blockly . Events . MOVE && h . index == e - 1 ) k . newParentId = f . newParentId , k . newInputName = f . newInputName , k . newCoordinate = f . newCoordinate , h . index = e ; else if ( f . type == Blockly . Events . CHANGE && f . element == k . element && f . name == k . name ) k . newValue =
2021-09-18 14:29:06 +00:00
f . newValue ; else if ( f . type == Blockly . Events . VIEWPORT _CHANGE ) k . viewTop = f . viewTop , k . viewLeft = f . viewLeft , k . scale = f . scale , k . oldScale = f . oldScale ; else if ( f . type != Blockly . Events . CLICK || k . type != Blockly . Events . BUBBLE _OPEN ) d [ g ] = { event : f , index : e } , c . push ( f ) } a = c . filter ( function ( l ) { return ! l . isNull ( ) } ) ; b || a . reverse ( ) ; for ( e = 1 ; f = a [ e ] ; e ++ ) f . type == Blockly . Events . CHANGE && "mutation" == f . element && a . unshift ( a . splice ( e , 1 ) [ 0 ] ) ; return a } ;
Blockly . Events . clearPendingUndo = function ( ) { for ( var a = 0 , b ; b = Blockly . Events . FIRE _QUEUE _ [ a ] ; a ++ ) b . recordUndo = ! 1 } ; Blockly . Events . disable = function ( ) { Blockly . Events . disabled _ ++ } ; Blockly . Events . enable = function ( ) { Blockly . Events . disabled _ -- } ; Blockly . Events . isEnabled = function ( ) { return 0 == Blockly . Events . disabled _ } ; Blockly . Events . getGroup = function ( ) { return Blockly . Events . group _ } ; Blockly . Events . setGroup = function ( a ) { Blockly . Events . group _ = "boolean" == typeof a ? a ? Blockly . utils . genUid ( ) : "" : a } ;
Blockly . Events . getDescendantIds = function ( a ) { var b = [ ] ; a = a . getDescendants ( ! 1 ) ; for ( var c = 0 , d ; d = a [ c ] ; c ++ ) b [ c ] = d . id ; return b } ; Blockly . Events . fromJson = function ( a , b ) { var c = Blockly . Events . get ( a . type ) ; if ( ! c ) throw Error ( "Unknown event type." ) ; c = new c ; c . fromJson ( a ) ; c . workspaceId = b . id ; return c } ; Blockly . Events . get = function ( a ) { return Blockly . registry . getClass ( Blockly . registry . Type . EVENT , a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Events . disableOrphans = function ( a ) { if ( ( a . type == Blockly . Events . MOVE || a . type == Blockly . Events . CREATE ) && a . workspaceId ) { var b = Blockly . Workspace . getById ( a . workspaceId ) , c = b . getBlockById ( a . blockId ) ; if ( c ) { a = Blockly . Events . recordUndo ; try { Blockly . Events . recordUndo = ! 1 ; var d = c . getParent ( ) ; if ( d && d . isEnabled ( ) ) { var e = c . getDescendants ( ! 1 ) ; b = 0 ; for ( var f ; f = e [ b ] ; b ++ ) f . setEnabled ( ! 0 ) } else if ( ( c . outputConnection || c . previousConnection ) && ! b . isDragging ( ) ) { do c . setEnabled ( ! 1 ) , c = c . getNextBlock ( ) ; while ( c ) } } finally { Blockly . Events . recordUndo =
a } } } } ; Blockly . Events . Abstract = function ( ) { this . isBlank = null ; this . workspaceId = void 0 ; this . group = Blockly . Events . getGroup ( ) ; this . recordUndo = Blockly . Events . recordUndo } ; Blockly . Events . Abstract . prototype . isUiEvent = ! 1 ; Blockly . Events . Abstract . prototype . toJson = function ( ) { var a = { type : this . type } ; this . group && ( a . group = this . group ) ; return a } ; Blockly . Events . Abstract . prototype . fromJson = function ( a ) { this . isBlank = ! 1 ; this . group = a . group } ; Blockly . Events . Abstract . prototype . isNull = function ( ) { return ! 1 } ;
2021-05-19 13:38:55 +00:00
Blockly . Events . Abstract . prototype . run = function ( a ) { } ; Blockly . Events . Abstract . prototype . getEventWorkspace _ = function ( ) { if ( this . workspaceId ) var a = Blockly . Workspace . getById ( this . workspaceId ) ; if ( ! a ) throw Error ( "Workspace is null. Event must have been generated from real Blockly events." ) ; return a } ; Blockly . utils . object = { } ; Blockly . utils . object . inherits = function ( a , b ) { a . superClass _ = b . prototype ; a . prototype = Object . create ( b . prototype ) ; a . prototype . constructor = a } ; Blockly . utils . object . mixin = function ( a , b ) { for ( var c in b ) a [ c ] = b [ c ] } ; Blockly . utils . object . deepMerge = function ( a , b ) { for ( var c in b ) a [ c ] = null != b [ c ] && "object" === typeof b [ c ] ? Blockly . utils . object . deepMerge ( a [ c ] || Object . create ( null ) , b [ c ] ) : b [ c ] ; return a } ; Blockly . utils . object . values = function ( a ) { return Object . values ? Object . values ( a ) : Object . keys ( a ) . map ( function ( b ) { return a [ b ] } ) } ; Blockly . utils . xml = { } ; Blockly . utils . xml . NAME _SPACE = "https://developers.google.com/blockly/xml" ; Blockly . utils . xml . document = function ( ) { return document } ; Blockly . utils . xml . createElement = function ( a ) { return Blockly . utils . xml . document ( ) . createElementNS ( Blockly . utils . xml . NAME _SPACE , a ) } ; Blockly . utils . xml . createTextNode = function ( a ) { return Blockly . utils . xml . document ( ) . createTextNode ( a ) } ; Blockly . utils . xml . textToDomDocument = function ( a ) { return ( new DOMParser ) . parseFromString ( a , "text/xml" ) } ;
2021-09-18 14:29:06 +00:00
Blockly . utils . xml . domToText = function ( a ) { return ( new XMLSerializer ) . serializeToString ( a ) } ; Blockly . inputTypes = { VALUE : Blockly . connectionTypes . INPUT _VALUE , STATEMENT : Blockly . connectionTypes . NEXT _STATEMENT , DUMMY : 5 } ; Blockly . Xml = { } ; Blockly . Xml . workspaceToDom = function ( a , b ) { var c = Blockly . utils . xml . createElement ( "xml" ) , d = Blockly . Xml . variablesToDom ( Blockly . Variables . allUsedVarModels ( a ) ) ; d . hasChildNodes ( ) && c . appendChild ( d ) ; var e = a . getTopComments ( ! 0 ) ; d = 0 ; for ( var f ; f = e [ d ] ; d ++ ) c . appendChild ( f . toXmlWithXY ( b ) ) ; a = a . getTopBlocks ( ! 0 ) ; for ( d = 0 ; e = a [ d ] ; d ++ ) c . appendChild ( Blockly . Xml . blockToDomWithXY ( e , b ) ) ; return c } ;
2021-05-19 13:38:55 +00:00
Blockly . Xml . variablesToDom = function ( a ) { for ( var b = Blockly . utils . xml . createElement ( "variables" ) , c = 0 , d ; d = a [ c ] ; c ++ ) { var e = Blockly . utils . xml . createElement ( "variable" ) ; e . appendChild ( Blockly . utils . xml . createTextNode ( d . name ) ) ; d . type && e . setAttribute ( "type" , d . type ) ; e . id = d . getId ( ) ; b . appendChild ( e ) } return b } ;
Blockly . Xml . blockToDomWithXY = function ( a , b ) { if ( a . isInsertionMarker ( ) && ( a = a . getChildren ( ! 1 ) [ 0 ] , ! a ) ) return new DocumentFragment ; var c ; a . workspace . RTL && ( c = a . workspace . getWidth ( ) ) ; b = Blockly . Xml . blockToDom ( a , b ) ; var d = a . getRelativeToSurfaceXY ( ) ; b . setAttribute ( "x" , Math . round ( a . workspace . RTL ? c - d . x : d . x ) ) ; b . setAttribute ( "y" , Math . round ( d . y ) ) ; return b } ; Blockly . Xml . fieldToDom _ = function ( a ) { if ( a . isSerializable ( ) ) { var b = Blockly . utils . xml . createElement ( "field" ) ; b . setAttribute ( "name" , a . name || "" ) ; return a . toXml ( b ) } return null } ;
Blockly . Xml . allFieldsToDom _ = function ( a , b ) { for ( var c = 0 , d ; d = a . inputList [ c ] ; c ++ ) for ( var e = 0 , f ; f = d . fieldRow [ e ] ; e ++ ) ( f = Blockly . Xml . fieldToDom _ ( f ) ) && b . appendChild ( f ) } ;
Blockly . Xml . blockToDom = function ( a , b ) { if ( a . isInsertionMarker ( ) ) return ( a = a . getChildren ( ! 1 ) [ 0 ] ) ? Blockly . Xml . blockToDom ( a ) : new DocumentFragment ; var c = Blockly . utils . xml . createElement ( a . isShadow ( ) ? "shadow" : "block" ) ; c . setAttribute ( "type" , a . type ) ; b || c . setAttribute ( "id" , a . id ) ; if ( a . mutationToDom ) { var d = a . mutationToDom ( ) ; d && ( d . hasChildNodes ( ) || d . hasAttributes ( ) ) && c . appendChild ( d ) } Blockly . Xml . allFieldsToDom _ ( a , c ) ; if ( d = a . getCommentText ( ) ) { var e = a . commentModel . size , f = a . commentModel . pinned , g = Blockly . utils . xml . createElement ( "comment" ) ;
g . appendChild ( Blockly . utils . xml . createTextNode ( d ) ) ; g . setAttribute ( "pinned" , f ) ; g . setAttribute ( "h" , e . height ) ; g . setAttribute ( "w" , e . width ) ; c . appendChild ( g ) } a . data && ( d = Blockly . utils . xml . createElement ( "data" ) , d . appendChild ( Blockly . utils . xml . createTextNode ( a . data ) ) , c . appendChild ( d ) ) ; for ( d = 0 ; e = a . inputList [ d ] ; d ++ ) { var h ; f = ! 0 ; if ( e . type != Blockly . inputTypes . DUMMY ) { var k = e . connection . targetBlock ( ) ; e . type == Blockly . inputTypes . VALUE ? h = Blockly . utils . xml . createElement ( "value" ) : e . type == Blockly . inputTypes . STATEMENT &&
( h = Blockly . utils . xml . createElement ( "statement" ) ) ; g = e . connection . getShadowDom ( ) ; ! g || k && k . isShadow ( ) || h . appendChild ( Blockly . Xml . cloneShadow _ ( g , b ) ) ; k && ( g = Blockly . Xml . blockToDom ( k , b ) , g . nodeType == Blockly . utils . dom . NodeType . ELEMENT _NODE && ( h . appendChild ( g ) , f = ! 1 ) ) ; h . setAttribute ( "name" , e . name ) ; f || c . appendChild ( h ) } } void 0 != a . inputsInline && a . inputsInline != a . inputsInlineDefault && c . setAttribute ( "inline" , a . inputsInline ) ; a . isCollapsed ( ) && c . setAttribute ( "collapsed" , ! 0 ) ; a . isEnabled ( ) || c . setAttribute ( "disabled" , ! 0 ) ;
a . isDeletable ( ) || a . isShadow ( ) || c . setAttribute ( "deletable" , ! 1 ) ; a . isMovable ( ) || a . isShadow ( ) || c . setAttribute ( "movable" , ! 1 ) ; a . isEditable ( ) || c . setAttribute ( "editable" , ! 1 ) ; if ( d = a . getNextBlock ( ) ) g = Blockly . Xml . blockToDom ( d , b ) , g . nodeType == Blockly . utils . dom . NodeType . ELEMENT _NODE && ( h = Blockly . utils . xml . createElement ( "next" ) , h . appendChild ( g ) , c . appendChild ( h ) ) ; g = a . nextConnection && a . nextConnection . getShadowDom ( ) ; ! g || d && d . isShadow ( ) || h . appendChild ( Blockly . Xml . cloneShadow _ ( g , b ) ) ; return c } ;
Blockly . Xml . cloneShadow _ = function ( a , b ) { for ( var c = a = a . cloneNode ( ! 0 ) , d ; c ; ) if ( b && "shadow" == c . nodeName && c . removeAttribute ( "id" ) , c . firstChild ) c = c . firstChild ; else { for ( ; c && ! c . nextSibling ; ) d = c , c = c . parentNode , d . nodeType == Blockly . utils . dom . NodeType . TEXT _NODE && "" == d . data . trim ( ) && c . firstChild != d && Blockly . utils . dom . removeNode ( d ) ; c && ( d = c , c = c . nextSibling , d . nodeType == Blockly . utils . dom . NodeType . TEXT _NODE && "" == d . data . trim ( ) && Blockly . utils . dom . removeNode ( d ) ) } return a } ;
Blockly . Xml . domToText = function ( a ) { return Blockly . utils . xml . domToText ( a ) . replace ( /<(\w+)([^<]*)\/>/g , "<$1$2></$1>" ) } ; Blockly . Xml . domToPrettyText = function ( a ) { a = Blockly . Xml . domToText ( a ) . split ( "<" ) ; for ( var b = "" , c = 1 ; c < a . length ; c ++ ) { var d = a [ c ] ; "/" == d [ 0 ] && ( b = b . substring ( 2 ) ) ; a [ c ] = b + "<" + d ; "/" != d [ 0 ] && "/>" != d . slice ( - 2 ) && ( b += " " ) } a = a . join ( "\n" ) ; a = a . replace ( /(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g , "$1</$2>" ) ; return a . replace ( /^\n/ , "" ) } ;
Blockly . Xml . textToDom = function ( a ) { var b = Blockly . utils . xml . textToDomDocument ( a ) ; if ( ! b || ! b . documentElement || b . getElementsByTagName ( "parsererror" ) . length ) throw Error ( "textToDom was unable to parse: " + a ) ; return b . documentElement } ; Blockly . Xml . clearWorkspaceAndLoadFromXml = function ( a , b ) { b . setResizesEnabled ( ! 1 ) ; b . clear ( ) ; a = Blockly . Xml . domToWorkspace ( a , b ) ; b . setResizesEnabled ( ! 0 ) ; return a } ;
Blockly . Xml . domToWorkspace = function ( a , b ) { if ( a instanceof Blockly . Workspace ) { var c = a ; a = b ; b = c ; console . warn ( "Deprecated call to Blockly.Xml.domToWorkspace, swap the arguments." ) } var d ; b . RTL && ( d = b . getWidth ( ) ) ; c = [ ] ; Blockly . utils . dom . startTextWidthCache ( ) ; var e = Blockly . Events . getGroup ( ) ; e || Blockly . Events . setGroup ( ! 0 ) ; b . setResizesEnabled && b . setResizesEnabled ( ! 1 ) ; var f = ! 0 ; try { for ( var g = 0 , h ; h = a . childNodes [ g ] ; g ++ ) { var k = h . nodeName . toLowerCase ( ) , l = h ; if ( "block" == k || "shadow" == k && ! Blockly . Events . recordUndo ) { var m =
Blockly . Xml . domToBlock ( l , b ) ; c . push ( m . id ) ; var n = l . hasAttribute ( "x" ) ? parseInt ( l . getAttribute ( "x" ) , 10 ) : 10 , p = l . hasAttribute ( "y" ) ? parseInt ( l . getAttribute ( "y" ) , 10 ) : 10 ; isNaN ( n ) || isNaN ( p ) || m . moveBy ( b . RTL ? d - n : n , p ) ; f = ! 1 } else { if ( "shadow" == k ) throw TypeError ( "Shadow block cannot be a top-level block." ) ; if ( "comment" == k ) b . rendered ? Blockly . WorkspaceCommentSvg ? Blockly . WorkspaceCommentSvg . fromXml ( l , b , d ) : console . warn ( "Missing require for Blockly.WorkspaceCommentSvg, ignoring workspace comment." ) : Blockly . WorkspaceComment ?
Blockly . WorkspaceComment . fromXml ( l , b ) : console . warn ( "Missing require for Blockly.WorkspaceComment, ignoring workspace comment." ) ; else if ( "variables" == k ) { if ( f ) Blockly . Xml . domToVariables ( l , b ) ; else throw Error ( "'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location." ) ; f = ! 1 } } } } finally { e || Blockly . Events . setGroup ( ! 1 ) , Blockly . utils . dom . stopTextWidthCache ( ) } b . setResizesEnabled && b . setResizesEnabled ( ! 0 ) ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . FINISHED _LOADING ) ) ( b ) ) ;
return c } ; Blockly . Xml . appendDomToWorkspace = function ( a , b ) { var c ; Object . prototype . hasOwnProperty . call ( b , "scale" ) && ( c = b . getBlocksBoundingBox ( ) ) ; a = Blockly . Xml . domToWorkspace ( a , b ) ; if ( c && c . top != c . bottom ) { var d = c . bottom ; var e = b . RTL ? c . right : c . left ; var f = Infinity , g = - Infinity , h = Infinity ; for ( c = 0 ; c < a . length ; c ++ ) { var k = b . getBlockById ( a [ c ] ) . getRelativeToSurfaceXY ( ) ; k . y < h && ( h = k . y ) ; k . x < f && ( f = k . x ) ; k . x > g && ( g = k . x ) } d = d - h + 10 ; e = b . RTL ? e - g : e - f ; for ( c = 0 ; c < a . length ; c ++ ) b . getBlockById ( a [ c ] ) . moveBy ( e , d ) } return a } ;
Blockly . Xml . domToBlock = function ( a , b ) { if ( a instanceof Blockly . Workspace ) { var c = a ; a = b ; b = c ; console . warn ( "Deprecated call to Blockly.Xml.domToBlock, swap the arguments." ) } Blockly . Events . disable ( ) ; c = b . getAllVariables ( ) ; try { var d = Blockly . Xml . domToBlockHeadless _ ( a , b ) , e = d . getDescendants ( ! 1 ) ; if ( b . rendered ) { d . setConnectionTracking ( ! 1 ) ; for ( var f = e . length - 1 ; 0 <= f ; f -- ) e [ f ] . initSvg ( ) ; for ( f = e . length - 1 ; 0 <= f ; f -- ) e [ f ] . render ( ! 1 ) ; setTimeout ( function ( ) { d . disposed || d . setConnectionTracking ( ! 0 ) } , 1 ) ; d . updateDisabled ( ) ; b . resizeContents ( ) } else for ( f =
e . length - 1 ; 0 <= f ; f -- ) e [ f ] . initModel ( ) } finally { Blockly . Events . enable ( ) } if ( Blockly . Events . isEnabled ( ) ) { a = Blockly . Variables . getAddedVariables ( b , c ) ; for ( f = 0 ; f < a . length ; f ++ ) b = a [ f ] , Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _CREATE ) ) ( b ) ) ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . CREATE ) ) ( d ) ) } return d } ;
Blockly . Xml . domToVariables = function ( a , b ) { for ( var c = 0 , d ; d = a . childNodes [ c ] ; c ++ ) if ( d . nodeType == Blockly . utils . dom . NodeType . ELEMENT _NODE ) { var e = d . getAttribute ( "type" ) , f = d . getAttribute ( "id" ) ; b . createVariable ( d . textContent , e , f ) } } ;
Blockly . Xml . mapSupportedXmlTags _ = function ( a ) { for ( var b = { mutation : [ ] , comment : [ ] , data : [ ] , field : [ ] , input : [ ] , next : [ ] } , c = 0 , d ; d = a . childNodes [ c ] ; c ++ ) if ( d . nodeType != Blockly . utils . dom . NodeType . TEXT _NODE ) switch ( d . nodeName . toLowerCase ( ) ) { case "mutation" : b . mutation . push ( d ) ; break ; case "comment" : if ( ! Blockly . Comment ) { console . warn ( "Missing require for Blockly.Comment, ignoring block comment." ) ; break } b . comment . push ( d ) ; break ; case "data" : b . data . push ( d ) ; break ; case "title" : case "field" : b . field . push ( d ) ; break ; case "value" : case "statement" : b . input . push ( d ) ;
break ; case "next" : b . next . push ( d ) ; break ; default : console . warn ( "Ignoring unknown tag: " + d . nodeName ) } return b } ; Blockly . Xml . applyMutationTagNodes _ = function ( a , b ) { for ( var c = ! 1 , d = 0 , e ; e = a [ d ] ; d ++ ) b . domToMutation && ( b . domToMutation ( e ) , b . initSvg && ( c = ! 0 ) ) ; return c } ;
Blockly . Xml . applyCommentTagNodes _ = function ( a , b ) { for ( var c = 0 , d ; d = a [ c ] ; c ++ ) { var e = d . textContent , f = "true" == d . getAttribute ( "pinned" ) , g = parseInt ( d . getAttribute ( "w" ) , 10 ) ; d = parseInt ( d . getAttribute ( "h" ) , 10 ) ; b . setCommentText ( e ) ; b . commentModel . pinned = f ; isNaN ( g ) || isNaN ( d ) || ( b . commentModel . size = new Blockly . utils . Size ( g , d ) ) ; f && b . getCommentIcon && ! b . isInFlyout && setTimeout ( function ( ) { b . getCommentIcon ( ) . setVisible ( ! 0 ) } , 1 ) } } ; Blockly . Xml . applyDataTagNodes _ = function ( a , b ) { for ( var c = 0 , d ; d = a [ c ] ; c ++ ) b . data = d . textContent } ;
Blockly . Xml . applyFieldTagNodes _ = function ( a , b ) { for ( var c = 0 , d ; d = a [ c ] ; c ++ ) { var e = d . getAttribute ( "name" ) ; Blockly . Xml . domToField _ ( b , e , d ) } } ; Blockly . Xml . findChildBlocks _ = function ( a ) { for ( var b = { childBlockElement : null , childShadowElement : null } , c = 0 , d ; d = a . childNodes [ c ] ; c ++ ) d . nodeType == Blockly . utils . dom . NodeType . ELEMENT _NODE && ( "block" == d . nodeName . toLowerCase ( ) ? b . childBlockElement = d : "shadow" == d . nodeName . toLowerCase ( ) && ( b . childShadowElement = d ) ) ; return b } ;
Blockly . Xml . applyInputTagNodes _ = function ( a , b , c , d ) { for ( var e = 0 , f ; f = a [ e ] ; e ++ ) { var g = f . getAttribute ( "name" ) , h = c . getInput ( g ) ; if ( ! h ) { console . warn ( "Ignoring non-existent input " + g + " in block " + d ) ; break } f = Blockly . Xml . findChildBlocks _ ( f ) ; if ( f . childBlockElement ) { if ( ! h . connection ) throw TypeError ( "Input connection does not exist." ) ; Blockly . Xml . domToBlockHeadless _ ( f . childBlockElement , b , h . connection , ! 1 ) } f . childShadowElement && h . connection . setShadowDom ( f . childShadowElement ) } } ;
Blockly . Xml . applyNextTagNodes _ = function ( a , b , c ) { for ( var d = 0 , e ; e = a [ d ] ; d ++ ) { e = Blockly . Xml . findChildBlocks _ ( e ) ; if ( e . childBlockElement ) { if ( ! c . nextConnection ) throw TypeError ( "Next statement does not exist." ) ; if ( c . nextConnection . isConnected ( ) ) throw TypeError ( "Next statement is already connected." ) ; Blockly . Xml . domToBlockHeadless _ ( e . childBlockElement , b , c . nextConnection , ! 0 ) } e . childShadowElement && c . nextConnection && c . nextConnection . setShadowDom ( e . childShadowElement ) } } ;
Blockly . Xml . domToBlockHeadless _ = function ( a , b , c , d ) { var e = a . getAttribute ( "type" ) ; if ( ! e ) throw TypeError ( "Block type unspecified: " + a . outerHTML ) ; var f = a . getAttribute ( "id" ) ; f = b . newBlock ( e , f ) ; var g = Blockly . Xml . mapSupportedXmlTags _ ( a ) , h = Blockly . Xml . applyMutationTagNodes _ ( g . mutation , f ) ; Blockly . Xml . applyCommentTagNodes _ ( g . comment , f ) ; Blockly . Xml . applyDataTagNodes _ ( g . data , f ) ; if ( c ) if ( d ) if ( f . previousConnection ) c . connect ( f . previousConnection ) ; else throw TypeError ( "Next block does not have previous statement." ) ;
else if ( f . outputConnection ) c . connect ( f . outputConnection ) ; else if ( f . previousConnection ) c . connect ( f . previousConnection ) ; else throw TypeError ( "Child block does not have output or previous statement." ) ; Blockly . Xml . applyFieldTagNodes _ ( g . field , f ) ; Blockly . Xml . applyInputTagNodes _ ( g . input , b , f , e ) ; Blockly . Xml . applyNextTagNodes _ ( g . next , b , f ) ; h && f . initSvg ( ) ; ( b = a . getAttribute ( "inline" ) ) && f . setInputsInline ( "true" == b ) ; ( b = a . getAttribute ( "disabled" ) ) && f . setEnabled ( "true" != b && "disabled" != b ) ; ( b = a . getAttribute ( "deletable" ) ) &&
f . setDeletable ( "true" == b ) ; ( b = a . getAttribute ( "movable" ) ) && f . setMovable ( "true" == b ) ; ( b = a . getAttribute ( "editable" ) ) && f . setEditable ( "true" == b ) ; ( b = a . getAttribute ( "collapsed" ) ) && f . setCollapsed ( "true" == b ) ; if ( "shadow" == a . nodeName . toLowerCase ( ) ) { a = f . getChildren ( ! 1 ) ; for ( b = 0 ; c = a [ b ] ; b ++ ) if ( ! c . isShadow ( ) ) throw TypeError ( "Shadow block not allowed non-shadow child." ) ; if ( f . getVarModels ( ) . length ) throw TypeError ( "Shadow blocks cannot have variable references." ) ; f . setShadow ( ! 0 ) } return f } ;
Blockly . Xml . domToField _ = function ( a , b , c ) { var d = a . getField ( b ) ; d ? d . fromXml ( c ) : console . warn ( "Ignoring non-existent field " + b + " in block " + a . type ) } ; Blockly . Xml . deleteNext = function ( a ) { for ( var b = 0 , c ; c = a . childNodes [ b ] ; b ++ ) if ( "next" == c . nodeName . toLowerCase ( ) ) { a . removeChild ( c ) ; break } } ; Blockly . Events . BlockBase = function ( a ) { Blockly . Events . BlockBase . superClass _ . constructor . call ( this ) ; this . blockId = ( this . isBlank = "undefined" == typeof a ) ? "" : a . id ; this . workspaceId = this . isBlank ? "" : a . workspace . id } ; Blockly . utils . object . inherits ( Blockly . Events . BlockBase , Blockly . Events . Abstract ) ; Blockly . Events . BlockBase . prototype . toJson = function ( ) { var a = Blockly . Events . BlockBase . superClass _ . toJson . call ( this ) ; a . blockId = this . blockId ; return a } ;
2021-09-18 14:29:06 +00:00
Blockly . Events . BlockBase . prototype . fromJson = function ( a ) { Blockly . Events . BlockBase . superClass _ . fromJson . call ( this , a ) ; this . blockId = a . blockId } ; Blockly . Events . BlockChange = function ( a , b , c , d , e ) { Blockly . Events . Change . superClass _ . constructor . call ( this , a ) ; a && ( this . element = "undefined" == typeof b ? "" : b , this . name = "undefined" == typeof c ? "" : c , this . oldValue = "undefined" == typeof d ? "" : d , this . newValue = "undefined" == typeof e ? "" : e ) } ; Blockly . utils . object . inherits ( Blockly . Events . BlockChange , Blockly . Events . BlockBase ) ;
Blockly . Events . Change = Blockly . Events . BlockChange ; Blockly . Events . BlockChange . prototype . type = Blockly . Events . CHANGE ; Blockly . Events . BlockChange . prototype . toJson = function ( ) { var a = Blockly . Events . BlockChange . superClass _ . toJson . call ( this ) ; a . element = this . element ; this . name && ( a . name = this . name ) ; a . oldValue = this . oldValue ; a . newValue = this . newValue ; return a } ;
Blockly . Events . BlockChange . prototype . fromJson = function ( a ) { Blockly . Events . BlockChange . superClass _ . fromJson . call ( this , a ) ; this . element = a . element ; this . name = a . name ; this . oldValue = a . oldValue ; this . newValue = a . newValue } ; Blockly . Events . BlockChange . prototype . isNull = function ( ) { return this . oldValue == this . newValue } ;
Blockly . Events . BlockChange . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) . getBlockById ( this . blockId ) ; if ( b ) switch ( b . mutator && b . mutator . setVisible ( ! 1 ) , a = a ? this . newValue : this . oldValue , this . element ) { case "field" : ( b = b . getField ( this . name ) ) ? b . setValue ( a ) : console . warn ( "Can't set non-existent field: " + this . name ) ; break ; case "comment" : b . setCommentText ( a || null ) ; break ; case "collapsed" : b . setCollapsed ( ! ! a ) ; break ; case "disabled" : b . setEnabled ( ! a ) ; break ; case "inline" : b . setInputsInline ( ! ! a ) ; break ; case "mutation" : var c =
"" ; b . mutationToDom && ( c = ( c = b . mutationToDom ( ) ) && Blockly . Xml . domToText ( c ) ) ; if ( b . domToMutation ) { var d = Blockly . Xml . textToDom ( a || "<mutation/>" ) ; b . domToMutation ( d ) } Blockly . Events . fire ( new Blockly . Events . BlockChange ( b , "mutation" , null , c , a ) ) ; break ; default : console . warn ( "Unknown change type: " + this . element ) } else console . warn ( "Can't change non-existent block: " + this . blockId ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Events . Create = function ( a ) { Blockly . Events . Create . superClass _ . constructor . call ( this , a ) ; a && ( a . isShadow ( ) && ( this . recordUndo = ! 1 ) , this . xml = a . workspace . rendered ? Blockly . Xml . blockToDomWithXY ( a ) : Blockly . Xml . blockToDom ( a ) , this . ids = Blockly . Events . getDescendantIds ( a ) ) } ; Blockly . utils . object . inherits ( Blockly . Events . Create , Blockly . Events . BlockBase ) ; Blockly . Events . BlockCreate = Blockly . Events . Create ; Blockly . Events . Create . prototype . type = Blockly . Events . CREATE ;
Blockly . Events . Create . prototype . toJson = function ( ) { var a = Blockly . Events . Create . superClass _ . toJson . call ( this ) ; a . xml = Blockly . Xml . domToText ( this . xml ) ; a . ids = this . ids ; this . recordUndo || ( a . recordUndo = this . recordUndo ) ; return a } ; Blockly . Events . Create . prototype . fromJson = function ( a ) { Blockly . Events . Create . superClass _ . fromJson . call ( this , a ) ; this . xml = Blockly . Xml . textToDom ( a . xml ) ; this . ids = a . ids ; void 0 !== a . recordUndo && ( this . recordUndo = a . recordUndo ) } ;
Blockly . Events . Create . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) ; if ( a ) a = Blockly . utils . xml . createElement ( "xml" ) , a . appendChild ( this . xml ) , Blockly . Xml . domToWorkspace ( a , b ) ; else { a = 0 ; for ( var c ; c = this . ids [ a ] ; a ++ ) { var d = b . getBlockById ( c ) ; d ? d . dispose ( ! 1 ) : c == this . blockId && console . warn ( "Can't uncreate non-existent block: " + c ) } } } ;
Blockly . Events . Delete = function ( a ) { Blockly . Events . Delete . superClass _ . constructor . call ( this , a ) ; if ( a ) { if ( a . getParent ( ) ) throw Error ( "Connected blocks cannot be deleted." ) ; a . isShadow ( ) && ( this . recordUndo = ! 1 ) ; this . oldXml = a . workspace . rendered ? Blockly . Xml . blockToDomWithXY ( a ) : Blockly . Xml . blockToDom ( a ) ; this . ids = Blockly . Events . getDescendantIds ( a ) } } ; Blockly . utils . object . inherits ( Blockly . Events . Delete , Blockly . Events . BlockBase ) ; Blockly . Events . BlockDelete = Blockly . Events . Delete ;
Blockly . Events . Delete . prototype . type = Blockly . Events . DELETE ; Blockly . Events . Delete . prototype . toJson = function ( ) { var a = Blockly . Events . Delete . superClass _ . toJson . call ( this ) ; a . oldXml = Blockly . Xml . domToText ( this . oldXml ) ; a . ids = this . ids ; this . recordUndo || ( a . recordUndo = this . recordUndo ) ; return a } ; Blockly . Events . Delete . prototype . fromJson = function ( a ) { Blockly . Events . Delete . superClass _ . fromJson . call ( this , a ) ; this . oldXml = Blockly . Xml . textToDom ( a . oldXml ) ; this . ids = a . ids ; void 0 !== a . recordUndo && ( this . recordUndo = a . recordUndo ) } ;
Blockly . Events . Delete . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) ; if ( a ) { a = 0 ; for ( var c ; c = this . ids [ a ] ; a ++ ) { var d = b . getBlockById ( c ) ; d ? d . dispose ( ! 1 ) : c == this . blockId && console . warn ( "Can't delete non-existent block: " + c ) } } else a = Blockly . utils . xml . createElement ( "xml" ) , a . appendChild ( this . oldXml ) , Blockly . Xml . domToWorkspace ( a , b ) } ;
Blockly . Events . Move = function ( a ) { Blockly . Events . Move . superClass _ . constructor . call ( this , a ) ; a && ( a . isShadow ( ) && ( this . recordUndo = ! 1 ) , a = this . currentLocation _ ( ) , this . oldParentId = a . parentId , this . oldInputName = a . inputName , this . oldCoordinate = a . coordinate ) } ; Blockly . utils . object . inherits ( Blockly . Events . Move , Blockly . Events . BlockBase ) ; Blockly . Events . BlockMove = Blockly . Events . Move ; Blockly . Events . Move . prototype . type = Blockly . Events . MOVE ;
Blockly . Events . Move . prototype . toJson = function ( ) { var a = Blockly . Events . Move . superClass _ . toJson . call ( this ) ; this . newParentId && ( a . newParentId = this . newParentId ) ; this . newInputName && ( a . newInputName = this . newInputName ) ; this . newCoordinate && ( a . newCoordinate = Math . round ( this . newCoordinate . x ) + "," + Math . round ( this . newCoordinate . y ) ) ; this . recordUndo || ( a . recordUndo = this . recordUndo ) ; return a } ;
Blockly . Events . Move . prototype . fromJson = function ( a ) { Blockly . Events . Move . superClass _ . fromJson . call ( this , a ) ; this . newParentId = a . newParentId ; this . newInputName = a . newInputName ; if ( a . newCoordinate ) { var b = a . newCoordinate . split ( "," ) ; this . newCoordinate = new Blockly . utils . Coordinate ( Number ( b [ 0 ] ) , Number ( b [ 1 ] ) ) } void 0 !== a . recordUndo && ( this . recordUndo = a . recordUndo ) } ;
Blockly . Events . Move . prototype . recordNew = function ( ) { var a = this . currentLocation _ ( ) ; this . newParentId = a . parentId ; this . newInputName = a . inputName ; this . newCoordinate = a . coordinate } ; Blockly . Events . Move . prototype . currentLocation _ = function ( ) { var a = this . getEventWorkspace _ ( ) . getBlockById ( this . blockId ) , b = { } , c = a . getParent ( ) ; if ( c ) { if ( b . parentId = c . id , a = c . getInputWithBlock ( a ) ) b . inputName = a . name } else b . coordinate = a . getRelativeToSurfaceXY ( ) ; return b } ;
Blockly . Events . Move . prototype . isNull = function ( ) { return this . oldParentId == this . newParentId && this . oldInputName == this . newInputName && Blockly . utils . Coordinate . equals ( this . oldCoordinate , this . newCoordinate ) } ;
Blockly . Events . Move . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) , c = b . getBlockById ( this . blockId ) ; if ( c ) { var d = a ? this . newParentId : this . oldParentId , e = a ? this . newInputName : this . oldInputName , f = a ? this . newCoordinate : this . oldCoordinate ; a = null ; if ( d && ( a = b . getBlockById ( d ) , ! a ) ) { console . warn ( "Can't connect to non-existent block: " + d ) ; return } c . getParent ( ) && c . unplug ( ) ; if ( f ) e = c . getRelativeToSurfaceXY ( ) , c . moveBy ( f . x - e . x , f . y - e . y ) ; else { c = c . outputConnection || c . previousConnection ; b = c . type ; if ( e ) { if ( a = a . getInput ( e ) ) var g =
2021-09-18 14:29:06 +00:00
a . connection } else b == Blockly . connectionTypes . PREVIOUS _STATEMENT && ( g = a . nextConnection ) ; g ? c . connect ( g ) : console . warn ( "Can't connect to non-existent input: " + e ) } } else console . warn ( "Can't move non-existent block: " + this . blockId ) } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . CREATE , Blockly . Events . Create ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . DELETE , Blockly . Events . Delete ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . CHANGE , Blockly . Events . BlockChange ) ;
2021-05-19 13:38:55 +00:00
Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . MOVE , Blockly . Events . Move ) ; Blockly . Events . FinishedLoading = function ( a ) { this . isBlank = "undefined" == typeof a ; this . workspaceId = a ? a . id : "" ; this . group = Blockly . Events . getGroup ( ) ; this . recordUndo = ! 1 } ; Blockly . utils . object . inherits ( Blockly . Events . FinishedLoading , Blockly . Events . Abstract ) ; Blockly . Events . FinishedLoading . prototype . type = Blockly . Events . FINISHED _LOADING ; Blockly . Events . FinishedLoading . prototype . toJson = function ( ) { var a = { type : this . type } ; this . group && ( a . group = this . group ) ; this . workspaceId && ( a . workspaceId = this . workspaceId ) ; return a } ;
Blockly . Events . FinishedLoading . prototype . fromJson = function ( a ) { this . isBlank = ! 1 ; this . workspaceId = a . workspaceId ; this . group = a . group } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . FINISHED _LOADING , Blockly . Events . FinishedLoading ) ; Blockly . Events . UiBase = function ( a ) { Blockly . Events . UiBase . superClass _ . constructor . call ( this ) ; this . isBlank = "undefined" == typeof a ; this . workspaceId = a ? a : "" ; this . recordUndo = ! 1 } ; Blockly . utils . object . inherits ( Blockly . Events . UiBase , Blockly . Events . Abstract ) ; Blockly . Events . UiBase . prototype . isUiEvent = ! 0 ;
Blockly . Events . Ui = function ( a , b , c , d ) { Blockly . Events . Ui . superClass _ . constructor . call ( this , a ? a . workspace . id : void 0 ) ; this . blockId = a ? a . id : null ; this . element = "undefined" == typeof b ? "" : b ; this . oldValue = "undefined" == typeof c ? "" : c ; this . newValue = "undefined" == typeof d ? "" : d } ; Blockly . utils . object . inherits ( Blockly . Events . Ui , Blockly . Events . UiBase ) ; Blockly . Events . Ui . prototype . type = Blockly . Events . UI ;
Blockly . Events . Ui . prototype . toJson = function ( ) { var a = Blockly . Events . Ui . superClass _ . toJson . call ( this ) ; a . element = this . element ; void 0 !== this . newValue && ( a . newValue = this . newValue ) ; this . blockId && ( a . blockId = this . blockId ) ; return a } ; Blockly . Events . Ui . prototype . fromJson = function ( a ) { Blockly . Events . Ui . superClass _ . fromJson . call ( this , a ) ; this . element = a . element ; this . newValue = a . newValue ; this . blockId = a . blockId } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . UI , Blockly . Events . Ui ) ; Blockly . Events . VarBase = function ( a ) { Blockly . Events . VarBase . superClass _ . constructor . call ( this ) ; this . varId = ( this . isBlank = "undefined" == typeof a ) ? "" : a . getId ( ) ; this . workspaceId = this . isBlank ? "" : a . workspace . id } ; Blockly . utils . object . inherits ( Blockly . Events . VarBase , Blockly . Events . Abstract ) ; Blockly . Events . VarBase . prototype . toJson = function ( ) { var a = Blockly . Events . VarBase . superClass _ . toJson . call ( this ) ; a . varId = this . varId ; return a } ;
Blockly . Events . VarBase . prototype . fromJson = function ( a ) { Blockly . Events . VarBase . superClass _ . toJson . call ( this ) ; this . varId = a . varId } ; Blockly . Events . VarCreate = function ( a ) { Blockly . Events . VarCreate . superClass _ . constructor . call ( this , a ) ; a && ( this . varType = a . type , this . varName = a . name ) } ; Blockly . utils . object . inherits ( Blockly . Events . VarCreate , Blockly . Events . VarBase ) ; Blockly . Events . VarCreate . prototype . type = Blockly . Events . VAR _CREATE ;
Blockly . Events . VarCreate . prototype . toJson = function ( ) { var a = Blockly . Events . VarCreate . superClass _ . toJson . call ( this ) ; a . varType = this . varType ; a . varName = this . varName ; return a } ; Blockly . Events . VarCreate . prototype . fromJson = function ( a ) { Blockly . Events . VarCreate . superClass _ . fromJson . call ( this , a ) ; this . varType = a . varType ; this . varName = a . varName } ; Blockly . Events . VarCreate . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) ; a ? b . createVariable ( this . varName , this . varType , this . varId ) : b . deleteVariableById ( this . varId ) } ;
Blockly . Events . VarDelete = function ( a ) { Blockly . Events . VarDelete . superClass _ . constructor . call ( this , a ) ; a && ( this . varType = a . type , this . varName = a . name ) } ; Blockly . utils . object . inherits ( Blockly . Events . VarDelete , Blockly . Events . VarBase ) ; Blockly . Events . VarDelete . prototype . type = Blockly . Events . VAR _DELETE ; Blockly . Events . VarDelete . prototype . toJson = function ( ) { var a = Blockly . Events . VarDelete . superClass _ . toJson . call ( this ) ; a . varType = this . varType ; a . varName = this . varName ; return a } ;
Blockly . Events . VarDelete . prototype . fromJson = function ( a ) { Blockly . Events . VarDelete . superClass _ . fromJson . call ( this , a ) ; this . varType = a . varType ; this . varName = a . varName } ; Blockly . Events . VarDelete . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) ; a ? b . deleteVariableById ( this . varId ) : b . createVariable ( this . varName , this . varType , this . varId ) } ; Blockly . Events . VarRename = function ( a , b ) { Blockly . Events . VarRename . superClass _ . constructor . call ( this , a ) ; a && ( this . oldName = a . name , this . newName = "undefined" == typeof b ? "" : b ) } ;
Blockly . utils . object . inherits ( Blockly . Events . VarRename , Blockly . Events . VarBase ) ; Blockly . Events . VarRename . prototype . type = Blockly . Events . VAR _RENAME ; Blockly . Events . VarRename . prototype . toJson = function ( ) { var a = Blockly . Events . VarRename . superClass _ . toJson . call ( this ) ; a . oldName = this . oldName ; a . newName = this . newName ; return a } ; Blockly . Events . VarRename . prototype . fromJson = function ( a ) { Blockly . Events . VarRename . superClass _ . fromJson . call ( this , a ) ; this . oldName = a . oldName ; this . newName = a . newName } ;
2021-09-18 14:29:06 +00:00
Blockly . Events . VarRename . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) ; a ? b . renameVariableById ( this . varId , this . newName ) : b . renameVariableById ( this . varId , this . oldName ) } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . VAR _CREATE , Blockly . Events . VarCreate ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . VAR _DELETE , Blockly . Events . VarDelete ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . VAR _RENAME , Blockly . Events . VarRename ) ; Blockly . BlockDragSurfaceSvg = function ( a ) { this . container _ = a ; this . createDom ( ) } ; Blockly . BlockDragSurfaceSvg . prototype . SVG _ = null ; Blockly . BlockDragSurfaceSvg . prototype . dragGroup _ = null ; Blockly . BlockDragSurfaceSvg . prototype . container _ = null ; Blockly . BlockDragSurfaceSvg . prototype . scale _ = 1 ; Blockly . BlockDragSurfaceSvg . prototype . surfaceXY _ = null ; Blockly . BlockDragSurfaceSvg . prototype . childSurfaceXY _ = new Blockly . utils . Coordinate ( 0 , 0 ) ;
2021-01-16 14:07:51 +00:00
Blockly . BlockDragSurfaceSvg . prototype . createDom = function ( ) { this . SVG _ || ( this . SVG _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { xmlns : Blockly . utils . dom . SVG _NS , "xmlns:html" : Blockly . utils . dom . HTML _NS , "xmlns:xlink" : Blockly . utils . dom . XLINK _NS , version : "1.1" , "class" : "blocklyBlockDragSurface" } , this . container _ ) , this . dragGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , this . SVG _ ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . BlockDragSurfaceSvg . prototype . setBlocksAndShow = function ( a ) { if ( this . dragGroup _ . childNodes . length ) throw Error ( "Already dragging a block." ) ; this . dragGroup _ . appendChild ( a ) ; this . SVG _ . style . display = "block" ; this . surfaceXY _ = new Blockly . utils . Coordinate ( 0 , 0 ) } ;
Blockly . BlockDragSurfaceSvg . prototype . translateAndScaleGroup = function ( a , b , c ) { this . scale _ = c ; a = a . toFixed ( 0 ) ; b = b . toFixed ( 0 ) ; this . childSurfaceXY _ . x = parseInt ( a , 10 ) ; this . childSurfaceXY _ . y = parseInt ( b , 10 ) ; this . dragGroup _ . setAttribute ( "transform" , "translate(" + a + "," + b + ") scale(" + c + ")" ) } ;
Blockly . BlockDragSurfaceSvg . prototype . translateSurfaceInternal _ = function ( ) { var a = this . surfaceXY _ . x , b = this . surfaceXY _ . y ; a = a . toFixed ( 0 ) ; b = b . toFixed ( 0 ) ; this . SVG _ . style . display = "block" ; Blockly . utils . dom . setCssTransform ( this . SVG _ , "translate3d(" + a + "px, " + b + "px, 0px)" ) } ; Blockly . BlockDragSurfaceSvg . prototype . translateBy = function ( a , b ) { this . surfaceXY _ = new Blockly . utils . Coordinate ( this . surfaceXY _ . x + a , this . surfaceXY _ . y + b ) ; this . translateSurfaceInternal _ ( ) } ;
Blockly . BlockDragSurfaceSvg . prototype . translateSurface = function ( a , b ) { this . surfaceXY _ = new Blockly . utils . Coordinate ( a * this . scale _ , b * this . scale _ ) ; this . translateSurfaceInternal _ ( ) } ; Blockly . BlockDragSurfaceSvg . prototype . getSurfaceTranslation = function ( ) { var a = Blockly . utils . getRelativeXY ( this . SVG _ ) ; return new Blockly . utils . Coordinate ( a . x / this . scale _ , a . y / this . scale _ ) } ; Blockly . BlockDragSurfaceSvg . prototype . getGroup = function ( ) { return this . dragGroup _ } ; Blockly . BlockDragSurfaceSvg . prototype . getSvgRoot = function ( ) { return this . SVG _ } ;
Blockly . BlockDragSurfaceSvg . prototype . getCurrentBlock = function ( ) { return this . dragGroup _ . firstChild } ; Blockly . BlockDragSurfaceSvg . prototype . getWsTranslation = function ( ) { return this . childSurfaceXY _ . clone ( ) } ; Blockly . BlockDragSurfaceSvg . prototype . clearAndHide = function ( a ) { a ? a . appendChild ( this . getCurrentBlock ( ) ) : this . dragGroup _ . removeChild ( this . getCurrentBlock ( ) ) ; this . SVG _ . style . display = "none" ; if ( this . dragGroup _ . childNodes . length ) throw Error ( "Drag group was not cleared." ) ; this . surfaceXY _ = null } ; Blockly . Css = { } ; Blockly . Css . injected _ = ! 1 ; Blockly . Css . register = function ( a ) { if ( Blockly . Css . injected _ ) throw Error ( "CSS already injected" ) ; Array . prototype . push . apply ( Blockly . Css . CONTENT , a ) ; a . length = 0 } ;
2021-01-16 14:07:51 +00:00
Blockly . Css . inject = function ( a , b ) { if ( ! Blockly . Css . injected _ ) { Blockly . Css . injected _ = ! 0 ; var c = Blockly . Css . CONTENT . join ( "\n" ) ; Blockly . Css . CONTENT . length = 0 ; a && ( a = b . replace ( /[\\/]$/ , "" ) , c = c . replace ( /<<<PATH>>>/g , a ) , a = document . createElement ( "style" ) , a . id = "blockly-common-style" , c = document . createTextNode ( c ) , a . appendChild ( c ) , document . head . insertBefore ( a , document . head . firstChild ) ) } } ;
Blockly . Css . CONTENT = [ ".blocklySvg {" , "background-color: #fff;" , "outline: none;" , "overflow: hidden;" , "position: absolute;" , "display: block;" , "}" , ".blocklyWidgetDiv {" , "display: none;" , "position: absolute;" , "z-index: 99999;" , "}" , ".injectionDiv {" , "height: 100%;" , "position: relative;" , "overflow: hidden;" , "touch-action: none;" , "}" , ".blocklyNonSelectable {" , "user-select: none;" , "-ms-user-select: none;" , "-webkit-user-select: none;" , "}" , ".blocklyWsDragSurface {" , "display: none;" , "position: absolute;" , "top: 0;" ,
"left: 0;" , "}" , ".blocklyWsDragSurface.blocklyOverflowVisible {" , "overflow: visible;" , "}" , ".blocklyBlockDragSurface {" , "display: none;" , "position: absolute;" , "top: 0;" , "left: 0;" , "right: 0;" , "bottom: 0;" , "overflow: visible !important;" , "z-index: 50;" , "}" , ".blocklyBlockCanvas.blocklyCanvasTransitioning," , ".blocklyBubbleCanvas.blocklyCanvasTransitioning {" , "transition: transform .5s;" , "}" , ".blocklyTooltipDiv {" , "background-color: #ffffc7;" , "border: 1px solid #ddc;" , "box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);" ,
"color: #000;" , "display: none;" , "font: 9pt sans-serif;" , "opacity: .9;" , "padding: 2px;" , "position: absolute;" , "z-index: 100000;" , "}" , ".blocklyDropDownDiv {" , "position: absolute;" , "left: 0;" , "top: 0;" , "z-index: 1000;" , "display: none;" , "border: 1px solid;" , "border-color: #dadce0;" , "background-color: #fff;" , "border-radius: 2px;" , "padding: 4px;" , "box-shadow: 0 0 3px 1px rgba(0,0,0,.3);" , "}" , ".blocklyDropDownDiv.blocklyFocused {" , "box-shadow: 0 0 6px 1px rgba(0,0,0,.3);" , "}" , ".blocklyDropDownContent {" ,
"max-height: 300px;" , "overflow: auto;" , "overflow-x: hidden;" , "position: relative;" , "}" , ".blocklyDropDownArrow {" , "position: absolute;" , "left: 0;" , "top: 0;" , "width: 16px;" , "height: 16px;" , "z-index: -1;" , "background-color: inherit;" , "border-color: inherit;" , "}" , ".blocklyDropDownButton {" , "display: inline-block;" , "float: left;" , "padding: 0;" , "margin: 4px;" , "border-radius: 4px;" , "outline: none;" , "border: 1px solid;" , "transition: box-shadow .1s;" , "cursor: pointer;" , "}" , ".blocklyArrowTop {" , "border-top: 1px solid;" ,
"border-left: 1px solid;" , "border-top-left-radius: 4px;" , "border-color: inherit;" , "}" , ".blocklyArrowBottom {" , "border-bottom: 1px solid;" , "border-right: 1px solid;" , "border-bottom-right-radius: 4px;" , "border-color: inherit;" , "}" , ".blocklyResizeSE {" , "cursor: se-resize;" , "fill: #aaa;" , "}" , ".blocklyResizeSW {" , "cursor: sw-resize;" , "fill: #aaa;" , "}" , ".blocklyResizeLine {" , "stroke: #515A5A;" , "stroke-width: 1;" , "}" , ".blocklyHighlightedConnectionPath {" , "fill: none;" , "stroke: #fc3;" , "stroke-width: 4px;" ,
"}" , ".blocklyPathLight {" , "fill: none;" , "stroke-linecap: round;" , "stroke-width: 1;" , "}" , ".blocklySelected>.blocklyPathLight {" , "display: none;" , "}" , ".blocklyDraggable {" , 'cursor: url("<<<PATH>>>/handopen.cur"), auto;' , "cursor: grab;" , "cursor: -webkit-grab;" , "}" , ".blocklyDragging {" , 'cursor: url("<<<PATH>>>/handclosed.cur"), auto;' , "cursor: grabbing;" , "cursor: -webkit-grabbing;" , "}" , ".blocklyDraggable:active {" , 'cursor: url("<<<PATH>>>/handclosed.cur"), auto;' , "cursor: grabbing;" , "cursor: -webkit-grabbing;" ,
"}" , ".blocklyBlockDragSurface .blocklyDraggable {" , 'cursor: url("<<<PATH>>>/handclosed.cur"), auto;' , "cursor: grabbing;" , "cursor: -webkit-grabbing;" , "}" , ".blocklyDragging.blocklyDraggingDelete {" , 'cursor: url("<<<PATH>>>/handdelete.cur"), auto;' , "}" , ".blocklyDragging>.blocklyPath," , ".blocklyDragging>.blocklyPathLight {" , "fill-opacity: .8;" , "stroke-opacity: .8;" , "}" , ".blocklyDragging>.blocklyPathDark {" , "display: none;" , "}" , ".blocklyDisabled>.blocklyPath {" , "fill-opacity: .5;" , "stroke-opacity: .5;" ,
"}" , ".blocklyDisabled>.blocklyPathLight," , ".blocklyDisabled>.blocklyPathDark {" , "display: none;" , "}" , ".blocklyInsertionMarker>.blocklyPath," , ".blocklyInsertionMarker>.blocklyPathLight," , ".blocklyInsertionMarker>.blocklyPathDark {" , "fill-opacity: .2;" , "stroke: none;" , "}" , ".blocklyMultilineText {" , "font-family: monospace;" , "}" , ".blocklyNonEditableText>text {" , "pointer-events: none;" , "}" , ".blocklyFlyout {" , "position: absolute;" , "z-index: 20;" , "}" , ".blocklyText text {" , "cursor: default;" , "}" , ".blocklySvg text," ,
".blocklyBlockDragSurface text {" , "user-select: none;" , "-ms-user-select: none;" , "-webkit-user-select: none;" , "cursor: inherit;" , "}" , ".blocklyHidden {" , "display: none;" , "}" , ".blocklyFieldDropdown:not(.blocklyHidden) {" , "display: block;" , "}" , ".blocklyIconGroup {" , "cursor: default;" , "}" , ".blocklyIconGroup:not(:hover)," , ".blocklyIconGroupReadonly {" , "opacity: .6;" , "}" , ".blocklyIconShape {" , "fill: #00f;" , "stroke: #fff;" , "stroke-width: 1px;" , "}" , ".blocklyIconSymbol {" , "fill: #fff;" , "}" , ".blocklyMinimalBody {" ,
"margin: 0;" , "padding: 0;" , "}" , ".blocklyHtmlInput {" , "border: none;" , "border-radius: 4px;" , "height: 100%;" , "margin: 0;" , "outline: none;" , "padding: 0;" , "width: 100%;" , "text-align: center;" , "display: block;" , "box-sizing: border-box;" , "}" , ".blocklyHtmlInput::-ms-clear {" , "display: none;" , "}" , ".blocklyMainBackground {" , "stroke-width: 1;" , "stroke: #c6c6c6;" , "}" , ".blocklyMutatorBackground {" , "fill: #fff;" , "stroke: #ddd;" , "stroke-width: 1;" , "}" , ".blocklyFlyoutBackground {" , "fill: #ddd;" , "fill-opacity: .8;" ,
"}" , ".blocklyMainWorkspaceScrollbar {" , "z-index: 20;" , "}" , ".blocklyFlyoutScrollbar {" , "z-index: 30;" , "}" , ".blocklyScrollbarHorizontal," , ".blocklyScrollbarVertical {" , "position: absolute;" , "outline: none;" , "}" , ".blocklyScrollbarBackground {" , "opacity: 0;" , "}" , ".blocklyScrollbarHandle {" , "fill: #ccc;" , "}" , ".blocklyScrollbarBackground:hover+.blocklyScrollbarHandle," , ".blocklyScrollbarHandle:hover {" , "fill: #bbb;" , "}" , ".blocklyFlyout .blocklyScrollbarHandle {" , "fill: #bbb;" , "}" , ".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle," ,
".blocklyFlyout .blocklyScrollbarHandle:hover {" , "fill: #aaa;" , "}" , ".blocklyInvalidInput {" , "background: #faa;" , "}" , ".blocklyVerticalMarker {" , "stroke-width: 3px;" , "fill: rgba(255,255,255,.5);" , "pointer-events: none;" , "}" , ".blocklyComputeCanvas {" , "position: absolute;" , "width: 0;" , "height: 0;" , "}" , ".blocklyNoPointerEvents {" , "pointer-events: none;" , "}" , ".blocklyContextMenu {" , "border-radius: 4px;" , "max-height: 100%;" , "}" , ".blocklyDropdownMenu {" , "border-radius: 2px;" , "padding: 0 !important;" , "}" ,
".blocklyDropdownMenu .blocklyMenuItem {" , "padding-left: 28px;" , "}" , ".blocklyDropdownMenu .blocklyMenuItemRtl {" , "padding-left: 5px;" , "padding-right: 28px;" , "}" , ".blocklyWidgetDiv .blocklyMenu {" , "background: #fff;" , "border: 1px solid transparent;" , "box-shadow: 0 0 3px 1px rgba(0,0,0,.3);" , "font: normal 13px Arial, sans-serif;" , "margin: 0;" , "outline: none;" , "padding: 4px 0;" , "position: absolute;" , "overflow-y: auto;" , "overflow-x: hidden;" , "max-height: 100%;" , "z-index: 20000;" , "}" , ".blocklyWidgetDiv .blocklyMenu.blocklyFocused {" ,
"box-shadow: 0 0 6px 1px rgba(0,0,0,.3);" , "}" , ".blocklyDropDownDiv .blocklyMenu {" , "background: inherit;" , "border: inherit;" , 'font: normal 13px "Helvetica Neue", Helvetica, sans-serif;' , "outline: none;" , "position: relative;" , "z-index: 20000;" , "}" , ".blocklyMenuItem {" , "border: none;" , "color: #000;" , "cursor: pointer;" , "list-style: none;" , "margin: 0;" , "min-width: 7em;" , "padding: 6px 15px;" , "white-space: nowrap;" , "}" , ".blocklyMenuItemDisabled {" , "color: #ccc;" , "cursor: inherit;" , "}" , ".blocklyMenuItemHighlight {" ,
2021-09-18 14:29:06 +00:00
"background-color: rgba(0,0,0,.1);" , "}" , ".blocklyMenuItemCheckbox {" , "height: 16px;" , "position: absolute;" , "width: 16px;" , "}" , ".blocklyMenuItemSelected .blocklyMenuItemCheckbox {" , "background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;" , "float: left;" , "margin-left: -24px;" , "position: static;" , "}" , ".blocklyMenuItemRtl .blocklyMenuItemCheckbox {" , "float: right;" , "margin-right: -24px;" , "}" ] ; Blockly . Grid = function ( a , b ) { this . gridPattern _ = a ; this . spacing _ = b . spacing ; this . length _ = b . length ; this . line2 _ = ( this . line1 _ = a . firstChild ) && this . line1 _ . nextSibling ; this . snapToGrid _ = b . snap } ; Blockly . Grid . prototype . scale _ = 1 ; Blockly . Grid . prototype . dispose = function ( ) { this . gridPattern _ = null } ; Blockly . Grid . prototype . shouldSnap = function ( ) { return this . snapToGrid _ } ; Blockly . Grid . prototype . getSpacing = function ( ) { return this . spacing _ } ; Blockly . Grid . prototype . getPatternId = function ( ) { return this . gridPattern _ . id } ;
2021-01-16 14:07:51 +00:00
Blockly . Grid . prototype . update = function ( a ) { this . scale _ = a ; var b = this . spacing _ * a || 100 ; this . gridPattern _ . setAttribute ( "width" , b ) ; this . gridPattern _ . setAttribute ( "height" , b ) ; b = Math . floor ( this . spacing _ / 2 ) + . 5 ; var c = b - this . length _ / 2 , d = b + this . length _ / 2 ; b *= a ; c *= a ; d *= a ; this . setLineAttributes _ ( this . line1 _ , a , c , d , b , b ) ; this . setLineAttributes _ ( this . line2 _ , a , b , b , c , d ) } ;
Blockly . Grid . prototype . setLineAttributes _ = function ( a , b , c , d , e , f ) { a && ( a . setAttribute ( "stroke-width" , b ) , a . setAttribute ( "x1" , c ) , a . setAttribute ( "y1" , e ) , a . setAttribute ( "x2" , d ) , a . setAttribute ( "y2" , f ) ) } ; Blockly . Grid . prototype . moveTo = function ( a , b ) { this . gridPattern _ . setAttribute ( "x" , a ) ; this . gridPattern _ . setAttribute ( "y" , b ) ; ( Blockly . utils . userAgent . IE || Blockly . utils . userAgent . EDGE ) && this . update ( this . scale _ ) } ;
Blockly . Grid . createDom = function ( a , b , c ) { a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATTERN , { id : "blocklyGridPattern" + a , patternUnits : "userSpaceOnUse" } , c ) ; 0 < b . length && 0 < b . spacing ? ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { stroke : b . colour } , a ) , 1 < b . length && Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { stroke : b . colour } , a ) ) : Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { } , a ) ; return a } ; Blockly . Theme = function ( a , b , c , d ) { this . name = a ; this . blockStyles = b || Object . create ( null ) ; this . categoryStyles = c || Object . create ( null ) ; this . componentStyles = d || Object . create ( null ) ; this . fontStyle = Object . create ( null ) ; this . startHats = null ; Blockly . registry . register ( Blockly . registry . Type . THEME , a , this ) } ; Blockly . Theme . prototype . getClassName = function ( ) { return this . name + "-theme" } ; Blockly . Theme . prototype . setBlockStyle = function ( a , b ) { this . blockStyles [ a ] = b } ;
Blockly . Theme . prototype . setCategoryStyle = function ( a , b ) { this . categoryStyles [ a ] = b } ; Blockly . Theme . prototype . getComponentStyle = function ( a ) { return ( a = this . componentStyles [ a ] ) && "string" == typeof a && this . getComponentStyle ( a ) ? this . getComponentStyle ( a ) : a ? String ( a ) : null } ; Blockly . Theme . prototype . setComponentStyle = function ( a , b ) { this . componentStyles [ a ] = b } ; Blockly . Theme . prototype . setFontStyle = function ( a ) { this . fontStyle = a } ; Blockly . Theme . prototype . setStartHats = function ( a ) { this . startHats = a } ;
Blockly . Theme . defineTheme = function ( a , b ) { var c = new Blockly . Theme ( a ) , d = b . base ; d && ( "string" == typeof d && ( d = Blockly . registry . getObject ( Blockly . registry . Type . THEME , d ) ) , d instanceof Blockly . Theme && ( Blockly . utils . object . deepMerge ( c , d ) , c . name = a ) ) ; Blockly . utils . object . deepMerge ( c . blockStyles , b . blockStyles ) ; Blockly . utils . object . deepMerge ( c . categoryStyles , b . categoryStyles ) ; Blockly . utils . object . deepMerge ( c . componentStyles , b . componentStyles ) ; Blockly . utils . object . deepMerge ( c . fontStyle , b . fontStyle ) ; null != b . startHats &&
( c . startHats = b . startHats ) ; return c } ; Blockly . Themes = { } ; Blockly . Themes . Classic = { } ; Blockly . Themes . Classic . defaultBlockStyles = { colour _blocks : { colourPrimary : "20" } , list _blocks : { colourPrimary : "260" } , logic _blocks : { colourPrimary : "210" } , loop _blocks : { colourPrimary : "120" } , math _blocks : { colourPrimary : "230" } , procedure _blocks : { colourPrimary : "290" } , text _blocks : { colourPrimary : "160" } , variable _blocks : { colourPrimary : "330" } , variable _dynamic _blocks : { colourPrimary : "310" } , hat _blocks : { colourPrimary : "330" , hat : "cap" } } ;
2021-05-19 13:38:55 +00:00
Blockly . Themes . Classic . categoryStyles = { colour _category : { colour : "20" } , list _category : { colour : "260" } , logic _category : { colour : "210" } , loop _category : { colour : "120" } , math _category : { colour : "230" } , procedure _category : { colour : "290" } , text _category : { colour : "160" } , variable _category : { colour : "330" } , variable _dynamic _category : { colour : "310" } } ; Blockly . Themes . Classic = new Blockly . Theme ( "classic" , Blockly . Themes . Classic . defaultBlockStyles , Blockly . Themes . Classic . categoryStyles ) ; Blockly . utils . IdGenerator = { } ; Blockly . utils . IdGenerator . nextId _ = 0 ; Blockly . utils . IdGenerator . getNextUniqueId = function ( ) { return "blockly-" + ( Blockly . utils . IdGenerator . nextId _ ++ ) . toString ( 36 ) } ; Blockly . utils . Metrics = function ( ) { } ; Blockly . utils . toolbox = { } ; Blockly . utils . toolbox . CATEGORY _TOOLBOX _KIND = "categoryToolbox" ; Blockly . utils . toolbox . FLYOUT _TOOLBOX _KIND = "flyoutToolbox" ; Blockly . utils . toolbox . Position = { TOP : 0 , BOTTOM : 1 , LEFT : 2 , RIGHT : 3 } ; Blockly . utils . toolbox . convertToolboxDefToJson = function ( a ) { if ( ! a ) return null ; if ( a instanceof Element || "string" == typeof a ) a = Blockly . utils . toolbox . parseToolboxTree ( a ) , a = Blockly . utils . toolbox . convertToToolboxJson _ ( a ) ; Blockly . utils . toolbox . validateToolbox _ ( a ) ; return a } ;
2021-01-16 14:07:51 +00:00
Blockly . utils . toolbox . validateToolbox _ = function ( a ) { var b = a . kind ; a = a . contents ; if ( b && b != Blockly . utils . toolbox . FLYOUT _TOOLBOX _KIND && b != Blockly . utils . toolbox . CATEGORY _TOOLBOX _KIND ) throw Error ( "Invalid toolbox kind " + b + ". Please supply either " + Blockly . utils . toolbox . FLYOUT _TOOLBOX _KIND + " or " + Blockly . utils . toolbox . CATEGORY _TOOLBOX _KIND ) ; if ( ! a ) throw Error ( "Toolbox must have a contents attribute." ) ; } ;
Blockly . utils . toolbox . convertFlyoutDefToJsonArray = function ( a ) { return a ? a . contents ? a . contents : Array . isArray ( a ) && 0 < a . length && ! a [ 0 ] . nodeType ? a : Blockly . utils . toolbox . xmlToJsonArray _ ( a ) : [ ] } ; Blockly . utils . toolbox . hasCategories = function ( a ) { if ( ! a ) return ! 1 ; var b = a . kind ; return b ? b == Blockly . utils . toolbox . CATEGORY _TOOLBOX _KIND : ! ! a . contents . filter ( function ( c ) { return "CATEGORY" == c . kind . toUpperCase ( ) } ) . length } ;
Blockly . utils . toolbox . isCategoryCollapsible = function ( a ) { return a && a . contents ? ! ! a . contents . filter ( function ( b ) { return "CATEGORY" == b . kind . toUpperCase ( ) } ) . length : ! 1 } ; Blockly . utils . toolbox . convertToToolboxJson _ = function ( a ) { var b = { contents : Blockly . utils . toolbox . xmlToJsonArray _ ( a ) } ; a instanceof Node && Blockly . utils . toolbox . addAttributes _ ( a , b ) ; return b } ;
Blockly . utils . toolbox . xmlToJsonArray _ = function ( a ) { var b = [ ] , c = a . childNodes ; c || ( c = a ) ; a = 0 ; for ( var d ; d = c [ a ] ; a ++ ) if ( d . tagName ) { var e = { } , f = d . tagName . toUpperCase ( ) ; e . kind = f ; "BLOCK" == f ? e . blockxml = d : d . childNodes && 0 < d . childNodes . length && ( e . contents = Blockly . utils . toolbox . xmlToJsonArray _ ( d ) ) ; Blockly . utils . toolbox . addAttributes _ ( d , e ) ; b . push ( e ) } return b } ;
Blockly . utils . toolbox . addAttributes _ = function ( a , b ) { for ( var c = 0 ; c < a . attributes . length ; c ++ ) { var d = a . attributes [ c ] ; - 1 < d . nodeName . indexOf ( "css-" ) ? ( b . cssconfig = b . cssconfig || { } , b . cssconfig [ d . nodeName . replace ( "css-" , "" ) ] = d . value ) : b [ d . nodeName ] = d . value } } ;
2021-05-19 13:38:55 +00:00
Blockly . utils . toolbox . parseToolboxTree = function ( a ) { if ( a ) { if ( "string" != typeof a && ( Blockly . utils . userAgent . IE && a . outerHTML ? a = a . outerHTML : a instanceof Element || ( a = null ) ) , "string" == typeof a && ( a = Blockly . Xml . textToDom ( a ) , "xml" != a . nodeName . toLowerCase ( ) ) ) throw TypeError ( "Toolbox should be an <xml> document." ) ; } else a = null ; return a } ; Blockly . Options = function ( a ) { var b = ! ! a . readOnly ; if ( b ) var c = null , d = ! 1 , e = ! 1 , f = ! 1 , g = ! 1 , h = ! 1 , k = ! 1 ; else { c = Blockly . utils . toolbox . convertToolboxDefToJson ( a . toolbox ) ; d = Blockly . utils . toolbox . hasCategories ( c ) ; e = a . trashcan ; void 0 === e && ( e = d ) ; var l = a . maxTrashcanContents ; e ? void 0 === l && ( l = 32 ) : l = 0 ; f = a . collapse ; void 0 === f && ( f = d ) ; g = a . comments ; void 0 === g && ( g = d ) ; h = a . disable ; void 0 === h && ( h = d ) ; k = a . sounds ; void 0 === k && ( k = ! 0 ) } var m = ! ! a . rtl , n = a . horizontalLayout ; void 0 === n && ( n = ! 1 ) ; var p = a . toolboxPosition ; p = "end" !== p ; p = n ? p ? Blockly . utils . toolbox . Position . TOP :
2021-01-16 14:07:51 +00:00
Blockly . utils . toolbox . Position . BOTTOM : p == m ? Blockly . utils . toolbox . Position . RIGHT : Blockly . utils . toolbox . Position . LEFT ; var q = a . css ; void 0 === q && ( q = ! 0 ) ; var t = "https://blockly-demo.appspot.com/static/media/" ; a . media ? t = a . media : a . path && ( t = a . path + "media/" ) ; var r = void 0 === a . oneBasedIndex ? ! 0 : ! ! a . oneBasedIndex , u = a . renderer || "geras" , v = a . plugins || { } ; this . RTL = m ; this . oneBasedIndex = r ; this . collapse = f ; this . comments = g ; this . disable = h ; this . readOnly = b ; this . maxBlocks = a . maxBlocks || Infinity ; this . maxInstances = a . maxInstances ;
2021-05-19 13:38:55 +00:00
this . pathToMedia = t ; this . hasCategories = d ; this . moveOptions = Blockly . Options . parseMoveOptions _ ( a , d ) ; this . hasScrollbars = ! ! this . moveOptions . scrollbars ; this . hasTrashcan = e ; this . maxTrashcanContents = l ; this . hasSounds = k ; this . hasCss = q ; this . horizontalLayout = n ; this . languageTree = c ; this . gridOptions = Blockly . Options . parseGridOptions _ ( a ) ; this . zoomOptions = Blockly . Options . parseZoomOptions _ ( a ) ; this . toolboxPosition = p ; this . theme = Blockly . Options . parseThemeOptions _ ( a ) ; this . renderer = u ; this . rendererOverrides = a . rendererOverrides ;
this . gridPattern = null ; this . parentWorkspace = a . parentWorkspace ; this . plugins = v } ; Blockly . BlocklyOptions = function ( ) { } ;
Blockly . Options . parseMoveOptions _ = function ( a , b ) { var c = a . move || { } , d = { } ; void 0 === c . scrollbars && void 0 === a . scrollbars ? d . scrollbars = b : "object" == typeof c . scrollbars ? ( d . scrollbars = { } , d . scrollbars . horizontal = ! ! c . scrollbars . horizontal , d . scrollbars . vertical = ! ! c . scrollbars . vertical , d . scrollbars . horizontal && d . scrollbars . vertical ? d . scrollbars = ! 0 : d . scrollbars . horizontal || d . scrollbars . vertical || ( d . scrollbars = ! 1 ) ) : d . scrollbars = ! ! c . scrollbars || ! ! a . scrollbars ; d . wheel = d . scrollbars && void 0 !== c . wheel ? ! ! c . wheel : "object" ==
typeof d . scrollbars ; d . drag = d . scrollbars ? void 0 === c . drag ? ! 0 : ! ! c . drag : ! 1 ; return d } ;
2021-01-16 14:07:51 +00:00
Blockly . Options . parseZoomOptions _ = function ( a ) { a = a . zoom || { } ; var b = { } ; b . controls = void 0 === a . controls ? ! 1 : ! ! a . controls ; b . wheel = void 0 === a . wheel ? ! 1 : ! ! a . wheel ; b . startScale = void 0 === a . startScale ? 1 : Number ( a . startScale ) ; b . maxScale = void 0 === a . maxScale ? 3 : Number ( a . maxScale ) ; b . minScale = void 0 === a . minScale ? . 3 : Number ( a . minScale ) ; b . scaleSpeed = void 0 === a . scaleSpeed ? 1.2 : Number ( a . scaleSpeed ) ; b . pinch = void 0 === a . pinch ? b . wheel || b . controls : ! ! a . pinch ; return b } ;
Blockly . Options . parseGridOptions _ = function ( a ) { a = a . grid || { } ; var b = { } ; b . spacing = Number ( a . spacing ) || 0 ; b . colour = a . colour || "#888" ; b . length = void 0 === a . length ? 1 : Number ( a . length ) ; b . snap = 0 < b . spacing && ! ! a . snap ; return b } ; Blockly . Options . parseThemeOptions _ = function ( a ) { a = a . theme || Blockly . Themes . Classic ; return "string" == typeof a ? Blockly . registry . getObject ( Blockly . registry . Type . THEME , a ) : a instanceof Blockly . Theme ? a : Blockly . Theme . defineTheme ( a . name || "builtin" + Blockly . utils . IdGenerator . getNextUniqueId ( ) , a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Options . parseToolboxTree = function ( a ) { Blockly . utils . deprecation . warn ( "Blockly.Options.parseToolboxTree" , "September 2020" , "September 2021" , "Blockly.utils.toolbox.parseToolboxTree" ) ; return Blockly . utils . toolbox . parseToolboxTree ( a ) } ; Blockly . ScrollbarPair = function ( a , b , c , d , e ) { this . workspace _ = a ; b = void 0 === b ? ! 0 : b ; c = void 0 === c ? ! 0 : c ; var f = b && c ; b && ( this . hScroll = new Blockly . Scrollbar ( a , ! 0 , f , d , e ) ) ; c && ( this . vScroll = new Blockly . Scrollbar ( a , ! 1 , f , d , e ) ) ; f && ( this . corner _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { height : Blockly . Scrollbar . scrollbarThickness , width : Blockly . Scrollbar . scrollbarThickness , "class" : "blocklyScrollbarBackground" } , null ) , Blockly . utils . dom . insertAfter ( this . corner _ , a . getBubbleCanvas ( ) ) ) ; this . oldHostMetrics _ =
null } ; Blockly . ScrollbarPair . prototype . dispose = function ( ) { Blockly . utils . dom . removeNode ( this . corner _ ) ; this . oldHostMetrics _ = this . workspace _ = this . corner _ = null ; this . hScroll && ( this . hScroll . dispose ( ) , this . hScroll = null ) ; this . vScroll && ( this . vScroll . dispose ( ) , this . vScroll = null ) } ;
2021-05-19 13:38:55 +00:00
Blockly . ScrollbarPair . prototype . resize = function ( ) { var a = this . workspace _ . getMetrics ( ) ; if ( a ) { var b = ! 1 , c = ! 1 ; this . oldHostMetrics _ && this . oldHostMetrics _ . viewWidth == a . viewWidth && this . oldHostMetrics _ . viewHeight == a . viewHeight && this . oldHostMetrics _ . absoluteTop == a . absoluteTop && this . oldHostMetrics _ . absoluteLeft == a . absoluteLeft ? ( this . oldHostMetrics _ && this . oldHostMetrics _ . scrollWidth == a . scrollWidth && this . oldHostMetrics _ . viewLeft == a . viewLeft && this . oldHostMetrics _ . scrollLeft == a . scrollLeft || ( b = ! 0 ) , this . oldHostMetrics _ &&
this . oldHostMetrics _ . scrollHeight == a . scrollHeight && this . oldHostMetrics _ . viewTop == a . viewTop && this . oldHostMetrics _ . scrollTop == a . scrollTop || ( c = ! 0 ) ) : c = b = ! 0 ; if ( b || c ) { try { Blockly . Events . disable ( ) , this . hScroll && b && this . hScroll . resize ( a ) , this . vScroll && c && this . vScroll . resize ( a ) } finally { Blockly . Events . enable ( ) } this . workspace _ . maybeFireViewportChangeEvent ( ) } this . hScroll && this . vScroll && ( this . oldHostMetrics _ && this . oldHostMetrics _ . viewWidth == a . viewWidth && this . oldHostMetrics _ . absoluteLeft == a . absoluteLeft || this . corner _ . setAttribute ( "x" ,
this . vScroll . position . x ) , this . oldHostMetrics _ && this . oldHostMetrics _ . viewHeight == a . viewHeight && this . oldHostMetrics _ . absoluteTop == a . absoluteTop || this . corner _ . setAttribute ( "y" , this . hScroll . position . y ) ) ; this . oldHostMetrics _ = a } } ; Blockly . ScrollbarPair . prototype . canScrollHorizontally = function ( ) { return ! ! this . hScroll } ; Blockly . ScrollbarPair . prototype . canScrollVertically = function ( ) { return ! ! this . vScroll } ;
Blockly . ScrollbarPair . prototype . setOrigin = function ( a , b ) { this . hScroll && this . hScroll . setOrigin ( a , b ) ; this . vScroll && this . vScroll . setOrigin ( a , b ) } ; Blockly . ScrollbarPair . prototype . set = function ( a , b , c ) { this . hScroll && this . hScroll . set ( a , ! 1 ) ; this . vScroll && this . vScroll . set ( b , ! 1 ) ; if ( c || void 0 === c ) a = { } , this . hScroll && ( a . x = this . hScroll . getRatio _ ( ) ) , this . vScroll && ( a . y = this . vScroll . getRatio _ ( ) ) , this . workspace _ . setMetrics ( a ) } ; Blockly . ScrollbarPair . prototype . setX = function ( a ) { this . hScroll && this . hScroll . set ( a , ! 0 ) } ;
Blockly . ScrollbarPair . prototype . setY = function ( a ) { this . vScroll && this . vScroll . set ( a , ! 0 ) } ; Blockly . ScrollbarPair . prototype . setContainerVisible = function ( a ) { this . hScroll && this . hScroll . setContainerVisible ( a ) ; this . vScroll && this . vScroll . setContainerVisible ( a ) } ; Blockly . ScrollbarPair . prototype . isVisible = function ( ) { var a = ! 1 ; this . hScroll && ( a = this . hScroll . isVisible ( ) ) ; this . vScroll && ( a = a || this . vScroll . isVisible ( ) ) ; return a } ;
Blockly . ScrollbarPair . prototype . resizeContent = function ( a ) { this . hScroll && this . hScroll . resizeContentHorizontal ( a ) ; this . vScroll && this . vScroll . resizeContentVertical ( a ) } ; Blockly . ScrollbarPair . prototype . resizeView = function ( a ) { this . hScroll && this . hScroll . resizeViewHorizontal ( a ) ; this . vScroll && this . vScroll . resizeViewVertical ( a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Scrollbar = function ( a , b , c , d , e ) { this . workspace _ = a ; this . pair _ = c || ! 1 ; this . horizontal _ = b ; this . margin _ = void 0 !== e ? e : Blockly . Scrollbar . DEFAULT _SCROLLBAR _MARGIN ; this . ratio = this . oldHostMetrics _ = null ; this . createDom _ ( d ) ; this . position = new Blockly . utils . Coordinate ( 0 , 0 ) ; a = Blockly . Scrollbar . scrollbarThickness ; b ? ( this . svgBackground _ . setAttribute ( "height" , a ) , this . outerSvg _ . setAttribute ( "height" , a ) , this . svgHandle _ . setAttribute ( "height" , a - 5 ) , this . svgHandle _ . setAttribute ( "y" , 2.5 ) , this . lengthAttribute _ = "width" ,
this . positionAttribute _ = "x" ) : ( this . svgBackground _ . setAttribute ( "width" , a ) , this . outerSvg _ . setAttribute ( "width" , a ) , this . svgHandle _ . setAttribute ( "width" , a - 5 ) , this . svgHandle _ . setAttribute ( "x" , 2.5 ) , this . lengthAttribute _ = "height" , this . positionAttribute _ = "y" ) ; this . onMouseDownBarWrapper _ = Blockly . browserEvents . conditionalBind ( this . svgBackground _ , "mousedown" , this , this . onMouseDownBar _ ) ; this . onMouseDownHandleWrapper _ = Blockly . browserEvents . conditionalBind ( this . svgHandle _ , "mousedown" , this , this . onMouseDownHandle _ ) } ;
Blockly . Scrollbar . prototype . origin _ = new Blockly . utils . Coordinate ( 0 , 0 ) ; Blockly . Scrollbar . prototype . startDragMouse _ = 0 ; Blockly . Scrollbar . prototype . scrollbarLength _ = 0 ; Blockly . Scrollbar . prototype . handleLength _ = 0 ; Blockly . Scrollbar . prototype . handlePosition _ = 0 ; Blockly . Scrollbar . prototype . isVisible _ = ! 0 ; Blockly . Scrollbar . prototype . containerVisible _ = ! 0 ; Blockly . Scrollbar . scrollbarThickness = 15 ; Blockly . Touch . TOUCH _ENABLED && ( Blockly . Scrollbar . scrollbarThickness = 25 ) ; Blockly . Scrollbar . DEFAULT _SCROLLBAR _MARGIN = . 5 ;
Blockly . Scrollbar . metricsAreEquivalent _ = function ( a , b ) { return a . viewWidth == b . viewWidth && a . viewHeight == b . viewHeight && a . viewLeft == b . viewLeft && a . viewTop == b . viewTop && a . absoluteTop == b . absoluteTop && a . absoluteLeft == b . absoluteLeft && a . scrollWidth == b . scrollWidth && a . scrollHeight == b . scrollHeight && a . scrollLeft == b . scrollLeft && a . scrollTop == b . scrollTop } ;
2021-05-19 13:38:55 +00:00
Blockly . Scrollbar . prototype . dispose = function ( ) { this . cleanUp _ ( ) ; Blockly . browserEvents . unbind ( this . onMouseDownBarWrapper _ ) ; this . onMouseDownBarWrapper _ = null ; Blockly . browserEvents . unbind ( this . onMouseDownHandleWrapper _ ) ; this . onMouseDownHandleWrapper _ = null ; Blockly . utils . dom . removeNode ( this . outerSvg _ ) ; this . svgBackground _ = this . svgGroup _ = this . outerSvg _ = null ; this . svgHandle _ && ( this . workspace _ . getThemeManager ( ) . unsubscribe ( this . svgHandle _ ) , this . svgHandle _ = null ) ; this . workspace _ = null } ;
Blockly . Scrollbar . prototype . constrainHandleLength _ = function ( a ) { return a = 0 >= a || isNaN ( a ) ? 0 : Math . min ( a , this . scrollbarLength _ ) } ; Blockly . Scrollbar . prototype . setHandleLength _ = function ( a ) { this . handleLength _ = a ; this . svgHandle _ . setAttribute ( this . lengthAttribute _ , this . handleLength _ ) } ; Blockly . Scrollbar . prototype . constrainHandlePosition _ = function ( a ) { return a = 0 >= a || isNaN ( a ) ? 0 : Math . min ( a , this . scrollbarLength _ - this . handleLength _ ) } ;
Blockly . Scrollbar . prototype . setHandlePosition = function ( a ) { this . handlePosition _ = a ; this . svgHandle _ . setAttribute ( this . positionAttribute _ , this . handlePosition _ ) } ; Blockly . Scrollbar . prototype . setScrollbarLength _ = function ( a ) { this . scrollbarLength _ = a ; this . outerSvg _ . setAttribute ( this . lengthAttribute _ , this . scrollbarLength _ ) ; this . svgBackground _ . setAttribute ( this . lengthAttribute _ , this . scrollbarLength _ ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Scrollbar . prototype . setPosition = function ( a , b ) { this . position . x = a ; this . position . y = b ; Blockly . utils . dom . setCssTransform ( this . outerSvg _ , "translate(" + ( this . position . x + this . origin _ . x ) + "px," + ( this . position . y + this . origin _ . y ) + "px)" ) } ;
Blockly . Scrollbar . prototype . resize = function ( a ) { if ( ! a && ( a = this . workspace _ . getMetrics ( ) , ! a ) ) return ; this . oldHostMetrics _ && Blockly . Scrollbar . metricsAreEquivalent _ ( a , this . oldHostMetrics _ ) || ( this . horizontal _ ? this . resizeHorizontal _ ( a ) : this . resizeVertical _ ( a ) , this . oldHostMetrics _ = a , this . updateMetrics _ ( ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Scrollbar . prototype . requiresViewResize _ = function ( a ) { return this . oldHostMetrics _ ? this . oldHostMetrics _ . viewWidth !== a . viewWidth || this . oldHostMetrics _ . viewHeight !== a . viewHeight || this . oldHostMetrics _ . absoluteLeft !== a . absoluteLeft || this . oldHostMetrics _ . absoluteTop !== a . absoluteTop : ! 0 } ; Blockly . Scrollbar . prototype . resizeHorizontal _ = function ( a ) { this . requiresViewResize _ ( a ) ? this . resizeViewHorizontal ( a ) : this . resizeContentHorizontal ( a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Scrollbar . prototype . resizeViewHorizontal = function ( a ) { var b = a . viewWidth - 2 * this . margin _ ; this . pair _ && ( b -= Blockly . Scrollbar . scrollbarThickness ) ; this . setScrollbarLength _ ( Math . max ( 0 , b ) ) ; b = a . absoluteLeft + this . margin _ ; this . pair _ && this . workspace _ . RTL && ( b += Blockly . Scrollbar . scrollbarThickness ) ; this . setPosition ( b , a . absoluteTop + a . viewHeight - Blockly . Scrollbar . scrollbarThickness - this . margin _ ) ; this . resizeContentHorizontal ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Scrollbar . prototype . resizeContentHorizontal = function ( a ) { if ( a . viewWidth >= a . scrollWidth ) this . setHandleLength _ ( this . scrollbarLength _ ) , this . setHandlePosition ( 0 ) , this . pair _ || this . setVisible ( ! 1 ) ; else { this . pair _ || this . setVisible ( ! 0 ) ; var b = this . scrollbarLength _ * a . viewWidth / a . scrollWidth ; b = this . constrainHandleLength _ ( b ) ; this . setHandleLength _ ( b ) ; b = a . scrollWidth - a . viewWidth ; var c = this . scrollbarLength _ - this . handleLength _ ; a = ( a . viewLeft - a . scrollLeft ) / b * c ; a = this . constrainHandlePosition _ ( a ) ; this . setHandlePosition ( a ) ;
this . ratio = c / b } } ; Blockly . Scrollbar . prototype . resizeVertical _ = function ( a ) { this . requiresViewResize _ ( a ) ? this . resizeViewVertical ( a ) : this . resizeContentVertical ( a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Scrollbar . prototype . resizeViewVertical = function ( a ) { var b = a . viewHeight - 2 * this . margin _ ; this . pair _ && ( b -= Blockly . Scrollbar . scrollbarThickness ) ; this . setScrollbarLength _ ( Math . max ( 0 , b ) ) ; this . setPosition ( this . workspace _ . RTL ? a . absoluteLeft + this . margin _ : a . absoluteLeft + a . viewWidth - Blockly . Scrollbar . scrollbarThickness - this . margin _ , a . absoluteTop + this . margin _ ) ; this . resizeContentVertical ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Scrollbar . prototype . resizeContentVertical = function ( a ) { if ( a . viewHeight >= a . scrollHeight ) this . setHandleLength _ ( this . scrollbarLength _ ) , this . setHandlePosition ( 0 ) , this . pair _ || this . setVisible ( ! 1 ) ; else { this . pair _ || this . setVisible ( ! 0 ) ; var b = this . scrollbarLength _ * a . viewHeight / a . scrollHeight ; b = this . constrainHandleLength _ ( b ) ; this . setHandleLength _ ( b ) ; b = a . scrollHeight - a . viewHeight ; var c = this . scrollbarLength _ - this . handleLength _ ; a = ( a . viewTop - a . scrollTop ) / b * c ; a = this . constrainHandlePosition _ ( a ) ; this . setHandlePosition ( a ) ;
this . ratio = c / b } } ;
2021-01-16 14:07:51 +00:00
Blockly . Scrollbar . prototype . createDom _ = function ( a ) { var b = "blocklyScrollbar" + ( this . horizontal _ ? "Horizontal" : "Vertical" ) ; a && ( b += " " + a ) ; this . outerSvg _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { "class" : b } , null ) ; this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , this . outerSvg _ ) ; this . svgBackground _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyScrollbarBackground" } , this . svgGroup _ ) ; a = Math . floor ( ( Blockly . Scrollbar . scrollbarThickness - 5 ) / 2 ) ;
this . svgHandle _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyScrollbarHandle" , rx : a , ry : a } , this . svgGroup _ ) ; this . workspace _ . getThemeManager ( ) . subscribe ( this . svgHandle _ , "scrollbarColour" , "fill" ) ; this . workspace _ . getThemeManager ( ) . subscribe ( this . svgHandle _ , "scrollbarOpacity" , "fill-opacity" ) ; Blockly . utils . dom . insertAfter ( this . outerSvg _ , this . workspace _ . getParentSvg ( ) ) } ; Blockly . Scrollbar . prototype . isVisible = function ( ) { return this . isVisible _ } ;
Blockly . Scrollbar . prototype . setContainerVisible = function ( a ) { var b = a != this . containerVisible _ ; this . containerVisible _ = a ; b && this . updateDisplay _ ( ) } ; Blockly . Scrollbar . prototype . setVisible = function ( a ) { var b = a != this . isVisible ( ) ; if ( this . pair _ ) throw Error ( "Unable to toggle visibility of paired scrollbars." ) ; this . isVisible _ = a ; b && this . updateDisplay _ ( ) } ;
Blockly . Scrollbar . prototype . updateDisplay _ = function ( ) { this . containerVisible _ && this . isVisible ( ) ? this . outerSvg _ . setAttribute ( "display" , "block" ) : this . outerSvg _ . setAttribute ( "display" , "none" ) } ;
Blockly . Scrollbar . prototype . onMouseDownBar _ = function ( a ) { this . workspace _ . markFocused ( ) ; Blockly . Touch . clearTouchIdentifier ( ) ; this . cleanUp _ ( ) ; if ( Blockly . utils . isRightButton ( a ) ) a . stopPropagation ( ) ; else { var b = Blockly . utils . mouseToSvg ( a , this . workspace _ . getParentSvg ( ) , this . workspace _ . getInverseScreenCTM ( ) ) ; b = this . horizontal _ ? b . x : b . y ; var c = Blockly . utils . getInjectionDivXY _ ( this . svgHandle _ ) ; c = this . horizontal _ ? c . x : c . y ; var d = this . handlePosition _ , e = . 95 * this . handleLength _ ; b <= c ? d -= e : b >= c + this . handleLength _ && ( d +=
2021-05-19 13:38:55 +00:00
e ) ; this . setHandlePosition ( this . constrainHandlePosition _ ( d ) ) ; this . updateMetrics _ ( ) ; a . stopPropagation ( ) ; a . preventDefault ( ) } } ;
Blockly . Scrollbar . prototype . onMouseDownHandle _ = function ( a ) { this . workspace _ . markFocused ( ) ; this . cleanUp _ ( ) ; Blockly . utils . isRightButton ( a ) ? a . stopPropagation ( ) : ( this . startDragHandle = this . handlePosition _ , this . workspace _ . setupDragSurface ( ) , this . startDragMouse _ = this . horizontal _ ? a . clientX : a . clientY , Blockly . Scrollbar . onMouseUpWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mouseup" , this , this . onMouseUpHandle _ ) , Blockly . Scrollbar . onMouseMoveWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mousemove" ,
this , this . onMouseMoveHandle _ ) , a . stopPropagation ( ) , a . preventDefault ( ) ) } ; Blockly . Scrollbar . prototype . onMouseMoveHandle _ = function ( a ) { this . setHandlePosition ( this . constrainHandlePosition _ ( this . startDragHandle + ( ( this . horizontal _ ? a . clientX : a . clientY ) - this . startDragMouse _ ) ) ) ; this . updateMetrics _ ( ) } ; Blockly . Scrollbar . prototype . onMouseUpHandle _ = function ( ) { this . workspace _ . resetDragSurface ( ) ; Blockly . Touch . clearTouchIdentifier ( ) ; this . cleanUp _ ( ) } ;
Blockly . Scrollbar . prototype . cleanUp _ = function ( ) { Blockly . hideChaff ( ! 0 ) ; Blockly . Scrollbar . onMouseUpWrapper _ && ( Blockly . browserEvents . unbind ( Blockly . Scrollbar . onMouseUpWrapper _ ) , Blockly . Scrollbar . onMouseUpWrapper _ = null ) ; Blockly . Scrollbar . onMouseMoveWrapper _ && ( Blockly . browserEvents . unbind ( Blockly . Scrollbar . onMouseMoveWrapper _ ) , Blockly . Scrollbar . onMouseMoveWrapper _ = null ) } ;
Blockly . Scrollbar . prototype . getRatio _ = function ( ) { var a = this . handlePosition _ / ( this . scrollbarLength _ - this . handleLength _ ) ; isNaN ( a ) && ( a = 0 ) ; return a } ; Blockly . Scrollbar . prototype . updateMetrics _ = function ( ) { var a = this . getRatio _ ( ) , b = { } ; this . horizontal _ ? b . x = a : b . y = a ; this . workspace _ . setMetrics ( b ) } ; Blockly . Scrollbar . prototype . set = function ( a , b ) { this . setHandlePosition ( this . constrainHandlePosition _ ( a * this . ratio ) ) ; ( b || void 0 === b ) && this . updateMetrics _ ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Scrollbar . prototype . setOrigin = function ( a , b ) { this . origin _ = new Blockly . utils . Coordinate ( a , b ) } ; Blockly . Tooltip = { } ; Blockly . Tooltip . visible = ! 1 ; Blockly . Tooltip . blocked _ = ! 1 ; Blockly . Tooltip . LIMIT = 50 ; Blockly . Tooltip . mouseOutPid _ = 0 ; Blockly . Tooltip . showPid _ = 0 ; Blockly . Tooltip . lastX _ = 0 ; Blockly . Tooltip . lastY _ = 0 ; Blockly . Tooltip . element _ = null ; Blockly . Tooltip . poisonedElement _ = null ; Blockly . Tooltip . OFFSET _X = 0 ; Blockly . Tooltip . OFFSET _Y = 10 ; Blockly . Tooltip . RADIUS _OK = 10 ; Blockly . Tooltip . HOVER _MS = 750 ; Blockly . Tooltip . MARGINS = 5 ; Blockly . Tooltip . DIV = null ;
Blockly . Tooltip . getTooltipOfObject = function ( a ) { if ( a = Blockly . Tooltip . getTargetObject _ ( a ) ) { for ( a = a . tooltip ; "function" == typeof a ; ) a = a ( ) ; if ( "string" != typeof a ) throw Error ( "Tooltip function must return a string." ) ; return a } return "" } ; Blockly . Tooltip . getTargetObject _ = function ( a ) { for ( ; a && a . tooltip ; ) { if ( "string" == typeof a . tooltip || "function" == typeof a . tooltip ) return a ; a = a . tooltip } return null } ;
Blockly . Tooltip . createDom = function ( ) { Blockly . Tooltip . DIV || ( Blockly . Tooltip . DIV = document . createElement ( "div" ) , Blockly . Tooltip . DIV . className = "blocklyTooltipDiv" , ( Blockly . parentContainer || document . body ) . appendChild ( Blockly . Tooltip . DIV ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Tooltip . bindMouseEvents = function ( a ) { a . mouseOverWrapper _ = Blockly . browserEvents . bind ( a , "mouseover" , null , Blockly . Tooltip . onMouseOver _ ) ; a . mouseOutWrapper _ = Blockly . browserEvents . bind ( a , "mouseout" , null , Blockly . Tooltip . onMouseOut _ ) ; a . addEventListener ( "mousemove" , Blockly . Tooltip . onMouseMove _ , ! 1 ) } ; Blockly . Tooltip . unbindMouseEvents = function ( a ) { a && ( Blockly . browserEvents . unbind ( a . mouseOverWrapper _ ) , Blockly . browserEvents . unbind ( a . mouseOutWrapper _ ) , a . removeEventListener ( "mousemove" , Blockly . Tooltip . onMouseMove _ ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Tooltip . onMouseOver _ = function ( a ) { Blockly . Tooltip . blocked _ || ( a = Blockly . Tooltip . getTargetObject _ ( a . currentTarget ) , Blockly . Tooltip . element _ != a && ( Blockly . Tooltip . hide ( ) , Blockly . Tooltip . poisonedElement _ = null , Blockly . Tooltip . element _ = a ) , clearTimeout ( Blockly . Tooltip . mouseOutPid _ ) ) } ; Blockly . Tooltip . onMouseOut _ = function ( a ) { Blockly . Tooltip . blocked _ || ( Blockly . Tooltip . mouseOutPid _ = setTimeout ( function ( ) { Blockly . Tooltip . element _ = null ; Blockly . Tooltip . poisonedElement _ = null ; Blockly . Tooltip . hide ( ) } , 1 ) , clearTimeout ( Blockly . Tooltip . showPid _ ) ) } ;
Blockly . Tooltip . onMouseMove _ = function ( a ) { if ( Blockly . Tooltip . element _ && Blockly . Tooltip . element _ . tooltip && ! Blockly . Tooltip . blocked _ ) if ( Blockly . Tooltip . visible ) { var b = Blockly . Tooltip . lastX _ - a . pageX ; a = Blockly . Tooltip . lastY _ - a . pageY ; Math . sqrt ( b * b + a * a ) > Blockly . Tooltip . RADIUS _OK && Blockly . Tooltip . hide ( ) } else Blockly . Tooltip . poisonedElement _ != Blockly . Tooltip . element _ && ( clearTimeout ( Blockly . Tooltip . showPid _ ) , Blockly . Tooltip . lastX _ = a . pageX , Blockly . Tooltip . lastY _ = a . pageY , Blockly . Tooltip . showPid _ = setTimeout ( Blockly . Tooltip . show _ ,
Blockly . Tooltip . HOVER _MS ) ) } ; Blockly . Tooltip . dispose = function ( ) { Blockly . Tooltip . element _ = null ; Blockly . Tooltip . poisonedElement _ = null ; Blockly . Tooltip . hide ( ) } ; Blockly . Tooltip . hide = function ( ) { Blockly . Tooltip . visible && ( Blockly . Tooltip . visible = ! 1 , Blockly . Tooltip . DIV && ( Blockly . Tooltip . DIV . style . display = "none" ) ) ; Blockly . Tooltip . showPid _ && clearTimeout ( Blockly . Tooltip . showPid _ ) } ; Blockly . Tooltip . block = function ( ) { Blockly . Tooltip . hide ( ) ; Blockly . Tooltip . blocked _ = ! 0 } ;
Blockly . Tooltip . unblock = function ( ) { Blockly . Tooltip . blocked _ = ! 1 } ;
Blockly . Tooltip . show _ = function ( ) { if ( ! Blockly . Tooltip . blocked _ && ( Blockly . Tooltip . poisonedElement _ = Blockly . Tooltip . element _ , Blockly . Tooltip . DIV ) ) { Blockly . Tooltip . DIV . textContent = "" ; var a = Blockly . Tooltip . getTooltipOfObject ( Blockly . Tooltip . element _ ) ; a = Blockly . utils . string . wrap ( a , Blockly . Tooltip . LIMIT ) ; a = a . split ( "\n" ) ; for ( var b = 0 ; b < a . length ; b ++ ) { var c = document . createElement ( "div" ) ; c . appendChild ( document . createTextNode ( a [ b ] ) ) ; Blockly . Tooltip . DIV . appendChild ( c ) } a = Blockly . Tooltip . element _ . RTL ; b = document . documentElement . clientWidth ;
c = document . documentElement . clientHeight ; Blockly . Tooltip . DIV . style . direction = a ? "rtl" : "ltr" ; Blockly . Tooltip . DIV . style . display = "block" ; Blockly . Tooltip . visible = ! 0 ; var d = Blockly . Tooltip . lastX _ ; d = a ? d - ( Blockly . Tooltip . OFFSET _X + Blockly . Tooltip . DIV . offsetWidth ) : d + Blockly . Tooltip . OFFSET _X ; var e = Blockly . Tooltip . lastY _ + Blockly . Tooltip . OFFSET _Y ; e + Blockly . Tooltip . DIV . offsetHeight > c + window . scrollY && ( e -= Blockly . Tooltip . DIV . offsetHeight + 2 * Blockly . Tooltip . OFFSET _Y ) ; a ? d = Math . max ( Blockly . Tooltip . MARGINS - window . scrollX ,
2021-05-19 13:38:55 +00:00
d ) : d + Blockly . Tooltip . DIV . offsetWidth > b + window . scrollX - 2 * Blockly . Tooltip . MARGINS && ( d = b - Blockly . Tooltip . DIV . offsetWidth - 2 * Blockly . Tooltip . MARGINS ) ; Blockly . Tooltip . DIV . style . top = e + "px" ; Blockly . Tooltip . DIV . style . left = d + "px" } } ; Blockly . utils . aria = { } ; Blockly . utils . aria . ARIA _PREFIX _ = "aria-" ; Blockly . utils . aria . ROLE _ATTRIBUTE _ = "role" ; Blockly . utils . aria . Role = { GRID : "grid" , GRIDCELL : "gridcell" , GROUP : "group" , LISTBOX : "listbox" , MENU : "menu" , MENUITEM : "menuitem" , MENUITEMCHECKBOX : "menuitemcheckbox" , OPTION : "option" , PRESENTATION : "presentation" , ROW : "row" , TREE : "tree" , TREEITEM : "treeitem" } ;
Blockly . utils . aria . State = { ACTIVEDESCENDANT : "activedescendant" , COLCOUNT : "colcount" , DISABLED : "disabled" , EXPANDED : "expanded" , INVALID : "invalid" , LABEL : "label" , LABELLEDBY : "labelledby" , LEVEL : "level" , ORIENTATION : "orientation" , POSINSET : "posinset" , ROWCOUNT : "rowcount" , SELECTED : "selected" , SETSIZE : "setsize" , VALUEMAX : "valuemax" , VALUEMIN : "valuemin" } ; Blockly . utils . aria . setRole = function ( a , b ) { a . setAttribute ( Blockly . utils . aria . ROLE _ATTRIBUTE _ , b ) } ;
2021-09-18 14:29:06 +00:00
Blockly . utils . aria . setState = function ( a , b , c ) { Array . isArray ( c ) && ( c = c . join ( " " ) ) ; a . setAttribute ( Blockly . utils . aria . ARIA _PREFIX _ + b , c ) } ; Blockly . IASTNodeLocation = function ( ) { } ; Blockly . IASTNodeLocationSvg = function ( ) { } ; Blockly . IASTNodeLocationWithBlock = function ( ) { } ; Blockly . IKeyboardAccessible = function ( ) { } ; Blockly . utils . deprecation = { } ; Blockly . utils . deprecation . warn = function ( a , b , c , d ) { a = a + " was deprecated on " + b + " and will be deleted on " + c + "." ; d && ( a += "\nUse " + d + " instead." ) ; console . warn ( a ) } ; Blockly . Connection = function ( a , b ) { this . sourceBlock _ = a ; this . type = b } ; Blockly . Connection . CAN _CONNECT = 0 ; Blockly . Connection . REASON _SELF _CONNECTION = 1 ; Blockly . Connection . REASON _WRONG _TYPE = 2 ; Blockly . Connection . REASON _TARGET _NULL = 3 ; Blockly . Connection . REASON _CHECKS _FAILED = 4 ; Blockly . Connection . REASON _DIFFERENT _WORKSPACES = 5 ; Blockly . Connection . REASON _SHADOW _PARENT = 6 ; Blockly . Connection . REASON _DRAG _CHECKS _FAILED = 7 ; Blockly . Connection . prototype . targetConnection = null ; Blockly . Connection . prototype . disposed = ! 1 ;
Blockly . Connection . prototype . check _ = null ; Blockly . Connection . prototype . shadowDom _ = null ; Blockly . Connection . prototype . x = 0 ; Blockly . Connection . prototype . y = 0 ;
Blockly . Connection . prototype . connect _ = function ( a ) { var b = Blockly . connectionTypes . INPUT _VALUE , c = this . getSourceBlock ( ) , d = a . getSourceBlock ( ) ; a . isConnected ( ) && a . disconnect ( ) ; if ( this . isConnected ( ) ) { var e = this . getShadowDom ( ! 0 ) ; this . shadowDom _ = null ; var f = this . targetBlock ( ) ; if ( f . isShadow ( ) ) f . dispose ( ! 1 ) ; else { this . disconnect ( ) ; var g = f } this . shadowDom _ = e } var h ; Blockly . Events . isEnabled ( ) && ( h = new ( Blockly . Events . get ( Blockly . Events . BLOCK _MOVE ) ) ( d ) ) ; Blockly . Connection . connectReciprocally _ ( this , a ) ; d . setParent ( c ) ;
h && ( h . recordNew ( ) , Blockly . Events . fire ( h ) ) ; if ( g ) if ( a = this . type === b ? g . outputConnection : g . previousConnection , d = Blockly . Connection . getConnectionForOrphanedConnection ( d , a ) ) a . connect ( d ) ; else a . onFailedConnect ( this ) } ; Blockly . Connection . prototype . dispose = function ( ) { if ( this . isConnected ( ) ) { this . setShadowDom ( null ) ; var a = this . targetBlock ( ) ; a && a . unplug ( ) } this . disposed = ! 0 } ; Blockly . Connection . prototype . getSourceBlock = function ( ) { return this . sourceBlock _ } ;
Blockly . Connection . prototype . isSuperior = function ( ) { return this . type == Blockly . connectionTypes . INPUT _VALUE || this . type == Blockly . connectionTypes . NEXT _STATEMENT } ; Blockly . Connection . prototype . isConnected = function ( ) { return ! ! this . targetConnection } ;
Blockly . Connection . prototype . canConnectWithReason = function ( a ) { Blockly . utils . deprecation . warn ( "Connection.prototype.canConnectWithReason" , "July 2020" , "July 2021" , "the workspace's connection checker" ) ; return this . getConnectionChecker ( ) . canConnectWithReason ( this , a , ! 1 ) } ;
Blockly . Connection . prototype . checkConnection = function ( a ) { Blockly . utils . deprecation . warn ( "Connection.prototype.checkConnection" , "July 2020" , "July 2021" , "the workspace's connection checker" ) ; var b = this . getConnectionChecker ( ) , c = b . canConnectWithReason ( this , a , ! 1 ) ; if ( c != Blockly . Connection . CAN _CONNECT ) throw Error ( b . getErrorMessage ( c , this , a ) ) ; } ; Blockly . Connection . prototype . getConnectionChecker = function ( ) { return this . sourceBlock _ . workspace . connectionChecker } ;
Blockly . Connection . prototype . isConnectionAllowed = function ( a ) { Blockly . utils . deprecation . warn ( "Connection.prototype.isConnectionAllowed" , "July 2020" , "July 2021" , "the workspace's connection checker" ) ; return this . getConnectionChecker ( ) . canConnect ( this , a , ! 0 ) } ; Blockly . Connection . prototype . onFailedConnect = function ( a ) { } ;
Blockly . Connection . prototype . connect = function ( a ) { if ( this . targetConnection != a && this . getConnectionChecker ( ) . canConnect ( this , a , ! 1 ) ) { var b = Blockly . Events . getGroup ( ) ; b || Blockly . Events . setGroup ( ! 0 ) ; this . isSuperior ( ) ? this . connect _ ( a ) : a . connect _ ( this ) ; b || Blockly . Events . setGroup ( ! 1 ) } } ; Blockly . Connection . connectReciprocally _ = function ( a , b ) { if ( ! a || ! b ) throw Error ( "Cannot connect null connections." ) ; a . targetConnection = b ; b . targetConnection = a } ;
Blockly . Connection . getSingleConnection _ = function ( a , b ) { var c = null ; b = b . outputConnection ; for ( var d = b . getConnectionChecker ( ) , e = 0 , f ; f = a . inputList [ e ] ; e ++ ) if ( ( f = f . connection ) && d . canConnect ( b , f , ! 1 ) ) { if ( c ) return null ; c = f } return c } ; Blockly . Connection . getConnectionForOrphanedOutput _ = function ( a , b ) { for ( var c ; c = Blockly . Connection . getSingleConnection _ ( a , b ) ; ) if ( a = c . targetBlock ( ) , ! a || a . isShadow ( ) ) return c ; return null } ;
Blockly . Connection . getConnectionForOrphanedConnection = function ( a , b ) { if ( b . type === Blockly . connectionTypes . OUTPUT _VALUE ) return Blockly . Connection . getConnectionForOrphanedOutput _ ( a , b . getSourceBlock ( ) ) ; a = a . lastConnectionInStack ( ! 0 ) ; var c = b . getConnectionChecker ( ) ; return a && c . canConnect ( b , a , ! 1 ) ? a : null } ;
Blockly . Connection . prototype . disconnect = function ( ) { var a = this . targetConnection ; if ( ! a ) throw Error ( "Source connection not connected." ) ; if ( a . targetConnection != this ) throw Error ( "Target connection not connected to source connection." ) ; if ( this . isSuperior ( ) ) { var b = this . sourceBlock _ ; var c = a . getSourceBlock ( ) ; a = this } else b = a . getSourceBlock ( ) , c = this . sourceBlock _ ; var d = Blockly . Events . getGroup ( ) ; d || Blockly . Events . setGroup ( ! 0 ) ; this . disconnectInternal _ ( b , c ) ; c . isShadow ( ) || a . respawnShadow _ ( ) ; d || Blockly . Events . setGroup ( ! 1 ) } ;
Blockly . Connection . prototype . disconnectInternal _ = function ( a , b ) { var c ; Blockly . Events . isEnabled ( ) && ( c = new ( Blockly . Events . get ( Blockly . Events . BLOCK _MOVE ) ) ( b ) ) ; this . targetConnection = this . targetConnection . targetConnection = null ; b . setParent ( null ) ; c && ( c . recordNew ( ) , Blockly . Events . fire ( c ) ) } ;
Blockly . Connection . prototype . respawnShadow _ = function ( ) { var a = this . getSourceBlock ( ) , b = this . getShadowDom ( ) ; if ( a . workspace && b ) if ( a = Blockly . Xml . domToBlock ( b , a . workspace ) , a . outputConnection ) this . connect ( a . outputConnection ) ; else if ( a . previousConnection ) this . connect ( a . previousConnection ) ; else throw Error ( "Child block does not have output or previous statement." ) ; } ; Blockly . Connection . prototype . targetBlock = function ( ) { return this . isConnected ( ) ? this . targetConnection . getSourceBlock ( ) : null } ;
Blockly . Connection . prototype . checkType = function ( a ) { Blockly . utils . deprecation . warn ( "Connection.prototype.checkType" , "October 2019" , "January 2021" , "the workspace's connection checker" ) ; return this . getConnectionChecker ( ) . canConnect ( this , a , ! 1 ) } ; Blockly . Connection . prototype . checkType _ = function ( a ) { Blockly . utils . deprecation . warn ( "Connection.prototype.checkType_" , "October 2019" , "January 2021" , "the workspace's connection checker" ) ; return this . checkType ( a ) } ;
Blockly . Connection . prototype . onCheckChanged _ = function ( ) { ! this . isConnected ( ) || this . targetConnection && this . getConnectionChecker ( ) . canConnect ( this , this . targetConnection , ! 1 ) || ( this . isSuperior ( ) ? this . targetBlock ( ) : this . sourceBlock _ ) . unplug ( ) } ; Blockly . Connection . prototype . setCheck = function ( a ) { a ? ( Array . isArray ( a ) || ( a = [ a ] ) , this . check _ = a , this . onCheckChanged _ ( ) ) : this . check _ = null ; return this } ; Blockly . Connection . prototype . getCheck = function ( ) { return this . check _ } ;
Blockly . Connection . prototype . setShadowDom = function ( a ) { this . shadowDom _ = a ; a = this . targetBlock ( ) ; a ? a . isShadow ( ) && ( a . dispose ( ! 1 ) , this . respawnShadow _ ( ) ) : this . respawnShadow _ ( ) } ; Blockly . Connection . prototype . getShadowDom = function ( a ) { return a && this . targetBlock ( ) . isShadow ( ) ? Blockly . Xml . blockToDom ( this . targetBlock ( ) ) : this . shadowDom _ } ; Blockly . Connection . prototype . neighbours = function ( a ) { return [ ] } ;
Blockly . Connection . prototype . getParentInput = function ( ) { for ( var a = null , b = this . sourceBlock _ . inputList , c = 0 ; c < b . length ; c ++ ) if ( b [ c ] . connection === this ) { a = b [ c ] ; break } return a } ;
Blockly . Connection . prototype . toString = function ( ) { var a = this . sourceBlock _ ; if ( ! a ) return "Orphan Connection" ; if ( a . outputConnection == this ) var b = "Output Connection of " ; else if ( a . previousConnection == this ) b = "Previous Connection of " ; else if ( a . nextConnection == this ) b = "Next Connection of " ; else { b = null ; for ( var c = 0 , d ; d = a . inputList [ c ] ; c ++ ) if ( d . connection == this ) { b = d ; break } if ( b ) b = 'Input "' + b . name + '" connection on ' ; else return console . warn ( "Connection not actually connected to sourceBlock_" ) , "Orphan Connection" } return b +
a . toDevString ( ) } ; Blockly . IConnectionChecker = function ( ) { } ; Blockly . ConnectionChecker = function ( ) { } ; Blockly . ConnectionChecker . prototype . canConnect = function ( a , b , c , d ) { return this . canConnectWithReason ( a , b , c , d ) == Blockly . Connection . CAN _CONNECT } ; Blockly . ConnectionChecker . prototype . canConnectWithReason = function ( a , b , c , d ) { var e = this . doSafetyChecks ( a , b ) ; return e != Blockly . Connection . CAN _CONNECT ? e : this . doTypeChecks ( a , b ) ? c && ! this . doDragChecks ( a , b , d || 0 ) ? Blockly . Connection . REASON _DRAG _CHECKS _FAILED : Blockly . Connection . CAN _CONNECT : Blockly . Connection . REASON _CHECKS _FAILED } ;
Blockly . ConnectionChecker . prototype . getErrorMessage = function ( a , b , c ) { switch ( a ) { case Blockly . Connection . REASON _SELF _CONNECTION : return "Attempted to connect a block to itself." ; case Blockly . Connection . REASON _DIFFERENT _WORKSPACES : return "Blocks not on same workspace." ; case Blockly . Connection . REASON _WRONG _TYPE : return "Attempt to connect incompatible types." ; case Blockly . Connection . REASON _TARGET _NULL : return "Target connection is null." ; case Blockly . Connection . REASON _CHECKS _FAILED : return "Connection checks failed. " +
( b + " expected " + b . getCheck ( ) + ", found " + c . getCheck ( ) ) ; case Blockly . Connection . REASON _SHADOW _PARENT : return "Connecting non-shadow to shadow block." ; case Blockly . Connection . REASON _DRAG _CHECKS _FAILED : return "Drag checks failed." ; default : return "Unknown connection failure: this should never happen!" } } ;
Blockly . ConnectionChecker . prototype . doSafetyChecks = function ( a , b ) { if ( ! a || ! b ) return Blockly . Connection . REASON _TARGET _NULL ; if ( a . isSuperior ( ) ) var c = a . getSourceBlock ( ) , d = b . getSourceBlock ( ) ; else d = a . getSourceBlock ( ) , c = b . getSourceBlock ( ) ; return c == d ? Blockly . Connection . REASON _SELF _CONNECTION : b . type != Blockly . OPPOSITE _TYPE [ a . type ] ? Blockly . Connection . REASON _WRONG _TYPE : c . workspace !== d . workspace ? Blockly . Connection . REASON _DIFFERENT _WORKSPACES : c . isShadow ( ) && ! d . isShadow ( ) ? Blockly . Connection . REASON _SHADOW _PARENT :
Blockly . Connection . CAN _CONNECT } ; Blockly . ConnectionChecker . prototype . doTypeChecks = function ( a , b ) { a = a . getCheck ( ) ; b = b . getCheck ( ) ; if ( ! a || ! b ) return ! 0 ; for ( var c = 0 ; c < a . length ; c ++ ) if ( - 1 != b . indexOf ( a [ c ] ) ) return ! 0 ; return ! 1 } ;
Blockly . ConnectionChecker . prototype . doDragChecks = function ( a , b , c ) { if ( a . distanceFrom ( b ) > c || b . getSourceBlock ( ) . isInsertionMarker ( ) ) return ! 1 ; switch ( b . type ) { case Blockly . connectionTypes . PREVIOUS _STATEMENT : return this . canConnectToPrevious _ ( a , b ) ; case Blockly . connectionTypes . OUTPUT _VALUE : if ( b . isConnected ( ) && ! b . targetBlock ( ) . isInsertionMarker ( ) || a . isConnected ( ) ) return ! 1 ; break ; case Blockly . connectionTypes . INPUT _VALUE : if ( b . isConnected ( ) && ! b . targetBlock ( ) . isMovable ( ) && ! b . targetBlock ( ) . isShadow ( ) ) return ! 1 ; break ;
case Blockly . connectionTypes . NEXT _STATEMENT : if ( b . isConnected ( ) && ! a . getSourceBlock ( ) . nextConnection && ! b . targetBlock ( ) . isShadow ( ) && b . targetBlock ( ) . nextConnection ) return ! 1 ; break ; default : return ! 1 } return - 1 != Blockly . draggingConnections . indexOf ( b ) ? ! 1 : ! 0 } ; Blockly . ConnectionChecker . prototype . canConnectToPrevious _ = function ( a , b ) { if ( a . targetConnection || - 1 != Blockly . draggingConnections . indexOf ( b ) ) return ! 1 ; if ( ! b . targetConnection ) return ! 0 ; a = b . targetBlock ( ) ; return a . isInsertionMarker ( ) ? ! a . getPreviousBlock ( ) : ! 1 } ;
Blockly . registry . register ( Blockly . registry . Type . CONNECTION _CHECKER , Blockly . registry . DEFAULT , Blockly . ConnectionChecker ) ; Blockly . VariableMap = function ( a ) { this . variableMap _ = Object . create ( null ) ; this . workspace = a } ; Blockly . VariableMap . prototype . clear = function ( ) { this . variableMap _ = Object . create ( null ) } ; Blockly . VariableMap . prototype . renameVariable = function ( a , b ) { var c = this . getVariable ( b , a . type ) , d = this . workspace . getAllBlocks ( ! 1 ) ; Blockly . Events . setGroup ( ! 0 ) ; try { c && c . getId ( ) != a . getId ( ) ? this . renameVariableWithConflict _ ( a , b , c , d ) : this . renameVariableAndUses _ ( a , b , d ) } finally { Blockly . Events . setGroup ( ! 1 ) } } ;
Blockly . VariableMap . prototype . renameVariableById = function ( a , b ) { var c = this . getVariableById ( a ) ; if ( ! c ) throw Error ( "Tried to rename a variable that didn't exist. ID: " + a ) ; this . renameVariable ( c , b ) } ; Blockly . VariableMap . prototype . renameVariableAndUses _ = function ( a , b , c ) { Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _RENAME ) ) ( a , b ) ) ; a . name = b ; for ( b = 0 ; b < c . length ; b ++ ) c [ b ] . updateVarName ( a ) } ;
Blockly . VariableMap . prototype . renameVariableWithConflict _ = function ( a , b , c , d ) { var e = a . type ; b != c . name && this . renameVariableAndUses _ ( c , b , d ) ; for ( b = 0 ; b < d . length ; b ++ ) d [ b ] . renameVarById ( a . getId ( ) , c . getId ( ) ) ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _DELETE ) ) ( a ) ) ; a = this . getVariablesOfType ( e ) . indexOf ( a ) ; this . variableMap _ [ e ] . splice ( a , 1 ) } ;
Blockly . VariableMap . prototype . createVariable = function ( a , b , c ) { var d = this . getVariable ( a , b ) ; if ( d ) { if ( c && d . getId ( ) != c ) throw Error ( 'Variable "' + a + '" is already in use and its id is "' + d . getId ( ) + '" which conflicts with the passed in id, "' + c + '".' ) ; return d } if ( c && this . getVariableById ( c ) ) throw Error ( 'Variable id, "' + c + '", is already in use.' ) ; d = c || Blockly . utils . genUid ( ) ; b = b || "" ; d = new Blockly . VariableModel ( this . workspace , a , b , d ) ; a = this . variableMap _ [ b ] || [ ] ; a . push ( d ) ; delete this . variableMap _ [ b ] ; this . variableMap _ [ b ] =
a ; return d } ; Blockly . VariableMap . prototype . deleteVariable = function ( a ) { for ( var b = this . variableMap _ [ a . type ] , c = 0 , d ; d = b [ c ] ; c ++ ) if ( d . getId ( ) == a . getId ( ) ) { b . splice ( c , 1 ) ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _DELETE ) ) ( a ) ) ; break } } ;
Blockly . VariableMap . prototype . deleteVariableById = function ( a ) { var b = this . getVariableById ( a ) ; if ( b ) { var c = b . name , d = this . getVariableUsesById ( a ) ; a = 0 ; for ( var e ; e = d [ a ] ; a ++ ) if ( "procedures_defnoreturn" == e . type || "procedures_defreturn" == e . type ) { a = e . getFieldValue ( "NAME" ) ; c = Blockly . Msg . CANNOT _DELETE _VARIABLE _PROCEDURE . replace ( "%1" , c ) . replace ( "%2" , a ) ; Blockly . alert ( c ) ; return } var f = this ; 1 < d . length ? ( c = Blockly . Msg . DELETE _VARIABLE _CONFIRMATION . replace ( "%1" , String ( d . length ) ) . replace ( "%2" , c ) , Blockly . confirm ( c , function ( g ) { g &&
b && f . deleteVariableInternal ( b , d ) } ) ) : f . deleteVariableInternal ( b , d ) } else console . warn ( "Can't delete non-existent variable: " + a ) } ; Blockly . VariableMap . prototype . deleteVariableInternal = function ( a , b ) { var c = Blockly . Events . getGroup ( ) ; c || Blockly . Events . setGroup ( ! 0 ) ; try { for ( var d = 0 ; d < b . length ; d ++ ) b [ d ] . dispose ( ! 0 ) ; this . deleteVariable ( a ) } finally { c || Blockly . Events . setGroup ( ! 1 ) } } ;
Blockly . VariableMap . prototype . getVariable = function ( a , b ) { if ( b = this . variableMap _ [ b || "" ] ) for ( var c = 0 , d ; d = b [ c ] ; c ++ ) if ( Blockly . Names . equals ( d . name , a ) ) return d ; return null } ; Blockly . VariableMap . prototype . getVariableById = function ( a ) { for ( var b = Object . keys ( this . variableMap _ ) , c = 0 ; c < b . length ; c ++ ) for ( var d = b [ c ] , e = 0 , f ; f = this . variableMap _ [ d ] [ e ] ; e ++ ) if ( f . getId ( ) == a ) return f ; return null } ; Blockly . VariableMap . prototype . getVariablesOfType = function ( a ) { return ( a = this . variableMap _ [ a || "" ] ) ? a . slice ( ) : [ ] } ;
Blockly . VariableMap . prototype . getVariableTypes = function ( a ) { var b = { } ; Blockly . utils . object . mixin ( b , this . variableMap _ ) ; a && a . getPotentialVariableMap ( ) && Blockly . utils . object . mixin ( b , a . getPotentialVariableMap ( ) . variableMap _ ) ; a = Object . keys ( b ) ; b = ! 1 ; for ( var c = 0 ; c < a . length ; c ++ ) "" == a [ c ] && ( b = ! 0 ) ; b || a . push ( "" ) ; return a } ; Blockly . VariableMap . prototype . getAllVariables = function ( ) { var a = [ ] , b ; for ( b in this . variableMap _ ) a = a . concat ( this . variableMap _ [ b ] ) ; return a } ;
Blockly . VariableMap . prototype . getAllVariableNames = function ( ) { var a = [ ] , b ; for ( b in this . variableMap _ ) for ( var c = this . variableMap _ [ b ] , d = 0 , e ; e = c [ d ] ; d ++ ) a . push ( e . name ) ; return a } ; Blockly . VariableMap . prototype . getVariableUsesById = function ( a ) { for ( var b = [ ] , c = this . workspace . getAllBlocks ( ! 1 ) , d = 0 ; d < c . length ; d ++ ) { var e = c [ d ] . getVarModels ( ) ; if ( e ) for ( var f = 0 ; f < e . length ; f ++ ) e [ f ] . getId ( ) == a && b . push ( c [ d ] ) } return b } ; Blockly . Workspace = function ( a ) { this . id = Blockly . utils . genUid ( ) ; Blockly . Workspace . WorkspaceDB _ [ this . id ] = this ; this . options = a || new Blockly . Options ( { } ) ; this . RTL = ! ! this . options . RTL ; this . horizontalLayout = ! ! this . options . horizontalLayout ; this . toolboxPosition = this . options . toolboxPosition ; this . connectionChecker = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . CONNECTION _CHECKER , this . options , ! 0 ) ) ( this ) ; this . topBlocks _ = [ ] ; this . topComments _ = [ ] ; this . commentDB _ = Object . create ( null ) ; this . listeners _ = [ ] ;
this . undoStack _ = [ ] ; this . redoStack _ = [ ] ; this . blockDB _ = Object . create ( null ) ; this . typedBlocksDB _ = Object . create ( null ) ; this . variableMap _ = new Blockly . VariableMap ( this ) ; this . potentialVariableMap _ = null } ; Blockly . Workspace . prototype . rendered = ! 1 ; Blockly . Workspace . prototype . isClearing = ! 1 ; Blockly . Workspace . prototype . MAX _UNDO = 1024 ; Blockly . Workspace . prototype . connectionDBList = null ; Blockly . Workspace . prototype . dispose = function ( ) { this . listeners _ . length = 0 ; this . clear ( ) ; delete Blockly . Workspace . WorkspaceDB _ [ this . id ] } ;
Blockly . Workspace . SCAN _ANGLE = 3 ; Blockly . Workspace . prototype . sortObjects _ = function ( a , b ) { a = a . getRelativeToSurfaceXY ( ) ; b = b . getRelativeToSurfaceXY ( ) ; return a . y + Blockly . Workspace . prototype . sortObjects _ . offset * a . x - ( b . y + Blockly . Workspace . prototype . sortObjects _ . offset * b . x ) } ; Blockly . Workspace . prototype . addTopBlock = function ( a ) { this . topBlocks _ . push ( a ) } ;
Blockly . Workspace . prototype . removeTopBlock = function ( a ) { if ( ! Blockly . utils . arrayRemove ( this . topBlocks _ , a ) ) throw Error ( "Block not present in workspace's list of top-most blocks." ) ; } ; Blockly . Workspace . prototype . getTopBlocks = function ( a ) { var b = [ ] . concat ( this . topBlocks _ ) ; a && 1 < b . length && ( this . sortObjects _ . offset = Math . sin ( Blockly . utils . math . toRadians ( Blockly . Workspace . SCAN _ANGLE ) ) , this . RTL && ( this . sortObjects _ . offset *= - 1 ) , b . sort ( this . sortObjects _ ) ) ; return b } ;
Blockly . Workspace . prototype . addTypedBlock = function ( a ) { this . typedBlocksDB _ [ a . type ] || ( this . typedBlocksDB _ [ a . type ] = [ ] ) ; this . typedBlocksDB _ [ a . type ] . push ( a ) } ; Blockly . Workspace . prototype . removeTypedBlock = function ( a ) { this . typedBlocksDB _ [ a . type ] . splice ( this . typedBlocksDB _ [ a . type ] . indexOf ( a ) , 1 ) ; this . typedBlocksDB _ [ a . type ] . length || delete this . typedBlocksDB _ [ a . type ] } ;
Blockly . Workspace . prototype . getBlocksByType = function ( a , b ) { if ( ! this . typedBlocksDB _ [ a ] ) return [ ] ; a = this . typedBlocksDB _ [ a ] . slice ( 0 ) ; b && 1 < a . length && ( this . sortObjects _ . offset = Math . sin ( Blockly . utils . math . toRadians ( Blockly . Workspace . SCAN _ANGLE ) ) , this . RTL && ( this . sortObjects _ . offset *= - 1 ) , a . sort ( this . sortObjects _ ) ) ; return a } ;
Blockly . Workspace . prototype . addTopComment = function ( a ) { this . topComments _ . push ( a ) ; this . commentDB _ [ a . id ] && console . warn ( 'Overriding an existing comment on this workspace, with id "' + a . id + '"' ) ; this . commentDB _ [ a . id ] = a } ; Blockly . Workspace . prototype . removeTopComment = function ( a ) { if ( ! Blockly . utils . arrayRemove ( this . topComments _ , a ) ) throw Error ( "Comment not present in workspace's list of top-most comments." ) ; delete this . commentDB _ [ a . id ] } ;
Blockly . Workspace . prototype . getTopComments = function ( a ) { var b = [ ] . concat ( this . topComments _ ) ; a && 1 < b . length && ( this . sortObjects _ . offset = Math . sin ( Blockly . utils . math . toRadians ( Blockly . Workspace . SCAN _ANGLE ) ) , this . RTL && ( this . sortObjects _ . offset *= - 1 ) , b . sort ( this . sortObjects _ ) ) ; return b } ;
Blockly . Workspace . prototype . getAllBlocks = function ( a ) { if ( a ) { a = this . getTopBlocks ( ! 0 ) ; for ( var b = [ ] , c = 0 ; c < a . length ; c ++ ) b . push . apply ( b , a [ c ] . getDescendants ( ! 0 ) ) } else for ( b = this . getTopBlocks ( ! 1 ) , c = 0 ; c < b . length ; c ++ ) b . push . apply ( b , b [ c ] . getChildren ( ! 1 ) ) ; return b . filter ( function ( d ) { return ! d . isInsertionMarker ( ) } ) } ;
Blockly . Workspace . prototype . clear = function ( ) { this . isClearing = ! 0 ; try { var a = Blockly . Events . getGroup ( ) ; for ( a || Blockly . Events . setGroup ( ! 0 ) ; this . topBlocks _ . length ; ) this . topBlocks _ [ 0 ] . dispose ( ! 1 ) ; for ( ; this . topComments _ . length ; ) this . topComments _ [ this . topComments _ . length - 1 ] . dispose ( ! 1 ) ; a || Blockly . Events . setGroup ( ! 1 ) ; this . variableMap _ . clear ( ) ; this . potentialVariableMap _ && this . potentialVariableMap _ . clear ( ) } finally { this . isClearing = ! 1 } } ;
Blockly . Workspace . prototype . renameVariableById = function ( a , b ) { this . variableMap _ . renameVariableById ( a , b ) } ; Blockly . Workspace . prototype . createVariable = function ( a , b , c ) { return this . variableMap _ . createVariable ( a , b , c ) } ; Blockly . Workspace . prototype . getVariableUsesById = function ( a ) { return this . variableMap _ . getVariableUsesById ( a ) } ; Blockly . Workspace . prototype . deleteVariableById = function ( a ) { this . variableMap _ . deleteVariableById ( a ) } ;
Blockly . Workspace . prototype . getVariable = function ( a , b ) { return this . variableMap _ . getVariable ( a , b ) } ; Blockly . Workspace . prototype . getVariableById = function ( a ) { return this . variableMap _ . getVariableById ( a ) } ; Blockly . Workspace . prototype . getVariablesOfType = function ( a ) { return this . variableMap _ . getVariablesOfType ( a ) } ; Blockly . Workspace . prototype . getVariableTypes = function ( ) { return this . variableMap _ . getVariableTypes ( this ) } ; Blockly . Workspace . prototype . getAllVariables = function ( ) { return this . variableMap _ . getAllVariables ( ) } ;
Blockly . Workspace . prototype . getAllVariableNames = function ( ) { return this . variableMap _ . getAllVariableNames ( ) } ; Blockly . Workspace . prototype . getWidth = function ( ) { return 0 } ; Blockly . Workspace . prototype . newBlock = function ( a , b ) { return new Blockly . Block ( this , a , b ) } ; Blockly . Workspace . prototype . remainingCapacity = function ( ) { return isNaN ( this . options . maxBlocks ) ? Infinity : this . options . maxBlocks - this . getAllBlocks ( ! 1 ) . length } ;
Blockly . Workspace . prototype . remainingCapacityOfType = function ( a ) { return this . options . maxInstances ? ( void 0 !== this . options . maxInstances [ a ] ? this . options . maxInstances [ a ] : Infinity ) - this . getBlocksByType ( a , ! 1 ) . length : Infinity } ; Blockly . Workspace . prototype . isCapacityAvailable = function ( a ) { if ( ! this . hasBlockLimits ( ) ) return ! 0 ; var b = 0 , c ; for ( c in a ) { if ( a [ c ] > this . remainingCapacityOfType ( c ) ) return ! 1 ; b += a [ c ] } return b > this . remainingCapacity ( ) ? ! 1 : ! 0 } ;
Blockly . Workspace . prototype . hasBlockLimits = function ( ) { return Infinity != this . options . maxBlocks || ! ! this . options . maxInstances } ; Blockly . Workspace . prototype . getUndoStack = function ( ) { return this . undoStack _ } ; Blockly . Workspace . prototype . getRedoStack = function ( ) { return this . redoStack _ } ;
Blockly . Workspace . prototype . undo = function ( a ) { var b = a ? this . redoStack _ : this . undoStack _ , c = a ? this . undoStack _ : this . redoStack _ , d = b . pop ( ) ; if ( d ) { for ( var e = [ d ] ; b . length && d . group && d . group == b [ b . length - 1 ] . group ; ) e . push ( b . pop ( ) ) ; for ( b = 0 ; d = e [ b ] ; b ++ ) c . push ( d ) ; e = Blockly . Events . filter ( e , a ) ; Blockly . Events . recordUndo = ! 1 ; try { for ( b = 0 ; d = e [ b ] ; b ++ ) d . run ( a ) } finally { Blockly . Events . recordUndo = ! 0 } } } ; Blockly . Workspace . prototype . clearUndo = function ( ) { this . undoStack _ . length = 0 ; this . redoStack _ . length = 0 ; Blockly . Events . clearPendingUndo ( ) } ;
Blockly . Workspace . prototype . addChangeListener = function ( a ) { this . listeners _ . push ( a ) ; return a } ; Blockly . Workspace . prototype . removeChangeListener = function ( a ) { Blockly . utils . arrayRemove ( this . listeners _ , a ) } ; Blockly . Workspace . prototype . fireChangeListener = function ( a ) { if ( a . recordUndo ) for ( this . undoStack _ . push ( a ) , this . redoStack _ . length = 0 ; this . undoStack _ . length > this . MAX _UNDO && 0 <= this . MAX _UNDO ; ) this . undoStack _ . shift ( ) ; for ( var b = 0 , c ; c = this . listeners _ [ b ] ; b ++ ) c ( a ) } ;
Blockly . Workspace . prototype . getBlockById = function ( a ) { return this . blockDB _ [ a ] || null } ; Blockly . Workspace . prototype . setBlockById = function ( a , b ) { this . blockDB _ [ a ] = b } ; Blockly . Workspace . prototype . removeBlockById = function ( a ) { delete this . blockDB _ [ a ] } ; Blockly . Workspace . prototype . getCommentById = function ( a ) { return this . commentDB _ [ a ] || null } ; Blockly . Workspace . prototype . allInputsFilled = function ( a ) { for ( var b = this . getTopBlocks ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) if ( ! d . allInputsFilled ( a ) ) return ! 1 ; return ! 0 } ;
Blockly . Workspace . prototype . getPotentialVariableMap = function ( ) { return this . potentialVariableMap _ } ; Blockly . Workspace . prototype . createPotentialVariableMap = function ( ) { this . potentialVariableMap _ = new Blockly . VariableMap ( this ) } ; Blockly . Workspace . prototype . getVariableMap = function ( ) { return this . variableMap _ } ; Blockly . Workspace . prototype . setVariableMap = function ( a ) { this . variableMap _ = a } ; Blockly . Workspace . WorkspaceDB _ = Object . create ( null ) ;
Blockly . Workspace . getById = function ( a ) { return Blockly . Workspace . WorkspaceDB _ [ a ] || null } ; Blockly . Workspace . getAll = function ( ) { var a = [ ] , b ; for ( b in Blockly . Workspace . WorkspaceDB _ ) a . push ( Blockly . Workspace . WorkspaceDB _ [ b ] ) ; return a } ; Blockly . WorkspaceDragSurfaceSvg = function ( a ) { this . container _ = a ; this . createDom ( ) } ; Blockly . WorkspaceDragSurfaceSvg . prototype . SVG _ = null ; Blockly . WorkspaceDragSurfaceSvg . prototype . container _ = null ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceDragSurfaceSvg . prototype . createDom = function ( ) { this . SVG _ || ( this . SVG _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { xmlns : Blockly . utils . dom . SVG _NS , "xmlns:html" : Blockly . utils . dom . HTML _NS , "xmlns:xlink" : Blockly . utils . dom . XLINK _NS , version : "1.1" , "class" : "blocklyWsDragSurface blocklyOverflowVisible" } , null ) , this . container _ . appendChild ( this . SVG _ ) ) } ;
Blockly . WorkspaceDragSurfaceSvg . prototype . translateSurface = function ( a , b ) { a = a . toFixed ( 0 ) ; b = b . toFixed ( 0 ) ; this . SVG _ . style . display = "block" ; Blockly . utils . dom . setCssTransform ( this . SVG _ , "translate3d(" + a + "px, " + b + "px, 0px)" ) } ; Blockly . WorkspaceDragSurfaceSvg . prototype . getSurfaceTranslation = function ( ) { return Blockly . utils . getRelativeXY ( this . SVG _ ) } ;
Blockly . WorkspaceDragSurfaceSvg . prototype . clearAndHide = function ( a ) { if ( ! a ) throw Error ( "Couldn't clear and hide the drag surface: missing new surface." ) ; var b = this . SVG _ . childNodes [ 0 ] , c = this . SVG _ . childNodes [ 1 ] ; if ( ! ( b && c && Blockly . utils . dom . hasClass ( b , "blocklyBlockCanvas" ) && Blockly . utils . dom . hasClass ( c , "blocklyBubbleCanvas" ) ) ) throw Error ( "Couldn't clear and hide the drag surface. A node was missing." ) ; null != this . previousSibling _ ? Blockly . utils . dom . insertAfter ( b , this . previousSibling _ ) : a . insertBefore ( b , a . firstChild ) ;
Blockly . utils . dom . insertAfter ( c , b ) ; this . SVG _ . style . display = "none" ; if ( this . SVG _ . childNodes . length ) throw Error ( "Drag surface was not cleared." ) ; Blockly . utils . dom . setCssTransform ( this . SVG _ , "" ) ; this . previousSibling _ = null } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceDragSurfaceSvg . prototype . setContentsAndShow = function ( a , b , c , d , e , f ) { if ( this . SVG _ . childNodes . length ) throw Error ( "Already dragging a block." ) ; this . previousSibling _ = c ; a . setAttribute ( "transform" , "translate(0, 0) scale(" + f + ")" ) ; b . setAttribute ( "transform" , "translate(0, 0) scale(" + f + ")" ) ; this . SVG _ . setAttribute ( "width" , d ) ; this . SVG _ . setAttribute ( "height" , e ) ; this . SVG _ . appendChild ( a ) ; this . SVG _ . appendChild ( b ) ; this . SVG _ . style . display = "block" } ; Blockly . blockRendering = { } ; Blockly . blockRendering . useDebugger = ! 1 ; Blockly . blockRendering . register = function ( a , b ) { Blockly . registry . register ( Blockly . registry . Type . RENDERER , a , b ) } ; Blockly . blockRendering . unregister = function ( a ) { Blockly . registry . unregister ( Blockly . registry . Type . RENDERER , a ) } ; Blockly . blockRendering . startDebugger = function ( ) { Blockly . blockRendering . useDebugger = ! 0 } ; Blockly . blockRendering . stopDebugger = function ( ) { Blockly . blockRendering . useDebugger = ! 1 } ;
Blockly . blockRendering . init = function ( a , b , c ) { a = new ( Blockly . registry . getClass ( Blockly . registry . Type . RENDERER , a ) ) ( a ) ; a . init ( b , c ) ; return a } ; Blockly . ASTNode = function ( a , b , c ) { if ( ! b ) throw Error ( "Cannot create a node without a location." ) ; this . type _ = a ; this . isConnection _ = Blockly . ASTNode . isConnectionType _ ( a ) ; this . location _ = b ; this . wsCoordinate _ = null ; this . processParams _ ( c || null ) } ; Blockly . ASTNode . types = { FIELD : "field" , BLOCK : "block" , INPUT : "input" , OUTPUT : "output" , NEXT : "next" , PREVIOUS : "previous" , STACK : "stack" , WORKSPACE : "workspace" } ; Blockly . ASTNode . NAVIGATE _ALL _FIELDS = ! 1 ; Blockly . ASTNode . DEFAULT _OFFSET _Y = - 20 ; Blockly . ASTNode . isConnectionType _ = function ( a ) { switch ( a ) { case Blockly . ASTNode . types . PREVIOUS : case Blockly . ASTNode . types . NEXT : case Blockly . ASTNode . types . INPUT : case Blockly . ASTNode . types . OUTPUT : return ! 0 } return ! 1 } ;
2021-01-16 14:07:51 +00:00
Blockly . ASTNode . createFieldNode = function ( a ) { return a ? new Blockly . ASTNode ( Blockly . ASTNode . types . FIELD , a ) : null } ;
2021-05-19 13:38:55 +00:00
Blockly . ASTNode . createConnectionNode = function ( a ) { if ( ! a ) return null ; var b = a . type ; return b == Blockly . connectionTypes . INPUT _VALUE || b == Blockly . connectionTypes . NEXT _STATEMENT && a . getParentInput ( ) ? Blockly . ASTNode . createInputNode ( a . getParentInput ( ) ) : b == Blockly . connectionTypes . NEXT _STATEMENT ? new Blockly . ASTNode ( Blockly . ASTNode . types . NEXT , a ) : b == Blockly . connectionTypes . OUTPUT _VALUE ? new Blockly . ASTNode ( Blockly . ASTNode . types . OUTPUT , a ) : b == Blockly . connectionTypes . PREVIOUS _STATEMENT ? new Blockly . ASTNode ( Blockly . ASTNode . types . PREVIOUS ,
a ) : null } ; Blockly . ASTNode . createInputNode = function ( a ) { return a && a . connection ? new Blockly . ASTNode ( Blockly . ASTNode . types . INPUT , a . connection ) : null } ; Blockly . ASTNode . createBlockNode = function ( a ) { return a ? new Blockly . ASTNode ( Blockly . ASTNode . types . BLOCK , a ) : null } ; Blockly . ASTNode . createStackNode = function ( a ) { return a ? new Blockly . ASTNode ( Blockly . ASTNode . types . STACK , a ) : null } ; Blockly . ASTNode . createWorkspaceNode = function ( a , b ) { return b && a ? new Blockly . ASTNode ( Blockly . ASTNode . types . WORKSPACE , a , { wsCoordinate : b } ) : null } ;
2021-01-16 14:07:51 +00:00
Blockly . ASTNode . createTopNode = function ( a ) { var b = a . previousConnection || a . outputConnection ; return b ? Blockly . ASTNode . createConnectionNode ( b ) : Blockly . ASTNode . createBlockNode ( a ) } ; Blockly . ASTNode . prototype . processParams _ = function ( a ) { a && a . wsCoordinate && ( this . wsCoordinate _ = a . wsCoordinate ) } ; Blockly . ASTNode . prototype . getLocation = function ( ) { return this . location _ } ; Blockly . ASTNode . prototype . getType = function ( ) { return this . type _ } ; Blockly . ASTNode . prototype . getWsCoordinate = function ( ) { return this . wsCoordinate _ } ;
Blockly . ASTNode . prototype . isConnection = function ( ) { return this . isConnection _ } ; Blockly . ASTNode . prototype . findNextForInput _ = function ( ) { var a = this . location _ . getParentInput ( ) , b = a . getSourceBlock ( ) ; a = b . inputList . indexOf ( a ) + 1 ; for ( var c ; c = b . inputList [ a ] ; a ++ ) { for ( var d = c . fieldRow , e = 0 , f ; f = d [ e ] ; e ++ ) if ( f . isClickable ( ) || Blockly . ASTNode . NAVIGATE _ALL _FIELDS ) return Blockly . ASTNode . createFieldNode ( f ) ; if ( c . connection ) return Blockly . ASTNode . createInputNode ( c ) } return null } ;
Blockly . ASTNode . prototype . findNextForField _ = function ( ) { var a = this . location _ , b = a . getParentInput ( ) , c = a . getSourceBlock ( ) , d = c . inputList . indexOf ( b ) ; for ( a = b . fieldRow . indexOf ( a ) + 1 ; b = c . inputList [ d ] ; d ++ ) { for ( var e = b . fieldRow ; a < e . length ; ) { if ( e [ a ] . isClickable ( ) || Blockly . ASTNode . NAVIGATE _ALL _FIELDS ) return Blockly . ASTNode . createFieldNode ( e [ a ] ) ; a ++ } a = 0 ; if ( b . connection ) return Blockly . ASTNode . createInputNode ( b ) } return null } ;
Blockly . ASTNode . prototype . findPrevForInput _ = function ( ) { for ( var a = this . location _ . getParentInput ( ) , b = a . getSourceBlock ( ) , c = b . inputList . indexOf ( a ) , d ; d = b . inputList [ c ] ; c -- ) { if ( d . connection && d !== a ) return Blockly . ASTNode . createInputNode ( d ) ; d = d . fieldRow ; for ( var e = d . length - 1 , f ; f = d [ e ] ; e -- ) if ( f . isClickable ( ) || Blockly . ASTNode . NAVIGATE _ALL _FIELDS ) return Blockly . ASTNode . createFieldNode ( f ) } return null } ;
Blockly . ASTNode . prototype . findPrevForField _ = function ( ) { var a = this . location _ , b = a . getParentInput ( ) , c = a . getSourceBlock ( ) , d = c . inputList . indexOf ( b ) ; a = b . fieldRow . indexOf ( a ) - 1 ; for ( var e ; e = c . inputList [ d ] ; d -- ) { if ( e . connection && e !== b ) return Blockly . ASTNode . createInputNode ( e ) ; for ( e = e . fieldRow ; - 1 < a ; ) { if ( e [ a ] . isClickable ( ) || Blockly . ASTNode . NAVIGATE _ALL _FIELDS ) return Blockly . ASTNode . createFieldNode ( e [ a ] ) ; a -- } 0 <= d - 1 && ( a = c . inputList [ d - 1 ] . fieldRow . length - 1 ) } return null } ;
Blockly . ASTNode . prototype . navigateBetweenStacks _ = function ( a ) { var b = this . getLocation ( ) ; b instanceof Blockly . Block || ( b = b . getSourceBlock ( ) ) ; if ( ! b || ! b . workspace ) return null ; var c = b . getRootBlock ( ) ; b = c . workspace . getTopBlocks ( ! 0 ) ; for ( var d = 0 , e ; e = b [ d ] ; d ++ ) if ( c . id == e . id ) return a = d + ( a ? 1 : - 1 ) , - 1 == a || a == b . length ? null : Blockly . ASTNode . createStackNode ( b [ a ] ) ; throw Error ( "Couldn't find " + ( a ? "next" : "previous" ) + " stack?!" ) ; } ;
Blockly . ASTNode . prototype . findTopASTNodeForBlock _ = function ( a ) { var b = a . previousConnection || a . outputConnection ; return b ? Blockly . ASTNode . createConnectionNode ( b ) : Blockly . ASTNode . createBlockNode ( a ) } ; Blockly . ASTNode . prototype . getOutAstNodeForBlock _ = function ( a ) { if ( ! a ) return null ; a = a . getTopStackBlock ( ) ; var b = a . previousConnection || a . outputConnection ; return b && b . targetConnection && b . targetConnection . getParentInput ( ) ? Blockly . ASTNode . createInputNode ( b . targetConnection . getParentInput ( ) ) : Blockly . ASTNode . createStackNode ( a ) } ;
Blockly . ASTNode . prototype . findFirstFieldOrInput _ = function ( a ) { a = a . inputList ; for ( var b = 0 , c ; c = a [ b ] ; b ++ ) { for ( var d = c . fieldRow , e = 0 , f ; f = d [ e ] ; e ++ ) if ( f . isClickable ( ) || Blockly . ASTNode . NAVIGATE _ALL _FIELDS ) return Blockly . ASTNode . createFieldNode ( f ) ; if ( c . connection ) return Blockly . ASTNode . createInputNode ( c ) } return null } ;
Blockly . ASTNode . prototype . getSourceBlock = function ( ) { return this . getType ( ) === Blockly . ASTNode . types . BLOCK ? this . getLocation ( ) : this . getType ( ) === Blockly . ASTNode . types . STACK ? this . getLocation ( ) : this . getType ( ) === Blockly . ASTNode . types . WORKSPACE ? null : this . getLocation ( ) . getSourceBlock ( ) } ;
Blockly . ASTNode . prototype . next = function ( ) { switch ( this . type _ ) { case Blockly . ASTNode . types . STACK : return this . navigateBetweenStacks _ ( ! 0 ) ; case Blockly . ASTNode . types . OUTPUT : var a = this . location _ ; return Blockly . ASTNode . createBlockNode ( a . getSourceBlock ( ) ) ; case Blockly . ASTNode . types . FIELD : return this . findNextForField _ ( ) ; case Blockly . ASTNode . types . INPUT : return this . findNextForInput _ ( ) ; case Blockly . ASTNode . types . BLOCK : return Blockly . ASTNode . createConnectionNode ( this . location _ . nextConnection ) ; case Blockly . ASTNode . types . PREVIOUS : return a =
this . location _ , Blockly . ASTNode . createBlockNode ( a . getSourceBlock ( ) ) ; case Blockly . ASTNode . types . NEXT : return a = this . location _ , Blockly . ASTNode . createConnectionNode ( a . targetConnection ) } return null } ;
Blockly . ASTNode . prototype . in = function ( ) { switch ( this . type _ ) { case Blockly . ASTNode . types . WORKSPACE : var a = this . location _ . getTopBlocks ( ! 0 ) ; if ( 0 < a . length ) return Blockly . ASTNode . createStackNode ( a [ 0 ] ) ; break ; case Blockly . ASTNode . types . STACK : return a = this . location _ , this . findTopASTNodeForBlock _ ( a ) ; case Blockly . ASTNode . types . BLOCK : return a = this . location _ , this . findFirstFieldOrInput _ ( a ) ; case Blockly . ASTNode . types . INPUT : return Blockly . ASTNode . createConnectionNode ( this . location _ . targetConnection ) } return null } ;
Blockly . ASTNode . prototype . prev = function ( ) { switch ( this . type _ ) { case Blockly . ASTNode . types . STACK : return this . navigateBetweenStacks _ ( ! 1 ) ; case Blockly . ASTNode . types . FIELD : return this . findPrevForField _ ( ) ; case Blockly . ASTNode . types . INPUT : return this . findPrevForInput _ ( ) ; case Blockly . ASTNode . types . BLOCK : var a = this . location _ ; return Blockly . ASTNode . createConnectionNode ( a . previousConnection || a . outputConnection ) ; case Blockly . ASTNode . types . PREVIOUS : a = this . location _ ; if ( ( a = a . targetConnection ) && ! a . getParentInput ( ) ) return Blockly . ASTNode . createConnectionNode ( a ) ;
break ; case Blockly . ASTNode . types . NEXT : return a = this . location _ , Blockly . ASTNode . createBlockNode ( a . getSourceBlock ( ) ) } return null } ;
Blockly . ASTNode . prototype . out = function ( ) { switch ( this . type _ ) { case Blockly . ASTNode . types . STACK : var a = this . location _ , b = a . getRelativeToSurfaceXY ( ) ; b = new Blockly . utils . Coordinate ( b . x , b . y + Blockly . ASTNode . DEFAULT _OFFSET _Y ) ; return Blockly . ASTNode . createWorkspaceNode ( a . workspace , b ) ; case Blockly . ASTNode . types . OUTPUT : return a = this . location _ , ( b = a . targetConnection ) ? Blockly . ASTNode . createConnectionNode ( b ) : Blockly . ASTNode . createStackNode ( a . getSourceBlock ( ) ) ; case Blockly . ASTNode . types . FIELD : return Blockly . ASTNode . createBlockNode ( this . location _ . getSourceBlock ( ) ) ;
2021-09-18 14:29:06 +00:00
case Blockly . ASTNode . types . INPUT : return a = this . location _ , Blockly . ASTNode . createBlockNode ( a . getSourceBlock ( ) ) ; case Blockly . ASTNode . types . BLOCK : return a = this . location _ , this . getOutAstNodeForBlock _ ( a ) ; case Blockly . ASTNode . types . PREVIOUS : return a = this . location _ , this . getOutAstNodeForBlock _ ( a . getSourceBlock ( ) ) ; case Blockly . ASTNode . types . NEXT : return a = this . location _ , this . getOutAstNodeForBlock _ ( a . getSourceBlock ( ) ) } return null } ; Blockly . Blocks = Object . create ( null ) ; Blockly . Extensions = { } ; Blockly . Extensions . ALL _ = Object . create ( null ) ; Blockly . Extensions . register = function ( a , b ) { if ( "string" != typeof a || "" == a . trim ( ) ) throw Error ( 'Error: Invalid extension name "' + a + '"' ) ; if ( Blockly . Extensions . ALL _ [ a ] ) throw Error ( 'Error: Extension "' + a + '" is already registered.' ) ; if ( "function" != typeof b ) throw Error ( 'Error: Extension "' + a + '" must be a function' ) ; Blockly . Extensions . ALL _ [ a ] = b } ;
2021-01-16 14:07:51 +00:00
Blockly . Extensions . registerMixin = function ( a , b ) { if ( ! b || "object" != typeof b ) throw Error ( 'Error: Mixin "' + a + '" must be a object' ) ; Blockly . Extensions . register ( a , function ( ) { this . mixin ( b ) } ) } ;
Blockly . Extensions . registerMutator = function ( a , b , c , d ) { var e = 'Error when registering mutator "' + a + '": ' ; Blockly . Extensions . checkHasFunction _ ( e , b . domToMutation , "domToMutation" ) ; Blockly . Extensions . checkHasFunction _ ( e , b . mutationToDom , "mutationToDom" ) ; var f = Blockly . Extensions . checkMutatorDialog _ ( b , e ) ; if ( c && "function" != typeof c ) throw Error ( 'Extension "' + a + '" is not a function' ) ; Blockly . Extensions . register ( a , function ( ) { if ( f ) { if ( ! Blockly . Mutator ) throw Error ( e + "Missing require for Blockly.Mutator" ) ; this . setMutator ( new Blockly . Mutator ( d ||
[ ] ) ) } this . mixin ( b ) ; c && c . apply ( this ) } ) } ; Blockly . Extensions . unregister = function ( a ) { Blockly . Extensions . ALL _ [ a ] ? delete Blockly . Extensions . ALL _ [ a ] : console . warn ( 'No extension mapping for name "' + a + '" found to unregister' ) } ;
Blockly . Extensions . apply = function ( a , b , c ) { var d = Blockly . Extensions . ALL _ [ a ] ; if ( "function" != typeof d ) throw Error ( 'Error: Extension "' + a + '" not found.' ) ; if ( c ) Blockly . Extensions . checkNoMutatorProperties _ ( a , b ) ; else var e = Blockly . Extensions . getMutatorProperties _ ( b ) ; d . apply ( b ) ; if ( c ) Blockly . Extensions . checkBlockHasMutatorProperties _ ( 'Error after applying mutator "' + a + '": ' , b ) ; else if ( ! Blockly . Extensions . mutatorPropertiesMatch _ ( e , b ) ) throw Error ( 'Error when applying extension "' + a + '": mutation properties changed when applying a non-mutator extension.' ) ;
} ; Blockly . Extensions . checkHasFunction _ = function ( a , b , c ) { if ( ! b ) throw Error ( a + 'missing required property "' + c + '"' ) ; if ( "function" != typeof b ) throw Error ( a + '" required property "' + c + '" must be a function' ) ; } ; Blockly . Extensions . checkNoMutatorProperties _ = function ( a , b ) { if ( Blockly . Extensions . getMutatorProperties _ ( b ) . length ) throw Error ( 'Error: tried to apply mutation "' + a + '" to a block that already has mutator functions. Block id: ' + b . id ) ; } ;
2021-09-18 14:29:06 +00:00
Blockly . Extensions . checkMutatorDialog _ = function ( a , b ) { var c = void 0 !== a . compose , d = void 0 !== a . decompose ; if ( c && d ) { if ( "function" != typeof a . compose ) throw Error ( b + "compose must be a function." ) ; if ( "function" != typeof a . decompose ) throw Error ( b + "decompose must be a function." ) ; return ! 0 } if ( ! c && ! d ) return ! 1 ; throw Error ( b + 'Must have both or neither of "compose" and "decompose"' ) ; } ;
2021-01-16 14:07:51 +00:00
Blockly . Extensions . checkBlockHasMutatorProperties _ = function ( a , b ) { if ( "function" != typeof b . domToMutation ) throw Error ( a + 'Applying a mutator didn\'t add "domToMutation"' ) ; if ( "function" != typeof b . mutationToDom ) throw Error ( a + 'Applying a mutator didn\'t add "mutationToDom"' ) ; Blockly . Extensions . checkMutatorDialog _ ( b , a ) } ;
Blockly . Extensions . getMutatorProperties _ = function ( a ) { var b = [ ] ; void 0 !== a . domToMutation && b . push ( a . domToMutation ) ; void 0 !== a . mutationToDom && b . push ( a . mutationToDom ) ; void 0 !== a . compose && b . push ( a . compose ) ; void 0 !== a . decompose && b . push ( a . decompose ) ; return b } ; Blockly . Extensions . mutatorPropertiesMatch _ = function ( a , b ) { b = Blockly . Extensions . getMutatorProperties _ ( b ) ; if ( b . length != a . length ) return ! 1 ; for ( var c = 0 ; c < b . length ; c ++ ) if ( a [ c ] != b [ c ] ) return ! 1 ; return ! 0 } ;
Blockly . Extensions . buildTooltipForDropdown = function ( a , b ) { var c = [ ] ; "object" == typeof document && Blockly . utils . runAfterPageLoad ( function ( ) { for ( var d in b ) Blockly . utils . checkMessageReferences ( b [ d ] ) } ) ; return function ( ) { this . type && - 1 == c . indexOf ( this . type ) && ( Blockly . Extensions . checkDropdownOptionsInTable _ ( this , a , b ) , c . push ( this . type ) ) ; this . setTooltip ( function ( ) { var d = String ( this . getFieldValue ( a ) ) , e = b [ d ] ; null == e ? - 1 == c . indexOf ( this . type ) && ( d = "No tooltip mapping for value " + d + " of field " + a , null != this . type &&
( d += " of block type " + this . type ) , console . warn ( d + "." ) ) : e = Blockly . utils . replaceMessageReferences ( e ) ; return e } . bind ( this ) ) } } ; Blockly . Extensions . checkDropdownOptionsInTable _ = function ( a , b , c ) { var d = a . getField ( b ) ; if ( ! d . isOptionListDynamic ( ) ) { d = d . getOptions ( ) ; for ( var e = 0 ; e < d . length ; ++ e ) { var f = d [ e ] [ 1 ] ; null == c [ f ] && console . warn ( "No tooltip mapping for value " + f + " of field " + b + " of block type " + a . type ) } } } ;
Blockly . Extensions . buildTooltipWithFieldText = function ( a , b ) { "object" == typeof document && Blockly . utils . runAfterPageLoad ( function ( ) { Blockly . utils . checkMessageReferences ( a ) } ) ; return function ( ) { this . setTooltip ( function ( ) { var c = this . getField ( b ) ; return Blockly . utils . replaceMessageReferences ( a ) . replace ( "%1" , c ? c . getText ( ) : "" ) } . bind ( this ) ) } } ;
Blockly . Extensions . extensionParentTooltip _ = function ( ) { this . tooltipWhenNotConnected _ = this . tooltip ; this . setTooltip ( function ( ) { var a = this . getParent ( ) ; return a && a . getInputsInline ( ) && a . tooltip || this . tooltipWhenNotConnected _ } . bind ( this ) ) } ; Blockly . Extensions . register ( "parent_tooltip_when_inline" , Blockly . Extensions . extensionParentTooltip _ ) ; Blockly . fieldRegistry = { } ; Blockly . fieldRegistry . register = function ( a , b ) { Blockly . registry . register ( Blockly . registry . Type . FIELD , a , b ) } ; Blockly . fieldRegistry . unregister = function ( a ) { Blockly . registry . unregister ( Blockly . registry . Type . FIELD , a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . fieldRegistry . fromJson = function ( a ) { var b = Blockly . registry . getObject ( Blockly . registry . Type . FIELD , a . type ) ; return b ? b . fromJson ( a ) : ( console . warn ( "Blockly could not create a field of type " + a . type + ". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached." ) , null ) } ; Blockly . IDeletable = function ( ) { } ; Blockly . blockAnimations = { } ; Blockly . blockAnimations . disconnectPid _ = 0 ; Blockly . blockAnimations . disconnectGroup _ = null ; Blockly . blockAnimations . disposeUiEffect = function ( a ) { var b = a . workspace , c = a . getSvgRoot ( ) ; b . getAudioManager ( ) . play ( "delete" ) ; a = b . getSvgXY ( c ) ; c = c . cloneNode ( ! 0 ) ; c . translateX _ = a . x ; c . translateY _ = a . y ; c . setAttribute ( "transform" , "translate(" + a . x + "," + a . y + ")" ) ; b . getParentSvg ( ) . appendChild ( c ) ; c . bBox _ = c . getBBox ( ) ; Blockly . blockAnimations . disposeUiStep _ ( c , b . RTL , new Date , b . scale ) } ;
2021-01-16 14:07:51 +00:00
Blockly . blockAnimations . disposeUiStep _ = function ( a , b , c , d ) { var e = ( new Date - c ) / 150 ; 1 < e ? Blockly . utils . dom . removeNode ( a ) : ( a . setAttribute ( "transform" , "translate(" + ( a . translateX _ + ( b ? - 1 : 1 ) * a . bBox _ . width * d / 2 * e ) + "," + ( a . translateY _ + a . bBox _ . height * d * e ) + ") scale(" + ( 1 - e ) * d + ")" ) , setTimeout ( Blockly . blockAnimations . disposeUiStep _ , 10 , a , b , c , d ) ) } ;
Blockly . blockAnimations . connectionUiEffect = function ( a ) { var b = a . workspace , c = b . scale ; b . getAudioManager ( ) . play ( "click" ) ; if ( ! ( 1 > c ) ) { var d = b . getSvgXY ( a . getSvgRoot ( ) ) ; a . outputConnection ? ( d . x += ( a . RTL ? 3 : - 3 ) * c , d . y += 13 * c ) : a . previousConnection && ( d . x += ( a . RTL ? - 23 : 23 ) * c , d . y += 3 * c ) ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE , { cx : d . x , cy : d . y , r : 0 , fill : "none" , stroke : "#888" , "stroke-width" : 10 } , b . getParentSvg ( ) ) ; Blockly . blockAnimations . connectionUiStep _ ( a , new Date , c ) } } ;
Blockly . blockAnimations . connectionUiStep _ = function ( a , b , c ) { var d = ( new Date - b ) / 150 ; 1 < d ? Blockly . utils . dom . removeNode ( a ) : ( a . setAttribute ( "r" , 25 * d * c ) , a . style . opacity = 1 - d , Blockly . blockAnimations . disconnectPid _ = setTimeout ( Blockly . blockAnimations . connectionUiStep _ , 10 , a , b , c ) ) } ;
Blockly . blockAnimations . disconnectUiEffect = function ( a ) { a . workspace . getAudioManager ( ) . play ( "disconnect" ) ; if ( ! ( 1 > a . workspace . scale ) ) { var b = a . getHeightWidth ( ) . height ; b = Math . atan ( 10 / b ) / Math . PI * 180 ; a . RTL || ( b *= - 1 ) ; Blockly . blockAnimations . disconnectUiStep _ ( a . getSvgRoot ( ) , b , new Date ) } } ;
Blockly . blockAnimations . disconnectUiStep _ = function ( a , b , c ) { var d = ( new Date - c ) / 200 ; 1 < d ? a . skew _ = "" : ( a . skew _ = "skewX(" + Math . round ( Math . sin ( d * Math . PI * 3 ) * ( 1 - d ) * b ) + ")" , Blockly . blockAnimations . disconnectGroup _ = a , Blockly . blockAnimations . disconnectPid _ = setTimeout ( Blockly . blockAnimations . disconnectUiStep _ , 10 , a , b , c ) ) ; a . setAttribute ( "transform" , a . translate _ + a . skew _ ) } ;
Blockly . blockAnimations . disconnectUiStop = function ( ) { if ( Blockly . blockAnimations . disconnectGroup _ ) { clearTimeout ( Blockly . blockAnimations . disconnectPid _ ) ; var a = Blockly . blockAnimations . disconnectGroup _ ; a . skew _ = "" ; a . setAttribute ( "transform" , a . translate _ ) ; Blockly . blockAnimations . disconnectGroup _ = null } } ; Blockly . Events . BlockDrag = function ( a , b , c ) { Blockly . Events . BlockDrag . superClass _ . constructor . call ( this , a ? a . workspace . id : void 0 ) ; this . blockId = a ? a . id : null ; this . isStart = b ; this . blocks = c } ; Blockly . utils . object . inherits ( Blockly . Events . BlockDrag , Blockly . Events . UiBase ) ; Blockly . Events . BlockDrag . prototype . type = Blockly . Events . BLOCK _DRAG ;
2021-09-18 14:29:06 +00:00
Blockly . Events . BlockDrag . prototype . toJson = function ( ) { var a = Blockly . Events . BlockDrag . superClass _ . toJson . call ( this ) ; a . isStart = this . isStart ; a . blockId = this . blockId ; a . blocks = this . blocks ; return a } ; Blockly . Events . BlockDrag . prototype . fromJson = function ( a ) { Blockly . Events . BlockDrag . superClass _ . fromJson . call ( this , a ) ; this . isStart = a . isStart ; this . blockId = a . blockId ; this . blocks = a . blocks } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . BLOCK _DRAG , Blockly . Events . BlockDrag ) ; Blockly . IBlockDragger = function ( ) { } ; Blockly . InsertionMarkerManager = function ( a ) { this . topBlock _ = Blockly . selected = a ; this . workspace _ = a . workspace ; this . lastMarker _ = this . lastOnStack _ = null ; this . firstMarker _ = this . createMarkerBlock _ ( this . topBlock _ ) ; this . localConnection _ = this . closestConnection _ = null ; this . wouldDeleteBlock _ = ! 1 ; this . fadedBlock _ = this . highlightedBlock _ = this . markerConnection _ = null ; this . availableConnections _ = this . initAvailableConnections _ ( ) } ; Blockly . InsertionMarkerManager . PREVIEW _TYPE = { INSERTION _MARKER : 0 , INPUT _OUTLINE : 1 , REPLACEMENT _FADE : 2 } ;
Blockly . InsertionMarkerManager . DUPLICATE _BLOCK _ERROR = "The insertion marker manager tried to create a marker but the result is missing %1. If you are using a mutator, make sure your domToMutation method is properly defined." ; Blockly . InsertionMarkerManager . prototype . dispose = function ( ) { this . availableConnections _ . length = 0 ; Blockly . Events . disable ( ) ; try { this . firstMarker _ && this . firstMarker _ . dispose ( ) , this . lastMarker _ && this . lastMarker _ . dispose ( ) } finally { Blockly . Events . enable ( ) } } ;
Blockly . InsertionMarkerManager . prototype . updateAvailableConnections = function ( ) { this . availableConnections _ = this . initAvailableConnections _ ( ) } ; Blockly . InsertionMarkerManager . prototype . wouldDeleteBlock = function ( ) { return this . wouldDeleteBlock _ } ; Blockly . InsertionMarkerManager . prototype . wouldConnectBlock = function ( ) { return ! ! this . closestConnection _ } ;
2021-01-16 14:07:51 +00:00
Blockly . InsertionMarkerManager . prototype . applyConnections = function ( ) { if ( this . closestConnection _ && ( Blockly . Events . disable ( ) , this . hidePreview _ ( ) , Blockly . Events . enable ( ) , this . localConnection _ . connect ( this . closestConnection _ ) , this . topBlock _ . rendered ) ) { var a = this . localConnection _ . isSuperior ( ) ? this . closestConnection _ : this . localConnection _ ; Blockly . blockAnimations . connectionUiEffect ( a . getSourceBlock ( ) ) ; this . topBlock _ . getRootBlock ( ) . bringToFront ( ) } } ;
Blockly . InsertionMarkerManager . prototype . update = function ( a , b ) { var c = this . getCandidate _ ( a ) ; if ( ( this . wouldDeleteBlock _ = this . shouldDelete _ ( c , b ) ) || this . shouldUpdatePreviews _ ( c , a ) ) Blockly . Events . disable ( ) , this . maybeHidePreview _ ( c ) , this . maybeShowPreview _ ( c ) , Blockly . Events . enable ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . InsertionMarkerManager . prototype . createMarkerBlock _ = function ( a ) { var b = a . type ; Blockly . Events . disable ( ) ; try { var c = this . workspace _ . newBlock ( b ) ; c . setInsertionMarker ( ! 0 ) ; if ( a . mutationToDom ) { var d = a . mutationToDom ( ) ; d && c . domToMutation ( d ) } for ( b = 0 ; b < a . inputList . length ; b ++ ) { var e = a . inputList [ b ] ; if ( e . name != Blockly . constants . COLLAPSED _INPUT _NAME ) { var f = c . inputList [ b ] ; if ( ! f ) throw Error ( Blockly . InsertionMarkerManager . DUPLICATE _BLOCK _ERROR . replace ( "%1" , "an input" ) ) ; for ( d = 0 ; d < e . fieldRow . length ; d ++ ) { var g =
e . fieldRow [ d ] , h = f . fieldRow [ d ] ; if ( ! h ) throw Error ( Blockly . InsertionMarkerManager . DUPLICATE _BLOCK _ERROR . replace ( "%1" , "a field" ) ) ; h . setValue ( g . getValue ( ) ) } } } c . setCollapsed ( a . isCollapsed ( ) ) ; c . setInputsInline ( a . getInputsInline ( ) ) ; c . initSvg ( ) ; c . getSvgRoot ( ) . setAttribute ( "visibility" , "hidden" ) } finally { Blockly . Events . enable ( ) } return c } ;
Blockly . InsertionMarkerManager . prototype . initAvailableConnections _ = function ( ) { var a = this . topBlock _ . getConnections _ ( ! 1 ) , b = this . topBlock _ . lastConnectionInStack ( ! 0 ) ; if ( b && b != this . topBlock _ . nextConnection ) { a . push ( b ) ; this . lastOnStack _ = b ; if ( this . lastMarker _ ) { Blockly . Events . disable ( ) ; try { this . lastMarker _ . dispose ( ) } finally { Blockly . Events . enable ( ) } } this . lastMarker _ = this . createMarkerBlock _ ( b . getSourceBlock ( ) ) } return a } ;
2021-01-16 14:07:51 +00:00
Blockly . InsertionMarkerManager . prototype . shouldUpdatePreviews _ = function ( a , b ) { var c = a . local , d = a . closest ; a = a . radius ; if ( c && d ) { if ( this . localConnection _ && this . closestConnection _ ) { if ( this . closestConnection _ == d && this . localConnection _ == c ) return ! 1 ; c = this . localConnection _ . x + b . x - this . closestConnection _ . x ; b = this . localConnection _ . y + b . y - this . closestConnection _ . y ; b = Math . sqrt ( c * c + b * b ) ; return ! ( d && a > b - Blockly . CURRENT _CONNECTION _PREFERENCE ) } if ( this . localConnection _ || this . closestConnection _ ) console . error ( "Only one of localConnection_ and closestConnection_ was set." ) ;
else return ! 0 } else return ! ( ! this . localConnection _ || ! this . closestConnection _ ) ; console . error ( "Returning true from shouldUpdatePreviews, but it's not clear why." ) ; return ! 0 } ; Blockly . InsertionMarkerManager . prototype . getCandidate _ = function ( a ) { for ( var b = this . getStartRadius _ ( ) , c = null , d = null , e = 0 ; e < this . availableConnections _ . length ; e ++ ) { var f = this . availableConnections _ [ e ] , g = f . closest ( b , a ) ; g . connection && ( c = g . connection , d = f , b = g . radius ) } return { closest : c , local : d , radius : b } } ;
2021-09-18 14:29:06 +00:00
Blockly . InsertionMarkerManager . prototype . getStartRadius _ = function ( ) { return this . closestConnection _ && this . localConnection _ ? Blockly . CONNECTING _SNAP _RADIUS : Blockly . SNAP _RADIUS } ; Blockly . InsertionMarkerManager . prototype . shouldDelete _ = function ( a , b ) { return b && this . workspace _ . getComponentManager ( ) . hasCapability ( b . id , Blockly . ComponentManager . Capability . DELETE _AREA ) ? b . wouldDelete ( this . topBlock _ , a && ! ! a . closest ) : ! 1 } ;
2021-01-16 14:07:51 +00:00
Blockly . InsertionMarkerManager . prototype . maybeShowPreview _ = function ( a ) { if ( ! this . wouldDeleteBlock _ ) { var b = a . closest ; a = a . local ; b && ( b == this . closestConnection _ || b . getSourceBlock ( ) . isInsertionMarker ( ) ? console . log ( "Trying to connect to an insertion marker" ) : ( this . closestConnection _ = b , this . localConnection _ = a , this . showPreview _ ( ) ) ) } } ;
Blockly . InsertionMarkerManager . prototype . showPreview _ = function ( ) { var a = this . closestConnection _ , b = this . workspace _ . getRenderer ( ) ; switch ( b . getConnectionPreviewMethod ( a , this . localConnection _ , this . topBlock _ ) ) { case Blockly . InsertionMarkerManager . PREVIEW _TYPE . INPUT _OUTLINE : this . showInsertionInputOutline _ ( ) ; break ; case Blockly . InsertionMarkerManager . PREVIEW _TYPE . INSERTION _MARKER : this . showInsertionMarker _ ( ) ; break ; case Blockly . InsertionMarkerManager . PREVIEW _TYPE . REPLACEMENT _FADE : this . showReplacementFade _ ( ) } a &&
b . shouldHighlightConnection ( a ) && a . highlight ( ) } ; Blockly . InsertionMarkerManager . prototype . maybeHidePreview _ = function ( a ) { if ( a . closest ) { var b = this . closestConnection _ != a . closest ; a = this . localConnection _ != a . local ; this . closestConnection _ && this . localConnection _ && ( b || a || this . wouldDeleteBlock _ ) && this . hidePreview _ ( ) } else this . hidePreview _ ( ) ; this . localConnection _ = this . closestConnection _ = this . markerConnection _ = null } ;
Blockly . InsertionMarkerManager . prototype . hidePreview _ = function ( ) { this . closestConnection _ && this . closestConnection _ . targetBlock ( ) && this . workspace _ . getRenderer ( ) . shouldHighlightConnection ( this . closestConnection _ ) && this . closestConnection _ . unhighlight ( ) ; this . fadedBlock _ ? this . hideReplacementFade _ ( ) : this . highlightedBlock _ ? this . hideInsertionInputOutline _ ( ) : this . markerConnection _ && this . hideInsertionMarker _ ( ) } ;
Blockly . InsertionMarkerManager . prototype . showInsertionMarker _ = function ( ) { var a = this . localConnection _ , b = this . closestConnection _ , c = this . lastOnStack _ && a == this . lastOnStack _ ? this . lastMarker _ : this . firstMarker _ ; a = c . getMatchingConnection ( a . getSourceBlock ( ) , a ) ; if ( a == this . markerConnection _ ) throw Error ( "Made it to showInsertionMarker_ even though the marker isn't changing" ) ; c . render ( ) ; c . rendered = ! 0 ; c . getSvgRoot ( ) . setAttribute ( "visibility" , "visible" ) ; a && b && c . positionNearConnection ( a , b ) ; b && a . connect ( b ) ; this . markerConnection _ =
a } ;
2021-05-19 13:38:55 +00:00
Blockly . InsertionMarkerManager . prototype . hideInsertionMarker _ = function ( ) { if ( this . markerConnection _ ) { var a = this . markerConnection _ , b = a . getSourceBlock ( ) , c = b . nextConnection , d = b . previousConnection , e = b . outputConnection ; e = a . type == Blockly . connectionTypes . INPUT _VALUE && ! ( e && e . targetConnection ) ; ! ( a != c || d && d . targetConnection ) || e ? a . targetBlock ( ) . unplug ( ! 1 ) : a . type == Blockly . connectionTypes . NEXT _STATEMENT && a != c ? ( c = a . targetConnection , c . getSourceBlock ( ) . unplug ( ! 1 ) , d = d ? d . targetConnection : null , b . unplug ( ! 0 ) , d && d . connect ( c ) ) : b . unplug ( ! 0 ) ;
2021-09-18 14:29:06 +00:00
if ( a . targetConnection ) throw Error ( "markerConnection_ still connected at the end of disconnectInsertionMarker" ) ; this . markerConnection _ = null ; ( a = b . getSvgRoot ( ) ) && a . setAttribute ( "visibility" , "hidden" ) } else console . log ( "No insertion marker connection to disconnect" ) } ; Blockly . InsertionMarkerManager . prototype . showInsertionInputOutline _ = function ( ) { var a = this . closestConnection _ ; this . highlightedBlock _ = a . getSourceBlock ( ) ; this . highlightedBlock _ . highlightShapeForInput ( a , ! 0 ) } ;
2021-01-16 14:07:51 +00:00
Blockly . InsertionMarkerManager . prototype . hideInsertionInputOutline _ = function ( ) { this . highlightedBlock _ . highlightShapeForInput ( this . closestConnection _ , ! 1 ) ; this . highlightedBlock _ = null } ; Blockly . InsertionMarkerManager . prototype . showReplacementFade _ = function ( ) { this . fadedBlock _ = this . closestConnection _ . targetBlock ( ) ; this . fadedBlock _ . fadeForReplacement ( ! 0 ) } ; Blockly . InsertionMarkerManager . prototype . hideReplacementFade _ = function ( ) { this . fadedBlock _ . fadeForReplacement ( ! 1 ) ; this . fadedBlock _ = null } ;
2021-09-18 14:29:06 +00:00
Blockly . InsertionMarkerManager . prototype . getInsertionMarkers = function ( ) { var a = [ ] ; this . firstMarker _ && a . push ( this . firstMarker _ ) ; this . lastMarker _ && a . push ( this . lastMarker _ ) ; return a } ; Blockly . BlockDragger = function ( a , b ) { this . draggingBlock _ = a ; this . workspace _ = b ; this . draggedConnectionManager _ = new Blockly . InsertionMarkerManager ( this . draggingBlock _ ) ; this . dragTarget _ = null ; this . wouldDeleteBlock _ = ! 1 ; this . startXY _ = this . draggingBlock _ . getRelativeToSurfaceXY ( ) ; this . dragIconData _ = Blockly . BlockDragger . initIconData _ ( a ) } ; Blockly . BlockDragger . prototype . dispose = function ( ) { this . dragIconData _ . length = 0 ; this . draggedConnectionManager _ && this . draggedConnectionManager _ . dispose ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockDragger . initIconData _ = function ( a ) { var b = [ ] ; a = a . getDescendants ( ! 1 ) ; for ( var c = 0 , d ; d = a [ c ] ; c ++ ) { d = d . getIcons ( ) ; for ( var e = 0 ; e < d . length ; e ++ ) { var f = { location : d [ e ] . getIconLocation ( ) , icon : d [ e ] } ; b . push ( f ) } } return b } ;
2021-09-18 14:29:06 +00:00
Blockly . BlockDragger . prototype . startDrag = function ( a , b ) { Blockly . Events . getGroup ( ) || Blockly . Events . setGroup ( ! 0 ) ; this . fireDragStartEvent _ ( ) ; this . workspace _ . isMutator && this . draggingBlock _ . bringToFront ( ) ; Blockly . utils . dom . startTextWidthCache ( ) ; this . workspace _ . setResizesEnabled ( ! 1 ) ; Blockly . blockAnimations . disconnectUiStop ( ) ; this . shouldDisconnect _ ( b ) && this . disconnectBlock _ ( b , a ) ; this . draggingBlock _ . setDragging ( ! 0 ) ; this . draggingBlock _ . moveToDragSurface ( ) } ;
Blockly . BlockDragger . prototype . shouldDisconnect _ = function ( a ) { return ! ! ( this . draggingBlock _ . getParent ( ) || a && this . draggingBlock _ . nextConnection && this . draggingBlock _ . nextConnection . targetBlock ( ) ) } ; Blockly . BlockDragger . prototype . disconnectBlock _ = function ( a , b ) { this . draggingBlock _ . unplug ( a ) ; a = this . pixelsToWorkspaceUnits _ ( b ) ; a = Blockly . utils . Coordinate . sum ( this . startXY _ , a ) ; this . draggingBlock _ . translate ( a . x , a . y ) ; Blockly . blockAnimations . disconnectUiEffect ( this . draggingBlock _ ) ; this . draggedConnectionManager _ . updateAvailableConnections ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockDragger . prototype . fireDragStartEvent _ = function ( ) { var a = new ( Blockly . Events . get ( Blockly . Events . BLOCK _DRAG ) ) ( this . draggingBlock _ , ! 0 , this . draggingBlock _ . getDescendants ( ! 1 ) ) ; Blockly . Events . fire ( a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . BlockDragger . prototype . drag = function ( a , b ) { b = this . pixelsToWorkspaceUnits _ ( b ) ; var c = Blockly . utils . Coordinate . sum ( this . startXY _ , b ) ; this . draggingBlock _ . moveDuringDrag ( c ) ; this . dragIcons _ ( b ) ; c = this . dragTarget _ ; this . dragTarget _ = this . workspace _ . getDragTarget ( a ) ; this . draggedConnectionManager _ . update ( b , this . dragTarget _ ) ; a = this . wouldDeleteBlock _ ; this . wouldDeleteBlock _ = this . draggedConnectionManager _ . wouldDeleteBlock ( ) ; a != this . wouldDeleteBlock _ && this . updateCursorDuringBlockDrag _ ( ) ; this . dragTarget _ !== c &&
( c && c . onDragExit ( this . draggingBlock _ ) , this . dragTarget _ && this . dragTarget _ . onDragEnter ( this . draggingBlock _ ) ) ; this . dragTarget _ && this . dragTarget _ . onDragOver ( this . draggingBlock _ ) } ;
Blockly . BlockDragger . prototype . endDrag = function ( a , b ) { this . drag ( a , b ) ; this . dragIconData _ = [ ] ; this . fireDragEndEvent _ ( ) ; Blockly . utils . dom . stopTextWidthCache ( ) ; Blockly . blockAnimations . disconnectUiStop ( ) ; if ( this . dragTarget _ && this . dragTarget _ . shouldPreventMove ( this . draggingBlock _ ) ) a = this . startXY _ ; else { a = this . getNewLocationAfterDrag _ ( b ) ; var c = a . delta ; a = a . newLocation } this . draggingBlock _ . moveOffDragSurface ( a ) ; if ( this . dragTarget _ ) this . dragTarget _ . onDrop ( this . draggingBlock _ ) ; this . maybeDeleteBlock _ ( ) || ( this . draggingBlock _ . setDragging ( ! 1 ) ,
c ? this . updateBlockAfterMove _ ( c ) : Blockly . bumpObjectIntoBounds _ ( this . draggingBlock _ . workspace , this . workspace _ . getMetricsManager ( ) . getScrollMetrics ( ! 0 ) , this . draggingBlock _ ) ) ; this . workspace _ . setResizesEnabled ( ! 0 ) ; Blockly . Events . setGroup ( ! 1 ) } ; Blockly . BlockDragger . prototype . getNewLocationAfterDrag _ = function ( a ) { var b = { } ; b . delta = this . pixelsToWorkspaceUnits _ ( a ) ; b . newLocation = Blockly . utils . Coordinate . sum ( this . startXY _ , b . delta ) ; return b } ;
Blockly . BlockDragger . prototype . maybeDeleteBlock _ = function ( ) { return this . wouldDeleteBlock _ ? ( this . fireMoveEvent _ ( ) , this . draggingBlock _ . dispose ( ! 1 , ! 0 ) , Blockly . draggingConnections = [ ] , ! 0 ) : ! 1 } ; Blockly . BlockDragger . prototype . updateBlockAfterMove _ = function ( a ) { this . draggingBlock _ . moveConnections ( a . x , a . y ) ; this . fireMoveEvent _ ( ) ; this . draggedConnectionManager _ . wouldConnectBlock ( ) ? this . draggedConnectionManager _ . applyConnections ( ) : this . draggingBlock _ . render ( ) ; this . draggingBlock _ . scheduleSnapAndBump ( ) } ;
Blockly . BlockDragger . prototype . fireDragEndEvent _ = function ( ) { var a = new ( Blockly . Events . get ( Blockly . Events . BLOCK _DRAG ) ) ( this . draggingBlock _ , ! 1 , this . draggingBlock _ . getDescendants ( ! 1 ) ) ; Blockly . Events . fire ( a ) } ; Blockly . BlockDragger . prototype . updateToolboxStyle _ = function ( a ) { var b = this . workspace _ . getToolbox ( ) ; if ( b ) { var c = this . draggingBlock _ . isDeletable ( ) ? "blocklyToolboxDelete" : "blocklyToolboxGrab" ; a && "function" == typeof b . removeStyle ? b . removeStyle ( c ) : a || "function" != typeof b . addStyle || b . addStyle ( c ) } } ;
Blockly . BlockDragger . prototype . fireMoveEvent _ = function ( ) { var a = new ( Blockly . Events . get ( Blockly . Events . BLOCK _MOVE ) ) ( this . draggingBlock _ ) ; a . oldCoordinate = this . startXY _ ; a . recordNew ( ) ; Blockly . Events . fire ( a ) } ; Blockly . BlockDragger . prototype . updateCursorDuringBlockDrag _ = function ( ) { this . draggingBlock _ . setDeleteStyle ( this . wouldDeleteBlock _ ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockDragger . prototype . pixelsToWorkspaceUnits _ = function ( a ) { a = new Blockly . utils . Coordinate ( a . x / this . workspace _ . scale , a . y / this . workspace _ . scale ) ; this . workspace _ . isMutator && a . scale ( 1 / this . workspace _ . options . parentWorkspace . scale ) ; return a } ; Blockly . BlockDragger . prototype . dragIcons _ = function ( a ) { for ( var b = 0 ; b < this . dragIconData _ . length ; b ++ ) { var c = this . dragIconData _ [ b ] ; c . icon . setIconLocation ( Blockly . utils . Coordinate . sum ( c . location , a ) ) } } ;
2021-09-18 14:29:06 +00:00
Blockly . BlockDragger . prototype . getInsertionMarkers = function ( ) { return this . draggedConnectionManager _ && this . draggedConnectionManager _ . getInsertionMarkers ? this . draggedConnectionManager _ . getInsertionMarkers ( ) : [ ] } ; Blockly . registry . register ( Blockly . registry . Type . BLOCK _DRAGGER , Blockly . registry . DEFAULT , Blockly . BlockDragger ) ; Blockly . IContextMenu = function ( ) { } ; Blockly . IDraggable = function ( ) { } ; Blockly . IBubble = function ( ) { } ; Blockly . Bubble = function ( a , b , c , d , e , f ) { this . workspace _ = a ; this . content _ = b ; this . shape _ = c ; this . onMouseDownResizeWrapper _ = this . onMouseDownBubbleWrapper _ = this . moveCallback _ = this . resizeCallback _ = null ; this . disposed = ! 1 ; c = Blockly . Bubble . ARROW _ANGLE ; this . workspace _ . RTL && ( c = - c ) ; this . arrow _radians _ = Blockly . utils . math . toRadians ( c ) ; a . getBubbleCanvas ( ) . appendChild ( this . createDom _ ( b , ! ( ! e || ! f ) ) ) ; this . setAnchorLocation ( d ) ; e && f || ( a = this . content _ . getBBox ( ) , e = a . width + 2 * Blockly . Bubble . BORDER _WIDTH , f = a . height + 2 * Blockly . Bubble . BORDER _WIDTH ) ;
2021-01-16 14:07:51 +00:00
this . setBubbleSize ( e , f ) ; this . positionBubble _ ( ) ; this . renderArrow _ ( ) ; this . rendered _ = ! 0 } ; Blockly . Bubble . BORDER _WIDTH = 6 ; Blockly . Bubble . ARROW _THICKNESS = 5 ; Blockly . Bubble . ARROW _ANGLE = 20 ; Blockly . Bubble . ARROW _BEND = 4 ; Blockly . Bubble . ANCHOR _RADIUS = 8 ; Blockly . Bubble . onMouseUpWrapper _ = null ; Blockly . Bubble . onMouseMoveWrapper _ = null ;
2021-05-19 13:38:55 +00:00
Blockly . Bubble . unbindDragEvents _ = function ( ) { Blockly . Bubble . onMouseUpWrapper _ && ( Blockly . browserEvents . unbind ( Blockly . Bubble . onMouseUpWrapper _ ) , Blockly . Bubble . onMouseUpWrapper _ = null ) ; Blockly . Bubble . onMouseMoveWrapper _ && ( Blockly . browserEvents . unbind ( Blockly . Bubble . onMouseMoveWrapper _ ) , Blockly . Bubble . onMouseMoveWrapper _ = null ) } ; Blockly . Bubble . bubbleMouseUp _ = function ( a ) { Blockly . Touch . clearTouchIdentifier ( ) ; Blockly . Bubble . unbindDragEvents _ ( ) } ; Blockly . Bubble . prototype . rendered _ = ! 1 ;
Blockly . Bubble . prototype . anchorXY _ = null ; Blockly . Bubble . prototype . relativeLeft _ = 0 ; Blockly . Bubble . prototype . relativeTop _ = 0 ; Blockly . Bubble . prototype . width _ = 0 ; Blockly . Bubble . prototype . height _ = 0 ; Blockly . Bubble . prototype . autoLayout _ = ! 0 ;
2021-01-16 14:07:51 +00:00
Blockly . Bubble . prototype . createDom _ = function ( a , b ) { this . bubbleGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , null ) ; var c = { filter : "url(#" + this . workspace _ . getRenderer ( ) . getConstants ( ) . embossFilterId + ")" } ; Blockly . utils . userAgent . JAVA _FX && ( c = { } ) ; c = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , c , this . bubbleGroup _ ) ; this . bubbleArrow _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { } , c ) ; this . bubbleBack _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyDraggable" ,
x : 0 , y : 0 , rx : Blockly . Bubble . BORDER _WIDTH , ry : Blockly . Bubble . BORDER _WIDTH } , c ) ; b ? ( this . resizeGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : this . workspace _ . RTL ? "blocklyResizeSW" : "blocklyResizeSE" } , this . bubbleGroup _ ) , b = 2 * Blockly . Bubble . BORDER _WIDTH , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . POLYGON , { points : "0,x x,x x,0" . replace ( /x/g , b . toString ( ) ) } , this . resizeGroup _ ) , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { "class" : "blocklyResizeLine" , x1 : b / 3 , y1 : b - 1 , x2 : b -
2021-05-19 13:38:55 +00:00
1 , y2 : b / 3 } , this . resizeGroup _ ) , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { "class" : "blocklyResizeLine" , x1 : 2 * b / 3 , y1 : b - 1 , x2 : b - 1 , y2 : 2 * b / 3 } , this . resizeGroup _ ) ) : this . resizeGroup _ = null ; this . workspace _ . options . readOnly || ( this . onMouseDownBubbleWrapper _ = Blockly . browserEvents . conditionalBind ( this . bubbleBack _ , "mousedown" , this , this . bubbleMouseDown _ ) , this . resizeGroup _ && ( this . onMouseDownResizeWrapper _ = Blockly . browserEvents . conditionalBind ( this . resizeGroup _ , "mousedown" , this , this . resizeMouseDown _ ) ) ) ;
this . bubbleGroup _ . appendChild ( a ) ; return this . bubbleGroup _ } ; Blockly . Bubble . prototype . getSvgRoot = function ( ) { return this . bubbleGroup _ } ; Blockly . Bubble . prototype . setSvgId = function ( a ) { this . bubbleGroup _ . dataset && ( this . bubbleGroup _ . dataset . blockId = a ) } ; Blockly . Bubble . prototype . bubbleMouseDown _ = function ( a ) { var b = this . workspace _ . getGesture ( a ) ; b && b . handleBubbleStart ( a , this ) } ; Blockly . Bubble . prototype . showContextMenu = function ( a ) { } ; Blockly . Bubble . prototype . isDeletable = function ( ) { return ! 1 } ;
Blockly . Bubble . prototype . setDeleteStyle = function ( a ) { } ;
Blockly . Bubble . prototype . resizeMouseDown _ = function ( a ) { this . promote ( ) ; Blockly . Bubble . unbindDragEvents _ ( ) ; Blockly . utils . isRightButton ( a ) || ( this . workspace _ . startDrag ( a , new Blockly . utils . Coordinate ( this . workspace _ . RTL ? - this . width _ : this . width _ , this . height _ ) ) , Blockly . Bubble . onMouseUpWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mouseup" , this , Blockly . Bubble . bubbleMouseUp _ ) , Blockly . Bubble . onMouseMoveWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mousemove" , this , this . resizeMouseMove _ ) ,
Blockly . hideChaff ( ) ) ; a . stopPropagation ( ) } ; Blockly . Bubble . prototype . resizeMouseMove _ = function ( a ) { this . autoLayout _ = ! 1 ; a = this . workspace _ . moveDrag ( a ) ; this . setBubbleSize ( this . workspace _ . RTL ? - a . x : a . x , a . y ) ; this . workspace _ . RTL && this . positionBubble _ ( ) } ; Blockly . Bubble . prototype . registerResizeEvent = function ( a ) { this . resizeCallback _ = a } ; Blockly . Bubble . prototype . registerMoveEvent = function ( a ) { this . moveCallback _ = a } ;
2021-01-16 14:07:51 +00:00
Blockly . Bubble . prototype . promote = function ( ) { var a = this . bubbleGroup _ . parentNode ; return a . lastChild !== this . bubbleGroup _ ? ( a . appendChild ( this . bubbleGroup _ ) , ! 0 ) : ! 1 } ; Blockly . Bubble . prototype . setAnchorLocation = function ( a ) { this . anchorXY _ = a ; this . rendered _ && this . positionBubble _ ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Bubble . prototype . layoutBubble _ = function ( ) { var a = this . workspace _ . getMetricsManager ( ) . getViewMetrics ( ! 0 ) , b = this . getOptimalRelativeLeft _ ( a ) , c = this . getOptimalRelativeTop _ ( a ) , d = this . shape _ . getBBox ( ) , e = { x : b , y : - this . height _ - this . workspace _ . getRenderer ( ) . getConstants ( ) . MIN _BLOCK _HEIGHT } , f = { x : - this . width _ - 30 , y : c } ; c = { x : d . width , y : c } ; var g = { x : b , y : d . height } ; b = d . width < d . height ? c : g ; d = d . width < d . height ? g : c ; c = this . getOverlap _ ( e , a ) ; g = this . getOverlap _ ( f , a ) ; var h = this . getOverlap _ ( b , a ) ; a = this . getOverlap _ ( d , a ) ;
a = Math . max ( c , g , h , a ) ; c == a ? ( this . relativeLeft _ = e . x , this . relativeTop _ = e . y ) : g == a ? ( this . relativeLeft _ = f . x , this . relativeTop _ = f . y ) : h == a ? ( this . relativeLeft _ = b . x , this . relativeTop _ = b . y ) : ( this . relativeLeft _ = d . x , this . relativeTop _ = d . y ) } ;
Blockly . Bubble . prototype . getOverlap _ = function ( a , b ) { var c = this . workspace _ . RTL ? this . anchorXY _ . x - a . x - this . width _ : a . x + this . anchorXY _ . x ; a = a . y + this . anchorXY _ . y ; return Math . max ( 0 , Math . min ( 1 , ( Math . min ( c + this . width _ , b . left + b . width ) - Math . max ( c , b . left ) ) * ( Math . min ( a + this . height _ , b . top + b . height ) - Math . max ( a , b . top ) ) / ( this . width _ * this . height _ ) ) ) } ;
Blockly . Bubble . prototype . getOptimalRelativeLeft _ = function ( a ) { var b = - this . width _ / 4 ; if ( this . width _ > a . width ) return b ; if ( this . workspace _ . RTL ) var c = this . anchorXY _ . x - b , d = c - this . width _ , e = a . left + a . width , f = a . left + Blockly . Scrollbar . scrollbarThickness / this . workspace _ . scale ; else d = b + this . anchorXY _ . x , c = d + this . width _ , f = a . left , e = a . left + a . width - Blockly . Scrollbar . scrollbarThickness / this . workspace _ . scale ; this . workspace _ . RTL ? d < f ? b = - ( f - this . anchorXY _ . x + this . width _ ) : c > e && ( b = - ( e - this . anchorXY _ . x ) ) : d < f ? b = f - this . anchorXY _ . x :
c > e && ( b = e - this . anchorXY _ . x - this . width _ ) ; return b } ; Blockly . Bubble . prototype . getOptimalRelativeTop _ = function ( a ) { var b = - this . height _ / 4 ; if ( this . height _ > a . height ) return b ; var c = this . anchorXY _ . y + b , d = c + this . height _ , e = a . top ; a = a . top + a . height - Blockly . Scrollbar . scrollbarThickness / this . workspace _ . scale ; var f = this . anchorXY _ . y ; c < e ? b = e - f : d > a && ( b = a - f - this . height _ ) ; return b } ;
2021-01-16 14:07:51 +00:00
Blockly . Bubble . prototype . positionBubble _ = function ( ) { var a = this . anchorXY _ . x ; a = this . workspace _ . RTL ? a - ( this . relativeLeft _ + this . width _ ) : a + this . relativeLeft _ ; this . moveTo ( a , this . relativeTop _ + this . anchorXY _ . y ) } ; Blockly . Bubble . prototype . moveTo = function ( a , b ) { this . bubbleGroup _ . setAttribute ( "transform" , "translate(" + a + "," + b + ")" ) } ; Blockly . Bubble . prototype . setDragging = function ( a ) { ! a && this . moveCallback _ && this . moveCallback _ ( ) } ;
Blockly . Bubble . prototype . getBubbleSize = function ( ) { return new Blockly . utils . Size ( this . width _ , this . height _ ) } ;
Blockly . Bubble . prototype . setBubbleSize = function ( a , b ) { var c = 2 * Blockly . Bubble . BORDER _WIDTH ; a = Math . max ( a , c + 45 ) ; b = Math . max ( b , c + 20 ) ; this . width _ = a ; this . height _ = b ; this . bubbleBack _ . setAttribute ( "width" , a ) ; this . bubbleBack _ . setAttribute ( "height" , b ) ; this . resizeGroup _ && ( this . workspace _ . RTL ? this . resizeGroup _ . setAttribute ( "transform" , "translate(" + 2 * Blockly . Bubble . BORDER _WIDTH + "," + ( b - c ) + ") scale(-1 1)" ) : this . resizeGroup _ . setAttribute ( "transform" , "translate(" + ( a - c ) + "," + ( b - c ) + ")" ) ) ; this . autoLayout _ && this . layoutBubble _ ( ) ;
this . positionBubble _ ( ) ; this . renderArrow _ ( ) ; this . resizeCallback _ && this . resizeCallback _ ( ) } ;
Blockly . Bubble . prototype . renderArrow _ = function ( ) { var a = [ ] , b = this . width _ / 2 , c = this . height _ / 2 , d = - this . relativeLeft _ , e = - this . relativeTop _ ; if ( b == d && c == e ) a . push ( "M " + b + "," + c ) ; else { e -= c ; d -= b ; this . workspace _ . RTL && ( d *= - 1 ) ; var f = Math . sqrt ( e * e + d * d ) , g = Math . acos ( d / f ) ; 0 > e && ( g = 2 * Math . PI - g ) ; var h = g + Math . PI / 2 ; h > 2 * Math . PI && ( h -= 2 * Math . PI ) ; var k = Math . sin ( h ) , l = Math . cos ( h ) , m = this . getBubbleSize ( ) ; h = ( m . width + m . height ) / Blockly . Bubble . ARROW _THICKNESS ; h = Math . min ( h , m . width , m . height ) / 4 ; m = 1 - Blockly . Bubble . ANCHOR _RADIUS / f ; d = b +
m * d ; e = c + m * e ; m = b + h * l ; var n = c + h * k ; b -= h * l ; c -= h * k ; k = g + this . arrow _radians _ ; k > 2 * Math . PI && ( k -= 2 * Math . PI ) ; g = Math . sin ( k ) * f / Blockly . Bubble . ARROW _BEND ; f = Math . cos ( k ) * f / Blockly . Bubble . ARROW _BEND ; a . push ( "M" + m + "," + n ) ; a . push ( "C" + ( m + f ) + "," + ( n + g ) + " " + d + "," + e + " " + d + "," + e ) ; a . push ( "C" + d + "," + e + " " + ( b + f ) + "," + ( c + g ) + " " + b + "," + c ) } a . push ( "z" ) ; this . bubbleArrow _ . setAttribute ( "d" , a . join ( " " ) ) } ; Blockly . Bubble . prototype . setColour = function ( a ) { this . bubbleBack _ . setAttribute ( "fill" , a ) ; this . bubbleArrow _ . setAttribute ( "fill" , a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Bubble . prototype . dispose = function ( ) { this . onMouseDownBubbleWrapper _ && Blockly . browserEvents . unbind ( this . onMouseDownBubbleWrapper _ ) ; this . onMouseDownResizeWrapper _ && Blockly . browserEvents . unbind ( this . onMouseDownResizeWrapper _ ) ; Blockly . Bubble . unbindDragEvents _ ( ) ; Blockly . utils . dom . removeNode ( this . bubbleGroup _ ) ; this . disposed = ! 0 } ;
2021-01-16 14:07:51 +00:00
Blockly . Bubble . prototype . moveDuringDrag = function ( a , b ) { a ? a . translateSurface ( b . x , b . y ) : this . moveTo ( b . x , b . y ) ; this . relativeLeft _ = this . workspace _ . RTL ? this . anchorXY _ . x - b . x - this . width _ : b . x - this . anchorXY _ . x ; this . relativeTop _ = b . y - this . anchorXY _ . y ; this . renderArrow _ ( ) } ; Blockly . Bubble . prototype . getRelativeToSurfaceXY = function ( ) { return new Blockly . utils . Coordinate ( this . workspace _ . RTL ? - this . relativeLeft _ + this . anchorXY _ . x - this . width _ : this . anchorXY _ . x + this . relativeLeft _ , this . anchorXY _ . y + this . relativeTop _ ) } ;
Blockly . Bubble . prototype . setAutoLayout = function ( a ) { this . autoLayout _ = a } ; Blockly . Bubble . textToDom = function ( a ) { var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TEXT , { "class" : "blocklyText blocklyBubbleText blocklyNoPointerEvents" , y : Blockly . Bubble . BORDER _WIDTH } , null ) ; a = a . split ( "\n" ) ; for ( var c = 0 ; c < a . length ; c ++ ) { var d = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TSPAN , { dy : "1em" , x : Blockly . Bubble . BORDER _WIDTH } , b ) , e = document . createTextNode ( a [ c ] ) ; d . appendChild ( e ) } return b } ;
Blockly . Bubble . createNonEditableBubble = function ( a , b , c ) { c = new Blockly . Bubble ( b . workspace , a , b . pathObject . svgPath , c , null , null ) ; c . setSvgId ( b . id ) ; if ( b . RTL ) { b = a . getBBox ( ) . width ; for ( var d = 0 , e ; e = a . childNodes [ d ] ; d ++ ) e . setAttribute ( "text-anchor" , "end" ) , e . setAttribute ( "x" , b + Blockly . Bubble . BORDER _WIDTH ) } return c } ; Blockly . Events . CommentBase = function ( a ) { this . commentId = ( this . isBlank = "undefined" == typeof a ) ? "" : a . id ; this . workspaceId = this . isBlank ? "" : a . workspace . id ; this . group = Blockly . Events . getGroup ( ) ; this . recordUndo = Blockly . Events . recordUndo } ; Blockly . utils . object . inherits ( Blockly . Events . CommentBase , Blockly . Events . Abstract ) ; Blockly . Events . CommentBase . prototype . toJson = function ( ) { var a = Blockly . Events . CommentBase . superClass _ . toJson . call ( this ) ; this . commentId && ( a . commentId = this . commentId ) ; return a } ;
Blockly . Events . CommentBase . prototype . fromJson = function ( a ) { Blockly . Events . CommentBase . superClass _ . fromJson . call ( this , a ) ; this . commentId = a . commentId } ; Blockly . Events . CommentChange = function ( a , b , c ) { Blockly . Events . CommentChange . superClass _ . constructor . call ( this , a ) ; a && ( this . oldContents _ = "undefined" == typeof b ? "" : b , this . newContents _ = "undefined" == typeof c ? "" : c ) } ; Blockly . utils . object . inherits ( Blockly . Events . CommentChange , Blockly . Events . CommentBase ) ; Blockly . Events . CommentChange . prototype . type = Blockly . Events . COMMENT _CHANGE ;
2021-05-19 13:38:55 +00:00
Blockly . Events . CommentChange . prototype . toJson = function ( ) { var a = Blockly . Events . CommentChange . superClass _ . toJson . call ( this ) ; a . oldContents = this . oldContents _ ; a . newContents = this . newContents _ ; return a } ; Blockly . Events . CommentChange . prototype . fromJson = function ( a ) { Blockly . Events . CommentChange . superClass _ . fromJson . call ( this , a ) ; this . oldContents _ = a . oldContents ; this . newContents _ = a . newContents } ; Blockly . Events . CommentChange . prototype . isNull = function ( ) { return this . oldContents _ == this . newContents _ } ;
2021-01-16 14:07:51 +00:00
Blockly . Events . CommentChange . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) . getCommentById ( this . commentId ) ; b ? b . setContent ( a ? this . newContents _ : this . oldContents _ ) : console . warn ( "Can't change non-existent comment: " + this . commentId ) } ; Blockly . Events . CommentCreate = function ( a ) { Blockly . Events . CommentCreate . superClass _ . constructor . call ( this , a ) ; a && ( this . xml = a . toXmlWithXY ( ) ) } ; Blockly . utils . object . inherits ( Blockly . Events . CommentCreate , Blockly . Events . CommentBase ) ;
Blockly . Events . CommentCreate . prototype . type = Blockly . Events . COMMENT _CREATE ; Blockly . Events . CommentCreate . prototype . toJson = function ( ) { var a = Blockly . Events . CommentCreate . superClass _ . toJson . call ( this ) ; a . xml = Blockly . Xml . domToText ( this . xml ) ; return a } ; Blockly . Events . CommentCreate . prototype . fromJson = function ( a ) { Blockly . Events . CommentCreate . superClass _ . fromJson . call ( this , a ) ; this . xml = Blockly . Xml . textToDom ( a . xml ) } ;
Blockly . Events . CommentCreate . prototype . run = function ( a ) { Blockly . Events . CommentCreateDeleteHelper ( this , a ) } ; Blockly . Events . CommentCreateDeleteHelper = function ( a , b ) { var c = a . getEventWorkspace _ ( ) ; b ? ( b = Blockly . utils . xml . createElement ( "xml" ) , b . appendChild ( a . xml ) , Blockly . Xml . domToWorkspace ( b , c ) ) : ( c = c . getCommentById ( a . commentId ) ) ? c . dispose ( ! 1 , ! 1 ) : console . warn ( "Can't uncreate non-existent comment: " + a . commentId ) } ;
Blockly . Events . CommentDelete = function ( a ) { Blockly . Events . CommentDelete . superClass _ . constructor . call ( this , a ) ; a && ( this . xml = a . toXmlWithXY ( ) ) } ; Blockly . utils . object . inherits ( Blockly . Events . CommentDelete , Blockly . Events . CommentBase ) ; Blockly . Events . CommentDelete . prototype . type = Blockly . Events . COMMENT _DELETE ; Blockly . Events . CommentDelete . prototype . toJson = function ( ) { return Blockly . Events . CommentDelete . superClass _ . toJson . call ( this ) } ;
Blockly . Events . CommentDelete . prototype . fromJson = function ( a ) { Blockly . Events . CommentDelete . superClass _ . fromJson . call ( this , a ) } ; Blockly . Events . CommentDelete . prototype . run = function ( a ) { Blockly . Events . CommentCreateDeleteHelper ( this , ! a ) } ; Blockly . Events . CommentMove = function ( a ) { Blockly . Events . CommentMove . superClass _ . constructor . call ( this , a ) ; a && ( this . comment _ = a , this . oldCoordinate _ = a . getXY ( ) , this . newCoordinate _ = null ) } ; Blockly . utils . object . inherits ( Blockly . Events . CommentMove , Blockly . Events . CommentBase ) ;
Blockly . Events . CommentMove . prototype . recordNew = function ( ) { if ( ! this . comment _ ) throw Error ( "Tried to record the new position of a comment on the same event twice." ) ; this . newCoordinate _ = this . comment _ . getXY ( ) ; this . comment _ = null } ; Blockly . Events . CommentMove . prototype . type = Blockly . Events . COMMENT _MOVE ; Blockly . Events . CommentMove . prototype . setOldCoordinate = function ( a ) { this . oldCoordinate _ = a } ;
2021-05-19 13:38:55 +00:00
Blockly . Events . CommentMove . prototype . toJson = function ( ) { var a = Blockly . Events . CommentMove . superClass _ . toJson . call ( this ) ; this . oldCoordinate _ && ( a . oldCoordinate = Math . round ( this . oldCoordinate _ . x ) + "," + Math . round ( this . oldCoordinate _ . y ) ) ; this . newCoordinate _ && ( a . newCoordinate = Math . round ( this . newCoordinate _ . x ) + "," + Math . round ( this . newCoordinate _ . y ) ) ; return a } ;
Blockly . Events . CommentMove . prototype . fromJson = function ( a ) { Blockly . Events . CommentMove . superClass _ . fromJson . call ( this , a ) ; if ( a . oldCoordinate ) { var b = a . oldCoordinate . split ( "," ) ; this . oldCoordinate _ = new Blockly . utils . Coordinate ( Number ( b [ 0 ] ) , Number ( b [ 1 ] ) ) } a . newCoordinate && ( b = a . newCoordinate . split ( "," ) , this . newCoordinate _ = new Blockly . utils . Coordinate ( Number ( b [ 0 ] ) , Number ( b [ 1 ] ) ) ) } ; Blockly . Events . CommentMove . prototype . isNull = function ( ) { return Blockly . utils . Coordinate . equals ( this . oldCoordinate _ , this . newCoordinate _ ) } ;
Blockly . Events . CommentMove . prototype . run = function ( a ) { var b = this . getEventWorkspace _ ( ) . getCommentById ( this . commentId ) ; if ( b ) { a = a ? this . newCoordinate _ : this . oldCoordinate _ ; var c = b . getXY ( ) ; b . moveBy ( a . x - c . x , a . y - c . y ) } else console . warn ( "Can't move non-existent comment: " + this . commentId ) } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . COMMENT _CREATE , Blockly . Events . CommentCreate ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . COMMENT _CHANGE , Blockly . Events . CommentChange ) ;
2021-09-18 14:29:06 +00:00
Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . COMMENT _MOVE , Blockly . Events . CommentMove ) ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . COMMENT _DELETE , Blockly . Events . CommentDelete ) ; Blockly . BubbleDragger = function ( a , b ) { this . draggingBubble _ = a ; this . workspace _ = b ; this . dragTarget _ = null ; this . wouldDeleteBubble _ = ! 1 ; this . startXY _ = this . draggingBubble _ . getRelativeToSurfaceXY ( ) ; this . dragSurface _ = Blockly . utils . is3dSupported ( ) && b . getBlockDragSurface ( ) ? b . getBlockDragSurface ( ) : null } ; Blockly . BubbleDragger . prototype . dispose = function ( ) { this . dragSurface _ = this . workspace _ = this . draggingBubble _ = null } ;
Blockly . BubbleDragger . prototype . startBubbleDrag = function ( ) { Blockly . Events . getGroup ( ) || Blockly . Events . setGroup ( ! 0 ) ; this . workspace _ . setResizesEnabled ( ! 1 ) ; this . draggingBubble _ . setAutoLayout ( ! 1 ) ; this . dragSurface _ && this . moveToDragSurface _ ( ) ; this . draggingBubble _ . setDragging && this . draggingBubble _ . setDragging ( ! 0 ) } ;
Blockly . BubbleDragger . prototype . dragBubble = function ( a , b ) { b = this . pixelsToWorkspaceUnits _ ( b ) ; b = Blockly . utils . Coordinate . sum ( this . startXY _ , b ) ; this . draggingBubble _ . moveDuringDrag ( this . dragSurface _ , b ) ; b = this . dragTarget _ ; this . dragTarget _ = this . workspace _ . getDragTarget ( a ) ; a = this . wouldDeleteBubble _ ; this . wouldDeleteBubble _ = this . shouldDelete _ ( this . dragTarget _ ) ; a != this . wouldDeleteBubble _ && this . updateCursorDuringBubbleDrag _ ( ) ; this . dragTarget _ !== b && ( b && b . onDragExit ( this . draggingBubble _ ) , this . dragTarget _ && this . dragTarget _ . onDragEnter ( this . draggingBubble _ ) ) ;
this . dragTarget _ && this . dragTarget _ . onDragOver ( this . draggingBubble _ ) } ; Blockly . BubbleDragger . prototype . shouldDelete _ = function ( a ) { return a && this . workspace _ . getComponentManager ( ) . hasCapability ( a . id , Blockly . ComponentManager . Capability . DELETE _AREA ) ? a . wouldDelete ( this . draggingBubble _ , ! 1 ) : ! 1 } ; Blockly . BubbleDragger . prototype . updateCursorDuringBubbleDrag _ = function ( ) { this . draggingBubble _ . setDeleteStyle ( this . wouldDeleteBubble _ ) } ;
Blockly . BubbleDragger . prototype . endBubbleDrag = function ( a , b ) { this . dragBubble ( a , b ) ; this . dragTarget _ && this . dragTarget _ . shouldPreventMove ( this . draggingBubble _ ) ? a = this . startXY _ : ( a = this . pixelsToWorkspaceUnits _ ( b ) , a = Blockly . utils . Coordinate . sum ( this . startXY _ , a ) ) ; this . draggingBubble _ . moveTo ( a . x , a . y ) ; if ( this . dragTarget _ ) this . dragTarget _ . onDrop ( this . draggingBubble _ ) ; this . wouldDeleteBubble _ ? ( this . fireMoveEvent _ ( ) , this . draggingBubble _ . dispose ( ! 1 , ! 0 ) ) : ( this . dragSurface _ && this . dragSurface _ . clearAndHide ( this . workspace _ . getBubbleCanvas ( ) ) ,
this . draggingBubble _ . setDragging && this . draggingBubble _ . setDragging ( ! 1 ) , this . fireMoveEvent _ ( ) ) ; this . workspace _ . setResizesEnabled ( ! 0 ) ; Blockly . Events . setGroup ( ! 1 ) } ; Blockly . BubbleDragger . prototype . fireMoveEvent _ = function ( ) { if ( this . draggingBubble _ . isComment ) { var a = new ( Blockly . Events . get ( Blockly . Events . COMMENT _MOVE ) ) ( this . draggingBubble _ ) ; a . setOldCoordinate ( this . startXY _ ) ; a . recordNew ( ) ; Blockly . Events . fire ( a ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . BubbleDragger . prototype . pixelsToWorkspaceUnits _ = function ( a ) { a = new Blockly . utils . Coordinate ( a . x / this . workspace _ . scale , a . y / this . workspace _ . scale ) ; this . workspace _ . isMutator && a . scale ( 1 / this . workspace _ . options . parentWorkspace . scale ) ; return a } ; Blockly . BubbleDragger . prototype . moveToDragSurface _ = function ( ) { this . draggingBubble _ . moveTo ( 0 , 0 ) ; this . dragSurface _ . translateSurface ( this . startXY _ . x , this . startXY _ . y ) ; this . dragSurface _ . setBlocksAndShow ( this . draggingBubble _ . getSvgRoot ( ) ) } ; Blockly . Events . Click = function ( a , b , c ) { Blockly . Events . Click . superClass _ . constructor . call ( this , a ? a . workspace . id : b ) ; this . blockId = a ? a . id : null ; this . targetType = c } ; Blockly . utils . object . inherits ( Blockly . Events . Click , Blockly . Events . UiBase ) ; Blockly . Events . Click . prototype . type = Blockly . Events . CLICK ; Blockly . Events . Click . prototype . toJson = function ( ) { var a = Blockly . Events . Click . superClass _ . toJson . call ( this ) ; a . targetType = this . targetType ; this . blockId && ( a . blockId = this . blockId ) ; return a } ;
2021-05-19 13:38:55 +00:00
Blockly . Events . Click . prototype . fromJson = function ( a ) { Blockly . Events . Click . superClass _ . fromJson . call ( this , a ) ; this . targetType = a . targetType ; this . blockId = a . blockId } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . CLICK , Blockly . Events . Click ) ; Blockly . WorkspaceDragger = function ( a ) { this . workspace _ = a ; this . horizontalScrollEnabled _ = this . workspace _ . isMovableHorizontally ( ) ; this . verticalScrollEnabled _ = this . workspace _ . isMovableVertically ( ) ; this . startScrollXY _ = new Blockly . utils . Coordinate ( a . scrollX , a . scrollY ) } ; Blockly . WorkspaceDragger . prototype . dispose = function ( ) { this . workspace _ = null } ; Blockly . WorkspaceDragger . prototype . startDrag = function ( ) { Blockly . selected && Blockly . selected . unselect ( ) ; this . workspace _ . setupDragSurface ( ) } ;
Blockly . WorkspaceDragger . prototype . endDrag = function ( a ) { this . drag ( a ) ; this . workspace _ . resetDragSurface ( ) } ;
Blockly . WorkspaceDragger . prototype . drag = function ( a ) { a = Blockly . utils . Coordinate . sum ( this . startScrollXY _ , a ) ; if ( this . horizontalScrollEnabled _ && this . verticalScrollEnabled _ ) this . workspace _ . scroll ( a . x , a . y ) ; else if ( this . horizontalScrollEnabled _ ) this . workspace _ . scroll ( a . x , this . workspace _ . scrollY ) ; else if ( this . verticalScrollEnabled _ ) this . workspace _ . scroll ( this . workspace _ . scrollX , a . y ) ; else throw new TypeError ( "Invalid state." ) ; } ; Blockly . Gesture = function ( a , b ) { this . mouseDownXY _ = null ; this . currentDragDeltaXY _ = new Blockly . utils . Coordinate ( 0 , 0 ) ; this . startWorkspace _ = this . targetBlock _ = this . startBlock _ = this . startField _ = this . startBubble _ = null ; this . creatorWorkspace _ = b ; this . isDraggingBubble _ = this . isDraggingBlock _ = this . isDraggingWorkspace _ = this . hasExceededDragRadius _ = ! 1 ; this . mostRecentEvent _ = a ; this . flyout _ = this . workspaceDragger _ = this . blockDragger _ = this . bubbleDragger _ = this . onUpWrapper _ = this . onMoveWrapper _ = null ; this . isEnding _ = this . hasStarted _ =
this . calledUpdateIsDragging _ = ! 1 ; this . healStack _ = ! Blockly . DRAG _STACK } ; Blockly . Gesture . prototype . dispose = function ( ) { Blockly . Touch . clearTouchIdentifier ( ) ; Blockly . Tooltip . unblock ( ) ; this . creatorWorkspace _ . clearGesture ( ) ; this . onMoveWrapper _ && Blockly . browserEvents . unbind ( this . onMoveWrapper _ ) ; this . onUpWrapper _ && Blockly . browserEvents . unbind ( this . onUpWrapper _ ) ; this . blockDragger _ && this . blockDragger _ . dispose ( ) ; this . workspaceDragger _ && this . workspaceDragger _ . dispose ( ) ; this . bubbleDragger _ && this . bubbleDragger _ . dispose ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . updateFromEvent _ = function ( a ) { var b = new Blockly . utils . Coordinate ( a . clientX , a . clientY ) ; this . updateDragDelta _ ( b ) && ( this . updateIsDragging _ ( ) , Blockly . longStop _ ( ) ) ; this . mostRecentEvent _ = a } ;
Blockly . Gesture . prototype . updateDragDelta _ = function ( a ) { this . currentDragDeltaXY _ = Blockly . utils . Coordinate . difference ( a , this . mouseDownXY _ ) ; return this . hasExceededDragRadius _ ? ! 1 : this . hasExceededDragRadius _ = Blockly . utils . Coordinate . magnitude ( this . currentDragDeltaXY _ ) > ( this . flyout _ ? Blockly . FLYOUT _DRAG _RADIUS : Blockly . DRAG _RADIUS ) } ;
Blockly . Gesture . prototype . updateIsDraggingFromFlyout _ = function ( ) { return this . targetBlock _ && this . flyout _ . isBlockCreatable _ ( this . targetBlock _ ) ? ! this . flyout _ . isScrollable ( ) || this . flyout _ . isDragTowardWorkspace ( this . currentDragDeltaXY _ ) ? ( this . startWorkspace _ = this . flyout _ . targetWorkspace , this . startWorkspace _ . updateScreenCalculationsIfScrolled ( ) , Blockly . Events . getGroup ( ) || Blockly . Events . setGroup ( ! 0 ) , this . startBlock _ = null , this . targetBlock _ = this . flyout _ . createBlock ( this . targetBlock _ ) , this . targetBlock _ . select ( ) ,
! 0 ) : ! 1 : ! 1 } ; Blockly . Gesture . prototype . updateIsDraggingBubble _ = function ( ) { if ( ! this . startBubble _ ) return ! 1 ; this . isDraggingBubble _ = ! 0 ; this . startDraggingBubble _ ( ) ; return ! 0 } ; Blockly . Gesture . prototype . updateIsDraggingBlock _ = function ( ) { if ( ! this . targetBlock _ ) return ! 1 ; this . flyout _ ? this . isDraggingBlock _ = this . updateIsDraggingFromFlyout _ ( ) : this . targetBlock _ . isMovable ( ) && ( this . isDraggingBlock _ = ! 0 ) ; return this . isDraggingBlock _ ? ( this . startDraggingBlock _ ( ) , ! 0 ) : ! 1 } ;
2021-05-19 13:38:55 +00:00
Blockly . Gesture . prototype . updateIsDraggingWorkspace _ = function ( ) { if ( this . flyout _ ? this . flyout _ . isScrollable ( ) : this . startWorkspace _ && this . startWorkspace _ . isDraggable ( ) ) this . workspaceDragger _ = new Blockly . WorkspaceDragger ( this . startWorkspace _ ) , this . isDraggingWorkspace _ = ! 0 , this . workspaceDragger _ . startDrag ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . updateIsDragging _ = function ( ) { if ( this . calledUpdateIsDragging _ ) throw Error ( "updateIsDragging_ should only be called once per gesture." ) ; this . calledUpdateIsDragging _ = ! 0 ; this . updateIsDraggingBubble _ ( ) || this . updateIsDraggingBlock _ ( ) || this . updateIsDraggingWorkspace _ ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Gesture . prototype . startDraggingBlock _ = function ( ) { this . blockDragger _ = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . BLOCK _DRAGGER , this . creatorWorkspace _ . options , ! 0 ) ) ( this . targetBlock _ , this . startWorkspace _ ) ; this . blockDragger _ . startDrag ( this . currentDragDeltaXY _ , this . healStack _ ) ; this . blockDragger _ . drag ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . startDraggingBubble _ = function ( ) { this . bubbleDragger _ = new Blockly . BubbleDragger ( this . startBubble _ , this . startWorkspace _ ) ; this . bubbleDragger _ . startBubbleDrag ( ) ; this . bubbleDragger _ . dragBubble ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Gesture . prototype . doStart = function ( a ) { Blockly . utils . isTargetInput ( a ) ? this . cancel ( ) : ( this . hasStarted _ = ! 0 , Blockly . blockAnimations . disconnectUiStop ( ) , this . startWorkspace _ . updateScreenCalculationsIfScrolled ( ) , this . startWorkspace _ . isMutator && this . startWorkspace _ . resize ( ) , Blockly . hideChaff ( ! ! this . flyout _ ) , this . startWorkspace _ . markFocused ( ) , this . mostRecentEvent _ = a , Blockly . Tooltip . block ( ) , this . targetBlock _ && this . targetBlock _ . select ( ) , Blockly . utils . isRightButton ( a ) ? this . handleRightClick ( a ) : ( "touchstart" !=
a . type . toLowerCase ( ) && "pointerdown" != a . type . toLowerCase ( ) || "mouse" == a . pointerType || Blockly . longStart ( a , this ) , this . mouseDownXY _ = new Blockly . utils . Coordinate ( a . clientX , a . clientY ) , this . healStack _ = a . altKey || a . ctrlKey || a . metaKey , this . bindMouseEvents ( a ) ) ) } ;
Blockly . Gesture . prototype . bindMouseEvents = function ( a ) { this . onMoveWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mousemove" , null , this . handleMove . bind ( this ) ) ; this . onUpWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mouseup" , null , this . handleUp . bind ( this ) ) ; a . preventDefault ( ) ; a . stopPropagation ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Gesture . prototype . handleMove = function ( a ) { this . updateFromEvent _ ( a ) ; this . isDraggingWorkspace _ ? this . workspaceDragger _ . drag ( this . currentDragDeltaXY _ ) : this . isDraggingBlock _ ? this . blockDragger _ . drag ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) : this . isDraggingBubble _ && this . bubbleDragger _ . dragBubble ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) ; a . preventDefault ( ) ; a . stopPropagation ( ) } ;
Blockly . Gesture . prototype . handleUp = function ( a ) { this . updateFromEvent _ ( a ) ; Blockly . longStop _ ( ) ; this . isEnding _ ? console . log ( "Trying to end a gesture recursively." ) : ( this . isEnding _ = ! 0 , this . isDraggingBubble _ ? this . bubbleDragger _ . endBubbleDrag ( a , this . currentDragDeltaXY _ ) : this . isDraggingBlock _ ? this . blockDragger _ . endDrag ( a , this . currentDragDeltaXY _ ) : this . isDraggingWorkspace _ ? this . workspaceDragger _ . endDrag ( this . currentDragDeltaXY _ ) : this . isBubbleClick _ ( ) ? this . doBubbleClick _ ( ) : this . isFieldClick _ ( ) ? this . doFieldClick _ ( ) :
2021-01-16 14:07:51 +00:00
this . isBlockClick _ ( ) ? this . doBlockClick _ ( ) : this . isWorkspaceClick _ ( ) && this . doWorkspaceClick _ ( a ) , a . preventDefault ( ) , a . stopPropagation ( ) , this . dispose ( ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Gesture . prototype . cancel = function ( ) { this . isEnding _ || ( Blockly . longStop _ ( ) , this . isDraggingBubble _ ? this . bubbleDragger _ . endBubbleDrag ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) : this . isDraggingBlock _ ? this . blockDragger _ . endDrag ( this . mostRecentEvent _ , this . currentDragDeltaXY _ ) : this . isDraggingWorkspace _ && this . workspaceDragger _ . endDrag ( this . currentDragDeltaXY _ ) , this . dispose ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . handleRightClick = function ( a ) { this . targetBlock _ ? ( this . bringBlockToFront _ ( ) , Blockly . hideChaff ( ! ! this . flyout _ ) , this . targetBlock _ . showContextMenu ( a ) ) : this . startBubble _ ? this . startBubble _ . showContextMenu ( a ) : this . startWorkspace _ && ! this . flyout _ && ( Blockly . hideChaff ( ) , this . startWorkspace _ . showContextMenu ( a ) ) ; a . preventDefault ( ) ; a . stopPropagation ( ) ; this . dispose ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Gesture . prototype . handleWsStart = function ( a , b ) { if ( this . hasStarted _ ) throw Error ( "Tried to call gesture.handleWsStart, but the gesture had already been started." ) ; this . setStartWorkspace _ ( b ) ; this . mostRecentEvent _ = a ; this . doStart ( a ) } ; Blockly . Gesture . prototype . fireWorkspaceClick _ = function ( a ) { Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . CLICK ) ) ( null , a . id , "workspace" ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . handleFlyoutStart = function ( a , b ) { if ( this . hasStarted _ ) throw Error ( "Tried to call gesture.handleFlyoutStart, but the gesture had already been started." ) ; this . setStartFlyout _ ( b ) ; this . handleWsStart ( a , b . getWorkspace ( ) ) } ; Blockly . Gesture . prototype . handleBlockStart = function ( a , b ) { if ( this . hasStarted _ ) throw Error ( "Tried to call gesture.handleBlockStart, but the gesture had already been started." ) ; this . setStartBlock ( b ) ; this . mostRecentEvent _ = a } ;
Blockly . Gesture . prototype . handleBubbleStart = function ( a , b ) { if ( this . hasStarted _ ) throw Error ( "Tried to call gesture.handleBubbleStart, but the gesture had already been started." ) ; this . setStartBubble ( b ) ; this . mostRecentEvent _ = a } ; Blockly . Gesture . prototype . doBubbleClick _ = function ( ) { this . startBubble _ . setFocus && this . startBubble _ . setFocus ( ) ; this . startBubble _ . select && this . startBubble _ . select ( ) } ; Blockly . Gesture . prototype . doFieldClick _ = function ( ) { this . startField _ . showEditor ( this . mostRecentEvent _ ) ; this . bringBlockToFront _ ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Gesture . prototype . doBlockClick _ = function ( ) { if ( this . flyout _ && this . flyout _ . autoClose ) this . targetBlock _ . isEnabled ( ) && ( Blockly . Events . getGroup ( ) || Blockly . Events . setGroup ( ! 0 ) , this . flyout _ . createBlock ( this . targetBlock _ ) . scheduleSnapAndBump ( ) ) ; else { var a = new ( Blockly . Events . get ( Blockly . Events . CLICK ) ) ( this . startBlock _ , this . startWorkspace _ . id , "block" ) ; Blockly . Events . fire ( a ) } this . bringBlockToFront _ ( ) ; Blockly . Events . setGroup ( ! 1 ) } ;
Blockly . Gesture . prototype . doWorkspaceClick _ = function ( a ) { a = this . creatorWorkspace _ ; Blockly . selected && Blockly . selected . unselect ( ) ; this . fireWorkspaceClick _ ( this . startWorkspace _ || a ) } ; Blockly . Gesture . prototype . bringBlockToFront _ = function ( ) { this . targetBlock _ && ! this . flyout _ && this . targetBlock _ . bringToFront ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Gesture . prototype . setStartField = function ( a ) { if ( this . hasStarted _ ) throw Error ( "Tried to call gesture.setStartField, but the gesture had already been started." ) ; this . startField _ || ( this . startField _ = a ) } ; Blockly . Gesture . prototype . setStartBubble = function ( a ) { this . startBubble _ || ( this . startBubble _ = a ) } ; Blockly . Gesture . prototype . setStartBlock = function ( a ) { this . startBlock _ || this . startBubble _ || ( this . startBlock _ = a , a . isInFlyout && a != a . getRootBlock ( ) ? this . setTargetBlock _ ( a . getRootBlock ( ) ) : this . setTargetBlock _ ( a ) ) } ;
Blockly . Gesture . prototype . setTargetBlock _ = function ( a ) { a . isShadow ( ) ? this . setTargetBlock _ ( a . getParent ( ) ) : this . targetBlock _ = a } ; Blockly . Gesture . prototype . setStartWorkspace _ = function ( a ) { this . startWorkspace _ || ( this . startWorkspace _ = a ) } ; Blockly . Gesture . prototype . setStartFlyout _ = function ( a ) { this . flyout _ || ( this . flyout _ = a ) } ; Blockly . Gesture . prototype . isBubbleClick _ = function ( ) { return ! ! this . startBubble _ && ! this . hasExceededDragRadius _ } ;
Blockly . Gesture . prototype . isBlockClick _ = function ( ) { return ! ! this . startBlock _ && ! this . hasExceededDragRadius _ && ! this . isFieldClick _ ( ) } ; Blockly . Gesture . prototype . isFieldClick _ = function ( ) { return ( this . startField _ ? this . startField _ . isClickable ( ) : ! 1 ) && ! this . hasExceededDragRadius _ && ( ! this . flyout _ || ! this . flyout _ . autoClose ) } ; Blockly . Gesture . prototype . isWorkspaceClick _ = function ( ) { return ! this . startBlock _ && ! this . startBubble _ && ! this . startField _ && ! this . hasExceededDragRadius _ } ;
2021-09-18 14:29:06 +00:00
Blockly . Gesture . prototype . isDragging = function ( ) { return this . isDraggingWorkspace _ || this . isDraggingBlock _ || this . isDraggingBubble _ } ; Blockly . Gesture . prototype . hasStarted = function ( ) { return this . hasStarted _ } ; Blockly . Gesture . prototype . getInsertionMarkers = function ( ) { return this . blockDragger _ ? this . blockDragger _ . getInsertionMarkers ( ) : [ ] } ;
Blockly . Gesture . prototype . getCurrentDragger = function ( ) { return this . isDraggingBlock _ ? this . blockDragger _ : this . isDraggingWorkspace _ ? this . workspaceDragger _ : this . isDraggingBubble _ ? this . bubbleDragger _ : null } ; Blockly . Gesture . inProgress = function ( ) { for ( var a = Blockly . Workspace . getAll ( ) , b = 0 , c ; c = a [ b ] ; b ++ ) if ( c . currentGesture _ ) return ! 0 ; return ! 1 } ; Blockly . IRegistrable = function ( ) { } ; Blockly . Marker = function ( ) { this . drawer _ = this . curNode _ = this . colour = null ; this . type = "marker" } ; Blockly . Marker . prototype . setDrawer = function ( a ) { this . drawer _ = a } ; Blockly . Marker . prototype . getDrawer = function ( ) { return this . drawer _ } ; Blockly . Marker . prototype . getCurNode = function ( ) { return this . curNode _ } ; Blockly . Marker . prototype . setCurNode = function ( a ) { var b = this . curNode _ ; this . curNode _ = a ; this . drawer _ && this . drawer _ . draw ( b , this . curNode _ ) } ;
Blockly . Marker . prototype . draw = function ( ) { this . drawer _ && this . drawer _ . draw ( this . curNode _ , this . curNode _ ) } ; Blockly . Marker . prototype . hide = function ( ) { this . drawer _ && this . drawer _ . hide ( ) } ; Blockly . Marker . prototype . dispose = function ( ) { this . getDrawer ( ) && this . getDrawer ( ) . dispose ( ) } ; Blockly . Cursor = function ( ) { Blockly . Cursor . superClass _ . constructor . call ( this ) ; this . type = "cursor" } ; Blockly . utils . object . inherits ( Blockly . Cursor , Blockly . Marker ) ; Blockly . Cursor . prototype . next = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; for ( a = a . next ( ) ; a && a . next ( ) && ( a . getType ( ) == Blockly . ASTNode . types . NEXT || a . getType ( ) == Blockly . ASTNode . types . BLOCK ) ; ) a = a . next ( ) ; a && this . setCurNode ( a ) ; return a } ;
Blockly . Cursor . prototype . in = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; if ( a . getType ( ) == Blockly . ASTNode . types . PREVIOUS || a . getType ( ) == Blockly . ASTNode . types . OUTPUT ) a = a . next ( ) ; ( a = a . in ( ) ) && this . setCurNode ( a ) ; return a } ; Blockly . Cursor . prototype . prev = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; for ( a = a . prev ( ) ; a && a . prev ( ) && ( a . getType ( ) == Blockly . ASTNode . types . NEXT || a . getType ( ) == Blockly . ASTNode . types . BLOCK ) ; ) a = a . prev ( ) ; a && this . setCurNode ( a ) ; return a } ;
Blockly . Cursor . prototype . out = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; ( a = a . out ( ) ) && a . getType ( ) == Blockly . ASTNode . types . BLOCK && ( a = a . prev ( ) || a ) ; a && this . setCurNode ( a ) ; return a } ; Blockly . registry . register ( Blockly . registry . Type . CURSOR , Blockly . registry . DEFAULT , Blockly . Cursor ) ; Blockly . MarkerManager = function ( a ) { this . cursorSvg _ = this . cursor _ = null ; this . markers _ = Object . create ( null ) ; this . workspace _ = a } ; Blockly . MarkerManager . LOCAL _MARKER = "local_marker_1" ; Blockly . MarkerManager . prototype . registerMarker = function ( a , b ) { this . markers _ [ a ] && this . unregisterMarker ( a ) ; b . setDrawer ( this . workspace _ . getRenderer ( ) . makeMarkerDrawer ( this . workspace _ , b ) ) ; this . setMarkerSvg ( b . getDrawer ( ) . createDom ( ) ) ; this . markers _ [ a ] = b } ;
Blockly . MarkerManager . prototype . unregisterMarker = function ( a ) { var b = this . markers _ [ a ] ; if ( b ) b . dispose ( ) , delete this . markers _ [ a ] ; else throw Error ( "Marker with ID " + a + " does not exist. Can only unregister markers that exist." ) ; } ; Blockly . MarkerManager . prototype . getCursor = function ( ) { return this . cursor _ } ; Blockly . MarkerManager . prototype . getMarker = function ( a ) { return this . markers _ [ a ] || null } ;
Blockly . MarkerManager . prototype . setCursor = function ( a ) { this . cursor _ && this . cursor _ . getDrawer ( ) && this . cursor _ . getDrawer ( ) . dispose ( ) ; if ( this . cursor _ = a ) a = this . workspace _ . getRenderer ( ) . makeMarkerDrawer ( this . workspace _ , this . cursor _ ) , this . cursor _ . setDrawer ( a ) , this . setCursorSvg ( this . cursor _ . getDrawer ( ) . createDom ( ) ) } ; Blockly . MarkerManager . prototype . setCursorSvg = function ( a ) { a ? ( this . workspace _ . getBlockCanvas ( ) . appendChild ( a ) , this . cursorSvg _ = a ) : this . cursorSvg _ = null } ;
Blockly . MarkerManager . prototype . setMarkerSvg = function ( a ) { a ? this . workspace _ . getBlockCanvas ( ) && ( this . cursorSvg _ ? this . workspace _ . getBlockCanvas ( ) . insertBefore ( a , this . cursorSvg _ ) : this . workspace _ . getBlockCanvas ( ) . appendChild ( a ) ) : this . markerSvg _ = null } ; Blockly . MarkerManager . prototype . updateMarkers = function ( ) { this . workspace _ . keyboardAccessibilityMode && this . cursorSvg _ && this . workspace _ . getCursor ( ) . draw ( ) } ;
Blockly . MarkerManager . prototype . dispose = function ( ) { for ( var a = Object . keys ( this . markers _ ) , b = 0 , c ; c = a [ b ] ; b ++ ) this . unregisterMarker ( c ) ; this . markers _ = null ; this . cursor _ && ( this . cursor _ . dispose ( ) , this . cursor _ = null ) } ; Blockly . WidgetDiv = { } ; Blockly . WidgetDiv . owner _ = null ; Blockly . WidgetDiv . dispose _ = null ; Blockly . WidgetDiv . rendererClassName _ = "" ; Blockly . WidgetDiv . themeClassName _ = "" ; Blockly . WidgetDiv . createDom = function ( ) { Blockly . WidgetDiv . DIV || ( Blockly . WidgetDiv . DIV = document . createElement ( "div" ) , Blockly . WidgetDiv . DIV . className = "blocklyWidgetDiv" , ( Blockly . parentContainer || document . body ) . appendChild ( Blockly . WidgetDiv . DIV ) ) } ;
Blockly . WidgetDiv . show = function ( a , b , c ) { Blockly . WidgetDiv . hide ( ) ; Blockly . WidgetDiv . owner _ = a ; Blockly . WidgetDiv . dispose _ = c ; a = Blockly . WidgetDiv . DIV ; a . style . direction = b ? "rtl" : "ltr" ; a . style . display = "block" ; b = Blockly . getMainWorkspace ( ) ; Blockly . WidgetDiv . rendererClassName _ = b . getRenderer ( ) . getClassName ( ) ; Blockly . WidgetDiv . themeClassName _ = b . getTheme ( ) . getClassName ( ) ; Blockly . utils . dom . addClass ( a , Blockly . WidgetDiv . rendererClassName _ ) ; Blockly . utils . dom . addClass ( a , Blockly . WidgetDiv . themeClassName _ ) } ;
Blockly . WidgetDiv . hide = function ( ) { if ( Blockly . WidgetDiv . isVisible ( ) ) { Blockly . WidgetDiv . owner _ = null ; var a = Blockly . WidgetDiv . DIV ; a . style . display = "none" ; a . style . left = "" ; a . style . top = "" ; Blockly . WidgetDiv . dispose _ && Blockly . WidgetDiv . dispose _ ( ) ; Blockly . WidgetDiv . dispose _ = null ; a . textContent = "" ; Blockly . WidgetDiv . rendererClassName _ && ( Blockly . utils . dom . removeClass ( a , Blockly . WidgetDiv . rendererClassName _ ) , Blockly . WidgetDiv . rendererClassName _ = "" ) ; Blockly . WidgetDiv . themeClassName _ && ( Blockly . utils . dom . removeClass ( a ,
Blockly . WidgetDiv . themeClassName _ ) , Blockly . WidgetDiv . themeClassName _ = "" ) ; Blockly . getMainWorkspace ( ) . markFocused ( ) } } ; Blockly . WidgetDiv . isVisible = function ( ) { return ! ! Blockly . WidgetDiv . owner _ } ; Blockly . WidgetDiv . hideIfOwner = function ( a ) { Blockly . WidgetDiv . owner _ == a && Blockly . WidgetDiv . hide ( ) } ; Blockly . WidgetDiv . positionInternal _ = function ( a , b , c ) { Blockly . WidgetDiv . DIV . style . left = a + "px" ; Blockly . WidgetDiv . DIV . style . top = b + "px" ; Blockly . WidgetDiv . DIV . style . height = c + "px" } ;
Blockly . WidgetDiv . positionWithAnchor = function ( a , b , c , d ) { var e = Blockly . WidgetDiv . calculateY _ ( a , b , c ) ; a = Blockly . WidgetDiv . calculateX _ ( a , b , c , d ) ; 0 > e ? Blockly . WidgetDiv . positionInternal _ ( a , 0 , c . height + e ) : Blockly . WidgetDiv . positionInternal _ ( a , e , c . height ) } ; Blockly . WidgetDiv . calculateX _ = function ( a , b , c , d ) { if ( d ) return b = Math . max ( b . right - c . width , a . left ) , Math . min ( b , a . right - c . width ) ; b = Math . min ( b . left , a . right - c . width ) ; return Math . max ( b , a . left ) } ;
Blockly . WidgetDiv . calculateY _ = function ( a , b , c ) { return b . bottom + c . height >= a . bottom ? b . top - c . height : b . bottom } ; Blockly . Field = function ( a , b , c ) { this . value _ = this . DEFAULT _VALUE ; this . tooltip _ = this . validator _ = null ; this . size _ = new Blockly . utils . Size ( 0 , 0 ) ; this . constants _ = this . mouseDownWrapper _ = this . textContent _ = this . textElement _ = this . borderRect _ = this . fieldGroup _ = this . markerSvg _ = this . cursorSvg _ = null ; c && this . configure _ ( c ) ; this . setValue ( a ) ; b && this . setValidator ( b ) } ; Blockly . Field . prototype . DEFAULT _VALUE = null ; Blockly . Field . prototype . name = void 0 ; Blockly . Field . prototype . disposed = ! 1 ;
2021-01-16 14:07:51 +00:00
Blockly . Field . prototype . maxDisplayLength = 50 ; Blockly . Field . prototype . sourceBlock _ = null ; Blockly . Field . prototype . isDirty _ = ! 0 ; Blockly . Field . prototype . visible _ = ! 0 ; Blockly . Field . prototype . clickTarget _ = null ; Blockly . Field . NBSP = "\u00a0" ; Blockly . Field . prototype . EDITABLE = ! 0 ; Blockly . Field . prototype . SERIALIZABLE = ! 1 ; Blockly . Field . prototype . configure _ = function ( a ) { var b = a . tooltip ; "string" == typeof b && ( b = Blockly . utils . replaceMessageReferences ( a . tooltip ) ) ; b && this . setTooltip ( b ) } ;
Blockly . Field . prototype . setSourceBlock = function ( a ) { if ( this . sourceBlock _ ) throw Error ( "Field already bound to a block." ) ; this . sourceBlock _ = a } ; Blockly . Field . prototype . getConstants = function ( ) { ! this . constants _ && this . sourceBlock _ && this . sourceBlock _ . workspace && this . sourceBlock _ . workspace . rendered && ( this . constants _ = this . sourceBlock _ . workspace . getRenderer ( ) . getConstants ( ) ) ; return this . constants _ } ; Blockly . Field . prototype . getSourceBlock = function ( ) { return this . sourceBlock _ } ;
Blockly . Field . prototype . init = function ( ) { this . fieldGroup _ || ( this . fieldGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , null ) , this . isVisible ( ) || ( this . fieldGroup _ . style . display = "none" ) , this . sourceBlock _ . getSvgRoot ( ) . appendChild ( this . fieldGroup _ ) , this . initView ( ) , this . updateEditable ( ) , this . setTooltip ( this . tooltip _ ) , this . bindEvents _ ( ) , this . initModel ( ) ) } ; Blockly . Field . prototype . initView = function ( ) { this . createBorderRect _ ( ) ; this . createTextElement _ ( ) } ; Blockly . Field . prototype . initModel = function ( ) { } ;
Blockly . Field . prototype . createBorderRect _ = function ( ) { this . borderRect _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { rx : this . getConstants ( ) . FIELD _BORDER _RECT _RADIUS , ry : this . getConstants ( ) . FIELD _BORDER _RECT _RADIUS , x : 0 , y : 0 , height : this . size _ . height , width : this . size _ . width , "class" : "blocklyFieldRect" } , this . fieldGroup _ ) } ;
Blockly . Field . prototype . createTextElement _ = function ( ) { this . textElement _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TEXT , { "class" : "blocklyText" } , this . fieldGroup _ ) ; this . getConstants ( ) . FIELD _TEXT _BASELINE _CENTER && this . textElement _ . setAttribute ( "dominant-baseline" , "central" ) ; this . textContent _ = document . createTextNode ( "" ) ; this . textElement _ . appendChild ( this . textContent _ ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Field . prototype . bindEvents _ = function ( ) { Blockly . Tooltip . bindMouseEvents ( this . getClickTarget _ ( ) ) ; this . mouseDownWrapper _ = Blockly . browserEvents . conditionalBind ( this . getClickTarget _ ( ) , "mousedown" , this , this . onMouseDown _ ) } ; Blockly . Field . prototype . fromXml = function ( a ) { this . setValue ( a . textContent ) } ; Blockly . Field . prototype . toXml = function ( a ) { a . textContent = this . getValue ( ) ; return a } ;
Blockly . Field . prototype . dispose = function ( ) { Blockly . DropDownDiv . hideIfOwner ( this ) ; Blockly . WidgetDiv . hideIfOwner ( this ) ; Blockly . Tooltip . unbindMouseEvents ( this . getClickTarget _ ( ) ) ; this . mouseDownWrapper _ && Blockly . browserEvents . unbind ( this . mouseDownWrapper _ ) ; Blockly . utils . dom . removeNode ( this . fieldGroup _ ) ; this . disposed = ! 0 } ;
2021-01-16 14:07:51 +00:00
Blockly . Field . prototype . updateEditable = function ( ) { var a = this . fieldGroup _ ; this . EDITABLE && a && ( this . sourceBlock _ . isEditable ( ) ? ( Blockly . utils . dom . addClass ( a , "blocklyEditableText" ) , Blockly . utils . dom . removeClass ( a , "blocklyNonEditableText" ) , a . style . cursor = this . CURSOR ) : ( Blockly . utils . dom . addClass ( a , "blocklyNonEditableText" ) , Blockly . utils . dom . removeClass ( a , "blocklyEditableText" ) , a . style . cursor = "" ) ) } ;
Blockly . Field . prototype . isClickable = function ( ) { return ! ! this . sourceBlock _ && this . sourceBlock _ . isEditable ( ) && ! ! this . showEditor _ && "function" === typeof this . showEditor _ } ; Blockly . Field . prototype . isCurrentlyEditable = function ( ) { return this . EDITABLE && ! ! this . sourceBlock _ && this . sourceBlock _ . isEditable ( ) } ;
Blockly . Field . prototype . isSerializable = function ( ) { var a = ! 1 ; this . name && ( this . SERIALIZABLE ? a = ! 0 : this . EDITABLE && ( console . warn ( "Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization." ) , a = ! 0 ) ) ; return a } ; Blockly . Field . prototype . isVisible = function ( ) { return this . visible _ } ;
Blockly . Field . prototype . setVisible = function ( a ) { if ( this . visible _ != a ) { this . visible _ = a ; var b = this . getSvgRoot ( ) ; b && ( b . style . display = a ? "block" : "none" ) } } ; Blockly . Field . prototype . setValidator = function ( a ) { this . validator _ = a } ; Blockly . Field . prototype . getValidator = function ( ) { return this . validator _ } ; Blockly . Field . prototype . getSvgRoot = function ( ) { return this . fieldGroup _ } ; Blockly . Field . prototype . applyColour = function ( ) { } ;
Blockly . Field . prototype . render _ = function ( ) { this . textContent _ && ( this . textContent _ . nodeValue = this . getDisplayText _ ( ) ) ; this . updateSize _ ( ) } ; Blockly . Field . prototype . showEditor = function ( a ) { this . isClickable ( ) && this . showEditor _ ( a ) } ;
Blockly . Field . prototype . updateSize _ = function ( a ) { var b = this . getConstants ( ) ; a = void 0 != a ? a : this . borderRect _ ? this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING : 0 ; var c = 2 * a , d = b . FIELD _TEXT _HEIGHT , e = 0 ; this . textElement _ && ( e = Blockly . utils . dom . getFastTextWidth ( this . textElement _ , b . FIELD _TEXT _FONTSIZE , b . FIELD _TEXT _FONTWEIGHT , b . FIELD _TEXT _FONTFAMILY ) , c += e ) ; this . borderRect _ && ( d = Math . max ( d , b . FIELD _BORDER _RECT _HEIGHT ) ) ; this . size _ . height = d ; this . size _ . width = c ; this . positionTextElement _ ( a , e ) ; this . positionBorderRect _ ( ) } ;
Blockly . Field . prototype . positionTextElement _ = function ( a , b ) { if ( this . textElement _ ) { var c = this . getConstants ( ) , d = this . size _ . height / 2 ; this . textElement _ . setAttribute ( "x" , this . sourceBlock _ . RTL ? this . size _ . width - b - a : a ) ; this . textElement _ . setAttribute ( "y" , c . FIELD _TEXT _BASELINE _CENTER ? d : d - c . FIELD _TEXT _HEIGHT / 2 + c . FIELD _TEXT _BASELINE ) } } ;
Blockly . Field . prototype . positionBorderRect _ = function ( ) { this . borderRect _ && ( this . borderRect _ . setAttribute ( "width" , this . size _ . width ) , this . borderRect _ . setAttribute ( "height" , this . size _ . height ) , this . borderRect _ . setAttribute ( "rx" , this . getConstants ( ) . FIELD _BORDER _RECT _RADIUS ) , this . borderRect _ . setAttribute ( "ry" , this . getConstants ( ) . FIELD _BORDER _RECT _RADIUS ) ) } ;
Blockly . Field . prototype . getSize = function ( ) { if ( ! this . isVisible ( ) ) return new Blockly . utils . Size ( 0 , 0 ) ; this . isDirty _ ? ( this . render _ ( ) , this . isDirty _ = ! 1 ) : this . visible _ && 0 == this . size _ . width && ( console . warn ( "Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead." ) , this . render _ ( ) ) ; return this . size _ } ;
Blockly . Field . prototype . getScaledBBox = function ( ) { if ( this . borderRect _ ) a = this . borderRect _ . getBoundingClientRect ( ) , c = Blockly . utils . style . getPageOffset ( this . borderRect _ ) , d = a . width , a = a . height ; else { var a = this . sourceBlock _ . getHeightWidth ( ) , b = this . sourceBlock _ . workspace . scale , c = this . getAbsoluteXY _ ( ) , d = a . width * b ; a = a . height * b ; Blockly . utils . userAgent . GECKO ? ( c . x += 1.5 * b , c . y += 1.5 * b ) : Blockly . utils . userAgent . EDGE || Blockly . utils . userAgent . IE || ( c . x -= . 5 * b , c . y -= . 5 * b ) ; d += 1 * b ; a += 1 * b } return new Blockly . utils . Rect ( c . y , c . y +
a , c . x , c . x + d ) } ; Blockly . Field . prototype . getDisplayText _ = function ( ) { var a = this . getText ( ) ; if ( ! a ) return Blockly . Field . NBSP ; a . length > this . maxDisplayLength && ( a = a . substring ( 0 , this . maxDisplayLength - 2 ) + "\u2026" ) ; a = a . replace ( /\s/g , Blockly . Field . NBSP ) ; this . sourceBlock _ && this . sourceBlock _ . RTL && ( a += "\u200f" ) ; return a } ; Blockly . Field . prototype . getText = function ( ) { if ( this . getText _ ) { var a = this . getText _ . call ( this ) ; if ( null !== a ) return String ( a ) } return String ( this . getValue ( ) ) } ;
Blockly . Field . prototype . markDirty = function ( ) { this . isDirty _ = ! 0 ; this . constants _ = null } ; Blockly . Field . prototype . forceRerender = function ( ) { this . isDirty _ = ! 0 ; this . sourceBlock _ && this . sourceBlock _ . rendered && ( this . sourceBlock _ . render ( ) , this . sourceBlock _ . bumpNeighbours ( ) , this . updateMarkers _ ( ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Field . prototype . setValue = function ( a ) { if ( null !== a ) { var b = this . doClassValidation _ ( a ) ; a = this . processValidation _ ( a , b ) ; if ( ! ( a instanceof Error ) ) { if ( b = this . getValidator ( ) ) if ( b = b . call ( this , a ) , a = this . processValidation _ ( a , b ) , a instanceof Error ) return ; b = this . sourceBlock _ ; if ( ! b || ! b . disposed ) { var c = this . getValue ( ) ; c === a ? this . doValueUpdate _ ( a ) : ( b && Blockly . Events . isEnabled ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( b , "field" , this . name || null , c , a ) ) , this . doValueUpdate _ ( a ) ,
this . isDirty _ && this . forceRerender ( ) ) } } } } ; Blockly . Field . prototype . processValidation _ = function ( a , b ) { if ( null === b ) return this . doValueInvalid _ ( a ) , this . isDirty _ && this . forceRerender ( ) , Error ( ) ; void 0 !== b && ( a = b ) ; return a } ; Blockly . Field . prototype . getValue = function ( ) { return this . value _ } ; Blockly . Field . prototype . doClassValidation _ = function ( a ) { return null === a || void 0 === a ? null : a } ; Blockly . Field . prototype . doValueUpdate _ = function ( a ) { this . value _ = a ; this . isDirty _ = ! 0 } ; Blockly . Field . prototype . doValueInvalid _ = function ( a ) { } ;
2021-01-16 14:07:51 +00:00
Blockly . Field . prototype . onMouseDown _ = function ( a ) { this . sourceBlock _ && this . sourceBlock _ . workspace && ( a = this . sourceBlock _ . workspace . getGesture ( a ) ) && a . setStartField ( this ) } ; Blockly . Field . prototype . setTooltip = function ( a ) { a || "" === a || ( a = this . sourceBlock _ ) ; var b = this . getClickTarget _ ( ) ; b ? b . tooltip = a : this . tooltip _ = a } ; Blockly . Field . prototype . getTooltip = function ( ) { var a = this . getClickTarget _ ( ) ; return a ? Blockly . Tooltip . getTooltipOfObject ( a ) : Blockly . Tooltip . getTooltipOfObject ( { tooltip : this . tooltip _ } ) } ;
Blockly . Field . prototype . getClickTarget _ = function ( ) { return this . clickTarget _ || this . getSvgRoot ( ) } ; Blockly . Field . prototype . getAbsoluteXY _ = function ( ) { return Blockly . utils . style . getPageOffset ( this . getClickTarget _ ( ) ) } ; Blockly . Field . prototype . referencesVariables = function ( ) { return ! 1 } ; Blockly . Field . prototype . getParentInput = function ( ) { for ( var a = null , b = this . sourceBlock _ , c = b . inputList , d = 0 ; d < b . inputList . length ; d ++ ) for ( var e = c [ d ] , f = e . fieldRow , g = 0 ; g < f . length ; g ++ ) if ( f [ g ] === this ) { a = e ; break } return a } ;
2021-05-19 13:38:55 +00:00
Blockly . Field . prototype . getFlipRtl = function ( ) { return ! 1 } ; Blockly . Field . prototype . isTabNavigable = function ( ) { return ! 1 } ; Blockly . Field . prototype . onShortcut = function ( a ) { return ! 1 } ; Blockly . Field . prototype . setCursorSvg = function ( a ) { a ? ( this . fieldGroup _ . appendChild ( a ) , this . cursorSvg _ = a ) : this . cursorSvg _ = null } ; Blockly . Field . prototype . setMarkerSvg = function ( a ) { a ? ( this . fieldGroup _ . appendChild ( a ) , this . markerSvg _ = a ) : this . markerSvg _ = null } ;
Blockly . Field . prototype . updateMarkers _ = function ( ) { var a = this . sourceBlock _ . workspace ; a . keyboardAccessibilityMode && this . cursorSvg _ && a . getCursor ( ) . draw ( ) ; a . keyboardAccessibilityMode && this . markerSvg _ && a . getMarker ( Blockly . MarkerManager . LOCAL _MARKER ) . draw ( ) } ; Blockly . FieldLabel = function ( a , b , c ) { this . class _ = null ; Blockly . FieldLabel . superClass _ . constructor . call ( this , a , null , c ) ; c || ( this . class _ = b || null ) } ; Blockly . utils . object . inherits ( Blockly . FieldLabel , Blockly . Field ) ; Blockly . FieldLabel . prototype . DEFAULT _VALUE = "" ; Blockly . FieldLabel . fromJson = function ( a ) { var b = Blockly . utils . replaceMessageReferences ( a . text ) ; return new Blockly . FieldLabel ( b , void 0 , a ) } ; Blockly . FieldLabel . prototype . EDITABLE = ! 1 ;
2021-01-16 14:07:51 +00:00
Blockly . FieldLabel . prototype . configure _ = function ( a ) { Blockly . FieldLabel . superClass _ . configure _ . call ( this , a ) ; this . class _ = a [ "class" ] } ; Blockly . FieldLabel . prototype . initView = function ( ) { this . createTextElement _ ( ) ; this . class _ && Blockly . utils . dom . addClass ( this . textElement _ , this . class _ ) } ; Blockly . FieldLabel . prototype . doClassValidation _ = function ( a ) { return null === a || void 0 === a ? null : String ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldLabel . prototype . setClass = function ( a ) { this . textElement _ && ( this . class _ && Blockly . utils . dom . removeClass ( this . textElement _ , this . class _ ) , a && Blockly . utils . dom . addClass ( this . textElement _ , a ) ) ; this . class _ = a } ; Blockly . fieldRegistry . register ( "field_label" , Blockly . FieldLabel ) ; Blockly . Input = function ( a , b , c , d ) { if ( a != Blockly . inputTypes . DUMMY && ! b ) throw Error ( "Value inputs and statement inputs must have non-empty name." ) ; this . type = a ; this . name = b ; this . sourceBlock _ = c ; this . connection = d ; this . fieldRow = [ ] } ; Blockly . Input . prototype . align = Blockly . constants . ALIGN . LEFT ; Blockly . Input . prototype . visible _ = ! 0 ; Blockly . Input . prototype . getSourceBlock = function ( ) { return this . sourceBlock _ } ; Blockly . Input . prototype . appendField = function ( a , b ) { this . insertFieldAt ( this . fieldRow . length , a , b ) ; return this } ;
Blockly . Input . prototype . insertFieldAt = function ( a , b , c ) { if ( 0 > a || a > this . fieldRow . length ) throw Error ( "index " + a + " out of bounds." ) ; if ( ! ( b || "" == b && c ) ) return a ; "string" == typeof b && ( b = Blockly . fieldRegistry . fromJson ( { type : "field_label" , text : b } ) ) ; b . setSourceBlock ( this . sourceBlock _ ) ; this . sourceBlock _ . rendered && ( b . init ( ) , b . applyColour ( ) ) ; b . name = c ; b . setVisible ( this . isVisible ( ) ) ; b . prefixField && ( a = this . insertFieldAt ( a , b . prefixField ) ) ; this . fieldRow . splice ( a , 0 , b ) ; ++ a ; b . suffixField && ( a = this . insertFieldAt ( a , b . suffixField ) ) ;
this . sourceBlock _ . rendered && ( this . sourceBlock _ = this . sourceBlock _ , this . sourceBlock _ . render ( ) , this . sourceBlock _ . bumpNeighbours ( ) ) ; return a } ; Blockly . Input . prototype . removeField = function ( a , b ) { for ( var c = 0 , d ; d = this . fieldRow [ c ] ; c ++ ) if ( d . name === a ) return d . dispose ( ) , this . fieldRow . splice ( c , 1 ) , this . sourceBlock _ . rendered && ( this . sourceBlock _ = this . sourceBlock _ , this . sourceBlock _ . render ( ) , this . sourceBlock _ . bumpNeighbours ( ) ) , ! 0 ; if ( b ) return ! 1 ; throw Error ( 'Field "' + a + '" not found.' ) ; } ;
Blockly . Input . prototype . isVisible = function ( ) { return this . visible _ } ; Blockly . Input . prototype . setVisible = function ( a ) { var b = [ ] ; if ( this . visible _ == a ) return b ; this . visible _ = a ; for ( var c = 0 , d ; d = this . fieldRow [ c ] ; c ++ ) d . setVisible ( a ) ; this . connection && ( this . connection = this . connection , a ? b = this . connection . startTrackingAll ( ) : this . connection . stopTrackingAll ( ) , c = this . connection . targetBlock ( ) ) && ( c . getSvgRoot ( ) . style . display = a ? "block" : "none" ) ; return b } ; Blockly . Input . prototype . markDirty = function ( ) { for ( var a = 0 , b ; b = this . fieldRow [ a ] ; a ++ ) b . markDirty ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Input . prototype . setCheck = function ( a ) { if ( ! this . connection ) throw Error ( "This input does not have a connection." ) ; this . connection . setCheck ( a ) ; return this } ; Blockly . Input . prototype . setAlign = function ( a ) { this . align = a ; this . sourceBlock _ . rendered && ( this . sourceBlock _ = this . sourceBlock _ , this . sourceBlock _ . render ( ) ) ; return this } ; Blockly . Input . prototype . setShadowDom = function ( a ) { if ( ! this . connection ) throw Error ( "This input does not have a connection." ) ; this . connection . setShadowDom ( a ) ; return this } ;
Blockly . Input . prototype . getShadowDom = function ( ) { if ( ! this . connection ) throw Error ( "This input does not have a connection." ) ; return this . connection . getShadowDom ( ) } ; Blockly . Input . prototype . init = function ( ) { if ( this . sourceBlock _ . workspace . rendered ) for ( var a = 0 ; a < this . fieldRow . length ; a ++ ) this . fieldRow [ a ] . init ( ) } ; Blockly . Input . prototype . dispose = function ( ) { for ( var a = 0 , b ; b = this . fieldRow [ a ] ; a ++ ) b . dispose ( ) ; this . connection && this . connection . dispose ( ) ; this . sourceBlock _ = null } ; Blockly . Block = function ( a , b , c ) { if ( Blockly . Generator && "undefined" != typeof Blockly . Generator . prototype [ b ] ) throw Error ( 'Block prototypeName "' + b + '" conflicts with Blockly.Generator members.' ) ; this . id = c && ! a . getBlockById ( c ) ? c : Blockly . utils . genUid ( ) ; a . setBlockById ( this . id , this ) ; this . previousConnection = this . nextConnection = this . outputConnection = null ; this . inputList = [ ] ; this . inputsInline = void 0 ; this . disabled = ! 1 ; this . tooltip = "" ; this . contextMenu = ! 0 ; this . parentBlock _ = null ; this . childBlocks _ = [ ] ; this . editable _ = this . movable _ =
this . deletable _ = ! 0 ; this . collapsed _ = this . isShadow _ = ! 1 ; this . comment = this . outputShape _ = null ; this . commentModel = { text : null , pinned : ! 1 , size : new Blockly . utils . Size ( 160 , 80 ) } ; this . xy _ = new Blockly . utils . Coordinate ( 0 , 0 ) ; this . workspace = a ; this . isInFlyout = a . isFlyout ; this . isInMutator = a . isMutator ; this . RTL = a . RTL ; this . isInsertionMarker _ = ! 1 ; this . hat = void 0 ; this . rendered = null ; this . statementInputCount = 0 ; if ( b ) { this . type = b ; c = Blockly . Blocks [ b ] ; if ( ! c || "object" != typeof c ) throw TypeError ( "Unknown block type: " + b ) ; Blockly . utils . object . mixin ( this ,
2021-05-19 13:38:55 +00:00
c ) } a . addTopBlock ( this ) ; a . addTypedBlock ( this ) ; ( a = Blockly . Events . getGroup ( ) ) || Blockly . Events . setGroup ( ! 0 ) ; b = Blockly . Events . recordUndo ; try { "function" == typeof this . init && ( Blockly . Events . recordUndo = ! 1 , this . init ( ) , Blockly . Events . recordUndo = b ) , Blockly . Events . isEnabled ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CREATE ) ) ( this ) ) } finally { a || Blockly . Events . setGroup ( ! 1 ) , Blockly . Events . recordUndo = b } this . inputsInlineDefault = this . inputsInline ; "function" == typeof this . onchange && this . setOnChange ( this . onchange ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Block . COLLAPSED _INPUT _NAME = Blockly . constants . COLLAPSED _INPUT _NAME ; Blockly . Block . COLLAPSED _FIELD _NAME = Blockly . constants . COLLAPSED _FIELD _NAME ; Blockly . Block . prototype . data = null ; Blockly . Block . prototype . disposed = ! 1 ; Blockly . Block . prototype . hue _ = null ; Blockly . Block . prototype . colour _ = "#000000" ; Blockly . Block . prototype . styleName _ = "" ;
2021-05-19 13:38:55 +00:00
Blockly . Block . prototype . dispose = function ( a ) { if ( this . workspace ) { this . onchangeWrapper _ && this . workspace . removeChangeListener ( this . onchangeWrapper _ ) ; this . unplug ( a ) ; Blockly . Events . isEnabled ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _DELETE ) ) ( this ) ) ; Blockly . Events . disable ( ) ; try { this . workspace && ( this . workspace . removeTopBlock ( this ) , this . workspace . removeTypedBlock ( this ) , this . workspace . removeBlockById ( this . id ) , this . workspace = null ) ; Blockly . selected == this && ( Blockly . selected = null ) ; for ( var b =
this . childBlocks _ . length - 1 ; 0 <= b ; b -- ) this . childBlocks _ [ b ] . dispose ( ! 1 ) ; b = 0 ; for ( var c ; c = this . inputList [ b ] ; b ++ ) c . dispose ( ) ; this . inputList . length = 0 ; var d = this . getConnections _ ( ! 0 ) ; b = 0 ; for ( var e ; e = d [ b ] ; b ++ ) e . dispose ( ) } finally { Blockly . Events . enable ( ) , this . disposed = ! 0 } } } ; Blockly . Block . prototype . initModel = function ( ) { for ( var a = 0 , b ; b = this . inputList [ a ] ; a ++ ) for ( var c = 0 , d ; d = b . fieldRow [ c ] ; c ++ ) d . initModel && d . initModel ( ) } ;
Blockly . Block . prototype . unplug = function ( a ) { this . outputConnection ? this . unplugFromRow _ ( a ) : this . previousConnection && this . unplugFromStack _ ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . unplugFromRow _ = function ( a ) { var b = null ; this . outputConnection . isConnected ( ) && ( b = this . outputConnection . targetConnection , this . outputConnection . disconnect ( ) ) ; if ( b && a && ( a = this . getOnlyValueConnection _ ( ) ) && a . isConnected ( ) && ! a . targetBlock ( ) . isShadow ( ) ) if ( a = a . targetConnection , a . disconnect ( ) , this . workspace . connectionChecker . canConnect ( a , b , ! 1 ) ) b . connect ( a ) ; else a . onFailedConnect ( b ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Block . prototype . getOnlyValueConnection _ = function ( ) { for ( var a = null , b = 0 ; b < this . inputList . length ; b ++ ) { var c = this . inputList [ b ] . connection ; if ( c && c . type == Blockly . connectionTypes . INPUT _VALUE && c . targetConnection ) { if ( a ) return null ; a = c } } return a } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . unplugFromStack _ = function ( a ) { var b = null ; this . previousConnection . isConnected ( ) && ( b = this . previousConnection . targetConnection , this . previousConnection . disconnect ( ) ) ; var c = this . getNextBlock ( ) ; a && c && ! c . isShadow ( ) && ( a = this . nextConnection . targetConnection , a . disconnect ( ) , b && this . workspace . connectionChecker . canConnect ( b , a , ! 1 ) && b . connect ( a ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Block . prototype . getConnections _ = function ( a ) { a = [ ] ; this . outputConnection && a . push ( this . outputConnection ) ; this . previousConnection && a . push ( this . previousConnection ) ; this . nextConnection && a . push ( this . nextConnection ) ; for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) c . connection && a . push ( c . connection ) ; return a } ; Blockly . Block . prototype . lastConnectionInStack = function ( a ) { for ( var b = this . nextConnection ; b ; ) { var c = b . targetBlock ( ) ; if ( ! c || a && c . isShadow ( ) ) return b ; b = c . nextConnection } return null } ;
Blockly . Block . prototype . bumpNeighbours = function ( ) { } ; Blockly . Block . prototype . getParent = function ( ) { return this . parentBlock _ } ; Blockly . Block . prototype . getInputWithBlock = function ( a ) { for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) if ( c . connection && c . connection . targetBlock ( ) == a ) return c ; return null } ; Blockly . Block . prototype . getSurroundParent = function ( ) { var a = this ; do { var b = a ; a = a . getParent ( ) ; if ( ! a ) return null } while ( a . getNextBlock ( ) == b ) ; return a } ;
Blockly . Block . prototype . getNextBlock = function ( ) { return this . nextConnection && this . nextConnection . targetBlock ( ) } ; Blockly . Block . prototype . getPreviousBlock = function ( ) { return this . previousConnection && this . previousConnection . targetBlock ( ) } ; Blockly . Block . prototype . getFirstStatementConnection = function ( ) { for ( var a = 0 , b ; b = this . inputList [ a ] ; a ++ ) if ( b . connection && b . connection . type == Blockly . connectionTypes . NEXT _STATEMENT ) return b . connection ; return null } ;
Blockly . Block . prototype . getRootBlock = function ( ) { var a = this ; do { var b = a ; a = b . parentBlock _ } while ( a ) ; return b } ; Blockly . Block . prototype . getTopStackBlock = function ( ) { var a = this ; do var b = a . getPreviousBlock ( ) ; while ( b && b . getNextBlock ( ) == a && ( a = b ) ) ; return a } ; Blockly . Block . prototype . getChildren = function ( a ) { if ( ! a ) return this . childBlocks _ ; a = [ ] ; for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) c . connection && ( c = c . connection . targetBlock ( ) ) && a . push ( c ) ; ( b = this . getNextBlock ( ) ) && a . push ( b ) ; return a } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . setParent = function ( a ) { if ( a != this . parentBlock _ ) { if ( this . parentBlock _ ) { Blockly . utils . arrayRemove ( this . parentBlock _ . childBlocks _ , this ) ; if ( this . previousConnection && this . previousConnection . isConnected ( ) ) throw Error ( "Still connected to previous block." ) ; if ( this . outputConnection && this . outputConnection . isConnected ( ) ) throw Error ( "Still connected to parent block." ) ; this . parentBlock _ = null } else this . workspace . removeTopBlock ( this ) ; ( this . parentBlock _ = a ) ? a . childBlocks _ . push ( this ) : this . workspace . addTopBlock ( this ) } } ;
Blockly . Block . prototype . getDescendants = function ( a ) { for ( var b = [ this ] , c = this . getChildren ( a ) , d , e = 0 ; d = c [ e ] ; e ++ ) b . push . apply ( b , d . getDescendants ( a ) ) ; return b } ; Blockly . Block . prototype . isDeletable = function ( ) { return this . deletable _ && ! this . isShadow _ && ! ( this . workspace && this . workspace . options . readOnly ) } ; Blockly . Block . prototype . setDeletable = function ( a ) { this . deletable _ = a } ; Blockly . Block . prototype . isMovable = function ( ) { return this . movable _ && ! this . isShadow _ && ! ( this . workspace && this . workspace . options . readOnly ) } ;
Blockly . Block . prototype . setMovable = function ( a ) { this . movable _ = a } ; Blockly . Block . prototype . isDuplicatable = function ( ) { return this . workspace . hasBlockLimits ( ) ? this . workspace . isCapacityAvailable ( Blockly . utils . getBlockTypeCounts ( this , ! 0 ) ) : ! 0 } ; Blockly . Block . prototype . isShadow = function ( ) { return this . isShadow _ } ; Blockly . Block . prototype . setShadow = function ( a ) { this . isShadow _ = a } ; Blockly . Block . prototype . isInsertionMarker = function ( ) { return this . isInsertionMarker _ } ;
Blockly . Block . prototype . setInsertionMarker = function ( a ) { this . isInsertionMarker _ = a } ; Blockly . Block . prototype . isEditable = function ( ) { return this . editable _ && ! ( this . workspace && this . workspace . options . readOnly ) } ; Blockly . Block . prototype . setEditable = function ( a ) { this . editable _ = a ; a = 0 ; for ( var b ; b = this . inputList [ a ] ; a ++ ) for ( var c = 0 , d ; d = b . fieldRow [ c ] ; c ++ ) d . updateEditable ( ) } ; Blockly . Block . prototype . isDisposed = function ( ) { return this . disposed } ;
Blockly . Block . prototype . getMatchingConnection = function ( a , b ) { var c = this . getConnections _ ( ! 0 ) ; a = a . getConnections _ ( ! 0 ) ; if ( c . length != a . length ) throw Error ( "Connection lists did not match in length." ) ; for ( var d = 0 ; d < a . length ; d ++ ) if ( a [ d ] == b ) return c [ d ] ; return null } ; Blockly . Block . prototype . setHelpUrl = function ( a ) { this . helpUrl = a } ; Blockly . Block . prototype . setTooltip = function ( a ) { this . tooltip = a } ; Blockly . Block . prototype . getTooltip = function ( ) { return Blockly . Tooltip . getTooltipOfObject ( this ) } ;
Blockly . Block . prototype . getColour = function ( ) { return this . colour _ } ; Blockly . Block . prototype . getStyleName = function ( ) { return this . styleName _ } ; Blockly . Block . prototype . getHue = function ( ) { return this . hue _ } ; Blockly . Block . prototype . setColour = function ( a ) { a = Blockly . utils . parseBlockColour ( a ) ; this . hue _ = a . hue ; this . colour _ = a . hex } ; Blockly . Block . prototype . setStyle = function ( a ) { this . styleName _ = a } ;
2021-09-18 14:29:06 +00:00
Blockly . Block . prototype . setOnChange = function ( a ) { if ( a && "function" != typeof a ) throw Error ( "onchange must be a function." ) ; this . onchangeWrapper _ && this . workspace . removeChangeListener ( this . onchangeWrapper _ ) ; if ( this . onchange = a ) this . onchangeWrapper _ = a . bind ( this ) , this . workspace . addChangeListener ( this . onchangeWrapper _ ) } ;
Blockly . Block . prototype . getField = function ( a ) { if ( "string" !== typeof a ) throw TypeError ( "Blockly.Block.prototype.getField expects a string with the field name but received " + ( void 0 === a ? "nothing" : a + " of type " + typeof a ) + " instead" ) ; for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) for ( var d = 0 , e ; e = c . fieldRow [ d ] ; d ++ ) if ( e . name === a ) return e ; return null } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . getVars = function ( ) { for ( var a = [ ] , b = 0 , c ; c = this . inputList [ b ] ; b ++ ) for ( var d = 0 , e ; e = c . fieldRow [ d ] ; d ++ ) e . referencesVariables ( ) && a . push ( e . getValue ( ) ) ; return a } ; Blockly . Block . prototype . getVarModels = function ( ) { for ( var a = [ ] , b = 0 , c ; c = this . inputList [ b ] ; b ++ ) for ( var d = 0 , e ; e = c . fieldRow [ d ] ; d ++ ) e . referencesVariables ( ) && ( e = this . workspace . getVariableById ( e . getValue ( ) ) ) && a . push ( e ) ; return a } ;
Blockly . Block . prototype . updateVarName = function ( a ) { for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) for ( var d = 0 , e ; e = c . fieldRow [ d ] ; d ++ ) e . referencesVariables ( ) && a . getId ( ) == e . getValue ( ) && e . refreshVariableName ( ) } ; Blockly . Block . prototype . renameVarById = function ( a , b ) { for ( var c = 0 , d ; d = this . inputList [ c ] ; c ++ ) for ( var e = 0 , f ; f = d . fieldRow [ e ] ; e ++ ) f . referencesVariables ( ) && a == f . getValue ( ) && f . setValue ( b ) } ; Blockly . Block . prototype . getFieldValue = function ( a ) { return ( a = this . getField ( a ) ) ? a . getValue ( ) : null } ;
Blockly . Block . prototype . setFieldValue = function ( a , b ) { var c = this . getField ( b ) ; if ( ! c ) throw Error ( 'Field "' + b + '" not found.' ) ; c . setValue ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Block . prototype . setPreviousStatement = function ( a , b ) { if ( a ) { void 0 === b && ( b = null ) ; if ( ! this . previousConnection ) { if ( this . outputConnection ) throw Error ( "Remove output connection prior to adding previous connection." ) ; this . previousConnection = this . makeConnection _ ( Blockly . connectionTypes . PREVIOUS _STATEMENT ) } this . previousConnection . setCheck ( b ) } else if ( this . previousConnection ) { if ( this . previousConnection . isConnected ( ) ) throw Error ( "Must disconnect previous statement before removing connection." ) ; this . previousConnection . dispose ( ) ;
this . previousConnection = null } } ; Blockly . Block . prototype . setNextStatement = function ( a , b ) { if ( a ) void 0 === b && ( b = null ) , this . nextConnection || ( this . nextConnection = this . makeConnection _ ( Blockly . connectionTypes . NEXT _STATEMENT ) ) , this . nextConnection . setCheck ( b ) ; else if ( this . nextConnection ) { if ( this . nextConnection . isConnected ( ) ) throw Error ( "Must disconnect next statement before removing connection." ) ; this . nextConnection . dispose ( ) ; this . nextConnection = null } } ;
Blockly . Block . prototype . setOutput = function ( a , b ) { if ( a ) { void 0 === b && ( b = null ) ; if ( ! this . outputConnection ) { if ( this . previousConnection ) throw Error ( "Remove previous connection prior to adding output connection." ) ; this . outputConnection = this . makeConnection _ ( Blockly . connectionTypes . OUTPUT _VALUE ) } this . outputConnection . setCheck ( b ) } else if ( this . outputConnection ) { if ( this . outputConnection . isConnected ( ) ) throw Error ( "Must disconnect output value before removing connection." ) ; this . outputConnection . dispose ( ) ; this . outputConnection =
null } } ; Blockly . Block . prototype . setInputsInline = function ( a ) { this . inputsInline != a && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this , "inline" , null , this . inputsInline , a ) ) , this . inputsInline = a ) } ;
Blockly . Block . prototype . getInputsInline = function ( ) { if ( void 0 != this . inputsInline ) return this . inputsInline ; for ( var a = 1 ; a < this . inputList . length ; a ++ ) if ( this . inputList [ a - 1 ] . type == Blockly . inputTypes . DUMMY && this . inputList [ a ] . type == Blockly . inputTypes . DUMMY ) return ! 1 ; for ( a = 1 ; a < this . inputList . length ; a ++ ) if ( this . inputList [ a - 1 ] . type == Blockly . inputTypes . VALUE && this . inputList [ a ] . type == Blockly . inputTypes . DUMMY ) return ! 0 ; return ! 1 } ; Blockly . Block . prototype . setOutputShape = function ( a ) { this . outputShape _ = a } ;
Blockly . Block . prototype . getOutputShape = function ( ) { return this . outputShape _ } ; Blockly . Block . prototype . isEnabled = function ( ) { return ! this . disabled } ; Blockly . Block . prototype . setEnabled = function ( a ) { this . isEnabled ( ) != a && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this , "disabled" , null , this . disabled , ! a ) ) , this . disabled = ! a ) } ; Blockly . Block . prototype . getInheritedDisabled = function ( ) { for ( var a = this . getSurroundParent ( ) ; a ; ) { if ( a . disabled ) return ! 0 ; a = a . getSurroundParent ( ) } return ! 1 } ;
Blockly . Block . prototype . isCollapsed = function ( ) { return this . collapsed _ } ; Blockly . Block . prototype . setCollapsed = function ( a ) { this . collapsed _ != a && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this , "collapsed" , null , this . collapsed _ , a ) ) , this . collapsed _ = a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . toString = function ( a , b ) { function c ( l ) { var m = l . getCheck ( ) ; ! m && l . targetConnection && ( m = l . targetConnection . getCheck ( ) ) ; return ! ! m && ( - 1 != m . indexOf ( "Boolean" ) || - 1 != m . indexOf ( "Number" ) ) } function d ( ) { g && g . getType ( ) == h . getType ( ) && g . getLocation ( ) == h . getLocation ( ) && ( g = null ) } var e = [ ] ; b = b || "?" ; var f = Blockly . ASTNode . NAVIGATE _ALL _FIELDS ; Blockly . ASTNode . NAVIGATE _ALL _FIELDS = ! 0 ; for ( var g = Blockly . ASTNode . createBlockNode ( this ) , h = g ; g ; ) { switch ( g . getType ( ) ) { case Blockly . ASTNode . types . INPUT : var k = g . getLocation ( ) ;
2021-09-18 14:29:06 +00:00
g . in ( ) ? c ( k ) && e . push ( "(" ) : e . push ( b ) ; break ; case Blockly . ASTNode . types . FIELD : k = g . getLocation ( ) , k . name != Blockly . constants . COLLAPSED _FIELD _NAME && e . push ( k . getText ( ) ) } k = g ; g = k . in ( ) || k . next ( ) ; if ( ! g ) { g = k . out ( ) ; for ( d ( ) ; g && ! g . next ( ) ; ) g = g . out ( ) , d ( ) , g && g . getType ( ) == Blockly . ASTNode . types . INPUT && c ( g . getLocation ( ) ) && e . push ( ")" ) ; g && ( g = g . next ( ) ) } } Blockly . ASTNode . NAVIGATE _ALL _FIELDS = f ; for ( b = 2 ; b < e . length ; b ++ ) "(" == e [ b - 2 ] && ")" == e [ b ] && ( e [ b - 2 ] = e [ b - 1 ] , e . splice ( b - 1 , 2 ) ) ; e = e . reduce ( function ( l , m ) { return l + ( "(" == l . substr ( - 1 ) ||
")" == m ? "" : " " ) + m } , "" ) ; e = e . trim ( ) || "???" ; a && e . length > a && ( e = e . substring ( 0 , a - 3 ) + "..." ) ; return e } ; Blockly . Block . prototype . appendValueInput = function ( a ) { return this . appendInput _ ( Blockly . inputTypes . VALUE , a ) } ; Blockly . Block . prototype . appendStatementInput = function ( a ) { return this . appendInput _ ( Blockly . inputTypes . STATEMENT , a ) } ; Blockly . Block . prototype . appendDummyInput = function ( a ) { return this . appendInput _ ( Blockly . inputTypes . DUMMY , a || "" ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . jsonInit = function ( a ) { var b = a . type ? 'Block "' + a . type + '": ' : "" ; if ( a . output && a . previousStatement ) throw Error ( b + "Must not have both an output and a previousStatement." ) ; a . style && a . style . hat && ( this . hat = a . style . hat , a . style = null ) ; if ( a . style && a . colour ) throw Error ( b + "Must not have both a colour and a style." ) ; a . style ? this . jsonInitStyle _ ( a , b ) : this . jsonInitColour _ ( a , b ) ; for ( var c = 0 ; void 0 !== a [ "message" + c ] ; ) this . interpolate _ ( a [ "message" + c ] , a [ "args" + c ] || [ ] , a [ "lastDummyAlign" + c ] , b ) , c ++ ; void 0 !==
a . inputsInline && this . setInputsInline ( a . inputsInline ) ; void 0 !== a . output && this . setOutput ( ! 0 , a . output ) ; void 0 !== a . outputShape && this . setOutputShape ( a . outputShape ) ; void 0 !== a . previousStatement && this . setPreviousStatement ( ! 0 , a . previousStatement ) ; void 0 !== a . nextStatement && this . setNextStatement ( ! 0 , a . nextStatement ) ; void 0 !== a . tooltip && ( c = a . tooltip , c = Blockly . utils . replaceMessageReferences ( c ) , this . setTooltip ( c ) ) ; void 0 !== a . enableContextMenu && ( c = a . enableContextMenu , this . contextMenu = ! ! c ) ; void 0 !== a . helpUrl && ( c =
2021-09-18 14:29:06 +00:00
a . helpUrl , c = Blockly . utils . replaceMessageReferences ( c ) , this . setHelpUrl ( c ) ) ; "string" == typeof a . extensions && ( console . warn ( b + "JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '" + a . type + "' block." ) , a . extensions = [ a . extensions ] ) ; void 0 !== a . mutator && Blockly . Extensions . apply ( a . mutator , this , ! 0 ) ; a = a . extensions ; if ( Array . isArray ( a ) ) for ( b = 0 ; b < a . length ; ++ b ) Blockly . Extensions . apply ( a [ b ] , this , ! 1 ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . jsonInitColour _ = function ( a , b ) { if ( "colour" in a ) if ( void 0 === a . colour ) console . warn ( b + "Undefined colour value." ) ; else { a = a . colour ; try { this . setColour ( a ) } catch ( c ) { console . warn ( b + "Illegal colour value: " , a ) } } } ; Blockly . Block . prototype . jsonInitStyle _ = function ( a , b ) { a = a . style ; try { this . setStyle ( a ) } catch ( c ) { console . warn ( b + "Style does not exist: " , a ) } } ;
Blockly . Block . prototype . mixin = function ( a , b ) { if ( void 0 !== b && "boolean" != typeof b ) throw Error ( "opt_disableCheck must be a boolean if provided" ) ; if ( ! b ) { b = [ ] ; for ( var c in a ) void 0 !== this [ c ] && b . push ( c ) ; if ( b . length ) throw Error ( "Mixin will overwrite block members: " + JSON . stringify ( b ) ) ; } Blockly . utils . object . mixin ( this , a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Block . prototype . interpolate _ = function ( a , b , c , d ) { a = Blockly . utils . tokenizeInterpolation ( a ) ; this . validateTokens _ ( a , b . length ) ; b = this . interpolateArguments _ ( a , b , c ) ; c = [ ] ; a = 0 ; for ( var e ; e = b [ a ] ; a ++ ) if ( this . isInputKeyword _ ( e . type ) ) { if ( e = this . inputFromJson _ ( e , d ) ) { for ( var f = 0 , g ; g = c [ f ] ; f ++ ) e . appendField ( g [ 0 ] , g [ 1 ] ) ; c . length = 0 } } else ( f = this . fieldFromJson _ ( e ) ) && c . push ( [ f , e . name ] ) } ;
Blockly . Block . prototype . validateTokens _ = function ( a , b ) { for ( var c = [ ] , d = 0 , e = 0 ; e < a . length ; e ++ ) { var f = a [ e ] ; if ( "number" == typeof f ) { if ( 1 > f || f > b ) throw Error ( 'Block "' + this . type + '": Message index %' + f + " out of range." ) ; if ( c [ f ] ) throw Error ( 'Block "' + this . type + '": Message index %' + f + " duplicated." ) ; c [ f ] = ! 0 ; d ++ } } if ( d != b ) throw Error ( 'Block "' + this . type + '": Message does not reference all ' + b + " arg(s)." ) ; } ;
Blockly . Block . prototype . interpolateArguments _ = function ( a , b , c ) { for ( var d = [ ] , e = 0 ; e < a . length ; e ++ ) { var f = a [ e ] ; "number" == typeof f && ( f = b [ f - 1 ] ) ; if ( "string" == typeof f && ( f = this . stringToFieldJson _ ( f ) , ! f ) ) continue ; d . push ( f ) } ( a = d . length ) && ! this . isInputKeyword _ ( d [ a - 1 ] . type ) && ( a = { type : "input_dummy" } , c && ( a . align = c ) , d . push ( a ) ) ; return d } ;
Blockly . Block . prototype . fieldFromJson _ = function ( a ) { var b = Blockly . fieldRegistry . fromJson ( a ) ; return ! b && a . alt ? "string" == typeof a . alt ? ( a = this . stringToFieldJson _ ( a . alt ) ) ? this . fieldFromJson _ ( a ) : null : this . fieldFromJson _ ( a . alt ) : b } ;
Blockly . Block . prototype . inputFromJson _ = function ( a , b ) { var c = { LEFT : Blockly . constants . ALIGN . LEFT , RIGHT : Blockly . constants . ALIGN . RIGHT , CENTRE : Blockly . constants . ALIGN . CENTRE , CENTER : Blockly . constants . ALIGN . CENTRE } , d = null ; switch ( a . type ) { case "input_value" : d = this . appendValueInput ( a . name ) ; break ; case "input_statement" : d = this . appendStatementInput ( a . name ) ; break ; case "input_dummy" : d = this . appendDummyInput ( a . name ) } if ( ! d ) return null ; a . check && d . setCheck ( a . check ) ; a . align && ( c = c [ a . align . toUpperCase ( ) ] , void 0 === c ? console . warn ( b +
"Illegal align value: " , a . align ) : d . setAlign ( c ) ) ; return d } ; Blockly . Block . prototype . isInputKeyword _ = function ( a ) { return "input_value" == a || "input_statement" == a || "input_dummy" == a } ; Blockly . Block . prototype . stringToFieldJson _ = function ( a ) { return ( a = a . trim ( ) ) ? { type : "field_label" , text : a } : null } ;
Blockly . Block . prototype . appendInput _ = function ( a , b ) { var c = null ; if ( a == Blockly . inputTypes . VALUE || a == Blockly . inputTypes . STATEMENT ) c = this . makeConnection _ ( a ) ; a == Blockly . inputTypes . STATEMENT && this . statementInputCount ++ ; a = new Blockly . Input ( a , b , this , c ) ; this . inputList . push ( a ) ; return a } ;
2021-01-16 14:07:51 +00:00
Blockly . Block . prototype . moveInputBefore = function ( a , b ) { if ( a != b ) { for ( var c = - 1 , d = b ? - 1 : this . inputList . length , e = 0 , f ; f = this . inputList [ e ] ; e ++ ) if ( f . name == a ) { if ( c = e , - 1 != d ) break } else if ( b && f . name == b && ( d = e , - 1 != c ) ) break ; if ( - 1 == c ) throw Error ( 'Named input "' + a + '" not found.' ) ; if ( - 1 == d ) throw Error ( 'Reference input "' + b + '" not found.' ) ; this . moveNumberedInputBefore ( c , d ) } } ;
Blockly . Block . prototype . moveNumberedInputBefore = function ( a , b ) { if ( a == b ) throw Error ( "Can't move input to itself." ) ; if ( a >= this . inputList . length ) throw RangeError ( "Input index " + a + " out of bounds." ) ; if ( b > this . inputList . length ) throw RangeError ( "Reference input " + b + " out of bounds." ) ; var c = this . inputList [ a ] ; this . inputList . splice ( a , 1 ) ; a < b && b -- ; this . inputList . splice ( b , 0 , c ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Block . prototype . removeInput = function ( a , b ) { for ( var c = 0 , d ; d = this . inputList [ c ] ; c ++ ) if ( d . name == a ) return d . type == Blockly . inputTypes . STATEMENT && this . statementInputCount -- , d . dispose ( ) , this . inputList . splice ( c , 1 ) , ! 0 ; if ( b ) return ! 1 ; throw Error ( "Input not found: " + a ) ; } ; Blockly . Block . prototype . getInput = function ( a ) { for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) if ( c . name == a ) return c ; return null } ; Blockly . Block . prototype . getInputTargetBlock = function ( a ) { return ( a = this . getInput ( a ) ) && a . connection && a . connection . targetBlock ( ) } ;
Blockly . Block . prototype . getCommentText = function ( ) { return this . commentModel . text } ; Blockly . Block . prototype . setCommentText = function ( a ) { this . commentModel . text != a && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this , "comment" , null , this . commentModel . text , a ) ) , this . comment = this . commentModel . text = a ) } ; Blockly . Block . prototype . setWarningText = function ( a , b ) { } ; Blockly . Block . prototype . setMutator = function ( a ) { } ; Blockly . Block . prototype . getRelativeToSurfaceXY = function ( ) { return this . xy _ } ;
Blockly . Block . prototype . moveBy = function ( a , b ) { if ( this . parentBlock _ ) throw Error ( "Block has parent." ) ; var c = new ( Blockly . Events . get ( Blockly . Events . BLOCK _MOVE ) ) ( this ) ; this . xy _ . translate ( a , b ) ; c . recordNew ( ) ; Blockly . Events . fire ( c ) } ; Blockly . Block . prototype . makeConnection _ = function ( a ) { return new Blockly . Connection ( this , a ) } ;
Blockly . Block . prototype . allInputsFilled = function ( a ) { void 0 === a && ( a = ! 0 ) ; if ( ! a && this . isShadow ( ) ) return ! 1 ; for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) if ( c . connection && ( c = c . connection . targetBlock ( ) , ! c || ! c . allInputsFilled ( a ) ) ) return ! 1 ; return ( b = this . getNextBlock ( ) ) ? b . allInputsFilled ( a ) : ! 0 } ; Blockly . Block . prototype . toDevString = function ( ) { var a = this . type ? '"' + this . type + '" block' : "Block" ; this . id && ( a += ' (id="' + this . id + '")' ) ; return a } ; Blockly . blockRendering . IPathObject = function ( a , b ) { } ; Blockly . utils . KeyCodes = { WIN _KEY _FF _LINUX : 0 , MAC _ENTER : 3 , BACKSPACE : 8 , TAB : 9 , NUM _CENTER : 12 , ENTER : 13 , SHIFT : 16 , CTRL : 17 , ALT : 18 , PAUSE : 19 , CAPS _LOCK : 20 , ESC : 27 , SPACE : 32 , PAGE _UP : 33 , PAGE _DOWN : 34 , END : 35 , HOME : 36 , LEFT : 37 , UP : 38 , RIGHT : 39 , DOWN : 40 , PLUS _SIGN : 43 , PRINT _SCREEN : 44 , INSERT : 45 , DELETE : 46 , ZERO : 48 , ONE : 49 , TWO : 50 , THREE : 51 , FOUR : 52 , FIVE : 53 , SIX : 54 , SEVEN : 55 , EIGHT : 56 , NINE : 57 , FF _SEMICOLON : 59 , FF _EQUALS : 61 , FF _DASH : 173 , FF _HASH : 163 , QUESTION _MARK : 63 , AT _SIGN : 64 , A : 65 , B : 66 , C : 67 , D : 68 , E : 69 , F : 70 , G : 71 , H : 72 , I : 73 , J : 74 , K : 75 , L : 76 , M : 77 ,
2021-01-16 14:07:51 +00:00
N : 78 , O : 79 , P : 80 , Q : 81 , R : 82 , S : 83 , T : 84 , U : 85 , V : 86 , W : 87 , X : 88 , Y : 89 , Z : 90 , META : 91 , WIN _KEY _RIGHT : 92 , CONTEXT _MENU : 93 , NUM _ZERO : 96 , NUM _ONE : 97 , NUM _TWO : 98 , NUM _THREE : 99 , NUM _FOUR : 100 , NUM _FIVE : 101 , NUM _SIX : 102 , NUM _SEVEN : 103 , NUM _EIGHT : 104 , NUM _NINE : 105 , NUM _MULTIPLY : 106 , NUM _PLUS : 107 , NUM _MINUS : 109 , NUM _PERIOD : 110 , NUM _DIVISION : 111 , F1 : 112 , F2 : 113 , F3 : 114 , F4 : 115 , F5 : 116 , F6 : 117 , F7 : 118 , F8 : 119 , F9 : 120 , F10 : 121 , F11 : 122 , F12 : 123 , NUMLOCK : 144 , SCROLL _LOCK : 145 , FIRST _MEDIA _KEY : 166 , LAST _MEDIA _KEY : 183 , SEMICOLON : 186 , DASH : 189 , EQUALS : 187 , COMMA : 188 ,
PERIOD : 190 , SLASH : 191 , APOSTROPHE : 192 , TILDE : 192 , SINGLE _QUOTE : 222 , OPEN _SQUARE _BRACKET : 219 , BACKSLASH : 220 , CLOSE _SQUARE _BRACKET : 221 , WIN _KEY : 224 , MAC _FF _META : 224 , MAC _WK _CMD _LEFT : 91 , MAC _WK _CMD _RIGHT : 93 , WIN _IME : 229 , VK _NONAME : 252 , PHANTOM : 255 } ; Blockly . Menu = function ( ) { this . menuItems _ = [ ] ; this . roleName _ = this . element _ = this . onKeyDownHandler _ = this . mouseLeaveHandler _ = this . mouseEnterHandler _ = this . clickHandler _ = this . mouseOverHandler _ = this . highlightedItem _ = this . openingCoords = null } ; Blockly . Menu . prototype . addChild = function ( a ) { this . menuItems _ . push ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Menu . prototype . render = function ( a ) { var b = document . createElement ( "div" ) ; b . className = "blocklyMenu goog-menu blocklyNonSelectable" ; b . tabIndex = 0 ; this . roleName _ && Blockly . utils . aria . setRole ( b , this . roleName _ ) ; this . element _ = b ; for ( var c = 0 , d ; d = this . menuItems _ [ c ] ; c ++ ) b . appendChild ( d . createDom ( ) ) ; this . mouseOverHandler _ = Blockly . browserEvents . conditionalBind ( b , "mouseover" , this , this . handleMouseOver _ , ! 0 ) ; this . clickHandler _ = Blockly . browserEvents . conditionalBind ( b , "click" , this , this . handleClick _ , ! 0 ) ; this . mouseEnterHandler _ =
Blockly . browserEvents . conditionalBind ( b , "mouseenter" , this , this . handleMouseEnter _ , ! 0 ) ; this . mouseLeaveHandler _ = Blockly . browserEvents . conditionalBind ( b , "mouseleave" , this , this . handleMouseLeave _ , ! 0 ) ; this . onKeyDownHandler _ = Blockly . browserEvents . conditionalBind ( b , "keydown" , this , this . handleKeyEvent _ ) ; a . appendChild ( b ) } ; Blockly . Menu . prototype . getElement = function ( ) { return this . element _ } ;
Blockly . Menu . prototype . focus = function ( ) { var a = this . getElement ( ) ; a && ( a . focus ( { preventScroll : ! 0 } ) , Blockly . utils . dom . addClass ( a , "blocklyFocused" ) ) } ; Blockly . Menu . prototype . blur _ = function ( ) { var a = this . getElement ( ) ; a && ( a . blur ( ) , Blockly . utils . dom . removeClass ( a , "blocklyFocused" ) ) } ; Blockly . Menu . prototype . setRole = function ( a ) { this . roleName _ = a } ;
Blockly . Menu . prototype . dispose = function ( ) { this . mouseOverHandler _ && ( Blockly . browserEvents . unbind ( this . mouseOverHandler _ ) , this . mouseOverHandler _ = null ) ; this . clickHandler _ && ( Blockly . browserEvents . unbind ( this . clickHandler _ ) , this . clickHandler _ = null ) ; this . mouseEnterHandler _ && ( Blockly . browserEvents . unbind ( this . mouseEnterHandler _ ) , this . mouseEnterHandler _ = null ) ; this . mouseLeaveHandler _ && ( Blockly . browserEvents . unbind ( this . mouseLeaveHandler _ ) , this . mouseLeaveHandler _ = null ) ; this . onKeyDownHandler _ && ( Blockly . browserEvents . unbind ( this . onKeyDownHandler _ ) ,
2021-01-16 14:07:51 +00:00
this . onKeyDownHandler _ = null ) ; for ( var a = 0 , b ; b = this . menuItems _ [ a ] ; a ++ ) b . dispose ( ) ; this . element _ = null } ; Blockly . Menu . prototype . getMenuItem _ = function ( a ) { for ( var b = this . getElement ( ) ; a && a != b ; ) { if ( Blockly . utils . dom . hasClass ( a , "blocklyMenuItem" ) ) for ( var c = 0 , d ; d = this . menuItems _ [ c ] ; c ++ ) if ( d . getElement ( ) == a ) return d ; a = a . parentElement } return null } ;
Blockly . Menu . prototype . setHighlighted = function ( a ) { var b = this . highlightedItem _ ; b && ( b . setHighlighted ( ! 1 ) , this . highlightedItem _ = null ) ; a && ( a . setHighlighted ( ! 0 ) , this . highlightedItem _ = a , b = this . getElement ( ) , Blockly . utils . style . scrollIntoContainerView ( a . getElement ( ) , b ) , Blockly . utils . aria . setState ( b , Blockly . utils . aria . State . ACTIVEDESCENDANT , a . getId ( ) ) ) } ; Blockly . Menu . prototype . highlightNext = function ( ) { var a = this . menuItems _ . indexOf ( this . highlightedItem _ ) ; this . highlightHelper _ ( a , 1 ) } ;
Blockly . Menu . prototype . highlightPrevious = function ( ) { var a = this . menuItems _ . indexOf ( this . highlightedItem _ ) ; this . highlightHelper _ ( 0 > a ? this . menuItems _ . length : a , - 1 ) } ; Blockly . Menu . prototype . highlightFirst _ = function ( ) { this . highlightHelper _ ( - 1 , 1 ) } ; Blockly . Menu . prototype . highlightLast _ = function ( ) { this . highlightHelper _ ( this . menuItems _ . length , - 1 ) } ; Blockly . Menu . prototype . highlightHelper _ = function ( a , b ) { a += b ; for ( var c ; c = this . menuItems _ [ a ] ; ) { if ( c . isEnabled ( ) ) { this . setHighlighted ( c ) ; break } a += b } } ;
Blockly . Menu . prototype . handleMouseOver _ = function ( a ) { ( a = this . getMenuItem _ ( a . target ) ) && ( a . isEnabled ( ) ? this . highlightedItem _ != a && this . setHighlighted ( a ) : this . setHighlighted ( null ) ) } ; Blockly . Menu . prototype . handleClick _ = function ( a ) { var b = this . openingCoords ; this . openingCoords = null ; if ( b && "number" == typeof a . clientX ) { var c = new Blockly . utils . Coordinate ( a . clientX , a . clientY ) ; if ( 1 > Blockly . utils . Coordinate . distance ( b , c ) ) return } ( a = this . getMenuItem _ ( a . target ) ) && a . performAction ( ) } ;
Blockly . Menu . prototype . handleMouseEnter _ = function ( a ) { this . focus ( ) } ; Blockly . Menu . prototype . handleMouseLeave _ = function ( a ) { this . getElement ( ) && ( this . blur _ ( ) , this . setHighlighted ( null ) ) } ;
Blockly . Menu . prototype . handleKeyEvent _ = function ( a ) { if ( this . menuItems _ . length && ! ( a . shiftKey || a . ctrlKey || a . metaKey || a . altKey ) ) { var b = this . highlightedItem _ ; switch ( a . keyCode ) { case Blockly . utils . KeyCodes . ENTER : case Blockly . utils . KeyCodes . SPACE : b && b . performAction ( ) ; break ; case Blockly . utils . KeyCodes . UP : this . highlightPrevious ( ) ; break ; case Blockly . utils . KeyCodes . DOWN : this . highlightNext ( ) ; break ; case Blockly . utils . KeyCodes . PAGE _UP : case Blockly . utils . KeyCodes . HOME : this . highlightFirst _ ( ) ; break ; case Blockly . utils . KeyCodes . PAGE _DOWN : case Blockly . utils . KeyCodes . END : this . highlightLast _ ( ) ;
break ; default : return } a . preventDefault ( ) ; a . stopPropagation ( ) } } ; Blockly . Menu . prototype . getSize = function ( ) { var a = this . getElement ( ) , b = Blockly . utils . style . getSize ( a ) ; b . height = a . scrollHeight ; return b } ; Blockly . MenuItem = function ( a , b ) { this . content _ = a ; this . value _ = b ; this . enabled _ = ! 0 ; this . element _ = null ; this . rightToLeft _ = ! 1 ; this . roleName _ = null ; this . highlight _ = this . checked _ = this . checkable _ = ! 1 ; this . actionHandler _ = null } ;
Blockly . MenuItem . prototype . createDom = function ( ) { var a = document . createElement ( "div" ) ; a . id = Blockly . utils . IdGenerator . getNextUniqueId ( ) ; this . element _ = a ; a . className = "blocklyMenuItem goog-menuitem " + ( this . enabled _ ? "" : "blocklyMenuItemDisabled goog-menuitem-disabled " ) + ( this . checked _ ? "blocklyMenuItemSelected goog-option-selected " : "" ) + ( this . highlight _ ? "blocklyMenuItemHighlight goog-menuitem-highlight " : "" ) + ( this . rightToLeft _ ? "blocklyMenuItemRtl goog-menuitem-rtl " : "" ) ; var b = document . createElement ( "div" ) ;
b . className = "blocklyMenuItemContent goog-menuitem-content" ; if ( this . checkable _ ) { var c = document . createElement ( "div" ) ; c . className = "blocklyMenuItemCheckbox goog-menuitem-checkbox" ; b . appendChild ( c ) } c = this . content _ ; "string" == typeof this . content _ && ( c = document . createTextNode ( this . content _ ) ) ; b . appendChild ( c ) ; a . appendChild ( b ) ; this . roleName _ && Blockly . utils . aria . setRole ( a , this . roleName _ ) ; Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . SELECTED , this . checkable _ && this . checked _ || ! 1 ) ; Blockly . utils . aria . setState ( a ,
Blockly . utils . aria . State . DISABLED , ! this . enabled _ ) ; return a } ; Blockly . MenuItem . prototype . dispose = function ( ) { this . element _ = null } ; Blockly . MenuItem . prototype . getElement = function ( ) { return this . element _ } ; Blockly . MenuItem . prototype . getId = function ( ) { return this . element _ . id } ; Blockly . MenuItem . prototype . getValue = function ( ) { return this . value _ } ; Blockly . MenuItem . prototype . setRightToLeft = function ( a ) { this . rightToLeft _ = a } ; Blockly . MenuItem . prototype . setRole = function ( a ) { this . roleName _ = a } ;
Blockly . MenuItem . prototype . setCheckable = function ( a ) { this . checkable _ = a } ; Blockly . MenuItem . prototype . setChecked = function ( a ) { this . checked _ = a } ; Blockly . MenuItem . prototype . setHighlighted = function ( a ) { this . highlight _ = a ; var b = this . getElement ( ) ; b && this . isEnabled ( ) && ( a ? ( Blockly . utils . dom . addClass ( b , "blocklyMenuItemHighlight" ) , Blockly . utils . dom . addClass ( b , "goog-menuitem-highlight" ) ) : ( Blockly . utils . dom . removeClass ( b , "blocklyMenuItemHighlight" ) , Blockly . utils . dom . removeClass ( b , "goog-menuitem-highlight" ) ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . MenuItem . prototype . isEnabled = function ( ) { return this . enabled _ } ; Blockly . MenuItem . prototype . setEnabled = function ( a ) { this . enabled _ = a } ; Blockly . MenuItem . prototype . performAction = function ( ) { this . isEnabled ( ) && this . actionHandler _ && this . actionHandler _ ( this ) } ; Blockly . MenuItem . prototype . onAction = function ( a , b ) { this . actionHandler _ = a . bind ( b ) } ; Blockly . ContextMenu = { } ; Blockly . ContextMenu . currentBlock = null ; Blockly . ContextMenu . menu _ = null ; Blockly . ContextMenu . show = function ( a , b , c ) { Blockly . WidgetDiv . show ( Blockly . ContextMenu , c , Blockly . ContextMenu . dispose ) ; if ( b . length ) { var d = Blockly . ContextMenu . populate _ ( b , c ) ; Blockly . ContextMenu . menu _ = d ; Blockly . ContextMenu . position _ ( d , a , c ) ; setTimeout ( function ( ) { d . focus ( ) } , 1 ) ; Blockly . ContextMenu . currentBlock = null } else Blockly . ContextMenu . hide ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . ContextMenu . populate _ = function ( a , b ) { var c = new Blockly . Menu ; c . setRole ( Blockly . utils . aria . Role . MENU ) ; for ( var d = 0 , e ; e = a [ d ] ; d ++ ) { var f = new Blockly . MenuItem ( e . text ) ; f . setRightToLeft ( b ) ; f . setRole ( Blockly . utils . aria . Role . MENUITEM ) ; c . addChild ( f ) ; f . setEnabled ( e . enabled ) ; if ( e . enabled ) f . onAction ( function ( g ) { Blockly . ContextMenu . hide ( ) ; this . callback ( this . scope ) } , e ) } return c } ;
Blockly . ContextMenu . position _ = function ( a , b , c ) { var d = Blockly . utils . getViewportBBox ( ) ; b = new Blockly . utils . Rect ( b . clientY + d . top , b . clientY + d . top , b . clientX + d . left , b . clientX + d . left ) ; Blockly . ContextMenu . createWidget _ ( a ) ; var e = a . getSize ( ) ; c && ( b . left += e . width , b . right += e . width , d . left += e . width , d . right += e . width ) ; Blockly . WidgetDiv . positionWithAnchor ( d , b , e , c ) ; a . focus ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . ContextMenu . createWidget _ = function ( a ) { a . render ( Blockly . WidgetDiv . DIV ) ; var b = a . getElement ( ) ; Blockly . utils . dom . addClass ( b , "blocklyContextMenu" ) ; Blockly . browserEvents . conditionalBind ( b , "contextmenu" , null , Blockly . utils . noEvent ) ; a . focus ( ) } ; Blockly . ContextMenu . hide = function ( ) { Blockly . WidgetDiv . hideIfOwner ( Blockly . ContextMenu ) ; Blockly . ContextMenu . currentBlock = null } ; Blockly . ContextMenu . dispose = function ( ) { Blockly . ContextMenu . menu _ && ( Blockly . ContextMenu . menu _ . dispose ( ) , Blockly . ContextMenu . menu _ = null ) } ;
Blockly . ContextMenu . callbackFactory = function ( a , b ) { return function ( ) { Blockly . Events . disable ( ) ; try { var c = Blockly . Xml . domToBlock ( b , a . workspace ) , d = a . getRelativeToSurfaceXY ( ) ; d . x = a . RTL ? d . x - Blockly . SNAP _RADIUS : d . x + Blockly . SNAP _RADIUS ; d . y += 2 * Blockly . SNAP _RADIUS ; c . moveBy ( d . x , d . y ) } finally { Blockly . Events . enable ( ) } Blockly . Events . isEnabled ( ) && ! c . isShadow ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CREATE ) ) ( c ) ) ; c . select ( ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . ContextMenu . commentDeleteOption = function ( a ) { return { text : Blockly . Msg . REMOVE _COMMENT , enabled : ! 0 , callback : function ( ) { Blockly . Events . setGroup ( ! 0 ) ; a . dispose ( ! 0 , ! 0 ) ; Blockly . Events . setGroup ( ! 1 ) } } } ; Blockly . ContextMenu . commentDuplicateOption = function ( a ) { return { text : Blockly . Msg . DUPLICATE _COMMENT , enabled : ! 0 , callback : function ( ) { Blockly . duplicate ( a ) } } } ;
Blockly . ContextMenu . workspaceCommentOption = function ( a , b ) { if ( ! Blockly . WorkspaceCommentSvg ) throw Error ( "Missing require for Blockly.WorkspaceCommentSvg" ) ; var c = { enabled : ! Blockly . utils . userAgent . IE } ; c . text = Blockly . Msg . ADD _COMMENT ; c . callback = function ( ) { var d = new Blockly . WorkspaceCommentSvg ( a , Blockly . Msg . WORKSPACE _COMMENT _DEFAULT _TEXT , Blockly . WorkspaceCommentSvg . DEFAULT _SIZE , Blockly . WorkspaceCommentSvg . DEFAULT _SIZE ) , e = a . getInjectionDiv ( ) . getBoundingClientRect ( ) ; e = new Blockly . utils . Coordinate ( b . clientX -
2021-09-18 14:29:06 +00:00
e . left , b . clientY - e . top ) ; var f = a . getOriginOffsetInPixels ( ) ; e = Blockly . utils . Coordinate . difference ( e , f ) ; e . scale ( 1 / a . scale ) ; d . moveBy ( e . x , e . y ) ; a . rendered && ( d . initSvg ( ) , d . render ( ) , d . select ( ) ) } ; return c } ; Blockly . ContextMenuRegistry = function ( ) { Blockly . ContextMenuRegistry . registry = this ; this . registry _ = Object . create ( null ) } ; Blockly . ContextMenuRegistry . ScopeType = { BLOCK : "block" , WORKSPACE : "workspace" } ; Blockly . ContextMenuRegistry . registry = null ; Blockly . ContextMenuRegistry . prototype . register = function ( a ) { if ( this . registry _ [ a . id ] ) throw Error ( 'Menu item with ID "' + a . id + '" is already registered.' ) ; this . registry _ [ a . id ] = a } ;
Blockly . ContextMenuRegistry . prototype . unregister = function ( a ) { if ( ! this . registry _ [ a ] ) throw Error ( 'Menu item with ID "' + a + '" not found.' ) ; delete this . registry _ [ a ] } ; Blockly . ContextMenuRegistry . prototype . getItem = function ( a ) { return this . registry _ [ a ] || null } ;
2021-01-16 14:07:51 +00:00
Blockly . ContextMenuRegistry . prototype . getContextMenuOptions = function ( a , b ) { var c = [ ] , d = this . registry _ ; Object . keys ( d ) . forEach ( function ( e ) { e = d [ e ] ; if ( a == e . scopeType ) { var f = e . preconditionFn ( b ) ; "hidden" != f && ( e = { text : "function" == typeof e . displayText ? e . displayText ( b ) : e . displayText , enabled : "enabled" == f , callback : e . callback , scope : b , weight : e . weight } , c . push ( e ) ) } } ) ; c . sort ( function ( e , f ) { return e . weight - f . weight } ) ; return c } ; new Blockly . ContextMenuRegistry ; Blockly . Events . Selected = function ( a , b , c ) { Blockly . Events . Selected . superClass _ . constructor . call ( this , c ) ; this . oldElementId = a ; this . newElementId = b } ; Blockly . utils . object . inherits ( Blockly . Events . Selected , Blockly . Events . UiBase ) ; Blockly . Events . Selected . prototype . type = Blockly . Events . SELECTED ; Blockly . Events . Selected . prototype . toJson = function ( ) { var a = Blockly . Events . Selected . superClass _ . toJson . call ( this ) ; a . oldElementId = this . oldElementId ; a . newElementId = this . newElementId ; return a } ;
2021-09-18 14:29:06 +00:00
Blockly . Events . Selected . prototype . fromJson = function ( a ) { Blockly . Events . Selected . superClass _ . fromJson . call ( this , a ) ; this . oldElementId = a . oldElementId ; this . newElementId = a . newElementId } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . SELECTED , Blockly . Events . Selected ) ; Blockly . IBoundedElement = function ( ) { } ; Blockly . ICopyable = function ( ) { } ; Blockly . RenderedConnection = function ( a , b ) { Blockly . RenderedConnection . superClass _ . constructor . call ( this , a , b ) ; this . db _ = a . workspace . connectionDBList [ b ] ; this . dbOpposite _ = a . workspace . connectionDBList [ Blockly . OPPOSITE _TYPE [ b ] ] ; this . offsetInBlock _ = new Blockly . utils . Coordinate ( 0 , 0 ) ; this . trackedState _ = Blockly . RenderedConnection . TrackedState . WILL _TRACK ; this . targetConnection = null } ; Blockly . utils . object . inherits ( Blockly . RenderedConnection , Blockly . Connection ) ;
2021-01-16 14:07:51 +00:00
Blockly . RenderedConnection . TrackedState = { WILL _TRACK : - 1 , UNTRACKED : 0 , TRACKED : 1 } ; Blockly . RenderedConnection . prototype . dispose = function ( ) { Blockly . RenderedConnection . superClass _ . dispose . call ( this ) ; this . trackedState _ == Blockly . RenderedConnection . TrackedState . TRACKED && this . db _ . removeConnection ( this , this . y ) } ; Blockly . RenderedConnection . prototype . getSourceBlock = function ( ) { return Blockly . RenderedConnection . superClass _ . getSourceBlock . call ( this ) } ; Blockly . RenderedConnection . prototype . targetBlock = function ( ) { return Blockly . RenderedConnection . superClass _ . targetBlock . call ( this ) } ;
Blockly . RenderedConnection . prototype . distanceFrom = function ( a ) { var b = this . x - a . x ; a = this . y - a . y ; return Math . sqrt ( b * b + a * a ) } ;
Blockly . RenderedConnection . prototype . bumpAwayFrom = function ( a ) { if ( ! this . sourceBlock _ . workspace . isDragging ( ) ) { var b = this . sourceBlock _ . getRootBlock ( ) ; if ( ! b . isInFlyout ) { var c = ! 1 ; if ( ! b . isMovable ( ) ) { b = a . getSourceBlock ( ) . getRootBlock ( ) ; if ( ! b . isMovable ( ) ) return ; a = this ; c = ! 0 } var d = Blockly . selected == b ; d || b . addSelect ( ) ; var e = a . x + Blockly . SNAP _RADIUS + Math . floor ( Math . random ( ) * Blockly . BUMP _RANDOMNESS ) - this . x , f = a . y + Blockly . SNAP _RADIUS + Math . floor ( Math . random ( ) * Blockly . BUMP _RANDOMNESS ) - this . y ; c && ( f = - f ) ; b . RTL && ( e = a . x -
Blockly . SNAP _RADIUS - Math . floor ( Math . random ( ) * Blockly . BUMP _RANDOMNESS ) - this . x ) ; b . moveBy ( e , f ) ; d || b . removeSelect ( ) } } } ;
Blockly . RenderedConnection . prototype . moveTo = function ( a , b ) { this . trackedState _ == Blockly . RenderedConnection . TrackedState . WILL _TRACK ? ( this . db _ . addConnection ( this , b ) , this . trackedState _ = Blockly . RenderedConnection . TrackedState . TRACKED ) : this . trackedState _ == Blockly . RenderedConnection . TrackedState . TRACKED && ( this . db _ . removeConnection ( this , this . y ) , this . db _ . addConnection ( this , b ) ) ; this . x = a ; this . y = b } ; Blockly . RenderedConnection . prototype . moveBy = function ( a , b ) { this . moveTo ( this . x + a , this . y + b ) } ;
Blockly . RenderedConnection . prototype . moveToOffset = function ( a ) { this . moveTo ( a . x + this . offsetInBlock _ . x , a . y + this . offsetInBlock _ . y ) } ; Blockly . RenderedConnection . prototype . setOffsetInBlock = function ( a , b ) { this . offsetInBlock _ . x = a ; this . offsetInBlock _ . y = b } ; Blockly . RenderedConnection . prototype . getOffsetInBlock = function ( ) { return this . offsetInBlock _ } ;
Blockly . RenderedConnection . prototype . tighten = function ( ) { var a = this . targetConnection . x - this . x , b = this . targetConnection . y - this . y ; if ( 0 != a || 0 != b ) { var c = this . targetBlock ( ) , d = c . getSvgRoot ( ) ; if ( ! d ) throw Error ( "block is not rendered." ) ; d = Blockly . utils . getRelativeXY ( d ) ; c . getSvgRoot ( ) . setAttribute ( "transform" , "translate(" + ( d . x - a ) + "," + ( d . y - b ) + ")" ) ; c . moveConnections ( - a , - b ) } } ; Blockly . RenderedConnection . prototype . closest = function ( a , b ) { return this . dbOpposite _ . searchForClosest ( this , a , b ) } ;
2021-05-19 13:38:55 +00:00
Blockly . RenderedConnection . prototype . highlight = function ( ) { var a = this . sourceBlock _ . workspace . getRenderer ( ) . getConstants ( ) ; var b = a . shapeFor ( this ) ; this . type == Blockly . connectionTypes . INPUT _VALUE || this . type == Blockly . connectionTypes . OUTPUT _VALUE ? ( a = a . TAB _OFFSET _FROM _TOP , b = Blockly . utils . svgPaths . moveBy ( 0 , - a ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , a ) + b . pathDown + Blockly . utils . svgPaths . lineOnAxis ( "v" , a ) ) : ( a = a . NOTCH _OFFSET _LEFT - a . CORNER _RADIUS , b = Blockly . utils . svgPaths . moveBy ( - a , 0 ) + Blockly . utils . svgPaths . lineOnAxis ( "h" ,
a ) + b . pathLeft + Blockly . utils . svgPaths . lineOnAxis ( "h" , a ) ) ; a = this . sourceBlock _ . getRelativeToSurfaceXY ( ) ; Blockly . Connection . highlightedPath _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyHighlightedConnectionPath" , d : b , transform : "translate(" + ( this . x - a . x ) + "," + ( this . y - a . y ) + ")" + ( this . sourceBlock _ . RTL ? " scale(-1 1)" : "" ) } , this . sourceBlock _ . getSvgRoot ( ) ) } ;
Blockly . RenderedConnection . prototype . unhighlight = function ( ) { Blockly . utils . dom . removeNode ( Blockly . Connection . highlightedPath _ ) ; delete Blockly . Connection . highlightedPath _ } ;
2021-01-16 14:07:51 +00:00
Blockly . RenderedConnection . prototype . setTracking = function ( a ) { a && this . trackedState _ == Blockly . RenderedConnection . TrackedState . TRACKED || ! a && this . trackedState _ == Blockly . RenderedConnection . TrackedState . UNTRACKED || this . sourceBlock _ . isInFlyout || ( a ? ( this . db _ . addConnection ( this , this . y ) , this . trackedState _ = Blockly . RenderedConnection . TrackedState . TRACKED ) : ( this . trackedState _ == Blockly . RenderedConnection . TrackedState . TRACKED && this . db _ . removeConnection ( this , this . y ) , this . trackedState _ = Blockly . RenderedConnection . TrackedState . UNTRACKED ) ) } ;
Blockly . RenderedConnection . prototype . stopTrackingAll = function ( ) { this . setTracking ( ! 1 ) ; if ( this . targetConnection ) for ( var a = this . targetBlock ( ) . getDescendants ( ! 1 ) , b = 0 ; b < a . length ; b ++ ) { for ( var c = a [ b ] , d = c . getConnections _ ( ! 0 ) , e = 0 ; e < d . length ; e ++ ) d [ e ] . setTracking ( ! 1 ) ; c = c . getIcons ( ) ; for ( e = 0 ; e < c . length ; e ++ ) c [ e ] . setVisible ( ! 1 ) } } ;
2021-05-19 13:38:55 +00:00
Blockly . RenderedConnection . prototype . startTrackingAll = function ( ) { this . setTracking ( ! 0 ) ; var a = [ ] ; if ( this . type != Blockly . connectionTypes . INPUT _VALUE && this . type != Blockly . connectionTypes . NEXT _STATEMENT ) return a ; var b = this . targetBlock ( ) ; if ( b ) { if ( b . isCollapsed ( ) ) { var c = [ ] ; b . outputConnection && c . push ( b . outputConnection ) ; b . nextConnection && c . push ( b . nextConnection ) ; b . previousConnection && c . push ( b . previousConnection ) } else c = b . getConnections _ ( ! 0 ) ; for ( var d = 0 ; d < c . length ; d ++ ) a . push . apply ( a , c [ d ] . startTrackingAll ( ) ) ;
2021-09-18 14:29:06 +00:00
a . length || ( a [ 0 ] = b ) } return a } ; Blockly . RenderedConnection . prototype . isConnectionAllowed = function ( a , b ) { Blockly . utils . deprecation . warn ( "RenderedConnection.prototype.isConnectionAllowed" , "July 2020" , "July 2021" , "Blockly.Workspace.prototype.getConnectionChecker().canConnect" ) ; return this . distanceFrom ( a ) > b ? ! 1 : Blockly . RenderedConnection . superClass _ . isConnectionAllowed . call ( this , a ) } ;
Blockly . RenderedConnection . prototype . onFailedConnect = function ( a ) { var b = this . getSourceBlock ( ) ; if ( Blockly . Events . recordUndo ) { var c = Blockly . Events . getGroup ( ) ; setTimeout ( function ( ) { b . isDisposed ( ) || b . getParent ( ) || ( Blockly . Events . setGroup ( c ) , this . bumpAwayFrom ( a ) , Blockly . Events . setGroup ( ! 1 ) ) } . bind ( this ) , Blockly . BUMP _DELAY ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . RenderedConnection . prototype . disconnectInternal _ = function ( a , b ) { Blockly . RenderedConnection . superClass _ . disconnectInternal _ . call ( this , a , b ) ; a . rendered && a . render ( ) ; b . rendered && ( b . updateDisabled ( ) , b . render ( ) , b . getSvgRoot ( ) . style . display = "block" ) } ; Blockly . RenderedConnection . prototype . respawnShadow _ = function ( ) { Blockly . RenderedConnection . superClass _ . respawnShadow _ . call ( this ) ; var a = this . targetBlock ( ) ; a && ( a . initSvg ( ) , a . render ( ! 1 ) , a = this . getSourceBlock ( ) , a . rendered && a . render ( ) ) } ;
Blockly . RenderedConnection . prototype . neighbours = function ( a ) { return this . dbOpposite _ . getNeighbours ( this , a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . RenderedConnection . prototype . connect _ = function ( a ) { Blockly . RenderedConnection . superClass _ . connect _ . call ( this , a ) ; var b = this . getSourceBlock ( ) ; a = a . getSourceBlock ( ) ; var c = b . rendered , d = a . rendered ; c && b . updateDisabled ( ) ; d && a . updateDisabled ( ) ; c && d && ( this . type == Blockly . connectionTypes . NEXT _STATEMENT || this . type == Blockly . connectionTypes . PREVIOUS _STATEMENT ? a . render ( ) : b . render ( ) ) ; if ( b = b . getInputWithBlock ( a ) ) b = b . isVisible ( ) , a . getSvgRoot ( ) . style . display = b ? "block" : "none" } ;
2021-09-18 14:29:06 +00:00
Blockly . RenderedConnection . prototype . onCheckChanged _ = function ( ) { ! this . isConnected ( ) || this . targetConnection && this . getConnectionChecker ( ) . canConnect ( this , this . targetConnection , ! 1 ) || ( ( this . isSuperior ( ) ? this . targetBlock ( ) : this . sourceBlock _ ) . unplug ( ) , this . sourceBlock _ . bumpNeighbours ( ) ) } ; Blockly . BasicCursor = function ( ) { Blockly . BasicCursor . superClass _ . constructor . call ( this ) } ; Blockly . utils . object . inherits ( Blockly . BasicCursor , Blockly . Cursor ) ; Blockly . BasicCursor . registrationName = "basicCursor" ; Blockly . BasicCursor . prototype . next = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; ( a = this . getNextNode _ ( a , this . validNode _ ) ) && this . setCurNode ( a ) ; return a } ; Blockly . BasicCursor . prototype . in = function ( ) { return this . next ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BasicCursor . prototype . prev = function ( ) { var a = this . getCurNode ( ) ; if ( ! a ) return null ; ( a = this . getPreviousNode _ ( a , this . validNode _ ) ) && this . setCurNode ( a ) ; return a } ; Blockly . BasicCursor . prototype . out = function ( ) { return this . prev ( ) } ; Blockly . BasicCursor . prototype . getNextNode _ = function ( a , b ) { if ( ! a ) return null ; var c = a . in ( ) || a . next ( ) ; if ( b ( c ) ) return c ; if ( c ) return this . getNextNode _ ( c , b ) ; a = this . findSiblingOrParent _ ( a . out ( ) ) ; return b ( a ) ? a : a ? this . getNextNode _ ( a , b ) : null } ;
Blockly . BasicCursor . prototype . getPreviousNode _ = function ( a , b ) { if ( ! a ) return null ; var c = a . prev ( ) ; c = c ? this . getRightMostChild _ ( c ) : a . out ( ) ; return b ( c ) ? c : c ? this . getPreviousNode _ ( c , b ) : null } ; Blockly . BasicCursor . prototype . validNode _ = function ( a ) { var b = ! 1 ; a = a && a . getType ( ) ; if ( a == Blockly . ASTNode . types . OUTPUT || a == Blockly . ASTNode . types . INPUT || a == Blockly . ASTNode . types . FIELD || a == Blockly . ASTNode . types . NEXT || a == Blockly . ASTNode . types . PREVIOUS || a == Blockly . ASTNode . types . WORKSPACE ) b = ! 0 ; return b } ;
2021-05-19 13:38:55 +00:00
Blockly . BasicCursor . prototype . findSiblingOrParent _ = function ( a ) { if ( ! a ) return null ; var b = a . next ( ) ; return b ? b : this . findSiblingOrParent _ ( a . out ( ) ) } ; Blockly . BasicCursor . prototype . getRightMostChild _ = function ( a ) { if ( ! a . in ( ) ) return a ; for ( a = a . in ( ) ; a . next ( ) ; ) a = a . next ( ) ; return this . getRightMostChild _ ( a ) } ; Blockly . registry . register ( Blockly . registry . Type . CURSOR , Blockly . BasicCursor . registrationName , Blockly . BasicCursor ) ; Blockly . TabNavigateCursor = function ( ) { Blockly . TabNavigateCursor . superClass _ . constructor . call ( this ) } ; Blockly . utils . object . inherits ( Blockly . TabNavigateCursor , Blockly . BasicCursor ) ; Blockly . TabNavigateCursor . prototype . validNode _ = function ( a ) { var b = ! 1 , c = a && a . getType ( ) ; a && ( a = a . getLocation ( ) , c == Blockly . ASTNode . types . FIELD && a && a . isTabNavigable ( ) && a . isClickable ( ) && ( b = ! 0 ) ) ; return b } ; Blockly . BlockSvg = function ( a , b , c ) { this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , null ) ; this . svgGroup _ . translate _ = "" ; this . style = a . getRenderer ( ) . getConstants ( ) . getBlockStyle ( null ) ; this . pathObject = a . getRenderer ( ) . makePathObject ( this . svgGroup _ , this . style ) ; this . renderIsInProgress _ = this . rendered = ! 1 ; this . workspace = a ; this . previousConnection = this . nextConnection = this . outputConnection = null ; this . useDragSurface _ = Blockly . utils . is3dSupported ( ) && ! ! a . getBlockDragSurface ( ) ; var d = this . pathObject . svgPath ;
2021-01-16 14:07:51 +00:00
d . tooltip = this ; Blockly . Tooltip . bindMouseEvents ( d ) ; Blockly . BlockSvg . superClass _ . constructor . call ( this , a , b , c ) ; this . svgGroup _ . dataset ? this . svgGroup _ . dataset . id = this . id : Blockly . utils . userAgent . IE && this . svgGroup _ . setAttribute ( "data-id" , this . id ) } ; Blockly . utils . object . inherits ( Blockly . BlockSvg , Blockly . Block ) ; Blockly . BlockSvg . prototype . height = 0 ; Blockly . BlockSvg . prototype . width = 0 ; Blockly . BlockSvg . prototype . warningTextDb _ = null ; Blockly . BlockSvg . INLINE = - 1 ; Blockly . BlockSvg . COLLAPSED _WARNING _ID = "TEMP_COLLAPSED_WARNING_" ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . initSvg = function ( ) { if ( ! this . workspace . rendered ) throw TypeError ( "Workspace is headless." ) ; for ( var a = 0 , b ; b = this . inputList [ a ] ; a ++ ) b . init ( ) ; b = this . getIcons ( ) ; for ( a = 0 ; a < b . length ; a ++ ) b [ a ] . createIcon ( ) ; this . applyColour ( ) ; this . pathObject . updateMovable ( this . isMovable ( ) ) ; a = this . getSvgRoot ( ) ; this . workspace . options . readOnly || this . eventsInit _ || ! a || Blockly . browserEvents . conditionalBind ( a , "mousedown" , this , this . onMouseDown _ ) ; this . eventsInit _ = ! 0 ; a . parentNode || this . workspace . getCanvas ( ) . appendChild ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . getColourSecondary = function ( ) { return this . style . colourSecondary } ; Blockly . BlockSvg . prototype . getColourTertiary = function ( ) { return this . style . colourTertiary } ; Blockly . BlockSvg . prototype . getColourShadow = function ( ) { Blockly . utils . deprecation . warn ( "BlockSvg.prototype.getColourShadow" , "January 2020" , "January 2021" , "style.colourSecondary" ) ; return this . getColourSecondary ( ) } ;
Blockly . BlockSvg . prototype . getColourBorder = function ( ) { Blockly . utils . deprecation . warn ( "BlockSvg.prototype.getColourBorder" , "January 2020" , "January 2021" , "style.colourTertiary" ) ; return { colourBorder : this . getColourTertiary ( ) , colourLight : null , colourDark : null } } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . select = function ( ) { if ( this . isShadow ( ) && this . getParent ( ) ) this . getParent ( ) . select ( ) ; else if ( Blockly . selected != this ) { var a = null ; if ( Blockly . selected ) { a = Blockly . selected . id ; Blockly . Events . disable ( ) ; try { Blockly . selected . unselect ( ) } finally { Blockly . Events . enable ( ) } } a = new ( Blockly . Events . get ( Blockly . Events . SELECTED ) ) ( a , this . id , this . workspace . id ) ; Blockly . Events . fire ( a ) ; Blockly . selected = this ; this . addSelect ( ) } } ;
Blockly . BlockSvg . prototype . unselect = function ( ) { if ( Blockly . selected == this ) { var a = new ( Blockly . Events . get ( Blockly . Events . SELECTED ) ) ( this . id , null , this . workspace . id ) ; a . workspaceId = this . workspace . id ; Blockly . Events . fire ( a ) ; Blockly . selected = null ; this . removeSelect ( ) } } ; Blockly . BlockSvg . prototype . mutator = null ; Blockly . BlockSvg . prototype . comment = null ; Blockly . BlockSvg . prototype . commentIcon _ = null ; Blockly . BlockSvg . prototype . warning = null ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . getIcons = function ( ) { var a = [ ] ; this . mutator && a . push ( this . mutator ) ; this . commentIcon _ && a . push ( this . commentIcon _ ) ; this . warning && a . push ( this . warning ) ; return a } ;
Blockly . BlockSvg . prototype . setParent = function ( a ) { var b = this . parentBlock _ ; if ( a != b ) { Blockly . utils . dom . startTextWidthCache ( ) ; Blockly . BlockSvg . superClass _ . setParent . call ( this , a ) ; Blockly . utils . dom . stopTextWidthCache ( ) ; var c = this . getSvgRoot ( ) ; if ( ! this . workspace . isClearing && c ) { var d = this . getRelativeToSurfaceXY ( ) ; a ? ( a . getSvgRoot ( ) . appendChild ( c ) , a = this . getRelativeToSurfaceXY ( ) , this . moveConnections ( a . x - d . x , a . y - d . y ) ) : b && ( this . workspace . getCanvas ( ) . appendChild ( c ) , this . translate ( d . x , d . y ) ) ; this . applyColour ( ) } } } ;
Blockly . BlockSvg . prototype . getRelativeToSurfaceXY = function ( ) { var a = 0 , b = 0 , c = this . useDragSurface _ ? this . workspace . getBlockDragSurface ( ) . getGroup ( ) : null , d = this . getSvgRoot ( ) ; if ( d ) { do { var e = Blockly . utils . getRelativeXY ( d ) ; a += e . x ; b += e . y ; this . useDragSurface _ && this . workspace . getBlockDragSurface ( ) . getCurrentBlock ( ) == d && ( e = this . workspace . getBlockDragSurface ( ) . getSurfaceTranslation ( ) , a += e . x , b += e . y ) ; d = d . parentNode } while ( d && d != this . workspace . getCanvas ( ) && d != c ) } return new Blockly . utils . Coordinate ( a , b ) } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . moveBy = function ( a , b ) { if ( this . parentBlock _ ) throw Error ( "Block has parent." ) ; var c = Blockly . Events . isEnabled ( ) ; if ( c ) var d = new ( Blockly . Events . get ( Blockly . Events . BLOCK _MOVE ) ) ( this ) ; var e = this . getRelativeToSurfaceXY ( ) ; this . translate ( e . x + a , e . y + b ) ; this . moveConnections ( a , b ) ; c && ( d . recordNew ( ) , Blockly . Events . fire ( d ) ) ; this . workspace . resizeContents ( ) } ; Blockly . BlockSvg . prototype . translate = function ( a , b ) { this . getSvgRoot ( ) . setAttribute ( "transform" , "translate(" + a + "," + b + ")" ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . moveToDragSurface = function ( ) { if ( this . useDragSurface _ ) { var a = this . getRelativeToSurfaceXY ( ) ; this . clearTransformAttributes _ ( ) ; this . workspace . getBlockDragSurface ( ) . translateSurface ( a . x , a . y ) ; ( a = this . getSvgRoot ( ) ) && this . workspace . getBlockDragSurface ( ) . setBlocksAndShow ( a ) } } ; Blockly . BlockSvg . prototype . moveTo = function ( a ) { var b = this . getRelativeToSurfaceXY ( ) ; this . moveBy ( a . x - b . x , a . y - b . y ) } ;
Blockly . BlockSvg . prototype . moveOffDragSurface = function ( a ) { this . useDragSurface _ && ( this . translate ( a . x , a . y ) , this . workspace . getBlockDragSurface ( ) . clearAndHide ( this . workspace . getCanvas ( ) ) ) } ; Blockly . BlockSvg . prototype . moveDuringDrag = function ( a ) { this . useDragSurface _ ? this . workspace . getBlockDragSurface ( ) . translateSurface ( a . x , a . y ) : ( this . svgGroup _ . translate _ = "translate(" + a . x + "," + a . y + ")" , this . svgGroup _ . setAttribute ( "transform" , this . svgGroup _ . translate _ + this . svgGroup _ . skew _ ) ) } ;
Blockly . BlockSvg . prototype . clearTransformAttributes _ = function ( ) { this . getSvgRoot ( ) . removeAttribute ( "transform" ) } ; Blockly . BlockSvg . prototype . snapToGrid = function ( ) { if ( this . workspace && ! this . workspace . isDragging ( ) && ! this . getParent ( ) && ! this . isInFlyout ) { var a = this . workspace . getGrid ( ) ; if ( a && a . shouldSnap ( ) ) { var b = a . getSpacing ( ) , c = b / 2 , d = this . getRelativeToSurfaceXY ( ) ; a = Math . round ( ( d . x - c ) / b ) * b + c - d . x ; b = Math . round ( ( d . y - c ) / b ) * b + c - d . y ; a = Math . round ( a ) ; b = Math . round ( b ) ; 0 == a && 0 == b || this . moveBy ( a , b ) } } } ;
Blockly . BlockSvg . prototype . getBoundingRectangle = function ( ) { var a = this . getRelativeToSurfaceXY ( ) , b = this . getHeightWidth ( ) ; if ( this . RTL ) { var c = a . x - b . width ; var d = a . x } else c = a . x , d = a . x + b . width ; return new Blockly . utils . Rect ( a . y , a . y + b . height , c , d ) } ; Blockly . BlockSvg . prototype . markDirty = function ( ) { this . pathObject . constants = this . workspace . getRenderer ( ) . getConstants ( ) ; for ( var a = 0 , b ; b = this . inputList [ a ] ; a ++ ) b . markDirty ( ) } ;
Blockly . BlockSvg . prototype . setCollapsed = function ( a ) { this . collapsed _ != a && ( Blockly . BlockSvg . superClass _ . setCollapsed . call ( this , a ) , a ? this . rendered && this . render ( ) : this . updateCollapsed _ ( ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . updateCollapsed _ = function ( ) { for ( var a = this . isCollapsed ( ) , b = Blockly . constants . COLLAPSED _INPUT _NAME , c = Blockly . constants . COLLAPSED _FIELD _NAME , d = 0 , e ; e = this . inputList [ d ] ; d ++ ) e . name != b && e . setVisible ( ! a ) ; if ( a ) { e = this . getIcons ( ) ; for ( d = 0 ; a = e [ d ] ; d ++ ) a . setVisible ( ! 1 ) ; d = this . toString ( Blockly . COLLAPSE _CHARS ) ; ( e = this . getField ( c ) ) ? e . setValue ( d ) : ( e = this . getInput ( b ) || this . appendDummyInput ( b ) , e . appendField ( new Blockly . FieldLabel ( d ) , c ) ) } else this . updateDisabled ( ) , this . removeInput ( b ) } ;
Blockly . BlockSvg . prototype . tab = function ( a , b ) { var c = new Blockly . TabNavigateCursor ; c . setCurNode ( Blockly . ASTNode . createFieldNode ( a ) ) ; a = c . getCurNode ( ) ; b ? c . next ( ) : c . prev ( ) ; ( b = c . getCurNode ( ) ) && b !== a && ( b . getLocation ( ) . showEditor ( ) , this . workspace . keyboardAccessibilityMode && this . workspace . getCursor ( ) . setCurNode ( b ) ) } ; Blockly . BlockSvg . prototype . onMouseDown _ = function ( a ) { var b = this . workspace && this . workspace . getGesture ( a ) ; b && b . handleBlockStart ( a , this ) } ;
Blockly . BlockSvg . prototype . showHelp = function ( ) { var a = "function" == typeof this . helpUrl ? this . helpUrl ( ) : this . helpUrl ; a && window . open ( a ) } ; Blockly . BlockSvg . prototype . generateContextMenu = function ( ) { if ( this . workspace . options . readOnly || ! this . contextMenu ) return null ; var a = Blockly . ContextMenuRegistry . registry . getContextMenuOptions ( Blockly . ContextMenuRegistry . ScopeType . BLOCK , { block : this } ) ; this . customContextMenu && this . customContextMenu ( a ) ; return a } ;
Blockly . BlockSvg . prototype . showContextMenu = function ( a ) { var b = this . generateContextMenu ( ) ; b && b . length && ( Blockly . ContextMenu . show ( a , b , this . RTL ) , Blockly . ContextMenu . currentBlock = this ) } ; Blockly . BlockSvg . prototype . moveConnections = function ( a , b ) { if ( this . rendered ) { for ( var c = this . getConnections _ ( ! 1 ) , d = 0 ; d < c . length ; d ++ ) c [ d ] . moveBy ( a , b ) ; c = this . getIcons ( ) ; for ( d = 0 ; d < c . length ; d ++ ) c [ d ] . computeIconLocation ( ) ; for ( d = 0 ; d < this . childBlocks _ . length ; d ++ ) this . childBlocks _ [ d ] . moveConnections ( a , b ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . setDragging = function ( a ) { if ( a ) { var b = this . getSvgRoot ( ) ; b . translate _ = "" ; b . skew _ = "" ; Blockly . draggingConnections = Blockly . draggingConnections . concat ( this . getConnections _ ( ! 0 ) ) ; Blockly . utils . dom . addClass ( this . svgGroup _ , "blocklyDragging" ) } else Blockly . draggingConnections = [ ] , Blockly . utils . dom . removeClass ( this . svgGroup _ , "blocklyDragging" ) ; for ( b = 0 ; b < this . childBlocks _ . length ; b ++ ) this . childBlocks _ [ b ] . setDragging ( a ) } ;
Blockly . BlockSvg . prototype . setMovable = function ( a ) { Blockly . BlockSvg . superClass _ . setMovable . call ( this , a ) ; this . pathObject . updateMovable ( a ) } ; Blockly . BlockSvg . prototype . setEditable = function ( a ) { Blockly . BlockSvg . superClass _ . setEditable . call ( this , a ) ; a = this . getIcons ( ) ; for ( var b = 0 ; b < a . length ; b ++ ) a [ b ] . updateEditable ( ) } ; Blockly . BlockSvg . prototype . setShadow = function ( a ) { Blockly . BlockSvg . superClass _ . setShadow . call ( this , a ) ; this . applyColour ( ) } ;
Blockly . BlockSvg . prototype . setInsertionMarker = function ( a ) { this . isInsertionMarker _ != a && ( this . isInsertionMarker _ = a ) && ( this . setColour ( this . workspace . getRenderer ( ) . getConstants ( ) . INSERTION _MARKER _COLOUR ) , this . pathObject . updateInsertionMarker ( ! 0 ) ) } ; Blockly . BlockSvg . prototype . getSvgRoot = function ( ) { return this . svgGroup _ } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . dispose = function ( a , b ) { if ( this . workspace ) { Blockly . Tooltip . dispose ( ) ; Blockly . Tooltip . unbindMouseEvents ( this . pathObject . svgPath ) ; Blockly . utils . dom . startTextWidthCache ( ) ; var c = this . workspace ; Blockly . selected == this && ( this . unselect ( ) , this . workspace . cancelCurrentGesture ( ) ) ; Blockly . ContextMenu . currentBlock == this && Blockly . ContextMenu . hide ( ) ; b && this . rendered && ( this . unplug ( a ) , Blockly . blockAnimations . disposeUiEffect ( this ) ) ; this . rendered = ! 1 ; if ( this . warningTextDb _ ) { for ( var d in this . warningTextDb _ ) clearTimeout ( this . warningTextDb _ [ d ] ) ;
this . warningTextDb _ = null } b = this . getIcons ( ) ; for ( d = 0 ; d < b . length ; d ++ ) b [ d ] . dispose ( ) ; Blockly . BlockSvg . superClass _ . dispose . call ( this , ! ! a ) ; Blockly . utils . dom . removeNode ( this . svgGroup _ ) ; c . resizeContents ( ) ; this . svgGroup _ = null ; Blockly . utils . dom . stopTextWidthCache ( ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . toCopyData = function ( ) { if ( this . isInsertionMarker _ ) return null ; var a = Blockly . Xml . blockToDom ( this , ! 0 ) ; Blockly . Xml . deleteNext ( a ) ; var b = this . getRelativeToSurfaceXY ( ) ; a . setAttribute ( "x" , this . RTL ? - b . x : b . x ) ; a . setAttribute ( "y" , b . y ) ; return { xml : a , source : this . workspace , typeCounts : Blockly . utils . getBlockTypeCounts ( this , ! 0 ) } } ;
Blockly . BlockSvg . prototype . applyColour = function ( ) { this . pathObject . applyColour ( this ) ; for ( var a = this . getIcons ( ) , b = 0 ; b < a . length ; b ++ ) a [ b ] . applyColour ( ) ; for ( a = 0 ; b = this . inputList [ a ] ; a ++ ) for ( var c = 0 , d ; d = b . fieldRow [ c ] ; c ++ ) d . applyColour ( ) } ; Blockly . BlockSvg . prototype . updateDisabled = function ( ) { var a = this . getChildren ( ! 1 ) ; this . applyColour ( ) ; if ( ! this . isCollapsed ( ) ) for ( var b = 0 , c ; c = a [ b ] ; b ++ ) c . rendered && c . updateDisabled ( ) } ; Blockly . BlockSvg . prototype . getCommentIcon = function ( ) { return this . commentIcon _ } ;
Blockly . BlockSvg . prototype . setCommentText = function ( a ) { if ( ! Blockly . Comment ) throw Error ( "Missing require for Blockly.Comment" ) ; this . commentModel . text != a && ( Blockly . BlockSvg . superClass _ . setCommentText . call ( this , a ) , a = null != a , ! ! this . commentIcon _ == a ? this . commentIcon _ . updateText ( ) : ( a ? this . comment = this . commentIcon _ = new Blockly . Comment ( this ) : ( this . commentIcon _ . dispose ( ) , this . comment = this . commentIcon _ = null ) , this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) ) ) } ;
Blockly . BlockSvg . prototype . setWarningText = function ( a , b ) { if ( ! Blockly . Warning ) throw Error ( "Missing require for Blockly.Warning" ) ; this . warningTextDb _ || ( this . warningTextDb _ = Object . create ( null ) ) ; var c = b || "" ; if ( c ) this . warningTextDb _ [ c ] && ( clearTimeout ( this . warningTextDb _ [ c ] ) , delete this . warningTextDb _ [ c ] ) ; else for ( var d in this . warningTextDb _ ) clearTimeout ( this . warningTextDb _ [ d ] ) , delete this . warningTextDb _ [ d ] ; if ( this . workspace . isDragging ( ) ) { var e = this ; this . warningTextDb _ [ c ] = setTimeout ( function ( ) { e . workspace &&
( delete e . warningTextDb _ [ c ] , e . setWarningText ( a , c ) ) } , 100 ) } else { this . isInFlyout && ( a = null ) ; b = ! 1 ; if ( "string" == typeof a ) { d = this . getSurroundParent ( ) ; for ( var f = null ; d ; ) d . isCollapsed ( ) && ( f = d ) , d = d . getSurroundParent ( ) ; f && f . setWarningText ( Blockly . Msg . COLLAPSED _WARNINGS _WARNING , Blockly . BlockSvg . COLLAPSED _WARNING _ID ) ; this . warning || ( this . warning = new Blockly . Warning ( this ) , b = ! 0 ) ; this . warning . setText ( a , c ) } else this . warning && ! c ? ( this . warning . dispose ( ) , b = ! 0 ) : this . warning && ( b = this . warning . getText ( ) , this . warning . setText ( "" ,
c ) , ( d = this . warning . getText ( ) ) || this . warning . dispose ( ) , b = b != d ) ; b && this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } } ; Blockly . BlockSvg . prototype . setMutator = function ( a ) { this . mutator && this . mutator !== a && this . mutator . dispose ( ) ; a && ( a . setBlock ( this ) , this . mutator = a , a . createIcon ( ) ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ;
Blockly . BlockSvg . prototype . setEnabled = function ( a ) { this . isEnabled ( ) != a && ( Blockly . BlockSvg . superClass _ . setEnabled . call ( this , a ) , this . rendered && ! this . getInheritedDisabled ( ) && this . updateDisabled ( ) ) } ; Blockly . BlockSvg . prototype . setHighlighted = function ( a ) { this . rendered && this . pathObject . updateHighlighted ( a ) } ; Blockly . BlockSvg . prototype . addSelect = function ( ) { this . pathObject . updateSelected ( ! 0 ) } ; Blockly . BlockSvg . prototype . removeSelect = function ( ) { this . pathObject . updateSelected ( ! 1 ) } ;
Blockly . BlockSvg . prototype . setDeleteStyle = function ( a ) { this . pathObject . updateDraggingDelete ( a ) } ; Blockly . BlockSvg . prototype . getColour = function ( ) { return this . style . colourPrimary } ; Blockly . BlockSvg . prototype . setColour = function ( a ) { Blockly . BlockSvg . superClass _ . setColour . call ( this , a ) ; a = this . workspace . getRenderer ( ) . getConstants ( ) . getBlockStyleForColour ( this . colour _ ) ; this . pathObject . setStyle ( a . style ) ; this . style = a . style ; this . styleName _ = a . name ; this . applyColour ( ) } ;
Blockly . BlockSvg . prototype . setStyle = function ( a ) { var b = this . workspace . getRenderer ( ) . getConstants ( ) . getBlockStyle ( a ) ; this . styleName _ = a ; if ( b ) this . hat = b . hat , this . pathObject . setStyle ( b ) , this . colour _ = b . colourPrimary , this . style = b , this . applyColour ( ) ; else throw Error ( "Invalid style name: " + a ) ; } ; Blockly . BlockSvg . prototype . bringToFront = function ( ) { var a = this ; do { var b = a . getSvgRoot ( ) , c = b . parentNode , d = c . childNodes ; d [ d . length - 1 ] !== b && c . appendChild ( b ) ; a = a . getParent ( ) } while ( a ) } ;
Blockly . BlockSvg . prototype . setPreviousStatement = function ( a , b ) { Blockly . BlockSvg . superClass _ . setPreviousStatement . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ; Blockly . BlockSvg . prototype . setNextStatement = function ( a , b ) { Blockly . BlockSvg . superClass _ . setNextStatement . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ; Blockly . BlockSvg . prototype . setOutput = function ( a , b ) { Blockly . BlockSvg . superClass _ . setOutput . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ;
Blockly . BlockSvg . prototype . setInputsInline = function ( a ) { Blockly . BlockSvg . superClass _ . setInputsInline . call ( this , a ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ; Blockly . BlockSvg . prototype . removeInput = function ( a , b ) { a = Blockly . BlockSvg . superClass _ . removeInput . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) ; return a } ;
Blockly . BlockSvg . prototype . moveNumberedInputBefore = function ( a , b ) { Blockly . BlockSvg . superClass _ . moveNumberedInputBefore . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) } ; Blockly . BlockSvg . prototype . appendInput _ = function ( a , b ) { a = Blockly . BlockSvg . superClass _ . appendInput _ . call ( this , a , b ) ; this . rendered && ( this . render ( ) , this . bumpNeighbours ( ) ) ; return a } ;
Blockly . BlockSvg . prototype . setConnectionTracking = function ( a ) { this . previousConnection && this . previousConnection . setTracking ( a ) ; this . outputConnection && this . outputConnection . setTracking ( a ) ; if ( this . nextConnection ) { this . nextConnection . setTracking ( a ) ; var b = this . nextConnection . targetBlock ( ) ; b && b . setConnectionTracking ( a ) } if ( ! this . collapsed _ ) for ( b = 0 ; b < this . inputList . length ; b ++ ) { var c = this . inputList [ b ] . connection ; c && ( c . setTracking ( a ) , ( c = c . targetBlock ( ) ) && c . setConnectionTracking ( a ) ) } } ;
2021-09-18 14:29:06 +00:00
Blockly . BlockSvg . prototype . getConnections _ = function ( a ) { var b = [ ] ; if ( a || this . rendered ) if ( this . outputConnection && b . push ( this . outputConnection ) , this . previousConnection && b . push ( this . previousConnection ) , this . nextConnection && b . push ( this . nextConnection ) , a || ! this . collapsed _ ) { a = 0 ; for ( var c ; c = this . inputList [ a ] ; a ++ ) c . connection && b . push ( c . connection ) } return b } ; Blockly . BlockSvg . prototype . lastConnectionInStack = function ( a ) { return Blockly . BlockSvg . superClass _ . lastConnectionInStack . call ( this , a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . getMatchingConnection = function ( a , b ) { return Blockly . BlockSvg . superClass _ . getMatchingConnection . call ( this , a , b ) } ; Blockly . BlockSvg . prototype . makeConnection _ = function ( a ) { return new Blockly . RenderedConnection ( this , a ) } ;
Blockly . BlockSvg . prototype . bumpNeighbours = function ( ) { if ( this . workspace && ! this . workspace . isDragging ( ) ) { var a = this . getRootBlock ( ) ; if ( ! a . isInFlyout ) for ( var b = this . getConnections _ ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) { d . isConnected ( ) && d . isSuperior ( ) && d . targetBlock ( ) . bumpNeighbours ( ) ; for ( var e = d . neighbours ( Blockly . SNAP _RADIUS ) , f = 0 , g ; g = e [ f ] ; f ++ ) d . isConnected ( ) && g . isConnected ( ) || g . getSourceBlock ( ) . getRootBlock ( ) != a && ( d . isSuperior ( ) ? g . bumpAwayFrom ( d ) : d . bumpAwayFrom ( g ) ) } } } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . scheduleSnapAndBump = function ( ) { var a = this , b = Blockly . Events . getGroup ( ) ; setTimeout ( function ( ) { Blockly . Events . setGroup ( b ) ; a . snapToGrid ( ) ; Blockly . Events . setGroup ( ! 1 ) } , Blockly . BUMP _DELAY / 2 ) ; setTimeout ( function ( ) { Blockly . Events . setGroup ( b ) ; a . bumpNeighbours ( ) ; Blockly . Events . setGroup ( ! 1 ) } , Blockly . BUMP _DELAY ) } ;
Blockly . BlockSvg . prototype . positionNearConnection = function ( a , b ) { a . type != Blockly . connectionTypes . NEXT _STATEMENT && a . type != Blockly . connectionTypes . INPUT _VALUE || this . moveBy ( b . x - a . x , b . y - a . y ) } ; Blockly . BlockSvg . prototype . getParent = function ( ) { return Blockly . BlockSvg . superClass _ . getParent . call ( this ) } ; Blockly . BlockSvg . prototype . getRootBlock = function ( ) { return Blockly . BlockSvg . superClass _ . getRootBlock . call ( this ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . render = function ( a ) { if ( ! this . renderIsInProgress _ ) { this . renderIsInProgress _ = ! 0 ; try { this . rendered = ! 0 ; Blockly . utils . dom . startTextWidthCache ( ) ; this . isCollapsed ( ) && this . updateCollapsed _ ( ) ; this . workspace . getRenderer ( ) . render ( this ) ; this . updateConnectionLocations _ ( ) ; if ( ! 1 !== a ) { var b = this . getParent ( ) ; b ? b . render ( ! 0 ) : this . workspace . resizeContents ( ) } Blockly . utils . dom . stopTextWidthCache ( ) ; this . updateMarkers _ ( ) } finally { this . renderIsInProgress _ = ! 1 } } } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . updateMarkers _ = function ( ) { this . workspace . keyboardAccessibilityMode && this . pathObject . cursorSvg && this . workspace . getCursor ( ) . draw ( ) ; this . workspace . keyboardAccessibilityMode && this . pathObject . markerSvg && this . workspace . getMarker ( Blockly . MarkerManager . LOCAL _MARKER ) . draw ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . BlockSvg . prototype . updateConnectionLocations _ = function ( ) { var a = this . getRelativeToSurfaceXY ( ) ; this . previousConnection && this . previousConnection . moveToOffset ( a ) ; this . outputConnection && this . outputConnection . moveToOffset ( a ) ; for ( var b = 0 ; b < this . inputList . length ; b ++ ) { var c = this . inputList [ b ] . connection ; c && ( c . moveToOffset ( a ) , c . isConnected ( ) && c . tighten ( ) ) } this . nextConnection && ( this . nextConnection . moveToOffset ( a ) , this . nextConnection . isConnected ( ) && this . nextConnection . tighten ( ) ) } ;
Blockly . BlockSvg . prototype . setCursorSvg = function ( a ) { this . pathObject . setCursorSvg ( a ) } ; Blockly . BlockSvg . prototype . setMarkerSvg = function ( a ) { this . pathObject . setMarkerSvg ( a ) } ; Blockly . BlockSvg . prototype . getHeightWidth = function ( ) { var a = this . height , b = this . width , c = this . getNextBlock ( ) ; if ( c ) { c = c . getHeightWidth ( ) ; var d = this . workspace . getRenderer ( ) . getConstants ( ) . NOTCH _HEIGHT ; a += c . height - d ; b = Math . max ( b , c . width ) } return { height : a , width : b } } ; Blockly . BlockSvg . prototype . fadeForReplacement = function ( a ) { this . pathObject . updateReplacementFade ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . BlockSvg . prototype . highlightShapeForInput = function ( a , b ) { this . pathObject . updateShapeForInputHighlight ( a , b ) } ; Blockly . ConnectionDB = function ( a ) { this . connections _ = [ ] ; this . connectionChecker _ = a } ; Blockly . ConnectionDB . prototype . addConnection = function ( a , b ) { b = this . calculateIndexForYPos _ ( b ) ; this . connections _ . splice ( b , 0 , a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . ConnectionDB . prototype . findIndexOfConnection _ = function ( a , b ) { if ( ! this . connections _ . length ) return - 1 ; var c = this . calculateIndexForYPos _ ( b ) ; if ( c >= this . connections _ . length ) return - 1 ; b = a . y ; for ( var d = c ; 0 <= d && this . connections _ [ d ] . y == b ; ) { if ( this . connections _ [ d ] == a ) return d ; d -- } for ( d = c ; d < this . connections _ . length && this . connections _ [ d ] . y == b ; ) { if ( this . connections _ [ d ] == a ) return d ; d ++ } return - 1 } ;
2021-01-16 14:07:51 +00:00
Blockly . ConnectionDB . prototype . calculateIndexForYPos _ = function ( a ) { if ( ! this . connections _ . length ) return 0 ; for ( var b = 0 , c = this . connections _ . length ; b < c ; ) { var d = Math . floor ( ( b + c ) / 2 ) ; if ( this . connections _ [ d ] . y < a ) b = d + 1 ; else if ( this . connections _ [ d ] . y > a ) c = d ; else { b = d ; break } } return b } ; Blockly . ConnectionDB . prototype . removeConnection = function ( a , b ) { a = this . findIndexOfConnection _ ( a , b ) ; if ( - 1 == a ) throw Error ( "Unable to find connection in connectionDB." ) ; this . connections _ . splice ( a , 1 ) } ;
Blockly . ConnectionDB . prototype . getNeighbours = function ( a , b ) { function c ( l ) { var m = e - d [ l ] . x , n = f - d [ l ] . y ; Math . sqrt ( m * m + n * n ) <= b && k . push ( d [ l ] ) ; return n < b } var d = this . connections _ , e = a . x , f = a . y ; a = 0 ; for ( var g = d . length - 2 , h = g ; a < h ; ) d [ h ] . y < f ? a = h : g = h , h = Math . floor ( ( a + g ) / 2 ) ; var k = [ ] ; g = a = h ; if ( d . length ) { for ( ; 0 <= a && c ( a ) ; ) a -- ; do g ++ ; while ( g < d . length && c ( g ) ) } return k } ; Blockly . ConnectionDB . prototype . isInYRange _ = function ( a , b , c ) { return Math . abs ( this . connections _ [ a ] . y - b ) <= c } ;
Blockly . ConnectionDB . prototype . searchForClosest = function ( a , b , c ) { if ( ! this . connections _ . length ) return { connection : null , radius : b } ; var d = a . y , e = a . x ; a . x = e + c . x ; a . y = d + c . y ; var f = this . calculateIndexForYPos _ ( a . y ) ; c = null ; for ( var g = b , h , k = f - 1 ; 0 <= k && this . isInYRange _ ( k , a . y , b ) ; ) h = this . connections _ [ k ] , this . connectionChecker _ . canConnect ( a , h , ! 0 , g ) && ( c = h , g = h . distanceFrom ( a ) ) , k -- ; for ( ; f < this . connections _ . length && this . isInYRange _ ( f , a . y , b ) ; ) h = this . connections _ [ f ] , this . connectionChecker _ . canConnect ( a , h , ! 0 , g ) && ( c = h , g = h . distanceFrom ( a ) ) ,
2021-05-19 13:38:55 +00:00
f ++ ; a . x = e ; a . y = d ; return { connection : c , radius : g } } ; Blockly . ConnectionDB . init = function ( a ) { var b = [ ] ; b [ Blockly . connectionTypes . INPUT _VALUE ] = new Blockly . ConnectionDB ( a ) ; b [ Blockly . connectionTypes . OUTPUT _VALUE ] = new Blockly . ConnectionDB ( a ) ; b [ Blockly . connectionTypes . NEXT _STATEMENT ] = new Blockly . ConnectionDB ( a ) ; b [ Blockly . connectionTypes . PREVIOUS _STATEMENT ] = new Blockly . ConnectionDB ( a ) ; return b } ; Blockly . Events . ThemeChange = function ( a , b ) { Blockly . Events . ThemeChange . superClass _ . constructor . call ( this , b ) ; this . themeName = a } ; Blockly . utils . object . inherits ( Blockly . Events . ThemeChange , Blockly . Events . UiBase ) ; Blockly . Events . ThemeChange . prototype . type = Blockly . Events . THEME _CHANGE ; Blockly . Events . ThemeChange . prototype . toJson = function ( ) { var a = Blockly . Events . ThemeChange . superClass _ . toJson . call ( this ) ; a . themeName = this . themeName ; return a } ;
Blockly . Events . ThemeChange . prototype . fromJson = function ( a ) { Blockly . Events . ThemeChange . superClass _ . fromJson . call ( this , a ) ; this . themeName = a . themeName } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . THEME _CHANGE , Blockly . Events . ThemeChange ) ; Blockly . Events . ViewportChange = function ( a , b , c , d , e ) { Blockly . Events . ViewportChange . superClass _ . constructor . call ( this , d ) ; this . viewTop = a ; this . viewLeft = b ; this . scale = c ; this . oldScale = e } ; Blockly . utils . object . inherits ( Blockly . Events . ViewportChange , Blockly . Events . UiBase ) ; Blockly . Events . ViewportChange . prototype . type = Blockly . Events . VIEWPORT _CHANGE ;
Blockly . Events . ViewportChange . prototype . toJson = function ( ) { var a = Blockly . Events . ViewportChange . superClass _ . toJson . call ( this ) ; a . viewTop = this . viewTop ; a . viewLeft = this . viewLeft ; a . scale = this . scale ; a . oldScale = this . oldScale ; return a } ; Blockly . Events . ViewportChange . prototype . fromJson = function ( a ) { Blockly . Events . ViewportChange . superClass _ . fromJson . call ( this , a ) ; this . viewTop = a . viewTop ; this . viewLeft = a . viewLeft ; this . scale = a . scale ; this . oldScale = a . oldScale } ;
2021-09-18 14:29:06 +00:00
Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . VIEWPORT _CHANGE , Blockly . Events . ViewportChange ) ; Blockly . IMetricsManager = function ( ) { } ; Blockly . MetricsManager = function ( a ) { this . workspace _ = a } ; Blockly . MetricsManager . prototype . getDimensionsPx _ = function ( a ) { var b = 0 , c = 0 ; a && ( b = a . getWidth ( ) , c = a . getHeight ( ) ) ; return new Blockly . utils . Size ( b , c ) } ; Blockly . MetricsManager . prototype . getFlyoutMetrics = function ( a ) { a = this . getDimensionsPx _ ( this . workspace _ . getFlyout ( a ) ) ; return { width : a . width , height : a . height , position : this . workspace _ . toolboxPosition } } ;
2021-05-19 13:38:55 +00:00
Blockly . MetricsManager . prototype . getToolboxMetrics = function ( ) { var a = this . getDimensionsPx _ ( this . workspace _ . getToolbox ( ) ) ; return { width : a . width , height : a . height , position : this . workspace _ . toolboxPosition } } ; Blockly . MetricsManager . prototype . getSvgMetrics = function ( ) { return this . workspace _ . getCachedParentSvgSize ( ) } ;
Blockly . MetricsManager . prototype . getAbsoluteMetrics = function ( ) { var a = 0 , b = this . getToolboxMetrics ( ) , c = this . getFlyoutMetrics ( ! 0 ) , d = ! ! this . workspace _ . getToolbox ( ) , e = ! ! this . workspace _ . getFlyout ( ! 0 ) , f = d ? b . position : c . position , g = f == Blockly . utils . toolbox . Position . LEFT ; f = f == Blockly . utils . toolbox . Position . TOP ; d && g ? a = b . width : e && g && ( a = c . width ) ; g = 0 ; d && f ? g = b . height : e && f && ( g = c . height ) ; return { top : g , left : a } } ;
Blockly . MetricsManager . prototype . getViewMetrics = function ( a ) { a = a ? this . workspace _ . scale : 1 ; var b = this . getSvgMetrics ( ) , c = this . getToolboxMetrics ( ) , d = this . getFlyoutMetrics ( ! 0 ) , e = this . workspace _ . getToolbox ( ) ? c . position : d . position ; if ( this . workspace _ . getToolbox ( ) ) if ( e == Blockly . utils . toolbox . Position . TOP || e == Blockly . utils . toolbox . Position . BOTTOM ) b . height -= c . height ; else { if ( e == Blockly . utils . toolbox . Position . LEFT || e == Blockly . utils . toolbox . Position . RIGHT ) b . width -= c . width } else if ( this . workspace _ . getFlyout ( ! 0 ) ) if ( e ==
Blockly . utils . toolbox . Position . TOP || e == Blockly . utils . toolbox . Position . BOTTOM ) b . height -= d . height ; else if ( e == Blockly . utils . toolbox . Position . LEFT || e == Blockly . utils . toolbox . Position . RIGHT ) b . width -= d . width ; return { height : b . height / a , width : b . width / a , top : - this . workspace _ . scrollY / a , left : - this . workspace _ . scrollX / a } } ;
Blockly . MetricsManager . prototype . getContentMetrics = function ( a ) { a = a ? 1 : this . workspace _ . scale ; var b = this . workspace _ . getBlocksBoundingBox ( ) ; return { height : ( b . bottom - b . top ) * a , width : ( b . right - b . left ) * a , top : b . top * a , left : b . left * a } } ; Blockly . MetricsManager . prototype . hasFixedEdges = function ( ) { return ! this . workspace _ . isMovableHorizontally ( ) || ! this . workspace _ . isMovableVertically ( ) } ;
Blockly . MetricsManager . prototype . getComputedFixedEdges _ = function ( a ) { if ( ! this . hasFixedEdges ( ) ) return { } ; var b = this . workspace _ . isMovableHorizontally ( ) , c = this . workspace _ . isMovableVertically ( ) ; a = a || this . getViewMetrics ( ! 1 ) ; var d = { } ; c || ( d . top = a . top , d . bottom = a . top + a . height ) ; b || ( d . left = a . left , d . right = a . left + a . width ) ; return d } ;
Blockly . MetricsManager . prototype . getPaddedContent _ = function ( a , b ) { var c = b . top + b . height , d = b . left + b . width , e = a . width ; a = a . height ; var f = e / 2 , g = a / 2 ; return { top : Math . min ( b . top - g , c - a ) , bottom : Math . max ( c + g , b . top + a ) , left : Math . min ( b . left - f , d - e ) , right : Math . max ( d + f , b . left + e ) } } ;
Blockly . MetricsManager . prototype . getScrollMetrics = function ( a , b , c ) { a = a ? this . workspace _ . scale : 1 ; b = b || this . getViewMetrics ( ! 1 ) ; var d = c || this . getContentMetrics ( ) ; c = this . getComputedFixedEdges _ ( b ) ; b = this . getPaddedContent _ ( b , d ) ; d = void 0 !== c . top ? c . top : b . top ; var e = void 0 !== c . left ? c . left : b . left ; return { top : d / a , left : e / a , width : ( ( void 0 !== c . right ? c . right : b . right ) - e ) / a , height : ( ( void 0 !== c . bottom ? c . bottom : b . bottom ) - d ) / a } } ;
Blockly . MetricsManager . prototype . getUiMetrics = function ( ) { return { viewMetrics : this . getViewMetrics ( ) , absoluteMetrics : this . getAbsoluteMetrics ( ) , toolboxMetrics : this . getToolboxMetrics ( ) } } ;
Blockly . MetricsManager . prototype . getMetrics = function ( ) { var a = this . getToolboxMetrics ( ) , b = this . getFlyoutMetrics ( ! 0 ) , c = this . getSvgMetrics ( ) , d = this . getAbsoluteMetrics ( ) , e = this . getViewMetrics ( ) , f = this . getContentMetrics ( ) , g = this . getScrollMetrics ( ! 1 , e , f ) ; return { contentHeight : f . height , contentWidth : f . width , contentTop : f . top , contentLeft : f . left , scrollHeight : g . height , scrollWidth : g . width , scrollTop : g . top , scrollLeft : g . left , viewHeight : e . height , viewWidth : e . width , viewTop : e . top , viewLeft : e . left , absoluteTop : d . top , absoluteLeft : d . left ,
svgHeight : c . height , svgWidth : c . width , toolboxWidth : a . width , toolboxHeight : a . height , toolboxPosition : a . position , flyoutWidth : b . width , flyoutHeight : b . height } } ; Blockly . registry . register ( Blockly . registry . Type . METRICS _MANAGER , Blockly . registry . DEFAULT , Blockly . MetricsManager ) ; Blockly . FlyoutMetricsManager = function ( a , b ) { this . flyout _ = b ; Blockly . FlyoutMetricsManager . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . FlyoutMetricsManager , Blockly . MetricsManager ) ;
Blockly . FlyoutMetricsManager . prototype . getBoundingBox _ = function ( ) { try { var a = this . workspace _ . getCanvas ( ) . getBBox ( ) } catch ( b ) { a = { height : 0 , y : 0 , width : 0 , x : 0 } } return a } ; Blockly . FlyoutMetricsManager . prototype . getContentMetrics = function ( a ) { var b = this . getBoundingBox _ ( ) ; a = a ? 1 : this . workspace _ . scale ; return { height : b . height * a , width : b . width * a , top : b . y * a , left : b . x * a } } ;
2021-09-18 14:29:06 +00:00
Blockly . FlyoutMetricsManager . prototype . getScrollMetrics = function ( a , b , c ) { b = c || this . getContentMetrics ( ) ; c = this . flyout _ . MARGIN * this . workspace _ . scale ; a = a ? this . workspace _ . scale : 1 ; return { height : ( b . height + 2 * c ) / a , width : ( b . width + b . left + c ) / a , top : 0 , left : 0 } } ; Blockly . ThemeManager = function ( a , b ) { this . workspace _ = a ; this . theme _ = b ; this . subscribedWorkspaces _ = [ ] ; this . componentDB _ = Object . create ( null ) } ; Blockly . ThemeManager . prototype . getTheme = function ( ) { return this . theme _ } ;
2021-01-16 14:07:51 +00:00
Blockly . ThemeManager . prototype . setTheme = function ( a ) { var b = this . theme _ ; this . theme _ = a ; if ( a = this . workspace _ . getInjectionDiv ( ) ) b && Blockly . utils . dom . removeClass ( a , b . getClassName ( ) ) , Blockly . utils . dom . addClass ( a , this . theme _ . getClassName ( ) ) ; for ( b = 0 ; a = this . subscribedWorkspaces _ [ b ] ; b ++ ) a . refreshTheme ( ) ; b = 0 ; a = Object . keys ( this . componentDB _ ) ; for ( var c ; c = a [ b ] ; b ++ ) for ( var d = 0 , e ; e = this . componentDB _ [ c ] [ d ] ; d ++ ) { var f = e . element ; e = e . propertyName ; var g = this . theme _ && this . theme _ . getComponentStyle ( c ) ; f . style [ e ] = g || "" } Blockly . hideChaff ( ) } ;
Blockly . ThemeManager . prototype . subscribeWorkspace = function ( a ) { this . subscribedWorkspaces _ . push ( a ) } ; Blockly . ThemeManager . prototype . unsubscribeWorkspace = function ( a ) { a = this . subscribedWorkspaces _ . indexOf ( a ) ; if ( 0 > a ) throw Error ( "Cannot unsubscribe a workspace that hasn't been subscribed." ) ; this . subscribedWorkspaces _ . splice ( a , 1 ) } ;
Blockly . ThemeManager . prototype . subscribe = function ( a , b , c ) { this . componentDB _ [ b ] || ( this . componentDB _ [ b ] = [ ] ) ; this . componentDB _ [ b ] . push ( { element : a , propertyName : c } ) ; b = this . theme _ && this . theme _ . getComponentStyle ( b ) ; a . style [ c ] = b || "" } ; Blockly . ThemeManager . prototype . unsubscribe = function ( a ) { if ( a ) for ( var b = Object . keys ( this . componentDB _ ) , c = 0 , d ; d = b [ c ] ; c ++ ) { for ( var e = this . componentDB _ [ d ] , f = e . length - 1 ; 0 <= f ; f -- ) e [ f ] . element === a && e . splice ( f , 1 ) ; this . componentDB _ [ d ] . length || delete this . componentDB _ [ d ] } } ;
Blockly . ThemeManager . prototype . dispose = function ( ) { this . componentDB _ = this . subscribedWorkspaces _ = this . theme _ = this . owner _ = null } ; Blockly . TouchGesture = function ( a , b ) { Blockly . TouchGesture . superClass _ . constructor . call ( this , a , b ) ; this . isMultiTouch _ = ! 1 ; this . cachedPoints _ = Object . create ( null ) ; this . startDistance _ = this . previousScale _ = 0 ; this . isPinchZoomEnabled _ = this . onStartWrapper _ = null } ; Blockly . utils . object . inherits ( Blockly . TouchGesture , Blockly . Gesture ) ; Blockly . TouchGesture . ZOOM _IN _MULTIPLIER = 5 ; Blockly . TouchGesture . ZOOM _OUT _MULTIPLIER = 6 ;
Blockly . TouchGesture . prototype . doStart = function ( a ) { this . isPinchZoomEnabled _ = this . startWorkspace _ . options . zoomOptions && this . startWorkspace _ . options . zoomOptions . pinch ; Blockly . TouchGesture . superClass _ . doStart . call ( this , a ) ; ! this . isEnding _ && Blockly . Touch . isTouchEvent ( a ) && this . handleTouchStart ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . TouchGesture . prototype . bindMouseEvents = function ( a ) { this . onStartWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mousedown" , null , this . handleStart . bind ( this ) , ! 0 ) ; this . onMoveWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mousemove" , null , this . handleMove . bind ( this ) , ! 0 ) ; this . onUpWrapper _ = Blockly . browserEvents . conditionalBind ( document , "mouseup" , null , this . handleUp . bind ( this ) , ! 0 ) ; a . preventDefault ( ) ; a . stopPropagation ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . TouchGesture . prototype . handleStart = function ( a ) { ! this . isDragging ( ) && Blockly . Touch . isTouchEvent ( a ) && ( this . handleTouchStart ( a ) , this . isMultiTouch ( ) && Blockly . longStop _ ( ) ) } ; Blockly . TouchGesture . prototype . handleMove = function ( a ) { this . isDragging ( ) ? Blockly . Touch . shouldHandleEvent ( a ) && Blockly . TouchGesture . superClass _ . handleMove . call ( this , a ) : this . isMultiTouch ( ) ? ( Blockly . Touch . isTouchEvent ( a ) && this . handleTouchMove ( a ) , Blockly . longStop _ ( ) ) : Blockly . TouchGesture . superClass _ . handleMove . call ( this , a ) } ;
Blockly . TouchGesture . prototype . handleUp = function ( a ) { Blockly . Touch . isTouchEvent ( a ) && ! this . isDragging ( ) && this . handleTouchEnd ( a ) ; ! this . isMultiTouch ( ) || this . isDragging ( ) ? Blockly . Touch . shouldHandleEvent ( a ) && Blockly . TouchGesture . superClass _ . handleUp . call ( this , a ) : ( a . preventDefault ( ) , a . stopPropagation ( ) , this . dispose ( ) ) } ; Blockly . TouchGesture . prototype . isMultiTouch = function ( ) { return this . isMultiTouch _ } ;
2021-05-19 13:38:55 +00:00
Blockly . TouchGesture . prototype . dispose = function ( ) { Blockly . TouchGesture . superClass _ . dispose . call ( this ) ; this . onStartWrapper _ && Blockly . browserEvents . unbind ( this . onStartWrapper _ ) } ;
Blockly . TouchGesture . prototype . handleTouchStart = function ( a ) { var b = Blockly . Touch . getTouchIdentifierFromEvent ( a ) ; this . cachedPoints _ [ b ] = this . getTouchPoint ( a ) ; b = Object . keys ( this . cachedPoints _ ) ; 2 == b . length && ( this . startDistance _ = Blockly . utils . Coordinate . distance ( this . cachedPoints _ [ b [ 0 ] ] , this . cachedPoints _ [ b [ 1 ] ] ) , this . isMultiTouch _ = ! 0 , a . preventDefault ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . TouchGesture . prototype . handleTouchMove = function ( a ) { var b = Blockly . Touch . getTouchIdentifierFromEvent ( a ) ; this . cachedPoints _ [ b ] = this . getTouchPoint ( a ) ; b = Object . keys ( this . cachedPoints _ ) ; this . isPinchZoomEnabled _ && 2 === b . length ? this . handlePinch _ ( a ) : Blockly . TouchGesture . superClass _ . handleMove . call ( this , a ) } ;
Blockly . TouchGesture . prototype . handlePinch _ = function ( a ) { var b = Object . keys ( this . cachedPoints _ ) ; b = Blockly . utils . Coordinate . distance ( this . cachedPoints _ [ b [ 0 ] ] , this . cachedPoints _ [ b [ 1 ] ] ) / this . startDistance _ ; if ( 0 < this . previousScale _ && Infinity > this . previousScale _ ) { var c = b - this . previousScale _ ; c = 0 < c ? c * Blockly . TouchGesture . ZOOM _IN _MULTIPLIER : c * Blockly . TouchGesture . ZOOM _OUT _MULTIPLIER ; var d = this . startWorkspace _ , e = Blockly . utils . mouseToSvg ( a , d . getParentSvg ( ) , d . getInverseScreenCTM ( ) ) ; d . zoom ( e . x , e . y , c ) } this . previousScale _ =
b ; a . preventDefault ( ) } ; Blockly . TouchGesture . prototype . handleTouchEnd = function ( a ) { a = Blockly . Touch . getTouchIdentifierFromEvent ( a ) ; this . cachedPoints _ [ a ] && delete this . cachedPoints _ [ a ] ; 2 > Object . keys ( this . cachedPoints _ ) . length && ( this . cachedPoints _ = Object . create ( null ) , this . previousScale _ = 0 ) } ; Blockly . TouchGesture . prototype . getTouchPoint = function ( a ) { return this . startWorkspace _ ? new Blockly . utils . Coordinate ( a . pageX ? a . pageX : a . changedTouches [ 0 ] . pageX , a . pageY ? a . pageY : a . changedTouches [ 0 ] . pageY ) : null } ; Blockly . WorkspaceAudio = function ( a ) { this . parentWorkspace _ = a ; this . SOUNDS _ = Object . create ( null ) } ; Blockly . WorkspaceAudio . prototype . lastSound _ = null ; Blockly . WorkspaceAudio . prototype . dispose = function ( ) { this . SOUNDS _ = this . parentWorkspace _ = null } ;
Blockly . WorkspaceAudio . prototype . load = function ( a , b ) { if ( a . length ) { try { var c = new Blockly . utils . global . Audio } catch ( h ) { return } for ( var d , e = 0 ; e < a . length ; e ++ ) { var f = a [ e ] , g = f . match ( /\.(\w+)$/ ) ; if ( g && c . canPlayType ( "audio/" + g [ 1 ] ) ) { d = new Blockly . utils . global . Audio ( f ) ; break } } d && d . play && ( this . SOUNDS _ [ b ] = d ) } } ;
Blockly . WorkspaceAudio . prototype . preload = function ( ) { for ( var a in this . SOUNDS _ ) { var b = this . SOUNDS _ [ a ] ; b . volume = . 01 ; var c = b . play ( ) ; void 0 !== c ? c . then ( b . pause ) . catch ( function ( ) { } ) : b . pause ( ) ; if ( Blockly . utils . userAgent . IPAD || Blockly . utils . userAgent . IPHONE ) break } } ;
2021-09-18 14:29:06 +00:00
Blockly . WorkspaceAudio . prototype . play = function ( a , b ) { var c = this . SOUNDS _ [ a ] ; c ? ( a = new Date , null != this . lastSound _ && a - this . lastSound _ < Blockly . SOUND _LIMIT || ( this . lastSound _ = a , c = Blockly . utils . userAgent . IPAD || Blockly . utils . userAgent . ANDROID ? c : c . cloneNode ( ) , c . volume = void 0 === b ? 1 : b , c . play ( ) ) ) : this . parentWorkspace _ && this . parentWorkspace _ . getAudioManager ( ) . play ( a , b ) } ; Blockly . WorkspaceSvg = function ( a , b , c ) { Blockly . WorkspaceSvg . superClass _ . constructor . call ( this , a ) ; this . metricsManager _ = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . METRICS _MANAGER , a , ! 0 ) ) ( this ) ; this . getMetrics = a . getMetrics || this . metricsManager _ . getMetrics . bind ( this . metricsManager _ ) ; this . setMetrics = a . setMetrics || Blockly . WorkspaceSvg . setTopLevelWorkspaceMetrics _ ; this . componentManager _ = new Blockly . ComponentManager ; this . connectionDBList = Blockly . ConnectionDB . init ( this . connectionChecker ) ;
b && ( this . blockDragSurface _ = b ) ; c && ( this . workspaceDragSurface _ = c ) ; this . useWorkspaceDragSurface _ = ! ! this . workspaceDragSurface _ && Blockly . utils . is3dSupported ( ) ; this . highlightedBlocks _ = [ ] ; this . audioManager _ = new Blockly . WorkspaceAudio ( a . parentWorkspace ) ; this . grid _ = this . options . gridPattern ? new Blockly . Grid ( this . options . gridPattern , a . gridOptions ) : null ; this . markerManager _ = new Blockly . MarkerManager ( this ) ; this . toolboxCategoryCallbacks _ = Object . create ( null ) ; this . flyoutButtonCallbacks _ = Object . create ( null ) ; Blockly . Variables &&
Blockly . Variables . flyoutCategory && this . registerToolboxCategoryCallback ( Blockly . VARIABLE _CATEGORY _NAME , Blockly . Variables . flyoutCategory ) ; Blockly . VariablesDynamic && Blockly . VariablesDynamic . flyoutCategory && this . registerToolboxCategoryCallback ( Blockly . VARIABLE _DYNAMIC _CATEGORY _NAME , Blockly . VariablesDynamic . flyoutCategory ) ; Blockly . Procedures && Blockly . Procedures . flyoutCategory && ( this . registerToolboxCategoryCallback ( Blockly . PROCEDURE _CATEGORY _NAME , Blockly . Procedures . flyoutCategory ) , this . addChangeListener ( Blockly . Procedures . mutatorOpenListener ) ) ;
this . themeManager _ = this . options . parentWorkspace ? this . options . parentWorkspace . getThemeManager ( ) : new Blockly . ThemeManager ( this , this . options . theme || Blockly . Themes . Classic ) ; this . themeManager _ . subscribeWorkspace ( this ) ; this . renderer _ = Blockly . blockRendering . init ( this . options . renderer || "geras" , this . getTheme ( ) , this . options . rendererOverrides ) ; this . cachedParentSvg _ = null ; this . keyboardAccessibilityMode = ! 1 ; this . topBoundedElements _ = [ ] ; this . dragTargetAreas _ = [ ] ; this . cachedParentSvgSize _ = new Blockly . utils . Size ( 0 , 0 ) } ;
Blockly . utils . object . inherits ( Blockly . WorkspaceSvg , Blockly . Workspace ) ; Blockly . WorkspaceSvg . prototype . resizeHandlerWrapper _ = null ; Blockly . WorkspaceSvg . prototype . rendered = ! 0 ; Blockly . WorkspaceSvg . prototype . isVisible _ = ! 0 ; Blockly . WorkspaceSvg . prototype . isFlyout = ! 1 ; Blockly . WorkspaceSvg . prototype . isMutator = ! 1 ; Blockly . WorkspaceSvg . prototype . resizesEnabled _ = ! 0 ; Blockly . WorkspaceSvg . prototype . scrollX = 0 ; Blockly . WorkspaceSvg . prototype . scrollY = 0 ; Blockly . WorkspaceSvg . prototype . startScrollX = 0 ;
Blockly . WorkspaceSvg . prototype . startScrollY = 0 ; Blockly . WorkspaceSvg . prototype . dragDeltaXY _ = null ; Blockly . WorkspaceSvg . prototype . scale = 1 ; Blockly . WorkspaceSvg . prototype . oldScale _ = 1 ; Blockly . WorkspaceSvg . prototype . oldTop _ = 0 ; Blockly . WorkspaceSvg . prototype . oldLeft _ = 0 ; Blockly . WorkspaceSvg . prototype . trashcan = null ; Blockly . WorkspaceSvg . prototype . scrollbar = null ; Blockly . WorkspaceSvg . prototype . flyout _ = null ; Blockly . WorkspaceSvg . prototype . toolbox _ = null ; Blockly . WorkspaceSvg . prototype . currentGesture _ = null ;
Blockly . WorkspaceSvg . prototype . blockDragSurface _ = null ; Blockly . WorkspaceSvg . prototype . workspaceDragSurface _ = null ; Blockly . WorkspaceSvg . prototype . useWorkspaceDragSurface _ = ! 1 ; Blockly . WorkspaceSvg . prototype . isDragSurfaceActive _ = ! 1 ; Blockly . WorkspaceSvg . prototype . injectionDiv _ = null ; Blockly . WorkspaceSvg . prototype . lastRecordedPageScroll _ = null ; Blockly . WorkspaceSvg . prototype . targetWorkspace = null ; Blockly . WorkspaceSvg . prototype . inverseScreenCTM _ = null ; Blockly . WorkspaceSvg . prototype . inverseScreenCTMDirty _ = ! 0 ;
Blockly . WorkspaceSvg . prototype . getMarkerManager = function ( ) { return this . markerManager _ } ; Blockly . WorkspaceSvg . prototype . getMetricsManager = function ( ) { return this . metricsManager _ } ; Blockly . WorkspaceSvg . prototype . setMetricsManager = function ( a ) { this . metricsManager _ = a ; this . getMetrics = this . metricsManager _ . getMetrics . bind ( this . metricsManager _ ) } ; Blockly . WorkspaceSvg . prototype . getComponentManager = function ( ) { return this . componentManager _ } ; Blockly . WorkspaceSvg . prototype . setCursorSvg = function ( a ) { this . markerManager _ . setCursorSvg ( a ) } ;
Blockly . WorkspaceSvg . prototype . setMarkerSvg = function ( a ) { this . markerManager _ . setMarkerSvg ( a ) } ; Blockly . WorkspaceSvg . prototype . getMarker = function ( a ) { return this . markerManager _ ? this . markerManager _ . getMarker ( a ) : null } ; Blockly . WorkspaceSvg . prototype . getCursor = function ( ) { return this . markerManager _ ? this . markerManager _ . getCursor ( ) : null } ; Blockly . WorkspaceSvg . prototype . getRenderer = function ( ) { return this . renderer _ } ; Blockly . WorkspaceSvg . prototype . getThemeManager = function ( ) { return this . themeManager _ } ;
Blockly . WorkspaceSvg . prototype . getTheme = function ( ) { return this . themeManager _ . getTheme ( ) } ; Blockly . WorkspaceSvg . prototype . setTheme = function ( a ) { a || ( a = Blockly . Themes . Classic ) ; this . themeManager _ . setTheme ( a ) } ;
Blockly . WorkspaceSvg . prototype . refreshTheme = function ( ) { this . svgGroup _ && this . renderer _ . refreshDom ( this . svgGroup _ , this . getTheme ( ) ) ; this . updateBlockStyles _ ( this . getAllBlocks ( ! 1 ) . filter ( function ( b ) { return ! ! b . getStyleName ( ) } ) ) ; this . refreshToolboxSelection ( ) ; this . toolbox _ && this . toolbox _ . refreshTheme ( ) ; this . isVisible ( ) && this . setVisible ( ! 0 ) ; var a = new ( Blockly . Events . get ( Blockly . Events . THEME _CHANGE ) ) ( this . getTheme ( ) . name , this . id ) ; Blockly . Events . fire ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . updateBlockStyles _ = function ( a ) { for ( var b = 0 , c ; c = a [ b ] ; b ++ ) { var d = c . getStyleName ( ) ; d && ( c . setStyle ( d ) , c . mutator && c . mutator . updateBlockStyle ( ) ) } } ; Blockly . WorkspaceSvg . prototype . getInverseScreenCTM = function ( ) { if ( this . inverseScreenCTMDirty _ ) { var a = this . getParentSvg ( ) . getScreenCTM ( ) ; a && ( this . inverseScreenCTM _ = a . inverse ( ) , this . inverseScreenCTMDirty _ = ! 1 ) } return this . inverseScreenCTM _ } ;
Blockly . WorkspaceSvg . prototype . updateInverseScreenCTM = function ( ) { this . inverseScreenCTMDirty _ = ! 0 } ; Blockly . WorkspaceSvg . prototype . isVisible = function ( ) { return this . isVisible _ } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . getSvgXY = function ( a ) { var b = 0 , c = 0 , d = 1 ; if ( Blockly . utils . dom . containsNode ( this . getCanvas ( ) , a ) || Blockly . utils . dom . containsNode ( this . getBubbleCanvas ( ) , a ) ) d = this . scale ; do { var e = Blockly . utils . getRelativeXY ( a ) ; if ( a == this . getCanvas ( ) || a == this . getBubbleCanvas ( ) ) d = 1 ; b += e . x * d ; c += e . y * d ; a = a . parentNode } while ( a && a != this . getParentSvg ( ) ) ; return new Blockly . utils . Coordinate ( b , c ) } ;
Blockly . WorkspaceSvg . prototype . getCachedParentSvgSize = function ( ) { var a = this . cachedParentSvgSize _ ; return new Blockly . utils . Size ( a . width , a . height ) } ; Blockly . WorkspaceSvg . prototype . getOriginOffsetInPixels = function ( ) { return Blockly . utils . getInjectionDivXY _ ( this . getCanvas ( ) ) } ; Blockly . WorkspaceSvg . prototype . getInjectionDiv = function ( ) { if ( ! this . injectionDiv _ ) for ( var a = this . svgGroup _ ; a ; ) { if ( - 1 != ( " " + ( a . getAttribute ( "class" ) || "" ) + " " ) . indexOf ( " injectionDiv " ) ) { this . injectionDiv _ = a ; break } a = a . parentNode } return this . injectionDiv _ } ;
Blockly . WorkspaceSvg . prototype . getBlockCanvas = function ( ) { return this . svgBlockCanvas _ } ; Blockly . WorkspaceSvg . prototype . setResizeHandlerWrapper = function ( a ) { this . resizeHandlerWrapper _ = a } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . createDom = function ( a ) { this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyWorkspace" } , null ) ; a && ( this . svgBackground _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { height : "100%" , width : "100%" , "class" : a } , this . svgGroup _ ) , "blocklyMainBackground" == a && this . grid _ ? this . svgBackground _ . style . fill = "url(#" + this . grid _ . getPatternId ( ) + ")" : this . themeManager _ . subscribe ( this . svgBackground _ , "workspaceBackgroundColour" , "fill" ) ) ; this . svgBlockCanvas _ =
2021-05-19 13:38:55 +00:00
Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyBlockCanvas" } , this . svgGroup _ ) ; this . svgBubbleCanvas _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyBubbleCanvas" } , this . svgGroup _ ) ; this . isFlyout || ( Blockly . browserEvents . conditionalBind ( this . svgGroup _ , "mousedown" , this , this . onMouseDown _ , ! 1 , ! 0 ) , Blockly . browserEvents . conditionalBind ( this . svgGroup _ , "wheel" , this , this . onMouseWheel _ ) ) ; this . options . hasCategories && ( this . toolbox _ = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . TOOLBOX ,
2021-09-18 14:29:06 +00:00
this . options , ! 0 ) ) ( this ) ) ; this . grid _ && this . grid _ . update ( this . scale ) ; this . recordDragTargets ( ) ; ( a = Blockly . registry . getClassFromOptions ( Blockly . registry . Type . CURSOR , this . options ) ) && this . markerManager _ . setCursor ( new a ) ; this . renderer _ . createDom ( this . svgGroup _ , this . getTheme ( ) ) ; return this . svgGroup _ } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . dispose = function ( ) { this . rendered = ! 1 ; this . currentGesture _ && this . currentGesture _ . cancel ( ) ; this . svgGroup _ && ( Blockly . utils . dom . removeNode ( this . svgGroup _ ) , this . svgGroup _ = null ) ; this . svgBubbleCanvas _ = this . svgBlockCanvas _ = null ; this . toolbox _ && ( this . toolbox _ . dispose ( ) , this . toolbox _ = null ) ; this . flyout _ && ( this . flyout _ . dispose ( ) , this . flyout _ = null ) ; this . trashcan && ( this . trashcan . dispose ( ) , this . trashcan = null ) ; this . scrollbar && ( this . scrollbar . dispose ( ) , this . scrollbar = null ) ; this . zoomControls _ &&
( this . zoomControls _ . dispose ( ) , this . zoomControls _ = null ) ; this . audioManager _ && ( this . audioManager _ . dispose ( ) , this . audioManager _ = null ) ; this . grid _ && ( this . grid _ . dispose ( ) , this . grid _ = null ) ; this . renderer _ . dispose ( ) ; this . markerManager _ && ( this . markerManager _ . dispose ( ) , this . markerManager _ = null ) ; Blockly . WorkspaceSvg . superClass _ . dispose . call ( this ) ; this . themeManager _ && ( this . themeManager _ . unsubscribeWorkspace ( this ) , this . themeManager _ . unsubscribe ( this . svgBackground _ ) , this . options . parentWorkspace || ( this . themeManager _ . dispose ( ) ,
2021-05-19 13:38:55 +00:00
this . themeManager _ = null ) ) ; this . flyoutButtonCallbacks _ = this . toolboxCategoryCallbacks _ = this . connectionDBList = null ; if ( ! this . options . parentWorkspace ) { var a = this . getParentSvg ( ) ; a && a . parentNode && Blockly . utils . dom . removeNode ( a . parentNode ) } this . resizeHandlerWrapper _ && ( Blockly . browserEvents . unbind ( this . resizeHandlerWrapper _ ) , this . resizeHandlerWrapper _ = null ) } ; Blockly . WorkspaceSvg . prototype . newBlock = function ( a , b ) { return new Blockly . BlockSvg ( this , a , b ) } ;
2021-09-18 14:29:06 +00:00
Blockly . WorkspaceSvg . prototype . addTrashcan = function ( ) { if ( ! Blockly . Trashcan ) throw Error ( "Missing require for Blockly.Trashcan" ) ; this . trashcan = new Blockly . Trashcan ( this ) ; var a = this . trashcan . createDom ( ) ; this . svgGroup _ . insertBefore ( a , this . svgBlockCanvas _ ) } ; Blockly . WorkspaceSvg . prototype . addZoomControls = function ( ) { if ( ! Blockly . ZoomControls ) throw Error ( "Missing require for Blockly.ZoomControls" ) ; this . zoomControls _ = new Blockly . ZoomControls ( this ) ; var a = this . zoomControls _ . createDom ( ) ; this . svgGroup _ . appendChild ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . addFlyout = function ( a ) { var b = new Blockly . Options ( { parentWorkspace : this , rtl : this . RTL , oneBasedIndex : this . options . oneBasedIndex , horizontalLayout : this . horizontalLayout , renderer : this . options . renderer , rendererOverrides : this . options . rendererOverrides , move : { scrollbars : ! 0 } } ) ; b . toolboxPosition = this . options . toolboxPosition ; this . flyout _ = this . horizontalLayout ? new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _HORIZONTAL _TOOLBOX , this . options , ! 0 ) ) ( b ) : new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _VERTICAL _TOOLBOX ,
2021-09-18 14:29:06 +00:00
this . options , ! 0 ) ) ( b ) ; this . flyout _ . autoClose = ! 1 ; this . flyout _ . getWorkspace ( ) . setVisible ( ! 0 ) ; return this . flyout _ . createDom ( a ) } ; Blockly . WorkspaceSvg . prototype . getFlyout = function ( a ) { return this . flyout _ || a ? this . flyout _ : this . toolbox _ ? this . toolbox _ . getFlyout ( ) : null } ; Blockly . WorkspaceSvg . prototype . getToolbox = function ( ) { return this . toolbox _ } ; Blockly . WorkspaceSvg . prototype . updateScreenCalculations _ = function ( ) { this . updateInverseScreenCTM ( ) ; this . recordDragTargets ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . resizeContents = function ( ) { this . resizesEnabled _ && this . rendered && ( this . scrollbar && this . scrollbar . resize ( ) , this . updateInverseScreenCTM ( ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . WorkspaceSvg . prototype . resize = function ( ) { this . toolbox _ && this . toolbox _ . position ( ) ; this . flyout _ && this . flyout _ . position ( ) ; for ( var a = this . componentManager _ . getComponents ( Blockly . ComponentManager . Capability . POSITIONABLE , ! 0 ) , b = this . getMetricsManager ( ) . getUiMetrics ( ) , c = [ ] , d = 0 , e ; e = a [ d ] ; d ++ ) e . position ( b , c ) , ( e = e . getBoundingRectangle ( ) ) && c . push ( e ) ; this . scrollbar && this . scrollbar . resize ( ) ; this . updateScreenCalculations _ ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . updateScreenCalculationsIfScrolled = function ( ) { var a = Blockly . utils . getDocumentScroll ( ) ; Blockly . utils . Coordinate . equals ( this . lastRecordedPageScroll _ , a ) || ( this . lastRecordedPageScroll _ = a , this . updateScreenCalculations _ ( ) ) } ; Blockly . WorkspaceSvg . prototype . getCanvas = function ( ) { return this . svgBlockCanvas _ } ;
Blockly . WorkspaceSvg . prototype . setCachedParentSvgSize = function ( a , b ) { var c = this . getParentSvg ( ) ; a && ( this . cachedParentSvgSize _ . width = a , c . cachedWidth _ = a ) ; b && ( this . cachedParentSvgSize _ . height = b , c . cachedHeight _ = b ) } ; Blockly . WorkspaceSvg . prototype . getBubbleCanvas = function ( ) { return this . svgBubbleCanvas _ } ; Blockly . WorkspaceSvg . prototype . getParentSvg = function ( ) { if ( ! this . cachedParentSvg _ ) for ( var a = this . svgGroup _ ; a ; ) { if ( "svg" == a . tagName ) { this . cachedParentSvg _ = a ; break } a = a . parentNode } return this . cachedParentSvg _ } ;
Blockly . WorkspaceSvg . prototype . maybeFireViewportChangeEvent = function ( ) { if ( Blockly . Events . isEnabled ( ) ) { var a = this . scale , b = - this . scrollY , c = - this . scrollX ; if ( ! ( a == this . oldScale _ && 1 > Math . abs ( b - this . oldTop _ ) && 1 > Math . abs ( c - this . oldLeft _ ) ) ) { var d = new ( Blockly . Events . get ( Blockly . Events . VIEWPORT _CHANGE ) ) ( b , c , a , this . id , this . oldScale _ ) ; this . oldScale _ = a ; this . oldTop _ = b ; this . oldLeft _ = c ; Blockly . Events . fire ( d ) } } } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . translate = function ( a , b ) { if ( this . useWorkspaceDragSurface _ && this . isDragSurfaceActive _ ) this . workspaceDragSurface _ . translateSurface ( a , b ) ; else { var c = "translate(" + a + "," + b + ") scale(" + this . scale + ")" ; this . svgBlockCanvas _ . setAttribute ( "transform" , c ) ; this . svgBubbleCanvas _ . setAttribute ( "transform" , c ) } this . blockDragSurface _ && this . blockDragSurface _ . translateAndScaleGroup ( a , b , this . scale ) ; this . grid _ && this . grid _ . moveTo ( a , b ) ; this . maybeFireViewportChangeEvent ( ) } ;
Blockly . WorkspaceSvg . prototype . resetDragSurface = function ( ) { if ( this . useWorkspaceDragSurface _ ) { this . isDragSurfaceActive _ = ! 1 ; var a = this . workspaceDragSurface _ . getSurfaceTranslation ( ) ; this . workspaceDragSurface _ . clearAndHide ( this . svgGroup _ ) ; a = "translate(" + a . x + "," + a . y + ") scale(" + this . scale + ")" ; this . svgBlockCanvas _ . setAttribute ( "transform" , a ) ; this . svgBubbleCanvas _ . setAttribute ( "transform" , a ) } } ;
Blockly . WorkspaceSvg . prototype . setupDragSurface = function ( ) { if ( this . useWorkspaceDragSurface _ && ! this . isDragSurfaceActive _ ) { this . isDragSurfaceActive _ = ! 0 ; var a = this . svgBlockCanvas _ . previousSibling , b = parseInt ( this . getParentSvg ( ) . getAttribute ( "width" ) , 10 ) , c = parseInt ( this . getParentSvg ( ) . getAttribute ( "height" ) , 10 ) , d = Blockly . utils . getRelativeXY ( this . getCanvas ( ) ) ; this . workspaceDragSurface _ . setContentsAndShow ( this . getCanvas ( ) , this . getBubbleCanvas ( ) , a , b , c , this . scale ) ; this . workspaceDragSurface _ . translateSurface ( d . x ,
d . y ) } } ; Blockly . WorkspaceSvg . prototype . getBlockDragSurface = function ( ) { return this . blockDragSurface _ } ; Blockly . WorkspaceSvg . prototype . getWidth = function ( ) { var a = this . getMetrics ( ) ; return a ? a . viewWidth / this . scale : 0 } ;
Blockly . WorkspaceSvg . prototype . setVisible = function ( a ) { this . isVisible _ = a ; if ( this . svgGroup _ ) if ( this . scrollbar && this . scrollbar . setContainerVisible ( a ) , this . getFlyout ( ) && this . getFlyout ( ) . setContainerVisible ( a ) , this . getParentSvg ( ) . style . display = a ? "block" : "none" , this . toolbox _ && this . toolbox _ . setVisible ( a ) , a ) { a = this . getAllBlocks ( ! 1 ) ; for ( var b = a . length - 1 ; 0 <= b ; b -- ) a [ b ] . markDirty ( ) ; this . render ( ) ; this . toolbox _ && this . toolbox _ . position ( ) } else Blockly . hideChaff ( ! 0 ) } ;
Blockly . WorkspaceSvg . prototype . render = function ( ) { for ( var a = this . getAllBlocks ( ! 1 ) , b = a . length - 1 ; 0 <= b ; b -- ) a [ b ] . render ( ! 1 ) ; if ( this . currentGesture _ ) for ( a = this . currentGesture _ . getInsertionMarkers ( ) , b = 0 ; b < a . length ; b ++ ) a [ b ] . render ( ! 1 ) ; this . markerManager _ . updateMarkers ( ) } ;
Blockly . WorkspaceSvg . prototype . highlightBlock = function ( a , b ) { if ( void 0 === b ) { for ( var c = 0 , d ; d = this . highlightedBlocks _ [ c ] ; c ++ ) d . setHighlighted ( ! 1 ) ; this . highlightedBlocks _ . length = 0 } if ( d = a ? this . getBlockById ( a ) : null ) ( a = void 0 === b || b ) ? - 1 == this . highlightedBlocks _ . indexOf ( d ) && this . highlightedBlocks _ . push ( d ) : Blockly . utils . arrayRemove ( this . highlightedBlocks _ , d ) , d . setHighlighted ( a ) } ;
Blockly . WorkspaceSvg . prototype . paste = function ( a ) { ! this . rendered || ! a . tagName || a . getElementsByTagName ( "block" ) . length >= this . remainingCapacity ( ) || ( this . currentGesture _ && this . currentGesture _ . cancel ( ) , "comment" == a . tagName . toLowerCase ( ) ? this . pasteWorkspaceComment _ ( a ) : this . pasteBlock _ ( a ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . pasteBlock _ = function ( a ) { Blockly . Events . disable ( ) ; try { var b = Blockly . Xml . domToBlock ( a , this ) , c = parseInt ( a . getAttribute ( "x" ) , 10 ) , d = parseInt ( a . getAttribute ( "y" ) , 10 ) ; if ( ! isNaN ( c ) && ! isNaN ( d ) ) { this . RTL && ( c = - c ) ; do { a = ! 1 ; for ( var e = this . getAllBlocks ( ! 1 ) , f = 0 , g ; g = e [ f ] ; f ++ ) { var h = g . getRelativeToSurfaceXY ( ) ; if ( 1 >= Math . abs ( c - h . x ) && 1 >= Math . abs ( d - h . y ) ) { a = ! 0 ; break } } if ( ! a ) { var k = b . getConnections _ ( ! 1 ) ; f = 0 ; for ( var l ; l = k [ f ] ; f ++ ) if ( l . closest ( Blockly . SNAP _RADIUS , new Blockly . utils . Coordinate ( c ,
d ) ) . connection ) { a = ! 0 ; break } } a && ( c = this . RTL ? c - Blockly . SNAP _RADIUS : c + Blockly . SNAP _RADIUS , d += 2 * Blockly . SNAP _RADIUS ) } while ( a ) ; b . moveBy ( c , d ) } } finally { Blockly . Events . enable ( ) } Blockly . Events . isEnabled ( ) && ! b . isShadow ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CREATE ) ) ( b ) ) ; b . select ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . pasteWorkspaceComment _ = function ( a ) { Blockly . Events . disable ( ) ; try { var b = Blockly . WorkspaceCommentSvg . fromXml ( a , this ) , c = parseInt ( a . getAttribute ( "x" ) , 10 ) , d = parseInt ( a . getAttribute ( "y" ) , 10 ) ; isNaN ( c ) || isNaN ( d ) || ( this . RTL && ( c = - c ) , b . moveBy ( c + 50 , d + 50 ) ) } finally { Blockly . Events . enable ( ) } Blockly . Events . isEnabled ( ) && Blockly . WorkspaceComment . fireCreateEvent ( b ) ; b . select ( ) } ;
Blockly . WorkspaceSvg . prototype . refreshToolboxSelection = function ( ) { var a = this . isFlyout ? this . targetWorkspace : this ; a && ! a . currentGesture _ && a . toolbox _ && a . toolbox _ . getFlyout ( ) && a . toolbox _ . refreshSelection ( ) } ; Blockly . WorkspaceSvg . prototype . renameVariableById = function ( a , b ) { Blockly . WorkspaceSvg . superClass _ . renameVariableById . call ( this , a , b ) ; this . refreshToolboxSelection ( ) } ; Blockly . WorkspaceSvg . prototype . deleteVariableById = function ( a ) { Blockly . WorkspaceSvg . superClass _ . deleteVariableById . call ( this , a ) ; this . refreshToolboxSelection ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . WorkspaceSvg . prototype . createVariable = function ( a , b , c ) { a = Blockly . WorkspaceSvg . superClass _ . createVariable . call ( this , a , b , c ) ; this . refreshToolboxSelection ( ) ; return a } ; Blockly . WorkspaceSvg . prototype . recordDeleteAreas = function ( ) { Blockly . utils . deprecation . warn ( "WorkspaceSvg.prototype.recordDeleteAreas" , "June 2021" , "June 2022" , "WorkspaceSvg.prototype.recordDragTargets" ) ; this . recordDragTargets ( ) } ;
Blockly . WorkspaceSvg . prototype . recordDragTargets = function ( ) { var a = this . componentManager _ . getComponents ( Blockly . ComponentManager . Capability . DRAG _TARGET , ! 0 ) ; this . dragTargetAreas _ = [ ] ; for ( var b = 0 , c ; c = a [ b ] ; b ++ ) { var d = c . getClientRect ( ) ; d && this . dragTargetAreas _ . push ( { component : c , clientRect : d } ) } } ; Blockly . WorkspaceSvg . prototype . getDragTarget = function ( a ) { for ( var b = 0 , c ; c = this . dragTargetAreas _ [ b ] ; b ++ ) if ( c . clientRect . contains ( a . clientX , a . clientY ) ) return c . component ; return null } ;
Blockly . WorkspaceSvg . prototype . onMouseDown _ = function ( a ) { var b = this . getGesture ( a ) ; b && b . handleWsStart ( a , this ) } ; Blockly . WorkspaceSvg . prototype . startDrag = function ( a , b ) { a = Blockly . utils . mouseToSvg ( a , this . getParentSvg ( ) , this . getInverseScreenCTM ( ) ) ; a . x /= this . scale ; a . y /= this . scale ; this . dragDeltaXY _ = Blockly . utils . Coordinate . difference ( b , a ) } ;
Blockly . WorkspaceSvg . prototype . moveDrag = function ( a ) { a = Blockly . utils . mouseToSvg ( a , this . getParentSvg ( ) , this . getInverseScreenCTM ( ) ) ; a . x /= this . scale ; a . y /= this . scale ; return Blockly . utils . Coordinate . sum ( this . dragDeltaXY _ , a ) } ; Blockly . WorkspaceSvg . prototype . isDragging = function ( ) { return null != this . currentGesture _ && this . currentGesture _ . isDragging ( ) } ; Blockly . WorkspaceSvg . prototype . isDraggable = function ( ) { return this . options . moveOptions && this . options . moveOptions . drag } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . isMovable = function ( ) { return this . options . moveOptions && ! ! this . options . moveOptions . scrollbars || this . options . moveOptions && this . options . moveOptions . wheel || this . options . moveOptions && this . options . moveOptions . drag || this . options . zoomOptions && this . options . zoomOptions . wheel || this . options . zoomOptions && this . options . zoomOptions . pinch } ; Blockly . WorkspaceSvg . prototype . isMovableHorizontally = function ( ) { var a = ! ! this . scrollbar ; return this . isMovable ( ) && ( ! a || a && this . scrollbar . canScrollHorizontally ( ) ) } ;
Blockly . WorkspaceSvg . prototype . isMovableVertically = function ( ) { var a = ! ! this . scrollbar ; return this . isMovable ( ) && ( ! a || a && this . scrollbar . canScrollVertically ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . onMouseWheel _ = function ( a ) { if ( Blockly . Gesture . inProgress ( ) ) a . preventDefault ( ) , a . stopPropagation ( ) ; else { var b = this . options . zoomOptions && this . options . zoomOptions . wheel , c = this . options . moveOptions && this . options . moveOptions . wheel ; if ( b || c ) { var d = Blockly . utils . getScrollDeltaPixels ( a ) ; ! b || ! a . ctrlKey && c ? ( b = this . scrollX - d . x , c = this . scrollY - d . y , a . shiftKey && ! d . x && ( b = this . scrollX - d . y , c = this . scrollY ) , this . scroll ( b , c ) ) : ( d = - d . y / 50 , b = Blockly . utils . mouseToSvg ( a , this . getParentSvg ( ) , this . getInverseScreenCTM ( ) ) ,
2021-05-19 13:38:55 +00:00
this . zoom ( b . x , b . y , d ) ) ; a . preventDefault ( ) } } } ; Blockly . WorkspaceSvg . prototype . getBlocksBoundingBox = function ( ) { var a = this . getTopBoundedElements ( ) ; if ( ! a . length ) return new Blockly . utils . Rect ( 0 , 0 , 0 , 0 ) ; for ( var b = a [ 0 ] . getBoundingRectangle ( ) , c = 1 ; c < a . length ; c ++ ) { var d = a [ c ] ; d . isInsertionMarker && d . isInsertionMarker ( ) || ( d = d . getBoundingRectangle ( ) , d . top < b . top && ( b . top = d . top ) , d . bottom > b . bottom && ( b . bottom = d . bottom ) , d . left < b . left && ( b . left = d . left ) , d . right > b . right && ( b . right = d . right ) ) } return b } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . cleanUp = function ( ) { this . setResizesEnabled ( ! 1 ) ; Blockly . Events . setGroup ( ! 0 ) ; for ( var a = this . getTopBlocks ( ! 0 ) , b = 0 , c = 0 , d ; d = a [ c ] ; c ++ ) if ( d . isMovable ( ) ) { var e = d . getRelativeToSurfaceXY ( ) ; d . moveBy ( - e . x , b - e . y ) ; d . snapToGrid ( ) ; b = d . getRelativeToSurfaceXY ( ) . y + d . getHeightWidth ( ) . height + this . renderer _ . getConstants ( ) . MIN _BLOCK _HEIGHT } Blockly . Events . setGroup ( ! 1 ) ; this . setResizesEnabled ( ! 0 ) } ;
Blockly . WorkspaceSvg . prototype . showContextMenu = function ( a ) { if ( ! this . options . readOnly && ! this . isFlyout ) { var b = Blockly . ContextMenuRegistry . registry . getContextMenuOptions ( Blockly . ContextMenuRegistry . ScopeType . WORKSPACE , { workspace : this } ) ; this . configureContextMenu && this . configureContextMenu ( b , a ) ; Blockly . ContextMenu . show ( a , b , this . RTL ) } } ;
Blockly . WorkspaceSvg . prototype . updateToolbox = function ( a ) { if ( a = Blockly . utils . toolbox . convertToolboxDefToJson ( a ) ) { if ( ! this . options . languageTree ) throw Error ( "Existing toolbox is null. Can't create new toolbox." ) ; if ( Blockly . utils . toolbox . hasCategories ( a ) ) { if ( ! this . toolbox _ ) throw Error ( "Existing toolbox has no categories. Can't change mode." ) ; this . options . languageTree = a ; this . toolbox _ . render ( a ) } else { if ( ! this . flyout _ ) throw Error ( "Existing toolbox has categories. Can't change mode." ) ; this . options . languageTree =
a ; this . flyout _ . show ( a ) } } else if ( this . options . languageTree ) throw Error ( "Can't nullify an existing toolbox." ) ; } ; Blockly . WorkspaceSvg . prototype . markFocused = function ( ) { this . options . parentWorkspace ? this . options . parentWorkspace . markFocused ( ) : ( Blockly . mainWorkspace = this , this . setBrowserFocus ( ) ) } ; Blockly . WorkspaceSvg . prototype . setBrowserFocus = function ( ) { document . activeElement && document . activeElement . blur && document . activeElement . blur ( ) ; try { this . getParentSvg ( ) . focus ( { preventScroll : ! 0 } ) } catch ( a ) { try { this . getParentSvg ( ) . parentNode . setActive ( ) } catch ( b ) { this . getParentSvg ( ) . parentNode . focus ( { preventScroll : ! 0 } ) } } } ;
Blockly . WorkspaceSvg . prototype . zoom = function ( a , b , c ) { c = Math . pow ( this . options . zoomOptions . scaleSpeed , c ) ; var d = this . scale * c ; if ( this . scale != d ) { d > this . options . zoomOptions . maxScale ? c = this . options . zoomOptions . maxScale / this . scale : d < this . options . zoomOptions . minScale && ( c = this . options . zoomOptions . minScale / this . scale ) ; var e = this . getCanvas ( ) . getCTM ( ) , f = this . getParentSvg ( ) . createSVGPoint ( ) ; f . x = a ; f . y = b ; f = f . matrixTransform ( e . inverse ( ) ) ; a = f . x ; b = f . y ; e = e . translate ( a * ( 1 - c ) , b * ( 1 - c ) ) . scale ( c ) ; this . scrollX = e . e ; this . scrollY =
e . f ; this . setScale ( d ) } } ; Blockly . WorkspaceSvg . prototype . zoomCenter = function ( a ) { var b = this . getMetrics ( ) ; if ( this . flyout _ ) { var c = b . svgWidth ? b . svgWidth / 2 : 0 ; b = b . svgHeight ? b . svgHeight / 2 : 0 } else c = b . viewWidth / 2 + b . absoluteLeft , b = b . viewHeight / 2 + b . absoluteTop ; this . zoom ( c , b , a ) } ;
Blockly . WorkspaceSvg . prototype . zoomToFit = function ( ) { if ( this . isMovable ( ) ) { var a = this . getMetrics ( ) , b = a . viewWidth ; a = a . viewHeight ; var c = this . getBlocksBoundingBox ( ) , d = c . right - c . left ; c = c . bottom - c . top ; if ( d ) { this . flyout _ && ( this . horizontalLayout ? ( a += this . flyout _ . getHeight ( ) , c += this . flyout _ . getHeight ( ) / this . scale ) : ( b += this . flyout _ . getWidth ( ) , d += this . flyout _ . getWidth ( ) / this . scale ) ) ; b /= d ; a /= c ; Blockly . Events . disable ( ) ; try { this . setScale ( Math . min ( b , a ) ) , this . scrollCenter ( ) } finally { Blockly . Events . enable ( ) } this . maybeFireViewportChangeEvent ( ) } } else console . warn ( "Tried to move a non-movable workspace. This could result in blocks becoming inaccessible." ) } ;
Blockly . WorkspaceSvg . prototype . beginCanvasTransition = function ( ) { Blockly . utils . dom . addClass ( this . svgBlockCanvas _ , "blocklyCanvasTransitioning" ) ; Blockly . utils . dom . addClass ( this . svgBubbleCanvas _ , "blocklyCanvasTransitioning" ) } ; Blockly . WorkspaceSvg . prototype . endCanvasTransition = function ( ) { Blockly . utils . dom . removeClass ( this . svgBlockCanvas _ , "blocklyCanvasTransitioning" ) ; Blockly . utils . dom . removeClass ( this . svgBubbleCanvas _ , "blocklyCanvasTransitioning" ) } ;
2021-05-19 13:38:55 +00:00
Blockly . WorkspaceSvg . prototype . scrollCenter = function ( ) { if ( this . isMovable ( ) ) { var a = this . getMetrics ( ) , b = ( a . scrollWidth - a . viewWidth ) / 2 , c = ( a . scrollHeight - a . viewHeight ) / 2 ; b = - b - a . scrollLeft ; c = - c - a . scrollTop ; this . scroll ( b , c ) } else console . warn ( "Tried to move a non-movable workspace. This could result in blocks becoming inaccessible." ) } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . centerOnBlock = function ( a ) { if ( this . isMovable ( ) ) { if ( a = a ? this . getBlockById ( a ) : null ) { var b = a . getRelativeToSurfaceXY ( ) , c = a . getHeightWidth ( ) , d = this . scale ; a = ( b . x + ( this . RTL ? - 1 : 1 ) * c . width / 2 ) * d ; b = ( b . y + c . height / 2 ) * d ; c = this . getMetrics ( ) ; this . scroll ( - ( a - c . viewWidth / 2 ) , - ( b - c . viewHeight / 2 ) ) } } else console . warn ( "Tried to move a non-movable workspace. This could result in blocks becoming inaccessible." ) } ;
2021-09-18 14:29:06 +00:00
Blockly . WorkspaceSvg . prototype . setScale = function ( a ) { this . options . zoomOptions . maxScale && a > this . options . zoomOptions . maxScale ? a = this . options . zoomOptions . maxScale : this . options . zoomOptions . minScale && a < this . options . zoomOptions . minScale && ( a = this . options . zoomOptions . minScale ) ; this . scale = a ; Blockly . hideChaff ( ! 1 ) ; this . flyout _ && ( this . flyout _ . reflow ( ) , this . recordDragTargets ( ) ) ; this . grid _ && this . grid _ . update ( this . scale ) ; a = this . getMetrics ( ) ; this . scrollX -= a . absoluteLeft ; this . scrollY -= a . absoluteTop ; a . viewLeft += a . absoluteLeft ;
2021-05-19 13:38:55 +00:00
a . viewTop += a . absoluteTop ; this . scroll ( this . scrollX , this . scrollY ) ; this . scrollbar && ( this . flyout _ ? this . scrollbar . resizeView ( a ) : this . scrollbar . resizeContent ( a ) ) } ; Blockly . WorkspaceSvg . prototype . getScale = function ( ) { return this . options . parentWorkspace ? this . options . parentWorkspace . getScale ( ) : this . scale } ;
Blockly . WorkspaceSvg . prototype . scroll = function ( a , b ) { Blockly . hideChaff ( ! 0 ) ; var c = this . getMetrics ( ) ; a = Math . min ( a , - c . scrollLeft ) ; b = Math . min ( b , - c . scrollTop ) ; var d = c . scrollTop + Math . max ( 0 , c . scrollHeight - c . viewHeight ) ; a = Math . max ( a , - ( c . scrollLeft + Math . max ( 0 , c . scrollWidth - c . viewWidth ) ) ) ; b = Math . max ( b , - d ) ; this . scrollX = a ; this . scrollY = b ; this . scrollbar && this . scrollbar . set ( - ( a + c . scrollLeft ) , - ( b + c . scrollTop ) , ! 1 ) ; a += c . absoluteLeft ; b += c . absoluteTop ; this . translate ( a , b ) } ;
Blockly . WorkspaceSvg . setTopLevelWorkspaceMetrics _ = function ( a ) { var b = this . getMetrics ( ) ; "number" == typeof a . x && ( this . scrollX = - ( b . scrollLeft + ( b . scrollWidth - b . viewWidth ) * a . x ) ) ; "number" == typeof a . y && ( this . scrollY = - ( b . scrollTop + ( b . scrollHeight - b . viewHeight ) * a . y ) ) ; this . translate ( this . scrollX + b . absoluteLeft , this . scrollY + b . absoluteTop ) } ; Blockly . WorkspaceSvg . prototype . getBlockById = function ( a ) { return Blockly . WorkspaceSvg . superClass _ . getBlockById . call ( this , a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . WorkspaceSvg . prototype . getTopBlocks = function ( a ) { return Blockly . WorkspaceSvg . superClass _ . getTopBlocks . call ( this , a ) } ; Blockly . WorkspaceSvg . prototype . addTopBlock = function ( a ) { this . addTopBoundedElement ( a ) ; Blockly . WorkspaceSvg . superClass _ . addTopBlock . call ( this , a ) } ; Blockly . WorkspaceSvg . prototype . removeTopBlock = function ( a ) { this . removeTopBoundedElement ( a ) ; Blockly . WorkspaceSvg . superClass _ . removeTopBlock . call ( this , a ) } ;
Blockly . WorkspaceSvg . prototype . addTopComment = function ( a ) { this . addTopBoundedElement ( a ) ; Blockly . WorkspaceSvg . superClass _ . addTopComment . call ( this , a ) } ; Blockly . WorkspaceSvg . prototype . removeTopComment = function ( a ) { this . removeTopBoundedElement ( a ) ; Blockly . WorkspaceSvg . superClass _ . removeTopComment . call ( this , a ) } ; Blockly . WorkspaceSvg . prototype . addTopBoundedElement = function ( a ) { this . topBoundedElements _ . push ( a ) } ;
Blockly . WorkspaceSvg . prototype . removeTopBoundedElement = function ( a ) { Blockly . utils . arrayRemove ( this . topBoundedElements _ , a ) } ; Blockly . WorkspaceSvg . prototype . getTopBoundedElements = function ( ) { return [ ] . concat ( this . topBoundedElements _ ) } ; Blockly . WorkspaceSvg . prototype . setResizesEnabled = function ( a ) { var b = ! this . resizesEnabled _ && a ; this . resizesEnabled _ = a ; b && this . resizeContents ( ) } ;
Blockly . WorkspaceSvg . prototype . clear = function ( ) { this . setResizesEnabled ( ! 1 ) ; Blockly . WorkspaceSvg . superClass _ . clear . call ( this ) ; this . topBoundedElements _ = [ ] ; this . setResizesEnabled ( ! 0 ) } ; Blockly . WorkspaceSvg . prototype . registerButtonCallback = function ( a , b ) { if ( "function" != typeof b ) throw TypeError ( "Button callbacks must be functions." ) ; this . flyoutButtonCallbacks _ [ a ] = b } ; Blockly . WorkspaceSvg . prototype . getButtonCallback = function ( a ) { return ( a = this . flyoutButtonCallbacks _ [ a ] ) ? a : null } ;
Blockly . WorkspaceSvg . prototype . removeButtonCallback = function ( a ) { this . flyoutButtonCallbacks _ [ a ] = null } ; Blockly . WorkspaceSvg . prototype . registerToolboxCategoryCallback = function ( a , b ) { if ( "function" != typeof b ) throw TypeError ( "Toolbox category callbacks must be functions." ) ; this . toolboxCategoryCallbacks _ [ a ] = b } ; Blockly . WorkspaceSvg . prototype . getToolboxCategoryCallback = function ( a ) { return this . toolboxCategoryCallbacks _ [ a ] || null } ;
Blockly . WorkspaceSvg . prototype . removeToolboxCategoryCallback = function ( a ) { this . toolboxCategoryCallbacks _ [ a ] = null } ; Blockly . WorkspaceSvg . prototype . getGesture = function ( a ) { var b = "mousedown" == a . type || "touchstart" == a . type || "pointerdown" == a . type , c = this . currentGesture _ ; return c ? b && c . hasStarted ( ) ? ( console . warn ( "Tried to start the same gesture twice." ) , c . cancel ( ) , null ) : c : b ? this . currentGesture _ = new Blockly . TouchGesture ( a , this ) : null } ;
Blockly . WorkspaceSvg . prototype . clearGesture = function ( ) { this . currentGesture _ = null } ; Blockly . WorkspaceSvg . prototype . cancelCurrentGesture = function ( ) { this . currentGesture _ && this . currentGesture _ . cancel ( ) } ; Blockly . WorkspaceSvg . prototype . getAudioManager = function ( ) { return this . audioManager _ } ; Blockly . WorkspaceSvg . prototype . getGrid = function ( ) { return this . grid _ } ; Blockly . inject = function ( a , b ) { Blockly . checkBlockColourConstants ( ) ; "string" == typeof a && ( a = document . getElementById ( a ) || document . querySelector ( a ) ) ; if ( ! a || ! Blockly . utils . dom . containsNode ( document , a ) ) throw Error ( "Error: container is not in current document." ) ; b = new Blockly . Options ( b || { } ) ; var c = document . createElement ( "div" ) ; c . className = "injectionDiv" ; c . tabIndex = 0 ; Blockly . utils . aria . setState ( c , Blockly . utils . aria . State . LABEL , Blockly . Msg . WORKSPACE _ARIA _LABEL ) ; a . appendChild ( c ) ; a = Blockly . createDom _ ( c , b ) ; var d =
new Blockly . BlockDragSurfaceSvg ( c ) , e = new Blockly . WorkspaceDragSurfaceSvg ( c ) , f = Blockly . createMainWorkspace _ ( a , b , d , e ) ; Blockly . init _ ( f ) ; Blockly . mainWorkspace = f ; Blockly . svgResize ( f ) ; c . addEventListener ( "focusin" , function ( ) { Blockly . mainWorkspace = f } ) ; return f } ;
Blockly . createDom _ = function ( a , b ) { a . setAttribute ( "dir" , "LTR" ) ; Blockly . Css . inject ( b . hasCss , b . pathToMedia ) ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { xmlns : Blockly . utils . dom . SVG _NS , "xmlns:html" : Blockly . utils . dom . HTML _NS , "xmlns:xlink" : Blockly . utils . dom . XLINK _NS , version : "1.1" , "class" : "blocklySvg" , tabindex : "0" } , a ) ; var c = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . DEFS , { } , a ) , d = String ( Math . random ( ) ) . substring ( 2 ) ; b . gridPattern = Blockly . Grid . createDom ( d , b . gridOptions , c ) ; return a } ;
2021-05-19 13:38:55 +00:00
Blockly . createMainWorkspace _ = function ( a , b , c , d ) { b . parentWorkspace = null ; b = new Blockly . WorkspaceSvg ( b , c , d ) ; c = b . options ; b . scale = c . zoomOptions . startScale ; a . appendChild ( b . createDom ( "blocklyMainBackground" ) ) ; Blockly . utils . dom . addClass ( b . getInjectionDiv ( ) , b . getRenderer ( ) . getClassName ( ) ) ; Blockly . utils . dom . addClass ( b . getInjectionDiv ( ) , b . getTheme ( ) . getClassName ( ) ) ; ! c . hasCategories && c . languageTree && ( d = b . addFlyout ( Blockly . utils . Svg . SVG ) , Blockly . utils . dom . insertAfter ( d , a ) ) ; c . hasTrashcan && b . addTrashcan ( ) ; c . zoomOptions &&
c . zoomOptions . controls && b . addZoomControls ( ) ; b . getThemeManager ( ) . subscribe ( a , "workspaceBackgroundColour" , "background-color" ) ; b . translate ( 0 , 0 ) ; b . addChangeListener ( Blockly . bumpIntoBoundsHandler _ ( b ) ) ; Blockly . svgResize ( b ) ; Blockly . WidgetDiv . createDom ( ) ; Blockly . DropDownDiv . createDom ( ) ; Blockly . Tooltip . createDom ( ) ; return b } ;
Blockly . extractObjectFromEvent _ = function ( a , b ) { var c = null ; switch ( b . type ) { case Blockly . Events . BLOCK _CREATE : case Blockly . Events . BLOCK _MOVE : ( c = a . getBlockById ( b . blockId ) ) && ( c = c . getRootBlock ( ) ) ; break ; case Blockly . Events . COMMENT _CREATE : case Blockly . Events . COMMENT _MOVE : c = a . getCommentById ( b . commentId ) } return c } ;
Blockly . bumpTopObjectsIntoBounds _ = function ( a ) { var b = a . getMetricsManager ( ) ; if ( b . hasFixedEdges ( ) && ! a . isDragging ( ) ) { b = b . getScrollMetrics ( ! 0 ) ; for ( var c = a . getTopBoundedElements ( ) , d = 0 , e ; e = c [ d ] ; d ++ ) Blockly . bumpObjectIntoBounds _ ( a , b , e ) } } ;
2021-09-18 14:29:06 +00:00
Blockly . bumpIntoBoundsHandler _ = function ( a ) { return function ( b ) { var c = a . getMetricsManager ( ) ; if ( c . hasFixedEdges ( ) && ! a . isDragging ( ) ) if ( - 1 !== Blockly . Events . BUMP _EVENTS . indexOf ( b . type ) ) { c = c . getScrollMetrics ( ! 0 ) ; var d = Blockly . extractObjectFromEvent _ ( a , b ) ; if ( d ) { var e = Blockly . Events . getGroup ( ) ; Blockly . Events . setGroup ( b . group ) ; Blockly . bumpObjectIntoBounds _ ( a , c , d ) && ! b . group && console . warn ( "Moved object in bounds but there was no event group. This may break undo." ) ; null !== e && Blockly . Events . setGroup ( e ) } } else b . type ===
2021-05-19 13:38:55 +00:00
Blockly . Events . VIEWPORT _CHANGE && b . scale > b . oldScale && Blockly . bumpTopObjectsIntoBounds _ ( a ) } } ; Blockly . bumpObjectIntoBounds _ = function ( a , b , c ) { var d = c . getBoundingRectangle ( ) , e = d . right - d . left , f = Blockly . utils . math . clamp ( b . top , d . top , b . top + b . height - ( d . bottom - d . top ) ) - d . top , g = b . left ; b = b . left + b . width - e ; a . RTL ? g = Math . min ( b , g ) : b = Math . max ( g , b ) ; return ( a = Blockly . utils . math . clamp ( g , d . left , b ) - d . left ) || f ? ( c . moveBy ( a , f ) , ! 0 ) : ! 1 } ;
Blockly . init _ = function ( a ) { var b = a . options , c = a . getParentSvg ( ) ; Blockly . browserEvents . conditionalBind ( c . parentNode , "contextmenu" , null , function ( e ) { Blockly . utils . isTargetInput ( e ) || e . preventDefault ( ) } ) ; c = Blockly . browserEvents . conditionalBind ( window , "resize" , null , function ( ) { Blockly . hideChaff ( ! 0 ) ; Blockly . svgResize ( a ) ; Blockly . bumpTopObjectsIntoBounds _ ( a ) } ) ; a . setResizeHandlerWrapper ( c ) ; Blockly . inject . bindDocumentEvents _ ( ) ; if ( b . languageTree ) { c = a . getToolbox ( ) ; var d = a . getFlyout ( ! 0 ) ; c ? c . init ( ) : d && ( d . init ( a ) , d . show ( b . languageTree ) ,
2021-09-18 14:29:06 +00:00
"function" == typeof d . scrollToStart && d . scrollToStart ( ) ) } b . hasTrashcan && a . trashcan . init ( ) ; b . zoomOptions && b . zoomOptions . controls && a . zoomControls _ . init ( ) ; b . moveOptions && b . moveOptions . scrollbars ? ( a . scrollbar = new Blockly . ScrollbarPair ( a , ! 0 === b . moveOptions . scrollbars || ! ! b . moveOptions . scrollbars . horizontal , ! 0 === b . moveOptions . scrollbars || ! ! b . moveOptions . scrollbars . vertical , "blocklyMainWorkspaceScrollbar" ) , a . scrollbar . resize ( ) ) : a . setMetrics ( { x : . 5 , y : . 5 } ) ; b . hasSounds && Blockly . inject . loadSounds _ ( b . pathToMedia ,
a ) } ;
Blockly . inject . bindDocumentEvents _ = function ( ) { Blockly . documentEventsBound _ || ( Blockly . browserEvents . conditionalBind ( document , "scroll" , null , function ( ) { for ( var a = Blockly . Workspace . getAll ( ) , b = 0 , c ; c = a [ b ] ; b ++ ) c . updateInverseScreenCTM && c . updateInverseScreenCTM ( ) } ) , Blockly . browserEvents . conditionalBind ( document , "keydown" , null , Blockly . onKeyDown ) , Blockly . browserEvents . bind ( document , "touchend" , null , Blockly . longStop _ ) , Blockly . browserEvents . bind ( document , "touchcancel" , null , Blockly . longStop _ ) , Blockly . utils . userAgent . IPAD && Blockly . browserEvents . conditionalBind ( window ,
"orientationchange" , document , function ( ) { Blockly . svgResize ( Blockly . getMainWorkspace ( ) ) } ) ) ; Blockly . documentEventsBound _ = ! 0 } ;
2021-05-19 13:38:55 +00:00
Blockly . inject . loadSounds _ = function ( a , b ) { var c = b . getAudioManager ( ) ; c . load ( [ a + "click.mp3" , a + "click.wav" , a + "click.ogg" ] , "click" ) ; c . load ( [ a + "disconnect.wav" , a + "disconnect.mp3" , a + "disconnect.ogg" ] , "disconnect" ) ; c . load ( [ a + "delete.mp3" , a + "delete.ogg" , a + "delete.wav" ] , "delete" ) ; var d = [ ] ; a = function ( ) { for ( ; d . length ; ) Blockly . browserEvents . unbind ( d . pop ( ) ) ; c . preload ( ) } ; d . push ( Blockly . browserEvents . conditionalBind ( document , "mousemove" , null , a , ! 0 ) ) ; d . push ( Blockly . browserEvents . conditionalBind ( document , "touchstart" ,
null , a , ! 0 ) ) } ; Blockly . Names = function ( a , b ) { this . variablePrefix _ = b || "" ; this . reservedDict _ = Object . create ( null ) ; if ( a ) for ( a = a . split ( "," ) , b = 0 ; b < a . length ; b ++ ) this . reservedDict _ [ a [ b ] ] = ! 0 ; this . reset ( ) } ; Blockly . Names . DEVELOPER _VARIABLE _TYPE = "DEVELOPER_VARIABLE" ; Blockly . Names . prototype . reset = function ( ) { this . db _ = Object . create ( null ) ; this . dbReverse _ = Object . create ( null ) ; this . variableMap _ = null } ; Blockly . Names . prototype . setVariableMap = function ( a ) { this . variableMap _ = a } ;
2021-09-18 14:29:06 +00:00
Blockly . Names . prototype . getNameForUserVariable _ = function ( a ) { return this . variableMap _ ? ( a = this . variableMap _ . getVariableById ( a ) ) ? a . name : null : ( console . warn ( "Deprecated call to Blockly.Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:\nBlockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());" ) , null ) } ;
Blockly . Names . prototype . populateVariables = function ( a ) { a = Blockly . Variables . allUsedVarModels ( a ) ; for ( var b = 0 ; b < a . length ; b ++ ) this . getName ( a [ b ] . getId ( ) , Blockly . VARIABLE _CATEGORY _NAME ) } ; Blockly . Names . prototype . populateProcedures = function ( a ) { a = Blockly . Procedures . allProcedures ( a ) ; a = a [ 0 ] . concat ( a [ 1 ] ) ; for ( var b = 0 ; b < a . length ; b ++ ) this . getName ( a [ b ] [ 0 ] , Blockly . PROCEDURE _CATEGORY _NAME ) } ;
Blockly . Names . prototype . getName = function ( a , b ) { var c = a ; b == Blockly . VARIABLE _CATEGORY _NAME && ( a = this . getNameForUserVariable _ ( a ) ) && ( c = a ) ; a = c . toLowerCase ( ) ; var d = b == Blockly . VARIABLE _CATEGORY _NAME || b == Blockly . Names . DEVELOPER _VARIABLE _TYPE ? this . variablePrefix _ : "" ; b in this . db _ || ( this . db _ [ b ] = Object . create ( null ) ) ; var e = this . db _ [ b ] ; if ( a in e ) return d + e [ a ] ; b = this . getDistinctName ( c , b ) ; e [ a ] = b . substr ( d . length ) ; return b } ; Blockly . Names . prototype . getUserNames = function ( a ) { return Object . keys ( this . db _ [ a ] || { } ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Names . prototype . getDistinctName = function ( a , b ) { a = this . safeName _ ( a ) ; for ( var c = "" ; this . dbReverse _ [ a + c ] || a + c in this . reservedDict _ ; ) c = c ? c + 1 : 2 ; a += c ; this . dbReverse _ [ a ] = ! 0 ; return ( b == Blockly . VARIABLE _CATEGORY _NAME || b == Blockly . Names . DEVELOPER _VARIABLE _TYPE ? this . variablePrefix _ : "" ) + a } ; Blockly . Names . prototype . safeName _ = function ( a ) { a ? ( a = encodeURI ( a . replace ( / /g , "_" ) ) . replace ( /[^\w]/g , "_" ) , - 1 != "0123456789" . indexOf ( a [ 0 ] ) && ( a = "my_" + a ) ) : a = Blockly . Msg . UNNAMED _KEY || "unnamed" ; return a } ;
Blockly . Names . equals = function ( a , b ) { return a . toLowerCase ( ) == b . toLowerCase ( ) } ; Blockly . Procedures = { } ; Blockly . Procedures . NAME _TYPE = Blockly . PROCEDURE _CATEGORY _NAME ; Blockly . Procedures . DEFAULT _ARG = "x" ; Blockly . Procedures . allProcedures = function ( a ) { var b = a . getBlocksByType ( "procedures_defnoreturn" , ! 1 ) . map ( function ( c ) { return c . getProcedureDef ( ) } ) ; a = a . getBlocksByType ( "procedures_defreturn" , ! 1 ) . map ( function ( c ) { return c . getProcedureDef ( ) } ) ; b . sort ( Blockly . Procedures . procTupleComparator _ ) ; a . sort ( Blockly . Procedures . procTupleComparator _ ) ; return [ b , a ] } ;
2021-09-18 14:29:06 +00:00
Blockly . Procedures . procTupleComparator _ = function ( a , b ) { return a [ 0 ] . localeCompare ( b [ 0 ] , void 0 , { sensitivity : "base" } ) } ; Blockly . Procedures . findLegalName = function ( a , b ) { if ( b . isInFlyout ) return a ; for ( a = a || Blockly . Msg . UNNAMED _KEY || "unnamed" ; ! Blockly . Procedures . isLegalName _ ( a , b . workspace , b ) ; ) { var c = a . match ( /^(.*?)(\d+)$/ ) ; a = c ? c [ 1 ] + ( parseInt ( c [ 2 ] , 10 ) + 1 ) : a + "2" } return a } ; Blockly . Procedures . isLegalName _ = function ( a , b , c ) { return ! Blockly . Procedures . isNameUsed ( a , b , c ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Procedures . isNameUsed = function ( a , b , c ) { b = b . getAllBlocks ( ! 1 ) ; for ( var d = 0 ; d < b . length ; d ++ ) if ( b [ d ] != c && b [ d ] . getProcedureDef ) { var e = b [ d ] . getProcedureDef ( ) ; if ( Blockly . Names . equals ( e [ 0 ] , a ) ) return ! 0 } return ! 1 } ; Blockly . Procedures . rename = function ( a ) { a = a . trim ( ) ; var b = Blockly . Procedures . findLegalName ( a , this . getSourceBlock ( ) ) , c = this . getValue ( ) ; if ( c != a && c != b ) { a = this . getSourceBlock ( ) . workspace . getAllBlocks ( ! 1 ) ; for ( var d = 0 ; d < a . length ; d ++ ) a [ d ] . renameProcedure && a [ d ] . renameProcedure ( c , b ) } return b } ;
Blockly . Procedures . flyoutCategory = function ( a ) { function b ( f , g ) { for ( var h = 0 ; h < f . length ; h ++ ) { var k = f [ h ] [ 0 ] , l = f [ h ] [ 1 ] , m = Blockly . utils . xml . createElement ( "block" ) ; m . setAttribute ( "type" , g ) ; m . setAttribute ( "gap" , 16 ) ; var n = Blockly . utils . xml . createElement ( "mutation" ) ; n . setAttribute ( "name" , k ) ; m . appendChild ( n ) ; for ( k = 0 ; k < l . length ; k ++ ) { var p = Blockly . utils . xml . createElement ( "arg" ) ; p . setAttribute ( "name" , l [ k ] ) ; n . appendChild ( p ) } c . push ( m ) } } var c = [ ] ; if ( Blockly . Blocks . procedures _defnoreturn ) { var d = Blockly . utils . xml . createElement ( "block" ) ;
d . setAttribute ( "type" , "procedures_defnoreturn" ) ; d . setAttribute ( "gap" , 16 ) ; var e = Blockly . utils . xml . createElement ( "field" ) ; e . setAttribute ( "name" , "NAME" ) ; e . appendChild ( Blockly . utils . xml . createTextNode ( Blockly . Msg . PROCEDURES _DEFNORETURN _PROCEDURE ) ) ; d . appendChild ( e ) ; c . push ( d ) } Blockly . Blocks . procedures _defreturn && ( d = Blockly . utils . xml . createElement ( "block" ) , d . setAttribute ( "type" , "procedures_defreturn" ) , d . setAttribute ( "gap" , 16 ) , e = Blockly . utils . xml . createElement ( "field" ) , e . setAttribute ( "name" , "NAME" ) , e . appendChild ( Blockly . utils . xml . createTextNode ( Blockly . Msg . PROCEDURES _DEFRETURN _PROCEDURE ) ) ,
d . appendChild ( e ) , c . push ( d ) ) ; Blockly . Blocks . procedures _ifreturn && ( d = Blockly . utils . xml . createElement ( "block" ) , d . setAttribute ( "type" , "procedures_ifreturn" ) , d . setAttribute ( "gap" , 16 ) , c . push ( d ) ) ; c . length && c [ c . length - 1 ] . setAttribute ( "gap" , 24 ) ; a = Blockly . Procedures . allProcedures ( a ) ; b ( a [ 0 ] , "procedures_callnoreturn" ) ; b ( a [ 1 ] , "procedures_callreturn" ) ; return c } ;
Blockly . Procedures . updateMutatorFlyout _ = function ( a ) { for ( var b = [ ] , c = a . getBlocksByType ( "procedures_mutatorarg" , ! 1 ) , d = 0 , e ; e = c [ d ] ; d ++ ) b . push ( e . getFieldValue ( "NAME" ) ) ; c = Blockly . utils . xml . createElement ( "xml" ) ; d = Blockly . utils . xml . createElement ( "block" ) ; d . setAttribute ( "type" , "procedures_mutatorarg" ) ; e = Blockly . utils . xml . createElement ( "field" ) ; e . setAttribute ( "name" , "NAME" ) ; b = Blockly . Variables . generateUniqueNameFromOptions ( Blockly . Procedures . DEFAULT _ARG , b ) ; b = Blockly . utils . xml . createTextNode ( b ) ; e . appendChild ( b ) ;
d . appendChild ( e ) ; c . appendChild ( d ) ; a . updateToolbox ( c ) } ; Blockly . Procedures . mutatorOpenListener = function ( a ) { if ( a . type == Blockly . Events . BUBBLE _OPEN && "mutator" === a . bubbleType && a . isOpen ) { a = Blockly . Workspace . getById ( a . workspaceId ) . getBlockById ( a . blockId ) ; var b = a . type ; if ( "procedures_defnoreturn" == b || "procedures_defreturn" == b ) a = a . mutator . getWorkspace ( ) , Blockly . Procedures . updateMutatorFlyout _ ( a ) , a . addChangeListener ( Blockly . Procedures . mutatorChangeListener _ ) } } ;
Blockly . Procedures . mutatorChangeListener _ = function ( a ) { if ( a . type == Blockly . Events . BLOCK _CREATE || a . type == Blockly . Events . BLOCK _DELETE || a . type == Blockly . Events . BLOCK _CHANGE ) a = Blockly . Workspace . getById ( a . workspaceId ) , Blockly . Procedures . updateMutatorFlyout _ ( a ) } ; Blockly . Procedures . getCallers = function ( a , b ) { var c = [ ] ; b = b . getAllBlocks ( ! 1 ) ; for ( var d = 0 ; d < b . length ; d ++ ) if ( b [ d ] . getProcedureCall ) { var e = b [ d ] . getProcedureCall ( ) ; e && Blockly . Names . equals ( e , a ) && c . push ( b [ d ] ) } return c } ;
2021-05-19 13:38:55 +00:00
Blockly . Procedures . mutateCallers = function ( a ) { var b = Blockly . Events . recordUndo , c = a . getProcedureDef ( ) [ 0 ] , d = a . mutationToDom ( ! 0 ) ; a = Blockly . Procedures . getCallers ( c , a . workspace ) ; c = 0 ; for ( var e ; e = a [ c ] ; c ++ ) { var f = e . mutationToDom ( ) ; f = f && Blockly . Xml . domToText ( f ) ; e . domToMutation ( d ) ; var g = e . mutationToDom ( ) ; g = g && Blockly . Xml . domToText ( g ) ; f != g && ( Blockly . Events . recordUndo = ! 1 , Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( e , "mutation" , null , f , g ) ) , Blockly . Events . recordUndo = b ) } } ;
2021-09-18 14:29:06 +00:00
Blockly . Procedures . getDefinition = function ( a , b ) { b = b . getAllBlocks ( ! 1 ) ; for ( var c = 0 ; c < b . length ; c ++ ) if ( b [ c ] . getProcedureDef ) { var d = b [ c ] . getProcedureDef ( ) ; if ( d && Blockly . Names . equals ( d [ 0 ] , a ) ) return b [ c ] } return null } ; Blockly . ShortcutRegistry = function ( ) { Blockly . ShortcutRegistry . registry = this ; this . registry _ = Object . create ( null ) ; this . keyMap _ = Object . create ( null ) } ; Blockly . ShortcutRegistry . modifierKeys = { Shift : Blockly . utils . KeyCodes . SHIFT , Control : Blockly . utils . KeyCodes . CTRL , Alt : Blockly . utils . KeyCodes . ALT , Meta : Blockly . utils . KeyCodes . META } ; Blockly . ShortcutRegistry . prototype . register = function ( a , b ) { if ( this . registry _ [ a . name ] && ! b ) throw Error ( 'Shortcut with name "' + a . name + '" already exists.' ) ; this . registry _ [ a . name ] = a } ;
2021-05-19 13:38:55 +00:00
Blockly . ShortcutRegistry . prototype . unregister = function ( a ) { if ( ! this . registry _ [ a ] ) return console . warn ( 'Keyboard shortcut with name "' + a + '" not found.' ) , ! 1 ; this . removeAllKeyMappings ( a ) ; delete this . registry _ [ a ] ; return ! 0 } ; Blockly . ShortcutRegistry . prototype . addKeyMapping = function ( a , b , c ) { a = String ( a ) ; var d = this . keyMap _ [ a ] ; if ( d && ! c ) throw Error ( 'Shortcut with name "' + b + '" collides with shortcuts ' + d . toString ( ) ) ; d && c ? d . unshift ( b ) : this . keyMap _ [ a ] = [ b ] } ;
2021-01-16 14:07:51 +00:00
Blockly . ShortcutRegistry . prototype . removeKeyMapping = function ( a , b , c ) { var d = this . keyMap _ [ a ] ; if ( ! d && ! c ) return console . warn ( 'No keyboard shortcut with name "' + b + '" registered with key code "' + a + '"' ) , ! 1 ; var e = d . indexOf ( b ) ; if ( - 1 < e ) return d . splice ( e , 1 ) , 0 == d . length && delete this . keyMap _ [ a ] , ! 0 ; c || console . warn ( 'No keyboard shortcut with name "' + b + '" registered with key code "' + a + '"' ) ; return ! 1 } ;
Blockly . ShortcutRegistry . prototype . removeAllKeyMappings = function ( a ) { for ( var b in this . keyMap _ ) this . removeKeyMapping ( b , a , ! 0 ) } ; Blockly . ShortcutRegistry . prototype . setKeyMap = function ( a ) { this . keyMap _ = a } ; Blockly . ShortcutRegistry . prototype . getKeyMap = function ( ) { return Blockly . utils . object . deepMerge ( Object . create ( null ) , this . keyMap _ ) } ; Blockly . ShortcutRegistry . prototype . getRegistry = function ( ) { return Blockly . utils . object . deepMerge ( Object . create ( null ) , this . registry _ ) } ;
Blockly . ShortcutRegistry . prototype . onKeyDown = function ( a , b ) { var c = this . serializeKeyEvent _ ( b ) ; c = this . getShortcutNamesByKeyCode ( c ) ; if ( ! c ) return ! 1 ; for ( var d = 0 , e ; e = c [ d ] ; d ++ ) if ( e = this . registry _ [ e ] , ( ! e . preconditionFn || e . preconditionFn ( a ) ) && e . callback && e . callback ( a , b , e ) ) return ! 0 ; return ! 1 } ; Blockly . ShortcutRegistry . prototype . getShortcutNamesByKeyCode = function ( a ) { return this . keyMap _ [ a ] || [ ] } ;
Blockly . ShortcutRegistry . prototype . getKeyCodesByShortcutName = function ( a ) { var b = [ ] , c ; for ( c in this . keyMap _ ) - 1 < this . keyMap _ [ c ] . indexOf ( a ) && b . push ( c ) ; return b } ; Blockly . ShortcutRegistry . prototype . serializeKeyEvent _ = function ( a ) { var b = "" , c ; for ( c in Blockly . ShortcutRegistry . modifierKeys ) a . getModifierState ( c ) && ( "" != b && ( b += "+" ) , b += c ) ; "" != b && a . keyCode ? b = b + "+" + a . keyCode : a . keyCode && ( b = a . keyCode . toString ( ) ) ; return b } ;
Blockly . ShortcutRegistry . prototype . checkModifiers _ = function ( a ) { for ( var b = Blockly . utils . object . values ( Blockly . ShortcutRegistry . modifierKeys ) , c = 0 , d ; d = a [ c ] ; c ++ ) if ( 0 > b . indexOf ( d ) ) throw Error ( d + " is not a valid modifier key." ) ; } ;
2021-09-18 14:29:06 +00:00
Blockly . ShortcutRegistry . prototype . createSerializedKey = function ( a , b ) { var c = "" ; if ( b ) { this . checkModifiers _ ( b ) ; for ( var d in Blockly . ShortcutRegistry . modifierKeys ) - 1 < b . indexOf ( Blockly . ShortcutRegistry . modifierKeys [ d ] ) && ( "" != c && ( c += "+" ) , c += d ) } "" != c && a ? c = c + "+" + a : a && ( c = a . toString ( ) ) ; return c } ; new Blockly . ShortcutRegistry ; Blockly . VariableModel = function ( a , b , c , d ) { this . workspace = a ; this . name = b ; this . type = c || "" ; this . id _ = d || Blockly . utils . genUid ( ) ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _CREATE ) ) ( this ) ) } ; Blockly . VariableModel . prototype . getId = function ( ) { return this . id _ } ; Blockly . VariableModel . compareByName = function ( a , b ) { return a . name . localeCompare ( b . name , void 0 , { sensitivity : "base" } ) } ; Blockly . Variables = { } ; Blockly . Variables . NAME _TYPE = Blockly . VARIABLE _CATEGORY _NAME ; Blockly . Variables . allUsedVarModels = function ( a ) { var b = a . getAllBlocks ( ! 1 ) ; a = Object . create ( null ) ; for ( var c = 0 ; c < b . length ; c ++ ) { var d = b [ c ] . getVarModels ( ) ; if ( d ) for ( var e = 0 ; e < d . length ; e ++ ) { var f = d [ e ] , g = f . getId ( ) ; g && ( a [ g ] = f ) } } b = [ ] ; for ( g in a ) b . push ( a [ g ] ) ; return b } ; Blockly . Variables . ALL _DEVELOPER _VARS _WARNINGS _BY _BLOCK _TYPE _ = { } ;
2021-01-16 14:07:51 +00:00
Blockly . Variables . allDeveloperVariables = function ( a ) { a = a . getAllBlocks ( ! 1 ) ; for ( var b = Object . create ( null ) , c = 0 , d ; d = a [ c ] ; c ++ ) { var e = d . getDeveloperVariables ; ! e && d . getDeveloperVars && ( e = d . getDeveloperVars , Blockly . Variables . ALL _DEVELOPER _VARS _WARNINGS _BY _BLOCK _TYPE _ [ d . type ] || ( console . warn ( "Function getDeveloperVars() deprecated. Use getDeveloperVariables() (block type '" + d . type + "')" ) , Blockly . Variables . ALL _DEVELOPER _VARS _WARNINGS _BY _BLOCK _TYPE _ [ d . type ] = ! 0 ) ) ; if ( e ) for ( d = e ( ) , e = 0 ; e < d . length ; e ++ ) b [ d [ e ] ] = ! 0 } return Object . keys ( b ) } ;
Blockly . Variables . flyoutCategory = function ( a ) { var b = [ ] , c = document . createElement ( "button" ) ; c . setAttribute ( "text" , "%{BKY_NEW_VARIABLE}" ) ; c . setAttribute ( "callbackKey" , "CREATE_VARIABLE" ) ; a . registerButtonCallback ( "CREATE_VARIABLE" , function ( d ) { Blockly . Variables . createVariableButtonHandler ( d . getTargetWorkspace ( ) ) } ) ; b . push ( c ) ; a = Blockly . Variables . flyoutCategoryBlocks ( a ) ; return b = b . concat ( a ) } ;
Blockly . Variables . flyoutCategoryBlocks = function ( a ) { a = a . getVariablesOfType ( "" ) ; var b = [ ] ; if ( 0 < a . length ) { var c = a [ a . length - 1 ] ; if ( Blockly . Blocks . variables _set ) { var d = Blockly . utils . xml . createElement ( "block" ) ; d . setAttribute ( "type" , "variables_set" ) ; d . setAttribute ( "gap" , Blockly . Blocks . math _change ? 8 : 24 ) ; d . appendChild ( Blockly . Variables . generateVariableFieldDom ( c ) ) ; b . push ( d ) } Blockly . Blocks . math _change && ( d = Blockly . utils . xml . createElement ( "block" ) , d . setAttribute ( "type" , "math_change" ) , d . setAttribute ( "gap" , Blockly . Blocks . variables _get ?
20 : 8 ) , d . appendChild ( Blockly . Variables . generateVariableFieldDom ( c ) ) , c = Blockly . Xml . textToDom ( '<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>' ) , d . appendChild ( c ) , b . push ( d ) ) ; if ( Blockly . Blocks . variables _get ) { a . sort ( Blockly . VariableModel . compareByName ) ; c = 0 ; for ( var e ; e = a [ c ] ; c ++ ) d = Blockly . utils . xml . createElement ( "block" ) , d . setAttribute ( "type" , "variables_get" ) , d . setAttribute ( "gap" , 8 ) , d . appendChild ( Blockly . Variables . generateVariableFieldDom ( e ) ) , b . push ( d ) } } return b } ;
Blockly . Variables . VAR _LETTER _OPTIONS = "ijkmnopqrstuvwxyzabcdefgh" ; Blockly . Variables . generateUniqueName = function ( a ) { return Blockly . Variables . generateUniqueNameFromOptions ( Blockly . Variables . VAR _LETTER _OPTIONS . charAt ( 0 ) , a . getAllVariableNames ( ) ) } ;
Blockly . Variables . generateUniqueNameFromOptions = function ( a , b ) { if ( ! b . length ) return a ; for ( var c = Blockly . Variables . VAR _LETTER _OPTIONS , d = "" , e = c . indexOf ( a ) ; ; ) { for ( var f = ! 1 , g = 0 ; g < b . length ; g ++ ) if ( b [ g ] . toLowerCase ( ) == a ) { f = ! 0 ; break } if ( ! f ) return a ; e ++ ; e == c . length && ( e = 0 , d = Number ( d ) + 1 ) ; a = c . charAt ( e ) + d } } ;
Blockly . Variables . createVariableButtonHandler = function ( a , b , c ) { var d = c || "" , e = function ( f ) { Blockly . Variables . promptName ( Blockly . Msg . NEW _VARIABLE _TITLE , f , function ( g ) { if ( g ) { var h = Blockly . Variables . nameUsedWithAnyType ( g , a ) ; if ( h ) { if ( h . type == d ) var k = Blockly . Msg . VARIABLE _ALREADY _EXISTS . replace ( "%1" , h . name ) ; else k = Blockly . Msg . VARIABLE _ALREADY _EXISTS _FOR _ANOTHER _TYPE , k = k . replace ( "%1" , h . name ) . replace ( "%2" , h . type ) ; Blockly . alert ( k , function ( ) { e ( g ) } ) } else a . createVariable ( g , d ) , b && b ( g ) } else b && b ( null ) } ) } ; e ( "" ) } ;
Blockly . Variables . createVariable = Blockly . Variables . createVariableButtonHandler ;
Blockly . Variables . renameVariable = function ( a , b , c ) { var d = function ( e ) { var f = Blockly . Msg . RENAME _VARIABLE _TITLE . replace ( "%1" , b . name ) ; Blockly . Variables . promptName ( f , e , function ( g ) { if ( g ) { var h = Blockly . Variables . nameUsedWithOtherType _ ( g , b . type , a ) ; h ? ( h = Blockly . Msg . VARIABLE _ALREADY _EXISTS _FOR _ANOTHER _TYPE . replace ( "%1" , h . name ) . replace ( "%2" , h . type ) , Blockly . alert ( h , function ( ) { d ( g ) } ) ) : ( a . renameVariableById ( b . getId ( ) , g ) , c && c ( g ) ) } else c && c ( null ) } ) } ; d ( "" ) } ;
Blockly . Variables . promptName = function ( a , b , c ) { Blockly . prompt ( a , b , function ( d ) { d && ( d = d . replace ( /[\s\xa0]+/g , " " ) . trim ( ) , d == Blockly . Msg . RENAME _VARIABLE || d == Blockly . Msg . NEW _VARIABLE ) && ( d = null ) ; c ( d ) } ) } ; Blockly . Variables . nameUsedWithOtherType _ = function ( a , b , c ) { c = c . getVariableMap ( ) . getAllVariables ( ) ; a = a . toLowerCase ( ) ; for ( var d = 0 , e ; e = c [ d ] ; d ++ ) if ( e . name . toLowerCase ( ) == a && e . type != b ) return e ; return null } ;
Blockly . Variables . nameUsedWithAnyType = function ( a , b ) { b = b . getVariableMap ( ) . getAllVariables ( ) ; a = a . toLowerCase ( ) ; for ( var c = 0 , d ; d = b [ c ] ; c ++ ) if ( d . name . toLowerCase ( ) == a ) return d ; return null } ; Blockly . Variables . generateVariableFieldDom = function ( a ) { var b = Blockly . utils . xml . createElement ( "field" ) ; b . setAttribute ( "name" , "VAR" ) ; b . setAttribute ( "id" , a . getId ( ) ) ; b . setAttribute ( "variabletype" , a . type ) ; a = Blockly . utils . xml . createTextNode ( a . name ) ; b . appendChild ( a ) ; return b } ;
Blockly . Variables . getOrCreateVariablePackage = function ( a , b , c , d ) { var e = Blockly . Variables . getVariable ( a , b , c , d ) ; e || ( e = Blockly . Variables . createVariable _ ( a , b , c , d ) ) ; return e } ; Blockly . Variables . getVariable = function ( a , b , c , d ) { var e = a . getPotentialVariableMap ( ) , f = null ; if ( b && ( f = a . getVariableById ( b ) , ! f && e && ( f = e . getVariableById ( b ) ) , f ) ) return f ; if ( c ) { if ( void 0 == d ) throw Error ( "Tried to look up a variable by name without a type" ) ; f = a . getVariable ( c , d ) ; ! f && e && ( f = e . getVariable ( c , d ) ) } return f } ;
2021-09-18 14:29:06 +00:00
Blockly . Variables . createVariable _ = function ( a , b , c , d ) { var e = a . getPotentialVariableMap ( ) ; c || ( c = Blockly . Variables . generateUniqueName ( a . isFlyout ? a . targetWorkspace : a ) ) ; return e ? e . createVariable ( c , d , b ) : a . createVariable ( c , d , b ) } ; Blockly . Variables . getAddedVariables = function ( a , b ) { a = a . getAllVariables ( ) ; var c = [ ] ; if ( b . length != a . length ) for ( var d = 0 ; d < a . length ; d ++ ) { var e = a [ d ] ; - 1 == b . indexOf ( e ) && c . push ( e ) } return c } ; Blockly . VERSION = "6.20210701.0" ; Blockly . mainWorkspace = null ; Blockly . selected = null ; Blockly . draggingConnections = [ ] ; Blockly . clipboardXml _ = null ; Blockly . clipboardSource _ = null ; Blockly . clipboardTypeCounts _ = null ; Blockly . cache3dSupported _ = null ; Blockly . parentContainer = null ; Blockly . svgSize = function ( a ) { Blockly . utils . deprecation . warn ( "Blockly.svgSize" , "March 2021" , "March 2022" , "workspace.getCachedParentSvgSize" ) ; return new Blockly . utils . Size ( a . cachedWidth _ , a . cachedHeight _ ) } ; Blockly . resizeSvgContents = function ( a ) { a . resizeContents ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . svgResize = function ( a ) { for ( ; a . options . parentWorkspace ; ) a = a . options . parentWorkspace ; var b = a . getParentSvg ( ) , c = a . getCachedParentSvgSize ( ) , d = b . parentNode ; if ( d ) { var e = d . offsetWidth ; d = d . offsetHeight ; c . width != e && ( b . setAttribute ( "width" , e + "px" ) , a . setCachedParentSvgSize ( e , null ) ) ; c . height != d && ( b . setAttribute ( "height" , d + "px" ) , a . setCachedParentSvgSize ( null , d ) ) ; a . resize ( ) } } ;
2021-09-18 14:29:06 +00:00
Blockly . onKeyDown = function ( a ) { var b = Blockly . mainWorkspace ; if ( b && ! ( Blockly . utils . isTargetInput ( a ) || b . rendered && ! b . isVisible ( ) ) ) Blockly . ShortcutRegistry . registry . onKeyDown ( b , a ) } ; Blockly . deleteBlock = function ( a ) { a . workspace . isFlyout || ( Blockly . Events . setGroup ( ! 0 ) , Blockly . hideChaff ( ) , a . outputConnection ? a . dispose ( ! 1 , ! 0 ) : a . dispose ( ! 0 , ! 0 ) , Blockly . Events . setGroup ( ! 1 ) ) } ; Blockly . copy = function ( a ) { if ( a = a . toCopyData ( ) ) Blockly . clipboardXml _ = a . xml , Blockly . clipboardSource _ = a . source , Blockly . clipboardTypeCounts _ = a . typeCounts } ;
2021-01-16 14:07:51 +00:00
Blockly . paste = function ( ) { if ( ! Blockly . clipboardXml _ ) return ! 1 ; var a = Blockly . clipboardSource _ ; a . isFlyout && ( a = a . targetWorkspace ) ; return Blockly . clipboardTypeCounts _ && a . isCapacityAvailable ( Blockly . clipboardTypeCounts _ ) ? ( Blockly . Events . setGroup ( ! 0 ) , a . paste ( Blockly . clipboardXml _ ) , Blockly . Events . setGroup ( ! 1 ) , ! 0 ) : ! 1 } ;
Blockly . duplicate = function ( a ) { var b = Blockly . clipboardXml _ , c = Blockly . clipboardSource _ ; Blockly . copy ( a ) ; a . workspace . paste ( Blockly . clipboardXml _ ) ; Blockly . clipboardXml _ = b ; Blockly . clipboardSource _ = c } ; Blockly . onContextMenu _ = function ( a ) { Blockly . utils . isTargetInput ( a ) || a . preventDefault ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . hideChaff = function ( a ) { Blockly . Tooltip . hide ( ) ; Blockly . WidgetDiv . hide ( ) ; Blockly . DropDownDiv . hideWithoutAnimation ( ) ; var b = ! ! a ; Blockly . getMainWorkspace ( ) . getComponentManager ( ) . getComponents ( Blockly . ComponentManager . Capability . AUTOHIDEABLE , ! 0 ) . forEach ( function ( c ) { c . autoHide ( b ) } ) } ; Blockly . getMainWorkspace = function ( ) { return Blockly . mainWorkspace } ; Blockly . alert = function ( a , b ) { alert ( a ) ; b && b ( ) } ; Blockly . confirm = function ( a , b ) { b ( confirm ( a ) ) } ; Blockly . prompt = function ( a , b , c ) { c ( prompt ( a , b ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . jsonInitFactory _ = function ( a ) { return function ( ) { this . jsonInit ( a ) } } ;
2021-05-19 13:38:55 +00:00
Blockly . defineBlocksWithJsonArray = function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) { var c = a [ b ] ; if ( c ) { var d = c . type ; null == d || "" === d ? console . warn ( "Block definition #" + b + " in JSON array is missing a type attribute. Skipping." ) : ( Blockly . Blocks [ d ] && console . warn ( "Block definition #" + b + ' in JSON array overwrites prior definition of "' + d + '".' ) , Blockly . Blocks [ d ] = { init : Blockly . jsonInitFactory _ ( c ) } ) } else console . warn ( "Block definition #" + b + " in JSON array is " + c + ". Skipping." ) } } ; Blockly . isNumber = function ( a ) { return /^\s*-?\d+(\.\d+)?\s*$/ . test ( a ) } ;
Blockly . hueToHex = function ( a ) { return Blockly . utils . colour . hsvToHex ( a , Blockly . HSV _SATURATION , 255 * Blockly . HSV _VALUE ) } ;
2021-01-16 14:07:51 +00:00
Blockly . checkBlockColourConstants = function ( ) { Blockly . checkBlockColourConstant _ ( "LOGIC_HUE" , [ "Blocks" , "logic" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "LOGIC_HUE" , [ "Constants" , "Logic" , "HUE" ] , 210 ) ; Blockly . checkBlockColourConstant _ ( "LOOPS_HUE" , [ "Blocks" , "loops" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "LOOPS_HUE" , [ "Constants" , "Loops" , "HUE" ] , 120 ) ; Blockly . checkBlockColourConstant _ ( "MATH_HUE" , [ "Blocks" , "math" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "MATH_HUE" , [ "Constants" , "Math" ,
"HUE" ] , 230 ) ; Blockly . checkBlockColourConstant _ ( "TEXTS_HUE" , [ "Blocks" , "texts" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "TEXTS_HUE" , [ "Constants" , "Text" , "HUE" ] , 160 ) ; Blockly . checkBlockColourConstant _ ( "LISTS_HUE" , [ "Blocks" , "lists" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "LISTS_HUE" , [ "Constants" , "Lists" , "HUE" ] , 260 ) ; Blockly . checkBlockColourConstant _ ( "COLOUR_HUE" , [ "Blocks" , "colour" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "COLOUR_HUE" , [ "Constants" , "Colour" , "HUE" ] , 20 ) ; Blockly . checkBlockColourConstant _ ( "VARIABLES_HUE" ,
[ "Blocks" , "variables" , "HUE" ] , void 0 ) ; Blockly . checkBlockColourConstant _ ( "VARIABLES_HUE" , [ "Constants" , "Variables" , "HUE" ] , 330 ) ; Blockly . checkBlockColourConstant _ ( "VARIABLES_DYNAMIC_HUE" , [ "Constants" , "VariablesDynamic" , "HUE" ] , 310 ) ; Blockly . checkBlockColourConstant _ ( "PROCEDURES_HUE" , [ "Blocks" , "procedures" , "HUE" ] , void 0 ) } ;
2021-05-19 13:38:55 +00:00
Blockly . checkBlockColourConstant _ = function ( a , b , c ) { for ( var d = "Blockly" , e = Blockly , f = 0 ; f < b . length ; ++ f ) d += "." + b [ f ] , e && ( e = e [ b [ f ] ] ) ; e && e !== c && ( a = ( void 0 === c ? '%1 has been removed. Use Blockly.Msg["%2"].' : '%1 is deprecated and unused. Override Blockly.Msg["%2"].' ) . replace ( "%1" , d ) . replace ( "%2" , a ) , console . warn ( a ) ) } ; Blockly . setParentContainer = function ( a ) { Blockly . parentContainer = a } ; Blockly . bindEvent _ = Blockly . browserEvents . bind ; Blockly . unbindEvent _ = Blockly . browserEvents . unbind ; Blockly . bindEventWithChecks _ = Blockly . browserEvents . conditionalBind ;
Blockly . ALIGN _LEFT = Blockly . constants . ALIGN . LEFT ; Blockly . ALIGN _CENTRE = Blockly . constants . ALIGN . CENTRE ; Blockly . ALIGN _RIGHT = Blockly . constants . ALIGN . RIGHT ; Blockly . INPUT _VALUE = Blockly . connectionTypes . INPUT _VALUE ; Blockly . OUTPUT _VALUE = Blockly . connectionTypes . OUTPUT _VALUE ; Blockly . NEXT _STATEMENT = Blockly . connectionTypes . NEXT _STATEMENT ; Blockly . PREVIOUS _STATEMENT = Blockly . connectionTypes . PREVIOUS _STATEMENT ; Blockly . DUMMY _INPUT = Blockly . inputTypes . DUMMY ; Blockly . TOOLBOX _AT _TOP = Blockly . utils . toolbox . Position . TOP ;
Blockly . TOOLBOX _AT _BOTTOM = Blockly . utils . toolbox . Position . BOTTOM ; Blockly . TOOLBOX _AT _LEFT = Blockly . utils . toolbox . Position . LEFT ; Blockly . TOOLBOX _AT _RIGHT = Blockly . utils . toolbox . Position . RIGHT ; Blockly . Events . BubbleOpen = function ( a , b , c ) { Blockly . Events . BubbleOpen . superClass _ . constructor . call ( this , a ? a . workspace . id : void 0 ) ; this . blockId = a ? a . id : null ; this . isOpen = b ; this . bubbleType = c } ; Blockly . utils . object . inherits ( Blockly . Events . BubbleOpen , Blockly . Events . UiBase ) ; Blockly . Events . BubbleOpen . prototype . type = Blockly . Events . BUBBLE _OPEN ;
2021-01-16 14:07:51 +00:00
Blockly . Events . BubbleOpen . prototype . toJson = function ( ) { var a = Blockly . Events . BubbleOpen . superClass _ . toJson . call ( this ) ; a . isOpen = this . isOpen ; a . bubbleType = this . bubbleType ; a . blockId = this . blockId ; return a } ; Blockly . Events . BubbleOpen . prototype . fromJson = function ( a ) { Blockly . Events . BubbleOpen . superClass _ . fromJson . call ( this , a ) ; this . isOpen = a . isOpen ; this . bubbleType = a . bubbleType ; this . blockId = a . blockId } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . BUBBLE _OPEN , Blockly . Events . BubbleOpen ) ; Blockly . Icon = function ( a ) { this . block _ = a ; this . iconGroup _ = null } ; Blockly . Icon . prototype . collapseHidden = ! 0 ; Blockly . Icon . prototype . SIZE = 17 ; Blockly . Icon . prototype . bubble _ = null ; Blockly . Icon . prototype . iconXY _ = null ;
2021-05-19 13:38:55 +00:00
Blockly . Icon . prototype . createIcon = function ( ) { this . iconGroup _ || ( this . iconGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyIconGroup" } , null ) , this . block _ . isInFlyout && Blockly . utils . dom . addClass ( this . iconGroup _ , "blocklyIconGroupReadonly" ) , this . drawIcon _ ( this . iconGroup _ ) , this . block _ . getSvgRoot ( ) . appendChild ( this . iconGroup _ ) , Blockly . browserEvents . conditionalBind ( this . iconGroup _ , "mouseup" , this , this . iconClick _ ) , this . updateEditable ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Icon . prototype . dispose = function ( ) { Blockly . utils . dom . removeNode ( this . iconGroup _ ) ; this . iconGroup _ = null ; this . setVisible ( ! 1 ) ; this . block _ = null } ; Blockly . Icon . prototype . updateEditable = function ( ) { } ; Blockly . Icon . prototype . isVisible = function ( ) { return ! ! this . bubble _ } ; Blockly . Icon . prototype . iconClick _ = function ( a ) { this . block _ . workspace . isDragging ( ) || this . block _ . isInFlyout || Blockly . utils . isRightButton ( a ) || this . setVisible ( ! this . isVisible ( ) ) } ;
Blockly . Icon . prototype . applyColour = function ( ) { this . isVisible ( ) && this . bubble _ . setColour ( this . block _ . style . colourPrimary ) } ; Blockly . Icon . prototype . setIconLocation = function ( a ) { this . iconXY _ = a ; this . isVisible ( ) && this . bubble _ . setAnchorLocation ( a ) } ;
Blockly . Icon . prototype . computeIconLocation = function ( ) { var a = this . block _ . getRelativeToSurfaceXY ( ) , b = Blockly . utils . getRelativeXY ( this . iconGroup _ ) ; a = new Blockly . utils . Coordinate ( a . x + b . x + this . SIZE / 2 , a . y + b . y + this . SIZE / 2 ) ; Blockly . utils . Coordinate . equals ( this . getIconLocation ( ) , a ) || this . setIconLocation ( a ) } ; Blockly . Icon . prototype . getIconLocation = function ( ) { return this . iconXY _ } ;
2021-09-18 14:29:06 +00:00
Blockly . Icon . prototype . getCorrectedSize = function ( ) { return new Blockly . utils . Size ( Blockly . Icon . prototype . SIZE , Blockly . Icon . prototype . SIZE - 2 ) } ; Blockly . Warning = function ( a ) { Blockly . Warning . superClass _ . constructor . call ( this , a ) ; this . createIcon ( ) ; this . text _ = Object . create ( null ) } ; Blockly . utils . object . inherits ( Blockly . Warning , Blockly . Icon ) ; Blockly . Warning . prototype . collapseHidden = ! 1 ;
2021-01-16 14:07:51 +00:00
Blockly . Warning . prototype . drawIcon _ = function ( a ) { Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyIconShape" , d : "M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyIconSymbol" , d : "m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyIconSymbol" , x : "7" , y : "11" , height : "2" , width : "2" } , a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Warning . prototype . setVisible = function ( a ) { a != this . isVisible ( ) && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BUBBLE _OPEN ) ) ( this . block _ , a , "warning" ) ) , a ? this . createBubble _ ( ) : this . disposeBubble _ ( ) ) } ; Blockly . Warning . prototype . createBubble _ = function ( ) { this . paragraphElement _ = Blockly . Bubble . textToDom ( this . getText ( ) ) ; this . bubble _ = Blockly . Bubble . createNonEditableBubble ( this . paragraphElement _ , this . block _ , this . iconXY _ ) ; this . applyColour ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Warning . prototype . disposeBubble _ = function ( ) { this . bubble _ . dispose ( ) ; this . paragraphElement _ = this . bubble _ = null } ; Blockly . Warning . prototype . setText = function ( a , b ) { this . text _ [ b ] != a && ( a ? this . text _ [ b ] = a : delete this . text _ [ b ] , this . isVisible ( ) && ( this . setVisible ( ! 1 ) , this . setVisible ( ! 0 ) ) ) } ; Blockly . Warning . prototype . getText = function ( ) { var a = [ ] , b ; for ( b in this . text _ ) a . push ( this . text _ [ b ] ) ; return a . join ( "\n" ) } ; Blockly . Warning . prototype . dispose = function ( ) { this . block _ . warning = null ; Blockly . Icon . prototype . dispose . call ( this ) } ; Blockly . Comment = function ( a ) { Blockly . Comment . superClass _ . constructor . call ( this , a ) ; this . model _ = a . commentModel ; this . model _ . text = this . model _ . text || "" ; this . cachedText _ = "" ; this . onInputWrapper _ = this . onChangeWrapper _ = this . onWheelWrapper _ = this . onMouseUpWrapper _ = null ; this . createIcon ( ) } ; Blockly . utils . object . inherits ( Blockly . Comment , Blockly . Icon ) ;
Blockly . Comment . prototype . drawIcon _ = function ( a ) { Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE , { "class" : "blocklyIconShape" , r : "8" , cx : "8" , cy : "8" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyIconSymbol" , d : "m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyIconSymbol" ,
x : "6.8" , y : "10.78" , height : "2" , width : "2" } , a ) } ;
Blockly . Comment . prototype . createEditor _ = function ( ) { this . foreignObject _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FOREIGNOBJECT , { x : Blockly . Bubble . BORDER _WIDTH , y : Blockly . Bubble . BORDER _WIDTH } , null ) ; var a = document . createElementNS ( Blockly . utils . dom . HTML _NS , "body" ) ; a . setAttribute ( "xmlns" , Blockly . utils . dom . HTML _NS ) ; a . className = "blocklyMinimalBody" ; var b = this . textarea _ = document . createElementNS ( Blockly . utils . dom . HTML _NS , "textarea" ) ; b . className = "blocklyCommentTextarea" ; b . setAttribute ( "dir" , this . block _ . RTL ?
2021-05-19 13:38:55 +00:00
"RTL" : "LTR" ) ; b . value = this . model _ . text ; this . resizeTextarea _ ( ) ; a . appendChild ( b ) ; this . foreignObject _ . appendChild ( a ) ; this . onMouseUpWrapper _ = Blockly . browserEvents . conditionalBind ( b , "mouseup" , this , this . startEdit _ , ! 0 , ! 0 ) ; this . onWheelWrapper _ = Blockly . browserEvents . conditionalBind ( b , "wheel" , this , function ( c ) { c . stopPropagation ( ) } ) ; this . onChangeWrapper _ = Blockly . browserEvents . conditionalBind ( b , "change" , this , function ( c ) { this . cachedText _ != this . model _ . text && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this . block _ ,
"comment" , null , this . cachedText _ , this . model _ . text ) ) } ) ; this . onInputWrapper _ = Blockly . browserEvents . conditionalBind ( b , "input" , this , function ( c ) { this . model _ . text = b . value } ) ; setTimeout ( b . focus . bind ( b ) , 0 ) ; return this . foreignObject _ } ; Blockly . Comment . prototype . updateEditable = function ( ) { Blockly . Comment . superClass _ . updateEditable . call ( this ) ; this . isVisible ( ) && ( this . disposeBubble _ ( ) , this . createBubble _ ( ) ) } ;
Blockly . Comment . prototype . onBubbleResize _ = function ( ) { this . isVisible ( ) && ( this . model _ . size = this . bubble _ . getBubbleSize ( ) , this . resizeTextarea _ ( ) ) } ; Blockly . Comment . prototype . resizeTextarea _ = function ( ) { var a = this . model _ . size , b = 2 * Blockly . Bubble . BORDER _WIDTH , c = a . width - b ; a = a . height - b ; this . foreignObject _ . setAttribute ( "width" , c ) ; this . foreignObject _ . setAttribute ( "height" , a ) ; this . textarea _ . style . width = c - 4 + "px" ; this . textarea _ . style . height = a - 4 + "px" } ;
Blockly . Comment . prototype . setVisible = function ( a ) { a != this . isVisible ( ) && ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BUBBLE _OPEN ) ) ( this . block _ , a , "comment" ) ) , ( this . model _ . pinned = a ) ? this . createBubble _ ( ) : this . disposeBubble _ ( ) ) } ; Blockly . Comment . prototype . createBubble _ = function ( ) { ! this . block _ . isEditable ( ) || Blockly . utils . userAgent . IE ? this . createNonEditableBubble _ ( ) : this . createEditableBubble _ ( ) } ;
Blockly . Comment . prototype . createEditableBubble _ = function ( ) { this . bubble _ = new Blockly . Bubble ( this . block _ . workspace , this . createEditor _ ( ) , this . block _ . pathObject . svgPath , this . iconXY _ , this . model _ . size . width , this . model _ . size . height ) ; this . bubble _ . setSvgId ( this . block _ . id ) ; this . bubble _ . registerResizeEvent ( this . onBubbleResize _ . bind ( this ) ) ; this . applyColour ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Comment . prototype . createNonEditableBubble _ = function ( ) { this . paragraphElement _ = Blockly . Bubble . textToDom ( this . block _ . getCommentText ( ) ) ; this . bubble _ = Blockly . Bubble . createNonEditableBubble ( this . paragraphElement _ , this . block _ , this . iconXY _ ) ; this . applyColour ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Comment . prototype . disposeBubble _ = function ( ) { this . onMouseUpWrapper _ && ( Blockly . browserEvents . unbind ( this . onMouseUpWrapper _ ) , this . onMouseUpWrapper _ = null ) ; this . onWheelWrapper _ && ( Blockly . browserEvents . unbind ( this . onWheelWrapper _ ) , this . onWheelWrapper _ = null ) ; this . onChangeWrapper _ && ( Blockly . browserEvents . unbind ( this . onChangeWrapper _ ) , this . onChangeWrapper _ = null ) ; this . onInputWrapper _ && ( Blockly . browserEvents . unbind ( this . onInputWrapper _ ) , this . onInputWrapper _ = null ) ; this . bubble _ . dispose ( ) ; this . paragraphElement _ =
this . foreignObject _ = this . textarea _ = this . bubble _ = null } ; Blockly . Comment . prototype . startEdit _ = function ( a ) { this . bubble _ . promote ( ) && this . textarea _ . focus ( ) ; this . cachedText _ = this . model _ . text } ; Blockly . Comment . prototype . getBubbleSize = function ( ) { return this . model _ . size } ; Blockly . Comment . prototype . setBubbleSize = function ( a , b ) { this . bubble _ ? this . bubble _ . setBubbleSize ( a , b ) : ( this . model _ . size . width = a , this . model _ . size . height = b ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Comment . prototype . updateText = function ( ) { this . textarea _ ? this . textarea _ . value = this . model _ . text : this . paragraphElement _ && ( this . paragraphElement _ . firstChild . textContent = this . model _ . text ) } ; Blockly . Comment . prototype . dispose = function ( ) { this . block _ . comment = null ; Blockly . Icon . prototype . dispose . call ( this ) } ; Blockly . Css . register ( ".blocklyCommentTextarea {,background-color: #fef49c;,border: 0;,outline: 0;,margin: 0;,padding: 3px;,resize: none;,display: block;,text-overflow: hidden;,}" . split ( "," ) ) ; Blockly . IComponent = function ( ) { } ; Blockly . IDragTarget = function ( ) { } ; Blockly . DragTarget = function ( ) { } ; Blockly . DragTarget . prototype . onDragEnter = function ( a ) { } ; Blockly . DragTarget . prototype . onDragOver = function ( a ) { } ; Blockly . DragTarget . prototype . onDragExit = function ( a ) { } ; Blockly . DragTarget . prototype . onDrop = function ( a ) { } ; Blockly . DragTarget . prototype . shouldPreventMove = function ( a ) { return ! 1 } ; Blockly . IDeleteArea = function ( ) { } ; Blockly . DeleteArea = function ( ) { Blockly . DeleteArea . superClass _ . constructor . call ( this ) ; this . wouldDelete _ = ! 1 } ; Blockly . utils . object . inherits ( Blockly . DeleteArea , Blockly . DragTarget ) ; Blockly . DeleteArea . prototype . wouldDelete = function ( a , b ) { a instanceof Blockly . BlockSvg ? ( a = ! a . getParent ( ) && a . isDeletable ( ) , this . updateWouldDelete _ ( a && ! b ) ) : this . updateWouldDelete _ ( a . isDeletable ( ) ) ; return this . wouldDelete _ } ; Blockly . DeleteArea . prototype . updateWouldDelete _ = function ( a ) { this . wouldDelete _ = a } ; Blockly . IFlyout = function ( ) { } ; Blockly . Flyout = function ( a ) { Blockly . Flyout . superClass _ . constructor . call ( this ) ; a . setMetrics = this . setMetrics _ . bind ( this ) ; this . workspace _ = new Blockly . WorkspaceSvg ( a ) ; this . workspace _ . setMetricsManager ( new Blockly . FlyoutMetricsManager ( this . workspace _ , this ) ) ; this . workspace _ . isFlyout = ! 0 ; this . workspace _ . setVisible ( this . isVisible _ ) ; this . id = Blockly . utils . genUid ( ) ; this . RTL = ! ! a . RTL ; this . horizontalLayout = ! 1 ; this . toolboxPosition _ = a . toolboxPosition ; this . eventWrappers _ = [ ] ; this . mats _ = [ ] ; this . buttons _ = [ ] ; this . listeners _ =
[ ] ; this . permanentlyDisabled _ = [ ] ; this . tabWidth _ = this . workspace _ . getRenderer ( ) . getConstants ( ) . TAB _WIDTH ; this . targetWorkspace = null } ; Blockly . utils . object . inherits ( Blockly . Flyout , Blockly . DeleteArea ) ; Blockly . Flyout . prototype . autoClose = ! 0 ; Blockly . Flyout . prototype . isVisible _ = ! 1 ; Blockly . Flyout . prototype . containerVisible _ = ! 0 ; Blockly . Flyout . prototype . CORNER _RADIUS = 8 ; Blockly . Flyout . prototype . MARGIN = Blockly . Flyout . prototype . CORNER _RADIUS ; Blockly . Flyout . prototype . GAP _X = 3 * Blockly . Flyout . prototype . MARGIN ;
Blockly . Flyout . prototype . GAP _Y = 3 * Blockly . Flyout . prototype . MARGIN ; Blockly . Flyout . prototype . SCROLLBAR _MARGIN = 2.5 ; Blockly . Flyout . prototype . width _ = 0 ; Blockly . Flyout . prototype . height _ = 0 ; Blockly . Flyout . prototype . dragAngleRange _ = 70 ;
2021-01-16 14:07:51 +00:00
Blockly . Flyout . prototype . createDom = function ( a ) { this . svgGroup _ = Blockly . utils . dom . createSvgElement ( a , { "class" : "blocklyFlyout" , style : "display: none" } , null ) ; this . svgBackground _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyFlyoutBackground" } , this . svgGroup _ ) ; this . svgGroup _ . appendChild ( this . workspace _ . createDom ( ) ) ; this . workspace _ . getThemeManager ( ) . subscribe ( this . svgBackground _ , "flyoutBackgroundColour" , "fill" ) ; this . workspace _ . getThemeManager ( ) . subscribe ( this . svgBackground _ , "flyoutOpacity" ,
2021-05-19 13:38:55 +00:00
"fill-opacity" ) ; return this . svgGroup _ } ;
2021-09-18 14:29:06 +00:00
Blockly . Flyout . prototype . init = function ( a ) { this . targetWorkspace = a ; this . workspace _ . targetWorkspace = a ; this . workspace _ . scrollbar = new Blockly . ScrollbarPair ( this . workspace _ , this . horizontalLayout , ! this . horizontalLayout , "blocklyFlyoutScrollbar" , this . SCROLLBAR _MARGIN ) ; this . hide ( ) ; Array . prototype . push . apply ( this . eventWrappers _ , Blockly . browserEvents . conditionalBind ( this . svgGroup _ , "wheel" , this , this . wheel _ ) ) ; this . autoClose || ( this . filterWrapper _ = this . filterForCapacity _ . bind ( this ) , this . targetWorkspace . addChangeListener ( this . filterWrapper _ ) ) ;
Array . prototype . push . apply ( this . eventWrappers _ , Blockly . browserEvents . conditionalBind ( this . svgBackground _ , "mousedown" , this , this . onMouseDown _ ) ) ; this . workspace _ . getGesture = this . targetWorkspace . getGesture . bind ( this . targetWorkspace ) ; this . workspace _ . setVariableMap ( this . targetWorkspace . getVariableMap ( ) ) ; this . workspace _ . createPotentialVariableMap ( ) ; a . getComponentManager ( ) . addComponent ( { component : this , weight : 1 , capabilities : [ Blockly . ComponentManager . Capability . DELETE _AREA , Blockly . ComponentManager . Capability . DRAG _TARGET ] } ) } ;
Blockly . Flyout . prototype . dispose = function ( ) { this . hide ( ) ; this . workspace _ . getComponentManager ( ) . removeComponent ( this . id ) ; Blockly . browserEvents . unbind ( this . eventWrappers _ ) ; this . filterWrapper _ && ( this . targetWorkspace . removeChangeListener ( this . filterWrapper _ ) , this . filterWrapper _ = null ) ; this . workspace _ && ( this . workspace _ . getThemeManager ( ) . unsubscribe ( this . svgBackground _ ) , this . workspace _ . targetWorkspace = null , this . workspace _ . dispose ( ) , this . workspace _ = null ) ; this . svgGroup _ && ( Blockly . utils . dom . removeNode ( this . svgGroup _ ) ,
this . svgGroup _ = null ) ; this . targetWorkspace = this . svgBackground _ = null } ; Blockly . Flyout . prototype . getWidth = function ( ) { return this . width _ } ; Blockly . Flyout . prototype . getHeight = function ( ) { return this . height _ } ; Blockly . Flyout . prototype . getFlyoutScale = function ( ) { return this . targetWorkspace . scale } ; Blockly . Flyout . prototype . getWorkspace = function ( ) { return this . workspace _ } ; Blockly . Flyout . prototype . isVisible = function ( ) { return this . isVisible _ } ;
Blockly . Flyout . prototype . setVisible = function ( a ) { var b = a != this . isVisible ( ) ; this . isVisible _ = a ; b && ( this . autoClose || this . workspace _ . recordDragTargets ( ) , this . updateDisplay _ ( ) ) } ; Blockly . Flyout . prototype . setContainerVisible = function ( a ) { var b = a != this . containerVisible _ ; this . containerVisible _ = a ; b && this . updateDisplay _ ( ) } ; Blockly . Flyout . prototype . updateDisplay _ = function ( ) { var a = this . containerVisible _ ? this . isVisible ( ) : ! 1 ; this . svgGroup _ . style . display = a ? "block" : "none" ; this . workspace _ . scrollbar . setContainerVisible ( a ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Flyout . prototype . positionAt _ = function ( a , b , c , d ) { this . svgGroup _ . setAttribute ( "width" , a ) ; this . svgGroup _ . setAttribute ( "height" , b ) ; this . workspace _ . setCachedParentSvgSize ( a , b ) ; "svg" == this . svgGroup _ . tagName ? Blockly . utils . dom . setCssTransform ( this . svgGroup _ , "translate(" + c + "px," + d + "px)" ) : this . svgGroup _ . setAttribute ( "transform" , "translate(" + c + "," + d + ")" ) ; if ( a = this . workspace _ . scrollbar ) a . setOrigin ( c , d ) , a . resize ( ) , a . hScroll && a . hScroll . setPosition ( a . hScroll . position . x , a . hScroll . position . y ) , a . vScroll && a . vScroll . setPosition ( a . vScroll . position . x ,
a . vScroll . position . y ) } ; Blockly . Flyout . prototype . hide = function ( ) { if ( this . isVisible ( ) ) { this . setVisible ( ! 1 ) ; for ( var a = 0 , b ; b = this . listeners _ [ a ] ; a ++ ) Blockly . browserEvents . unbind ( b ) ; this . listeners _ . length = 0 ; this . reflowWrapper _ && ( this . workspace _ . removeChangeListener ( this . reflowWrapper _ ) , this . reflowWrapper _ = null ) } } ;
Blockly . Flyout . prototype . show = function ( a ) { this . workspace _ . setResizesEnabled ( ! 1 ) ; this . hide ( ) ; this . clearOldBlocks _ ( ) ; "string" == typeof a && ( a = this . getDynamicCategoryContents _ ( a ) ) ; this . setVisible ( ! 0 ) ; a = Blockly . utils . toolbox . convertFlyoutDefToJsonArray ( a ) ; a = this . createFlyoutInfo _ ( a ) ; this . layout _ ( a . contents , a . gaps ) ; this . listeners _ . push ( Blockly . browserEvents . conditionalBind ( this . svgBackground _ , "mouseover" , this , function ( ) { for ( var b = this . workspace _ . getTopBlocks ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) d . removeSelect ( ) } ) ) ; this . horizontalLayout ?
2021-01-16 14:07:51 +00:00
this . height _ = 0 : this . width _ = 0 ; this . workspace _ . setResizesEnabled ( ! 0 ) ; this . reflow ( ) ; this . filterForCapacity _ ( ) ; this . position ( ) ; this . reflowWrapper _ = this . reflow . bind ( this ) ; this . workspace _ . addChangeListener ( this . reflowWrapper _ ) } ;
Blockly . Flyout . prototype . createFlyoutInfo _ = function ( a ) { var b = [ ] , c = [ ] ; this . permanentlyDisabled _ . length = 0 ; for ( var d = this . horizontalLayout ? this . GAP _X : this . GAP _Y , e = 0 , f ; f = a [ e ] ; e ++ ) switch ( f . custom && ( f = this . getDynamicCategoryContents _ ( f . custom ) , f = Blockly . utils . toolbox . convertFlyoutDefToJsonArray ( f ) , a . splice . apply ( a , [ e , 1 ] . concat ( f ) ) , f = a [ e ] ) , f . kind . toUpperCase ( ) ) { case "BLOCK" : var g = f , h = this . getBlockXml _ ( g ) ; f = this . createBlock _ ( h ) ; g = parseInt ( g . gap || h . getAttribute ( "gap" ) , 10 ) ; c . push ( isNaN ( g ) ? d : g ) ; b . push ( { type : "block" ,
block : f } ) ; break ; case "SEP" : this . addSeparatorGap _ ( f , c , d ) ; break ; case "LABEL" : f = this . createButton _ ( f , ! 0 ) ; b . push ( { type : "button" , button : f } ) ; c . push ( d ) ; break ; case "BUTTON" : f = this . createButton _ ( f , ! 1 ) , b . push ( { type : "button" , button : f } ) , c . push ( d ) } return { contents : b , gaps : c } } ;
Blockly . Flyout . prototype . getDynamicCategoryContents _ = function ( a ) { a = this . workspace _ . targetWorkspace . getToolboxCategoryCallback ( a ) ; if ( "function" != typeof a ) throw TypeError ( "Couldn't find a callback function when opening a toolbox category." ) ; a = a ( this . workspace _ . targetWorkspace ) ; if ( ! Array . isArray ( a ) ) throw new TypeError ( "Result of toolbox category callback must be an array." ) ; return a } ;
Blockly . Flyout . prototype . createButton _ = function ( a , b ) { if ( ! Blockly . FlyoutButton ) throw Error ( "Missing require for Blockly.FlyoutButton" ) ; return new Blockly . FlyoutButton ( this . workspace _ , this . targetWorkspace , a , b ) } ; Blockly . Flyout . prototype . createBlock _ = function ( a ) { a = Blockly . Xml . domToBlock ( a , this . workspace _ ) ; a . isEnabled ( ) || this . permanentlyDisabled _ . push ( a ) ; return a } ;
Blockly . Flyout . prototype . getBlockXml _ = function ( a ) { var b = null , c = a . blockxml ; c && "string" != typeof c ? b = c : c && "string" == typeof c ? ( b = Blockly . Xml . textToDom ( c ) , a . blockxml = b ) : a . type && ( b = Blockly . utils . xml . createElement ( "xml" ) , b . setAttribute ( "type" , a . type ) , b . setAttribute ( "disabled" , a . disabled ) , a . blockxml = b ) ; if ( ! b ) throw Error ( "Error: Invalid block definition. Block definition must have blockxml or type." ) ; return b } ;
Blockly . Flyout . prototype . addSeparatorGap _ = function ( a , b , c ) { a = parseInt ( a . gap , 10 ) ; ! isNaN ( a ) && 0 < b . length ? b [ b . length - 1 ] = a : b . push ( c ) } ; Blockly . Flyout . prototype . clearOldBlocks _ = function ( ) { for ( var a = this . workspace _ . getTopBlocks ( ! 1 ) , b = 0 , c ; c = a [ b ] ; b ++ ) c . workspace == this . workspace _ && c . dispose ( ! 1 , ! 1 ) ; for ( b = 0 ; b < this . mats _ . length ; b ++ ) if ( a = this . mats _ [ b ] ) Blockly . Tooltip . unbindMouseEvents ( a ) , Blockly . utils . dom . removeNode ( a ) ; for ( b = this . mats _ . length = 0 ; a = this . buttons _ [ b ] ; b ++ ) a . dispose ( ) ; this . buttons _ . length = 0 ; this . workspace _ . getPotentialVariableMap ( ) . clear ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Flyout . prototype . addBlockListeners _ = function ( a , b , c ) { this . listeners _ . push ( Blockly . browserEvents . conditionalBind ( a , "mousedown" , null , this . blockMouseDown _ ( b ) ) ) ; this . listeners _ . push ( Blockly . browserEvents . conditionalBind ( c , "mousedown" , null , this . blockMouseDown _ ( b ) ) ) ; this . listeners _ . push ( Blockly . browserEvents . bind ( a , "mouseenter" , b , b . addSelect ) ) ; this . listeners _ . push ( Blockly . browserEvents . bind ( a , "mouseleave" , b , b . removeSelect ) ) ; this . listeners _ . push ( Blockly . browserEvents . bind ( c , "mouseenter" , b , b . addSelect ) ) ;
this . listeners _ . push ( Blockly . browserEvents . bind ( c , "mouseleave" , b , b . removeSelect ) ) } ; Blockly . Flyout . prototype . blockMouseDown _ = function ( a ) { var b = this ; return function ( c ) { var d = b . targetWorkspace . getGesture ( c ) ; d && ( d . setStartBlock ( a ) , d . handleFlyoutStart ( c , b ) ) } } ; Blockly . Flyout . prototype . onMouseDown _ = function ( a ) { var b = this . targetWorkspace . getGesture ( a ) ; b && b . handleFlyoutStart ( a , this ) } ; Blockly . Flyout . prototype . isBlockCreatable _ = function ( a ) { return a . isEnabled ( ) } ;
Blockly . Flyout . prototype . createBlock = function ( a ) { var b = null ; Blockly . Events . disable ( ) ; var c = this . targetWorkspace . getAllVariables ( ) ; this . targetWorkspace . setResizesEnabled ( ! 1 ) ; try { b = this . placeNewBlock _ ( a ) } finally { Blockly . Events . enable ( ) } Blockly . hideChaff ( ) ; a = Blockly . Variables . getAddedVariables ( this . targetWorkspace , c ) ; if ( Blockly . Events . isEnabled ( ) ) { Blockly . Events . setGroup ( ! 0 ) ; for ( c = 0 ; c < a . length ; c ++ ) { var d = a [ c ] ; Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . VAR _CREATE ) ) ( d ) ) } Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CREATE ) ) ( b ) ) } this . autoClose ?
this . hide ( ) : this . filterForCapacity _ ( ) ; return b } ; Blockly . Flyout . prototype . initFlyoutButton _ = function ( a , b , c ) { var d = a . createDom ( ) ; a . moveTo ( b , c ) ; a . show ( ) ; this . listeners _ . push ( Blockly . browserEvents . conditionalBind ( d , "mousedown" , this , this . onMouseDown _ ) ) ; this . buttons _ . push ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Flyout . prototype . createRect _ = function ( a , b , c , d , e ) { b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "fill-opacity" : 0 , x : b , y : c , height : d . height , width : d . width } , null ) ; b . tooltip = a ; Blockly . Tooltip . bindMouseEvents ( b ) ; this . workspace _ . getCanvas ( ) . insertBefore ( b , a . getSvgRoot ( ) ) ; a . flyoutRect _ = b ; return this . mats _ [ e ] = b } ;
Blockly . Flyout . prototype . moveRectToBlock _ = function ( a , b ) { var c = b . getHeightWidth ( ) ; a . setAttribute ( "width" , c . width ) ; a . setAttribute ( "height" , c . height ) ; b = b . getRelativeToSurfaceXY ( ) ; a . setAttribute ( "y" , b . y ) ; a . setAttribute ( "x" , this . RTL ? b . x - c . width : b . x ) } ;
Blockly . Flyout . prototype . filterForCapacity _ = function ( ) { for ( var a = this . workspace _ . getTopBlocks ( ! 1 ) , b = 0 , c ; c = a [ b ] ; b ++ ) if ( - 1 == this . permanentlyDisabled _ . indexOf ( c ) ) for ( var d = this . targetWorkspace . isCapacityAvailable ( Blockly . utils . getBlockTypeCounts ( c ) ) ; c ; ) c . setEnabled ( d ) , c = c . getNextBlock ( ) } ; Blockly . Flyout . prototype . reflow = function ( ) { this . reflowWrapper _ && this . workspace _ . removeChangeListener ( this . reflowWrapper _ ) ; this . reflowInternal _ ( ) ; this . reflowWrapper _ && this . workspace _ . addChangeListener ( this . reflowWrapper _ ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Flyout . prototype . isScrollable = function ( ) { return this . workspace _ . scrollbar ? this . workspace _ . scrollbar . isVisible ( ) : ! 1 } ;
2021-01-16 14:07:51 +00:00
Blockly . Flyout . prototype . placeNewBlock _ = function ( a ) { var b = this . targetWorkspace ; if ( ! a . getSvgRoot ( ) ) throw Error ( "oldBlock is not rendered." ) ; var c = Blockly . Xml . blockToDom ( a , ! 0 ) ; b . setResizesEnabled ( ! 1 ) ; c = Blockly . Xml . domToBlock ( c , b ) ; if ( ! c . getSvgRoot ( ) ) throw Error ( "block is not rendered." ) ; var d = b . getOriginOffsetInPixels ( ) , e = this . workspace _ . getOriginOffsetInPixels ( ) ; a = a . getRelativeToSurfaceXY ( ) ; a . scale ( this . workspace _ . scale ) ; a = Blockly . utils . Coordinate . sum ( e , a ) ; d = Blockly . utils . Coordinate . difference ( a , d ) ;
2021-05-19 13:38:55 +00:00
d . scale ( 1 / b . scale ) ; c . moveBy ( d . x , d . y ) ; return c } ; Blockly . HorizontalFlyout = function ( a ) { Blockly . HorizontalFlyout . superClass _ . constructor . call ( this , a ) ; this . horizontalLayout = ! 0 } ; Blockly . utils . object . inherits ( Blockly . HorizontalFlyout , Blockly . Flyout ) ;
Blockly . HorizontalFlyout . prototype . setMetrics _ = function ( a ) { if ( this . isVisible ( ) ) { var b = this . workspace _ . getMetricsManager ( ) , c = b . getScrollMetrics ( ) , d = b . getViewMetrics ( ) ; b = b . getAbsoluteMetrics ( ) ; "number" == typeof a . x && ( this . workspace _ . scrollX = - ( c . left + ( c . width - d . width ) * a . x ) ) ; this . workspace _ . translate ( this . workspace _ . scrollX + b . left , this . workspace _ . scrollY + b . top ) } } ; Blockly . HorizontalFlyout . prototype . getX = function ( ) { return 0 } ;
Blockly . HorizontalFlyout . prototype . getY = function ( ) { if ( ! this . isVisible ( ) ) return 0 ; var a = this . targetWorkspace . getMetricsManager ( ) , b = a . getAbsoluteMetrics ( ) , c = a . getViewMetrics ( ) ; a = a . getToolboxMetrics ( ) ; var d = this . toolboxPosition _ == Blockly . utils . toolbox . Position . TOP ; return this . targetWorkspace . toolboxPosition == this . toolboxPosition _ ? this . targetWorkspace . getToolbox ( ) ? d ? a . height : c . height - this . height _ : d ? 0 : c . height : d ? 0 : c . height + b . top - this . height _ } ;
Blockly . HorizontalFlyout . prototype . position = function ( ) { if ( this . isVisible ( ) && this . targetWorkspace . isVisible ( ) ) { var a = this . targetWorkspace . getMetricsManager ( ) . getViewMetrics ( ) ; this . width _ = a . width ; this . setBackgroundPath _ ( a . width - 2 * this . CORNER _RADIUS , this . height _ - this . CORNER _RADIUS ) ; a = this . getX ( ) ; var b = this . getY ( ) ; this . positionAt _ ( this . width _ , this . height _ , a , b ) } } ;
Blockly . HorizontalFlyout . prototype . setBackgroundPath _ = function ( a , b ) { var c = this . toolboxPosition _ == Blockly . utils . toolbox . Position . TOP , d = [ "M 0," + ( c ? 0 : this . CORNER _RADIUS ) ] ; c ? ( d . push ( "h" , a + 2 * this . CORNER _RADIUS ) , d . push ( "v" , b ) , d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , 1 , - this . CORNER _RADIUS , this . CORNER _RADIUS ) , d . push ( "h" , - a ) , d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , 1 , - this . CORNER _RADIUS , - this . CORNER _RADIUS ) ) : ( d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , 1 , this . CORNER _RADIUS ,
- this . CORNER _RADIUS ) , d . push ( "h" , a ) , d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , 1 , this . CORNER _RADIUS , this . CORNER _RADIUS ) , d . push ( "v" , b ) , d . push ( "h" , - a - 2 * this . CORNER _RADIUS ) ) ; d . push ( "z" ) ; this . svgBackground _ . setAttribute ( "d" , d . join ( " " ) ) } ; Blockly . HorizontalFlyout . prototype . scrollToStart = function ( ) { this . workspace _ . scrollbar . setX ( this . RTL ? Infinity : 0 ) } ;
Blockly . HorizontalFlyout . prototype . wheel _ = function ( a ) { var b = Blockly . utils . getScrollDeltaPixels ( a ) ; if ( b = b . x || b . y ) { var c = this . workspace _ . getMetricsManager ( ) , d = c . getScrollMetrics ( ) ; b = c . getViewMetrics ( ) . left - d . left + b ; this . workspace _ . scrollbar . setX ( b ) ; Blockly . WidgetDiv . hide ( ) ; Blockly . DropDownDiv . hideWithoutAnimation ( ) } a . preventDefault ( ) ; a . stopPropagation ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . HorizontalFlyout . prototype . layout _ = function ( a , b ) { this . workspace _ . scale = this . targetWorkspace . scale ; var c = this . MARGIN , d = c + this . tabWidth _ ; this . RTL && ( a = a . reverse ( ) ) ; for ( var e = 0 , f ; f = a [ e ] ; e ++ ) if ( "block" == f . type ) { f = f . block ; for ( var g = f . getDescendants ( ! 1 ) , h = 0 , k ; k = g [ h ] ; h ++ ) k . isInFlyout = ! 0 ; f . render ( ) ; g = f . getSvgRoot ( ) ; h = f . getHeightWidth ( ) ; k = f . outputConnection ? this . tabWidth _ : 0 ; k = this . RTL ? d + h . width : d - k ; f . moveBy ( k , c ) ; k = this . createRect _ ( f , k , c , h , e ) ; d += h . width + b [ e ] ; this . addBlockListeners _ ( g , f , k ) } else "button" ==
f . type && ( this . initFlyoutButton _ ( f . button , d , c ) , d += f . button . width + b [ e ] ) } ; Blockly . HorizontalFlyout . prototype . isDragTowardWorkspace = function ( a ) { a = Math . atan2 ( a . y , a . x ) / Math . PI * 180 ; var b = this . dragAngleRange _ ; return a < 90 + b && a > 90 - b || a > - 90 - b && a < - 90 + b ? ! 0 : ! 1 } ;
2021-09-18 14:29:06 +00:00
Blockly . HorizontalFlyout . prototype . getClientRect = function ( ) { if ( ! this . svgGroup _ || this . autoClose || ! this . isVisible ( ) ) return null ; var a = this . svgGroup _ . getBoundingClientRect ( ) , b = a . top ; return this . toolboxPosition _ == Blockly . utils . toolbox . Position . TOP ? new Blockly . utils . Rect ( - 1E9 , b + a . height , - 1E9 , 1E9 ) : new Blockly . utils . Rect ( b , 1E9 , - 1E9 , 1E9 ) } ;
2021-05-19 13:38:55 +00:00
Blockly . HorizontalFlyout . prototype . reflowInternal _ = function ( ) { this . workspace _ . scale = this . getFlyoutScale ( ) ; for ( var a = 0 , b = this . workspace _ . getTopBlocks ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) a = Math . max ( a , d . getHeightWidth ( ) . height ) ; a += 1.5 * this . MARGIN ; a *= this . workspace _ . scale ; a += Blockly . Scrollbar . scrollbarThickness ; if ( this . height _ != a ) { for ( c = 0 ; d = b [ c ] ; c ++ ) d . flyoutRect _ && this . moveRectToBlock _ ( d . flyoutRect _ , d ) ; this . targetWorkspace . toolboxPosition != this . toolboxPosition _ || this . toolboxPosition _ != Blockly . utils . toolbox . Position . TOP ||
2021-09-18 14:29:06 +00:00
this . targetWorkspace . getToolbox ( ) || this . targetWorkspace . translate ( this . targetWorkspace . scrollX , this . targetWorkspace . scrollY + a ) ; this . height _ = a ; this . position ( ) ; this . targetWorkspace . recordDragTargets ( ) } } ; Blockly . registry . register ( Blockly . registry . Type . FLYOUTS _HORIZONTAL _TOOLBOX , Blockly . registry . DEFAULT , Blockly . HorizontalFlyout ) ; Blockly . VerticalFlyout = function ( a ) { Blockly . VerticalFlyout . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . VerticalFlyout , Blockly . Flyout ) ; Blockly . VerticalFlyout . registryName = "verticalFlyout" ;
2021-05-19 13:38:55 +00:00
Blockly . VerticalFlyout . prototype . setMetrics _ = function ( a ) { if ( this . isVisible ( ) ) { var b = this . workspace _ . getMetricsManager ( ) , c = b . getScrollMetrics ( ) , d = b . getViewMetrics ( ) ; b = b . getAbsoluteMetrics ( ) ; "number" == typeof a . y && ( this . workspace _ . scrollY = - ( c . top + ( c . height - d . height ) * a . y ) ) ; this . workspace _ . translate ( this . workspace _ . scrollX + b . left , this . workspace _ . scrollY + b . top ) } } ;
Blockly . VerticalFlyout . prototype . getX = function ( ) { if ( ! this . isVisible ( ) ) return 0 ; var a = this . targetWorkspace . getMetricsManager ( ) , b = a . getAbsoluteMetrics ( ) , c = a . getViewMetrics ( ) ; a = a . getToolboxMetrics ( ) ; return this . targetWorkspace . toolboxPosition == this . toolboxPosition _ ? this . targetWorkspace . getToolbox ( ) ? this . toolboxPosition _ == Blockly . utils . toolbox . Position . LEFT ? a . width : c . width - this . width _ : this . toolboxPosition _ == Blockly . utils . toolbox . Position . LEFT ? 0 : c . width : this . toolboxPosition _ == Blockly . utils . toolbox . Position . LEFT ?
0 : c . width + b . left - this . width _ } ; Blockly . VerticalFlyout . prototype . getY = function ( ) { return 0 } ; Blockly . VerticalFlyout . prototype . position = function ( ) { if ( this . isVisible ( ) && this . targetWorkspace . isVisible ( ) ) { var a = this . targetWorkspace . getMetricsManager ( ) . getViewMetrics ( ) ; this . height _ = a . height ; this . setBackgroundPath _ ( this . width _ - this . CORNER _RADIUS , a . height - 2 * this . CORNER _RADIUS ) ; a = this . getX ( ) ; var b = this . getY ( ) ; this . positionAt _ ( this . width _ , this . height _ , a , b ) } } ;
Blockly . VerticalFlyout . prototype . setBackgroundPath _ = function ( a , b ) { var c = this . toolboxPosition _ == Blockly . utils . toolbox . Position . RIGHT , d = a + this . CORNER _RADIUS ; d = [ "M " + ( c ? d : 0 ) + ",0" ] ; d . push ( "h" , c ? - a : a ) ; d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , c ? 0 : 1 , c ? - this . CORNER _RADIUS : this . CORNER _RADIUS , this . CORNER _RADIUS ) ; d . push ( "v" , Math . max ( 0 , b ) ) ; d . push ( "a" , this . CORNER _RADIUS , this . CORNER _RADIUS , 0 , 0 , c ? 0 : 1 , c ? this . CORNER _RADIUS : - this . CORNER _RADIUS , this . CORNER _RADIUS ) ; d . push ( "h" , c ? a : - a ) ; d . push ( "z" ) ; this . svgBackground _ . setAttribute ( "d" ,
d . join ( " " ) ) } ; Blockly . VerticalFlyout . prototype . scrollToStart = function ( ) { this . workspace _ . scrollbar . setY ( 0 ) } ; Blockly . VerticalFlyout . prototype . wheel _ = function ( a ) { var b = Blockly . utils . getScrollDeltaPixels ( a ) ; if ( b . y ) { var c = this . workspace _ . getMetricsManager ( ) , d = c . getScrollMetrics ( ) ; b = c . getViewMetrics ( ) . top - d . top + b . y ; this . workspace _ . scrollbar . setY ( b ) ; Blockly . WidgetDiv . hide ( ) ; Blockly . DropDownDiv . hideWithoutAnimation ( ) } a . preventDefault ( ) ; a . stopPropagation ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . VerticalFlyout . prototype . layout _ = function ( a , b ) { this . workspace _ . scale = this . targetWorkspace . scale ; for ( var c = this . MARGIN , d = this . RTL ? c : c + this . tabWidth _ , e = 0 , f ; f = a [ e ] ; e ++ ) if ( "block" == f . type ) { f = f . block ; for ( var g = f . getDescendants ( ! 1 ) , h = 0 , k ; k = g [ h ] ; h ++ ) k . isInFlyout = ! 0 ; f . render ( ) ; g = f . getSvgRoot ( ) ; h = f . getHeightWidth ( ) ; k = f . outputConnection ? d - this . tabWidth _ : d ; f . moveBy ( k , c ) ; k = this . createRect _ ( f , this . RTL ? k - h . width : k , c , h , e ) ; this . addBlockListeners _ ( g , f , k ) ; c += h . height + b [ e ] } else "button" == f . type && ( this . initFlyoutButton _ ( f . button ,
2021-09-18 14:29:06 +00:00
d , c ) , c += f . button . height + b [ e ] ) } ; Blockly . VerticalFlyout . prototype . isDragTowardWorkspace = function ( a ) { a = Math . atan2 ( a . y , a . x ) / Math . PI * 180 ; var b = this . dragAngleRange _ ; return a < b && a > - b || a < - 180 + b || a > 180 - b ? ! 0 : ! 1 } ;
Blockly . VerticalFlyout . prototype . getClientRect = function ( ) { if ( ! this . svgGroup _ || this . autoClose || ! this . isVisible ( ) ) return null ; var a = this . svgGroup _ . getBoundingClientRect ( ) , b = a . left ; return this . toolboxPosition _ == Blockly . utils . toolbox . Position . LEFT ? new Blockly . utils . Rect ( - 1E9 , 1E9 , - 1E9 , b + a . width ) : new Blockly . utils . Rect ( - 1E9 , 1E9 , b , 1E9 ) } ;
2021-05-19 13:38:55 +00:00
Blockly . VerticalFlyout . prototype . reflowInternal _ = function ( ) { this . workspace _ . scale = this . getFlyoutScale ( ) ; for ( var a = 0 , b = this . workspace _ . getTopBlocks ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) { var e = d . getHeightWidth ( ) . width ; d . outputConnection && ( e -= this . tabWidth _ ) ; a = Math . max ( a , e ) } for ( c = 0 ; d = this . buttons _ [ c ] ; c ++ ) a = Math . max ( a , d . width ) ; a += 1.5 * this . MARGIN + this . tabWidth _ ; a *= this . workspace _ . scale ; a += Blockly . Scrollbar . scrollbarThickness ; if ( this . width _ != a ) { for ( c = 0 ; d = b [ c ] ; c ++ ) { if ( this . RTL ) { e = d . getRelativeToSurfaceXY ( ) . x ; var f = a / this . workspace _ . scale -
this . MARGIN ; d . outputConnection || ( f -= this . tabWidth _ ) ; d . moveBy ( f - e , 0 ) } d . flyoutRect _ && this . moveRectToBlock _ ( d . flyoutRect _ , d ) } if ( this . RTL ) for ( c = 0 ; d = this . buttons _ [ c ] ; c ++ ) b = d . getPosition ( ) . y , d . moveTo ( a / this . workspace _ . scale - d . width - this . MARGIN - this . tabWidth _ , b ) ; this . targetWorkspace . toolboxPosition != this . toolboxPosition _ || this . toolboxPosition _ != Blockly . utils . toolbox . Position . LEFT || this . targetWorkspace . getToolbox ( ) || this . targetWorkspace . translate ( this . targetWorkspace . scrollX + a , this . targetWorkspace . scrollY ) ;
2021-09-18 14:29:06 +00:00
this . width _ = a ; this . position ( ) ; this . targetWorkspace . recordDragTargets ( ) } } ; Blockly . registry . register ( Blockly . registry . Type . FLYOUTS _VERTICAL _TOOLBOX , Blockly . registry . DEFAULT , Blockly . VerticalFlyout ) ; Blockly . FlyoutButton = function ( a , b , c , d ) { this . workspace _ = a ; this . targetWorkspace _ = b ; this . text _ = c . text ; this . position _ = new Blockly . utils . Coordinate ( 0 , 0 ) ; this . isLabel _ = d ; this . callbackKey _ = c . callbackKey || c . callbackkey ; this . cssClass _ = c [ "web-class" ] || null ; this . onMouseUpWrapper _ = null ; this . info = c } ; Blockly . FlyoutButton . MARGIN _X = 5 ; Blockly . FlyoutButton . MARGIN _Y = 2 ; Blockly . FlyoutButton . prototype . width = 0 ; Blockly . FlyoutButton . prototype . height = 0 ;
2021-01-16 14:07:51 +00:00
Blockly . FlyoutButton . prototype . createDom = function ( ) { var a = this . isLabel _ ? "blocklyFlyoutLabel" : "blocklyFlyoutButton" ; this . cssClass _ && ( a += " " + this . cssClass _ ) ; this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : a } , this . workspace _ . getCanvas ( ) ) ; if ( ! this . isLabel _ ) var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyFlyoutButtonShadow" , rx : 4 , ry : 4 , x : 1 , y : 1 } , this . svgGroup _ ) ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : this . isLabel _ ?
"blocklyFlyoutLabelBackground" : "blocklyFlyoutButtonBackground" , rx : 4 , ry : 4 } , this . svgGroup _ ) ; var c = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TEXT , { "class" : this . isLabel _ ? "blocklyFlyoutLabelText" : "blocklyText" , x : 0 , y : 0 , "text-anchor" : "middle" } , this . svgGroup _ ) , d = Blockly . utils . replaceMessageReferences ( this . text _ ) ; this . workspace _ . RTL && ( d += "\u200f" ) ; c . textContent = d ; this . isLabel _ && ( this . svgText _ = c , this . workspace _ . getThemeManager ( ) . subscribe ( this . svgText _ , "flyoutForegroundColour" , "fill" ) ) ; var e = Blockly . utils . style . getComputedStyle ( c ,
"fontSize" ) , f = Blockly . utils . style . getComputedStyle ( c , "fontWeight" ) , g = Blockly . utils . style . getComputedStyle ( c , "fontFamily" ) ; this . width = Blockly . utils . dom . getFastTextWidthWithSizeString ( c , e , f , g ) ; d = Blockly . utils . dom . measureFontMetrics ( d , e , f , g ) ; this . height = d . height ; this . isLabel _ || ( this . width += 2 * Blockly . FlyoutButton . MARGIN _X , this . height += 2 * Blockly . FlyoutButton . MARGIN _Y , b . setAttribute ( "width" , this . width ) , b . setAttribute ( "height" , this . height ) ) ; a . setAttribute ( "width" , this . width ) ; a . setAttribute ( "height" , this . height ) ;
2021-05-19 13:38:55 +00:00
c . setAttribute ( "x" , this . width / 2 ) ; c . setAttribute ( "y" , this . height / 2 - d . height / 2 + d . baseline ) ; this . updateTransform _ ( ) ; this . onMouseUpWrapper _ = Blockly . browserEvents . conditionalBind ( this . svgGroup _ , "mouseup" , this , this . onMouseUp _ ) ; return this . svgGroup _ } ; Blockly . FlyoutButton . prototype . show = function ( ) { this . updateTransform _ ( ) ; this . svgGroup _ . setAttribute ( "display" , "block" ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FlyoutButton . prototype . updateTransform _ = function ( ) { this . svgGroup _ . setAttribute ( "transform" , "translate(" + this . position _ . x + "," + this . position _ . y + ")" ) } ; Blockly . FlyoutButton . prototype . moveTo = function ( a , b ) { this . position _ . x = a ; this . position _ . y = b ; this . updateTransform _ ( ) } ; Blockly . FlyoutButton . prototype . isLabel = function ( ) { return this . isLabel _ } ; Blockly . FlyoutButton . prototype . getPosition = function ( ) { return this . position _ } ; Blockly . FlyoutButton . prototype . getButtonText = function ( ) { return this . text _ } ;
2021-05-19 13:38:55 +00:00
Blockly . FlyoutButton . prototype . getTargetWorkspace = function ( ) { return this . targetWorkspace _ } ; Blockly . FlyoutButton . prototype . dispose = function ( ) { this . onMouseUpWrapper _ && Blockly . browserEvents . unbind ( this . onMouseUpWrapper _ ) ; this . svgGroup _ && Blockly . utils . dom . removeNode ( this . svgGroup _ ) ; this . svgText _ && this . workspace _ . getThemeManager ( ) . unsubscribe ( this . svgText _ ) } ;
2021-09-18 14:29:06 +00:00
Blockly . FlyoutButton . prototype . onMouseUp _ = function ( a ) { ( a = this . targetWorkspace _ . getGesture ( a ) ) && a . cancel ( ) ; this . isLabel _ && this . callbackKey _ ? console . warn ( "Labels should not have callbacks. Label text: " + this . text _ ) : this . isLabel _ || this . callbackKey _ && this . targetWorkspace _ . getButtonCallback ( this . callbackKey _ ) ? this . isLabel _ || this . targetWorkspace _ . getButtonCallback ( this . callbackKey _ ) ( this ) : console . warn ( "Buttons should have callbacks. Button text: " + this . text _ ) } ; Blockly . Css . register ( ".blocklyFlyoutButton {,fill: #888;,cursor: default;,},.blocklyFlyoutButtonShadow {,fill: #666;,},.blocklyFlyoutButton:hover {,fill: #aaa;,},.blocklyFlyoutLabel {,cursor: default;,},.blocklyFlyoutLabelBackground {,opacity: 0;,}" . split ( "," ) ) ; Blockly . Generator = function ( a ) { this . name _ = a ; this . FUNCTION _NAME _PLACEHOLDER _REGEXP _ = new RegExp ( this . FUNCTION _NAME _PLACEHOLDER _ , "g" ) } ; Blockly . Generator . prototype . INFINITE _LOOP _TRAP = null ; Blockly . Generator . prototype . STATEMENT _PREFIX = null ; Blockly . Generator . prototype . STATEMENT _SUFFIX = null ; Blockly . Generator . prototype . INDENT = " " ; Blockly . Generator . prototype . COMMENT _WRAP = 60 ; Blockly . Generator . prototype . ORDER _OVERRIDES = [ ] ; Blockly . Generator . prototype . isInitialized = null ;
2021-01-16 14:07:51 +00:00
Blockly . Generator . prototype . workspaceToCode = function ( a ) { a || ( console . warn ( "No workspace specified in workspaceToCode call. Guessing." ) , a = Blockly . getMainWorkspace ( ) ) ; var b = [ ] ; this . init ( a ) ; a = a . getTopBlocks ( ! 0 ) ; for ( var c = 0 , d ; d = a [ c ] ; c ++ ) { var e = this . blockToCode ( d ) ; Array . isArray ( e ) && ( e = e [ 0 ] ) ; e && ( d . outputConnection && ( e = this . scrubNakedValue ( e ) , this . STATEMENT _PREFIX && ! d . suppressPrefixSuffix && ( e = this . injectId ( this . STATEMENT _PREFIX , d ) + e ) , this . STATEMENT _SUFFIX && ! d . suppressPrefixSuffix && ( e += this . injectId ( this . STATEMENT _SUFFIX ,
d ) ) ) , b . push ( e ) ) } b = b . join ( "\n" ) ; b = this . finish ( b ) ; b = b . replace ( /^\s+\n/ , "" ) ; b = b . replace ( /\n\s+$/ , "\n" ) ; return b = b . replace ( /[ \t]+\n/g , "\n" ) } ; Blockly . Generator . prototype . prefixLines = function ( a , b ) { return b + a . replace ( /(?!\n$)\n/g , "\n" + b ) } ; Blockly . Generator . prototype . allNestedComments = function ( a ) { var b = [ ] ; a = a . getDescendants ( ! 0 ) ; for ( var c = 0 ; c < a . length ; c ++ ) { var d = a [ c ] . getCommentText ( ) ; d && b . push ( d ) } b . length && b . push ( "" ) ; return b . join ( "\n" ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Generator . prototype . blockToCode = function ( a , b ) { ! 1 === this . isInitialized && console . warn ( "Generator init was not called before blockToCode was called." ) ; if ( ! a ) return "" ; if ( ! a . isEnabled ( ) ) return b ? "" : this . blockToCode ( a . getNextBlock ( ) ) ; if ( a . isInsertionMarker ( ) ) return b ? "" : this . blockToCode ( a . getChildren ( ! 1 ) [ 0 ] ) ; var c = this [ a . type ] ; if ( "function" != typeof c ) throw Error ( 'Language "' + this . name _ + '" does not know how to generate code for block type "' + a . type + '".' ) ; c = c . call ( a , a ) ; if ( Array . isArray ( c ) ) { if ( ! a . outputConnection ) throw TypeError ( "Expecting string from statement block: " +
2021-01-16 14:07:51 +00:00
a . type ) ; return [ this . scrub _ ( a , c [ 0 ] , b ) , c [ 1 ] ] } if ( "string" == typeof c ) return this . STATEMENT _PREFIX && ! a . suppressPrefixSuffix && ( c = this . injectId ( this . STATEMENT _PREFIX , a ) + c ) , this . STATEMENT _SUFFIX && ! a . suppressPrefixSuffix && ( c += this . injectId ( this . STATEMENT _SUFFIX , a ) ) , this . scrub _ ( a , c , b ) ; if ( null === c ) return "" ; throw SyntaxError ( "Invalid code generated: " + c ) ; } ;
Blockly . Generator . prototype . valueToCode = function ( a , b , c ) { if ( isNaN ( c ) ) throw TypeError ( "Expecting valid order from block: " + a . type ) ; var d = a . getInputTargetBlock ( b ) ; if ( ! d ) return "" ; b = this . blockToCode ( d ) ; if ( "" === b ) return "" ; if ( ! Array . isArray ( b ) ) throw TypeError ( "Expecting tuple from value block: " + d . type ) ; a = b [ 0 ] ; b = b [ 1 ] ; if ( isNaN ( b ) ) throw TypeError ( "Expecting valid order from value block: " + d . type ) ; if ( ! a ) return "" ; d = ! 1 ; var e = Math . floor ( c ) , f = Math . floor ( b ) ; if ( e <= f && ( e != f || 0 != e && 99 != e ) ) for ( d = ! 0 , e = 0 ; e < this . ORDER _OVERRIDES . length ; e ++ ) if ( this . ORDER _OVERRIDES [ e ] [ 0 ] ==
c && this . ORDER _OVERRIDES [ e ] [ 1 ] == b ) { d = ! 1 ; break } d && ( a = "(" + a + ")" ) ; return a } ; Blockly . Generator . prototype . statementToCode = function ( a , b ) { a = a . getInputTargetBlock ( b ) ; b = this . blockToCode ( a ) ; if ( "string" != typeof b ) throw TypeError ( "Expecting code from statement block: " + ( a && a . type ) ) ; b && ( b = this . prefixLines ( b , this . INDENT ) ) ; return b } ;
Blockly . Generator . prototype . addLoopTrap = function ( a , b ) { this . INFINITE _LOOP _TRAP && ( a = this . prefixLines ( this . injectId ( this . INFINITE _LOOP _TRAP , b ) , this . INDENT ) + a ) ; this . STATEMENT _SUFFIX && ! b . suppressPrefixSuffix && ( a = this . prefixLines ( this . injectId ( this . STATEMENT _SUFFIX , b ) , this . INDENT ) + a ) ; this . STATEMENT _PREFIX && ! b . suppressPrefixSuffix && ( a += this . prefixLines ( this . injectId ( this . STATEMENT _PREFIX , b ) , this . INDENT ) ) ; return a } ;
Blockly . Generator . prototype . injectId = function ( a , b ) { b = b . id . replace ( /\$/g , "$$$$" ) ; return a . replace ( /%1/g , "'" + b + "'" ) } ; Blockly . Generator . prototype . RESERVED _WORDS _ = "" ; Blockly . Generator . prototype . addReservedWords = function ( a ) { this . RESERVED _WORDS _ += a + "," } ; Blockly . Generator . prototype . FUNCTION _NAME _PLACEHOLDER _ = "{leCUI8hutHZI4480Dc}" ;
2021-09-18 14:29:06 +00:00
Object . defineProperty ( Blockly . Generator . prototype , "variableDB_" , { get : function ( ) { Blockly . utils . deprecation . warn ( "variableDB_" , "May 2021" , "May 2026" , "nameDB_" ) ; return this . nameDB _ } , set : function ( a ) { Blockly . utils . deprecation . warn ( "variableDB_" , "May 2021" , "May 2026" , "nameDB_" ) ; this . nameDB _ = a } } ) ;
Blockly . Generator . prototype . provideFunction _ = function ( a , b ) { if ( ! this . definitions _ [ a ] ) { var c = this . nameDB _ . getDistinctName ( a , Blockly . PROCEDURE _CATEGORY _NAME ) ; this . functionNames _ [ a ] = c ; b = b . join ( "\n" ) . replace ( this . FUNCTION _NAME _PLACEHOLDER _REGEXP _ , c ) ; for ( var d ; d != b ; ) d = b , b = b . replace ( /^(( {2})*) {2}/gm , "$1\x00" ) ; b = b . replace ( /\0/g , this . INDENT ) ; this . definitions _ [ a ] = b } return this . functionNames _ [ a ] } ; Blockly . Generator . prototype . init = function ( a ) { this . definitions _ = Object . create ( null ) ; this . functionNames _ = Object . create ( null ) } ;
Blockly . Generator . prototype . scrub _ = function ( a , b , c ) { return b } ; Blockly . Generator . prototype . finish = function ( a ) { delete this . definitions _ ; delete this . functionNames _ ; return a } ; Blockly . Generator . prototype . scrubNakedValue = function ( a ) { return a } ; Blockly . IToolboxItem = function ( ) { } ; Blockly . ISelectableToolboxItem = function ( ) { } ; Blockly . ICollapsibleToolboxItem = function ( ) { } ; Blockly . ToolboxItem = function ( a , b , c ) { this . id _ = a . toolboxitemid || Blockly . utils . IdGenerator . getNextUniqueId ( ) ; this . level _ = ( this . parent _ = c || null ) ? this . parent _ . getLevel ( ) + 1 : 0 ; this . toolboxItemDef _ = a ; this . parentToolbox _ = b ; this . workspace _ = this . parentToolbox _ . getWorkspace ( ) } ; Blockly . ToolboxItem . prototype . init = function ( ) { } ; Blockly . ToolboxItem . prototype . getDiv = function ( ) { return null } ; Blockly . ToolboxItem . prototype . getId = function ( ) { return this . id _ } ; Blockly . ToolboxItem . prototype . getParent = function ( ) { return null } ;
2021-01-16 14:07:51 +00:00
Blockly . ToolboxItem . prototype . getLevel = function ( ) { return this . level _ } ; Blockly . ToolboxItem . prototype . isSelectable = function ( ) { return ! 1 } ; Blockly . ToolboxItem . prototype . isCollapsible = function ( ) { return ! 1 } ; Blockly . ToolboxItem . prototype . dispose = function ( ) { } ; Blockly . ToolboxCategory = function ( a , b , c ) { Blockly . ToolboxCategory . superClass _ . constructor . call ( this , a , b , c ) ; this . name _ = Blockly . utils . replaceMessageReferences ( a . name ) ; this . colour _ = this . getColour _ ( a ) ; this . labelDom _ = this . iconDom _ = this . rowContents _ = this . rowDiv _ = this . htmlDiv _ = null ; this . cssConfig _ = this . makeDefaultCssConfig _ ( ) ; Blockly . utils . object . mixin ( this . cssConfig _ , a . cssconfig || a . cssConfig ) ; this . isDisabled _ = this . isHidden _ = ! 1 ; this . flyoutItems _ = [ ] ; this . parseContents _ ( a ) } ;
Blockly . utils . object . inherits ( Blockly . ToolboxCategory , Blockly . ToolboxItem ) ; Blockly . ToolboxCategory . registrationName = "category" ; Blockly . ToolboxCategory . nestedPadding = 19 ; Blockly . ToolboxCategory . borderWidth = 8 ; Blockly . ToolboxCategory . defaultBackgroundColour = "#57e" ;
Blockly . ToolboxCategory . prototype . makeDefaultCssConfig _ = function ( ) { return { container : "blocklyToolboxCategory" , row : "blocklyTreeRow" , rowcontentcontainer : "blocklyTreeRowContentContainer" , icon : "blocklyTreeIcon" , label : "blocklyTreeLabel" , contents : "blocklyToolboxContents" , selected : "blocklyTreeSelected" , openicon : "blocklyTreeIconOpen" , closedicon : "blocklyTreeIconClosed" } } ;
Blockly . ToolboxCategory . prototype . parseContents _ = function ( a ) { var b = a . contents ; if ( a . custom ) this . flyoutItems _ = a . custom ; else if ( b ) { a = 0 ; for ( var c ; c = b [ a ] ; a ++ ) this . flyoutItems _ . push ( c ) } } ; Blockly . ToolboxCategory . prototype . init = function ( ) { this . createDom _ ( ) ; "true" == this . toolboxItemDef _ . hidden && this . hide ( ) } ;
Blockly . ToolboxCategory . prototype . createDom _ = function ( ) { this . htmlDiv _ = this . createContainer _ ( ) ; Blockly . utils . aria . setRole ( this . htmlDiv _ , Blockly . utils . aria . Role . TREEITEM ) ; Blockly . utils . aria . setState ( this . htmlDiv _ , Blockly . utils . aria . State . SELECTED , ! 1 ) ; Blockly . utils . aria . setState ( this . htmlDiv _ , Blockly . utils . aria . State . LEVEL , this . level _ ) ; this . rowDiv _ = this . createRowContainer _ ( ) ; this . rowDiv _ . style . pointerEvents = "auto" ; this . htmlDiv _ . appendChild ( this . rowDiv _ ) ; this . rowContents _ = this . createRowContentsContainer _ ( ) ;
this . rowContents _ . style . pointerEvents = "none" ; this . rowDiv _ . appendChild ( this . rowContents _ ) ; this . iconDom _ = this . createIconDom _ ( ) ; Blockly . utils . aria . setRole ( this . iconDom _ , Blockly . utils . aria . Role . PRESENTATION ) ; this . rowContents _ . appendChild ( this . iconDom _ ) ; this . labelDom _ = this . createLabelDom _ ( this . name _ ) ; this . rowContents _ . appendChild ( this . labelDom _ ) ; Blockly . utils . aria . setState ( this . htmlDiv _ , Blockly . utils . aria . State . LABELLEDBY , this . labelDom _ . getAttribute ( "id" ) ) ; this . addColourBorder _ ( this . colour _ ) ; return this . htmlDiv _ } ;
Blockly . ToolboxCategory . prototype . createContainer _ = function ( ) { var a = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( a , this . cssConfig _ . container ) ; return a } ; Blockly . ToolboxCategory . prototype . createRowContainer _ = function ( ) { var a = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( a , this . cssConfig _ . row ) ; var b = Blockly . ToolboxCategory . nestedPadding * this . getLevel ( ) ; b = b . toString ( ) + "px" ; this . workspace _ . RTL ? a . style . paddingRight = b : a . style . paddingLeft = b ; return a } ;
Blockly . ToolboxCategory . prototype . createRowContentsContainer _ = function ( ) { var a = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( a , this . cssConfig _ . rowcontentcontainer ) ; return a } ; Blockly . ToolboxCategory . prototype . createIconDom _ = function ( ) { var a = document . createElement ( "span" ) ; this . parentToolbox _ . isHorizontal ( ) || Blockly . utils . dom . addClass ( a , this . cssConfig _ . icon ) ; a . style . display = "inline-block" ; return a } ;
Blockly . ToolboxCategory . prototype . createLabelDom _ = function ( a ) { var b = document . createElement ( "span" ) ; b . setAttribute ( "id" , this . getId ( ) + ".label" ) ; b . textContent = a ; Blockly . utils . dom . addClass ( b , this . cssConfig _ . label ) ; return b } ; Blockly . ToolboxCategory . prototype . refreshTheme = function ( ) { this . colour _ = this . getColour _ ( this . toolboxItemDef _ ) ; this . addColourBorder _ ( this . colour _ ) } ;
Blockly . ToolboxCategory . prototype . addColourBorder _ = function ( a ) { a && ( a = Blockly . ToolboxCategory . borderWidth + "px solid " + ( a || "#ddd" ) , this . workspace _ . RTL ? this . rowDiv _ . style . borderRight = a : this . rowDiv _ . style . borderLeft = a ) } ; Blockly . ToolboxCategory . prototype . getColour _ = function ( a ) { var b = a . categorystyle || a . categoryStyle ; if ( ( a = a . colour ) && b ) console . warn ( 'Toolbox category "' + this . name _ + '" must not have both a style and a colour' ) ; else return b ? this . getColourfromStyle _ ( b ) : this . parseColour _ ( a ) ; return "" } ;
Blockly . ToolboxCategory . prototype . getColourfromStyle _ = function ( a ) { var b = this . workspace _ . getTheme ( ) ; if ( a && b ) { if ( ( b = b . categoryStyles [ a ] ) && b . colour ) return this . parseColour _ ( b . colour ) ; console . warn ( 'Style "' + a + '" must exist and contain a colour value' ) } return "" } ; Blockly . ToolboxCategory . prototype . getClickTarget = function ( ) { return this . rowDiv _ } ;
Blockly . ToolboxCategory . prototype . parseColour _ = function ( a ) { a = Blockly . utils . replaceMessageReferences ( a ) ; if ( null == a || "" === a ) return "" ; var b = Number ( a ) ; if ( isNaN ( b ) ) { if ( b = Blockly . utils . colour . parse ( a ) ) return b ; console . warn ( 'Toolbox category "' + this . name _ + '" has unrecognized colour attribute: ' + a ) ; return "" } return Blockly . hueToHex ( b ) } ; Blockly . ToolboxCategory . prototype . openIcon _ = function ( a ) { a && ( Blockly . utils . dom . removeClasses ( a , this . cssConfig _ . closedicon ) , Blockly . utils . dom . addClass ( a , this . cssConfig _ . openicon ) ) } ;
Blockly . ToolboxCategory . prototype . closeIcon _ = function ( a ) { a && ( Blockly . utils . dom . removeClasses ( a , this . cssConfig _ . openicon ) , Blockly . utils . dom . addClass ( a , this . cssConfig _ . closedicon ) ) } ; Blockly . ToolboxCategory . prototype . setVisible _ = function ( a ) { this . htmlDiv _ . style . display = a ? "block" : "none" ; this . isHidden _ = ! a ; this . parentToolbox _ . getSelectedItem ( ) == this && this . parentToolbox _ . clearSelection ( ) } ; Blockly . ToolboxCategory . prototype . hide = function ( ) { this . setVisible _ ( ! 1 ) } ; Blockly . ToolboxCategory . prototype . show = function ( ) { this . setVisible _ ( ! 0 ) } ;
Blockly . ToolboxCategory . prototype . isVisible = function ( ) { return ! this . isHidden _ && this . allAncestorsExpanded _ ( ) } ; Blockly . ToolboxCategory . prototype . allAncestorsExpanded _ = function ( ) { for ( var a = this ; a . getParent ( ) ; ) if ( a = a . getParent ( ) , ! a . isExpanded ( ) ) return ! 1 ; return ! 0 } ; Blockly . ToolboxCategory . prototype . isSelectable = function ( ) { return this . isVisible ( ) && ! this . isDisabled _ } ; Blockly . ToolboxCategory . prototype . onClick = function ( a ) { } ;
Blockly . ToolboxCategory . prototype . setSelected = function ( a ) { if ( a ) { var b = this . parseColour _ ( Blockly . ToolboxCategory . defaultBackgroundColour ) ; this . rowDiv _ . style . backgroundColor = this . colour _ || b ; Blockly . utils . dom . addClass ( this . rowDiv _ , this . cssConfig _ . selected ) } else this . rowDiv _ . style . backgroundColor = "" , Blockly . utils . dom . removeClass ( this . rowDiv _ , this . cssConfig _ . selected ) ; Blockly . utils . aria . setState ( this . htmlDiv _ , Blockly . utils . aria . State . SELECTED , a ) } ;
Blockly . ToolboxCategory . prototype . setDisabled = function ( a ) { this . isDisabled _ = a ; this . getDiv ( ) . setAttribute ( "disabled" , a ) ; a ? this . getDiv ( ) . setAttribute ( "disabled" , "true" ) : this . getDiv ( ) . removeAttribute ( "disabled" ) } ; Blockly . ToolboxCategory . prototype . getName = function ( ) { return this . name _ } ; Blockly . ToolboxCategory . prototype . getParent = function ( ) { return this . parent _ } ; Blockly . ToolboxCategory . prototype . getDiv = function ( ) { return this . htmlDiv _ } ; Blockly . ToolboxCategory . prototype . getContents = function ( ) { return this . flyoutItems _ } ;
Blockly . ToolboxCategory . prototype . updateFlyoutContents = function ( a ) { this . flyoutItems _ = [ ] ; "string" == typeof a ? this . toolboxItemDef _ . custom = a : ( delete this . toolboxItemDef _ . custom , this . toolboxItemDef _ . contents = Blockly . utils . toolbox . convertFlyoutDefToJsonArray ( a ) ) ; this . parseContents _ ( this . toolboxItemDef _ ) } ; Blockly . ToolboxCategory . prototype . dispose = function ( ) { Blockly . utils . dom . removeNode ( this . htmlDiv _ ) } ;
Blockly . Css . register ( [ ".blocklyTreeRow:not(.blocklyTreeSelected):hover {" , "background-color: rgba(255, 255, 255, 0.2);" , "}" , '.blocklyToolboxDiv[layout="h"] .blocklyToolboxCategory {' , "margin: 1px 5px 1px 0;" , "}" , '.blocklyToolboxDiv[dir="RTL"][layout="h"] .blocklyToolboxCategory {' , "margin: 1px 0 1px 5px;" , "}" , ".blocklyTreeRow {" , "height: 22px;" , "line-height: 22px;" , "margin-bottom: 3px;" , "padding-right: 8px;" , "white-space: nowrap;" , "}" , '.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {' , "margin-left: 8px;" ,
"padding-right: 0px" , "}" , ".blocklyTreeIcon {" , "background-image: url(<<<PATH>>>/sprites.png);" , "height: 16px;" , "vertical-align: middle;" , "visibility: hidden;" , "width: 16px;" , "}" , ".blocklyTreeIconClosed {" , "background-position: -32px -1px;" , "}" , '.blocklyToolboxDiv[dir="RTL"] .blocklyTreeIconClosed {' , "background-position: 0 -1px;" , "}" , ".blocklyTreeSelected>.blocklyTreeIconClosed {" , "background-position: -32px -17px;" , "}" , '.blocklyToolboxDiv[dir="RTL"] .blocklyTreeSelected>.blocklyTreeIconClosed {' ,
"background-position: 0 -17px;" , "}" , ".blocklyTreeIconOpen {" , "background-position: -16px -1px;" , "}" , ".blocklyTreeSelected>.blocklyTreeIconOpen {" , "background-position: -16px -17px;" , "}" , ".blocklyTreeLabel {" , "cursor: default;" , "font: 16px sans-serif;" , "padding: 0 3px;" , "vertical-align: middle;" , "}" , ".blocklyToolboxDelete .blocklyTreeLabel {" , 'cursor: url("<<<PATH>>>/handdelete.cur"), auto;' , "}" , ".blocklyTreeSelected .blocklyTreeLabel {" , "color: #fff;" , "}" ] ) ;
Blockly . registry . register ( Blockly . registry . Type . TOOLBOX _ITEM , Blockly . ToolboxCategory . registrationName , Blockly . ToolboxCategory ) ; Blockly . ToolboxSeparator = function ( a , b ) { Blockly . ToolboxSeparator . superClass _ . constructor . call ( this , a , b ) ; this . cssConfig _ = { container : "blocklyTreeSeparator" } ; Blockly . utils . object . mixin ( this . cssConfig _ , a . cssconfig || a . cssConfig ) } ; Blockly . utils . object . inherits ( Blockly . ToolboxSeparator , Blockly . ToolboxItem ) ; Blockly . ToolboxSeparator . registrationName = "sep" ; Blockly . ToolboxSeparator . prototype . init = function ( ) { this . createDom _ ( ) } ;
Blockly . ToolboxSeparator . prototype . createDom _ = function ( ) { var a = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( a , this . cssConfig _ . container ) ; return this . htmlDiv _ = a } ; Blockly . ToolboxSeparator . prototype . getDiv = function ( ) { return this . htmlDiv _ } ; Blockly . ToolboxSeparator . prototype . dispose = function ( ) { Blockly . utils . dom . removeNode ( this . htmlDiv _ ) } ; Blockly . Css . register ( '.blocklyTreeSeparator {,border-bottom: solid #e5e5e5 1px;,height: 0;,margin: 5px 0;,},.blocklyToolboxDiv[layout="h"] .blocklyTreeSeparator {,border-right: solid #e5e5e5 1px;,border-bottom: none;,height: auto;,margin: 0 5px 0 5px;,padding: 5px 0;,width: 0;,}' . split ( "," ) ) ;
Blockly . registry . register ( Blockly . registry . Type . TOOLBOX _ITEM , Blockly . ToolboxSeparator . registrationName , Blockly . ToolboxSeparator ) ; Blockly . CollapsibleToolboxCategory = function ( a , b , c ) { this . subcategoriesDiv _ = null ; this . expanded _ = ! 1 ; this . toolboxItems _ = [ ] ; Blockly . CollapsibleToolboxCategory . superClass _ . constructor . call ( this , a , b , c ) } ; Blockly . utils . object . inherits ( Blockly . CollapsibleToolboxCategory , Blockly . ToolboxCategory ) ; Blockly . CollapsibleToolboxCategory . registrationName = "collapsibleCategory" ;
Blockly . CollapsibleToolboxCategory . prototype . makeDefaultCssConfig _ = function ( ) { var a = Blockly . CollapsibleToolboxCategory . superClass _ . makeDefaultCssConfig _ . call ( this ) ; a . contents = "blocklyToolboxContents" ; return a } ;
Blockly . CollapsibleToolboxCategory . prototype . parseContents _ = function ( a ) { var b = a . contents , c = ! 0 ; if ( a . custom ) this . flyoutItems _ = a . custom ; else if ( b ) { a = 0 ; for ( var d ; d = b [ a ] ; a ++ ) ! Blockly . registry . hasItem ( Blockly . registry . Type . TOOLBOX _ITEM , d . kind ) || d . kind . toLowerCase ( ) == Blockly . ToolboxSeparator . registrationName && c ? ( this . flyoutItems _ . push ( d ) , c = ! 0 ) : ( this . createToolboxItem _ ( d ) , c = ! 1 ) } } ;
Blockly . CollapsibleToolboxCategory . prototype . createToolboxItem _ = function ( a ) { var b = a . kind ; "CATEGORY" == b . toUpperCase ( ) && Blockly . utils . toolbox . isCategoryCollapsible ( a ) && ( b = Blockly . CollapsibleToolboxCategory . registrationName ) ; a = new ( Blockly . registry . getClass ( Blockly . registry . Type . TOOLBOX _ITEM , b ) ) ( a , this . parentToolbox _ , this ) ; this . toolboxItems _ . push ( a ) } ;
Blockly . CollapsibleToolboxCategory . prototype . init = function ( ) { Blockly . CollapsibleToolboxCategory . superClass _ . init . call ( this ) ; this . setExpanded ( "true" == this . toolboxItemDef _ . expanded || this . toolboxItemDef _ . expanded ) } ;
Blockly . CollapsibleToolboxCategory . prototype . createDom _ = function ( ) { Blockly . CollapsibleToolboxCategory . superClass _ . createDom _ . call ( this ) ; var a = this . getChildToolboxItems ( ) ; this . subcategoriesDiv _ = this . createSubCategoriesDom _ ( a ) ; Blockly . utils . aria . setRole ( this . subcategoriesDiv _ , Blockly . utils . aria . Role . GROUP ) ; this . htmlDiv _ . appendChild ( this . subcategoriesDiv _ ) ; return this . htmlDiv _ } ;
Blockly . CollapsibleToolboxCategory . prototype . createIconDom _ = function ( ) { var a = document . createElement ( "span" ) ; this . parentToolbox _ . isHorizontal ( ) || ( Blockly . utils . dom . addClass ( a , this . cssConfig _ . icon ) , a . style . visibility = "visible" ) ; a . style . display = "inline-block" ; return a } ;
Blockly . CollapsibleToolboxCategory . prototype . createSubCategoriesDom _ = function ( a ) { var b = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( b , this . cssConfig _ . contents ) ; for ( var c = 0 ; c < a . length ; c ++ ) { var d = a [ c ] ; d . init ( ) ; var e = d . getDiv ( ) ; b . appendChild ( e ) ; d . getClickTarget && d . getClickTarget ( ) . setAttribute ( "id" , d . getId ( ) ) } return b } ;
Blockly . CollapsibleToolboxCategory . prototype . setExpanded = function ( a ) { this . expanded _ != a && ( ( this . expanded _ = a ) ? ( this . subcategoriesDiv _ . style . display = "block" , this . openIcon _ ( this . iconDom _ ) ) : ( this . subcategoriesDiv _ . style . display = "none" , this . closeIcon _ ( this . iconDom _ ) ) , Blockly . utils . aria . setState ( this . htmlDiv _ , Blockly . utils . aria . State . EXPANDED , a ) , this . parentToolbox _ . handleToolboxItemResize ( ) ) } ;
Blockly . CollapsibleToolboxCategory . prototype . setVisible _ = function ( a ) { this . htmlDiv _ . style . display = a ? "block" : "none" ; for ( var b = 0 , c ; c = this . getChildToolboxItems ( ) [ b ] ; b ++ ) c . setVisible _ ( a ) ; this . isHidden _ = ! a ; this . parentToolbox _ . getSelectedItem ( ) == this && this . parentToolbox _ . clearSelection ( ) } ; Blockly . CollapsibleToolboxCategory . prototype . isExpanded = function ( ) { return this . expanded _ } ; Blockly . CollapsibleToolboxCategory . prototype . isCollapsible = function ( ) { return ! 0 } ;
Blockly . CollapsibleToolboxCategory . prototype . onClick = function ( a ) { this . toggleExpanded ( ) } ; Blockly . CollapsibleToolboxCategory . prototype . toggleExpanded = function ( ) { this . setExpanded ( ! this . expanded _ ) } ; Blockly . CollapsibleToolboxCategory . prototype . getDiv = function ( ) { return this . htmlDiv _ } ; Blockly . CollapsibleToolboxCategory . prototype . getChildToolboxItems = function ( ) { return this . toolboxItems _ } ; Blockly . registry . register ( Blockly . registry . Type . TOOLBOX _ITEM , Blockly . CollapsibleToolboxCategory . registrationName , Blockly . CollapsibleToolboxCategory ) ; Blockly . Events . ToolboxItemSelect = function ( a , b , c ) { Blockly . Events . ToolboxItemSelect . superClass _ . constructor . call ( this , c ) ; this . oldItem = a ; this . newItem = b } ; Blockly . utils . object . inherits ( Blockly . Events . ToolboxItemSelect , Blockly . Events . UiBase ) ; Blockly . Events . ToolboxItemSelect . prototype . type = Blockly . Events . TOOLBOX _ITEM _SELECT ; Blockly . Events . ToolboxItemSelect . prototype . toJson = function ( ) { var a = Blockly . Events . ToolboxItemSelect . superClass _ . toJson . call ( this ) ; a . oldItem = this . oldItem ; a . newItem = this . newItem ; return a } ;
2021-09-18 14:29:06 +00:00
Blockly . Events . ToolboxItemSelect . prototype . fromJson = function ( a ) { Blockly . Events . ToolboxItemSelect . superClass _ . fromJson . call ( this , a ) ; this . oldItem = a . oldItem ; this . newItem = a . newItem } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . TOOLBOX _ITEM _SELECT , Blockly . Events . ToolboxItemSelect ) ; Blockly . IAutoHideable = function ( ) { } ; Blockly . IStyleable = function ( ) { } ; Blockly . IToolbox = function ( ) { } ; Blockly . Toolbox = function ( a ) { Blockly . Toolbox . superClass _ . constructor . call ( this ) ; this . workspace _ = a ; this . id = "toolbox" ; this . toolboxDef _ = a . options . languageTree || { contents : [ ] } ; this . horizontalLayout _ = a . options . horizontalLayout ; this . contentsDiv _ = this . HtmlDiv = null ; this . isVisible _ = ! 1 ; this . contents _ = [ ] ; this . height _ = this . width _ = 0 ; this . RTL = a . options . RTL ; this . flyout _ = null ; this . contentMap _ = Object . create ( null ) ; this . toolboxPosition = a . options . toolboxPosition ; this . previouslySelectedItem _ = this . selectedItem _ = null ; this . boundEvents _ =
[ ] } ; Blockly . utils . object . inherits ( Blockly . Toolbox , Blockly . DeleteArea ) ; Blockly . Toolbox . prototype . onShortcut = function ( a ) { return ! 1 } ;
Blockly . Toolbox . prototype . init = function ( ) { var a = this . workspace _ , b = a . getParentSvg ( ) ; this . flyout _ = this . createFlyout _ ( ) ; this . HtmlDiv = this . createDom _ ( this . workspace _ ) ; Blockly . utils . dom . insertAfter ( this . flyout _ . createDom ( "svg" ) , b ) ; this . setVisible ( ! 0 ) ; this . flyout _ . init ( a ) ; this . render ( this . toolboxDef _ ) ; a = a . getThemeManager ( ) ; a . subscribe ( this . HtmlDiv , "toolboxBackgroundColour" , "background-color" ) ; a . subscribe ( this . HtmlDiv , "toolboxForegroundColour" , "color" ) ; this . workspace _ . getComponentManager ( ) . addComponent ( { component : this ,
weight : 1 , capabilities : [ Blockly . ComponentManager . Capability . AUTOHIDEABLE , Blockly . ComponentManager . Capability . DELETE _AREA , Blockly . ComponentManager . Capability . DRAG _TARGET ] } ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Toolbox . prototype . createDom _ = function ( a ) { a = a . getParentSvg ( ) ; var b = this . createContainer _ ( ) ; this . contentsDiv _ = this . createContentsContainer _ ( ) ; this . contentsDiv _ . tabIndex = 0 ; Blockly . utils . aria . setRole ( this . contentsDiv _ , Blockly . utils . aria . Role . TREE ) ; b . appendChild ( this . contentsDiv _ ) ; a . parentNode . insertBefore ( b , a ) ; this . attachEvents _ ( b , this . contentsDiv _ ) ; return b } ;
Blockly . Toolbox . prototype . createContainer _ = function ( ) { var a = document . createElement ( "div" ) ; a . setAttribute ( "layout" , this . isHorizontal ( ) ? "h" : "v" ) ; Blockly . utils . dom . addClass ( a , "blocklyToolboxDiv" ) ; Blockly . utils . dom . addClass ( a , "blocklyNonSelectable" ) ; a . setAttribute ( "dir" , this . RTL ? "RTL" : "LTR" ) ; return a } ;
2021-05-19 13:38:55 +00:00
Blockly . Toolbox . prototype . createContentsContainer _ = function ( ) { var a = document . createElement ( "div" ) ; Blockly . utils . dom . addClass ( a , "blocklyToolboxContents" ) ; this . isHorizontal ( ) && ( a . style . flexDirection = "row" ) ; return a } ; Blockly . Toolbox . prototype . attachEvents _ = function ( a , b ) { a = Blockly . browserEvents . conditionalBind ( a , "click" , this , this . onClick _ , ! 1 , ! 0 ) ; this . boundEvents _ . push ( a ) ; b = Blockly . browserEvents . conditionalBind ( b , "keydown" , this , this . onKeyDown _ , ! 1 , ! 0 ) ; this . boundEvents _ . push ( b ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Toolbox . prototype . onClick _ = function ( a ) { if ( Blockly . utils . isRightButton ( a ) || a . target == this . HtmlDiv ) Blockly . hideChaff ( ! 1 ) ; else { var b = a . target . getAttribute ( "id" ) ; b && ( b = this . getToolboxItemById ( b ) , b . isSelectable ( ) && ( this . setSelectedItem ( b ) , b . onClick ( a ) ) ) ; Blockly . hideChaff ( ! 0 ) } Blockly . Touch . clearTouchIdentifier ( ) } ;
Blockly . Toolbox . prototype . onKeyDown _ = function ( a ) { var b = ! 1 ; switch ( a . keyCode ) { case Blockly . utils . KeyCodes . DOWN : b = this . selectNext _ ( ) ; break ; case Blockly . utils . KeyCodes . UP : b = this . selectPrevious _ ( ) ; break ; case Blockly . utils . KeyCodes . LEFT : b = this . selectParent _ ( ) ; break ; case Blockly . utils . KeyCodes . RIGHT : b = this . selectChild _ ( ) ; break ; case Blockly . utils . KeyCodes . ENTER : case Blockly . utils . KeyCodes . SPACE : this . selectedItem _ && this . selectedItem _ . isCollapsible ( ) && ( this . selectedItem _ . toggleExpanded ( ) , b = ! 0 ) ; break ; default : b =
! 1 } ! b && this . selectedItem _ && this . selectedItem _ . onKeyDown && ( b = this . selectedItem _ . onKeyDown ( a ) ) ; b && a . preventDefault ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Toolbox . prototype . createFlyout _ = function ( ) { var a = this . workspace _ , b = new Blockly . Options ( { parentWorkspace : a , rtl : a . RTL , oneBasedIndex : a . options . oneBasedIndex , horizontalLayout : a . horizontalLayout , renderer : a . options . renderer , rendererOverrides : a . options . rendererOverrides , move : { scrollbars : ! 0 } } ) ; b . toolboxPosition = a . options . toolboxPosition ; return new ( a . horizontalLayout ? Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _HORIZONTAL _TOOLBOX , a . options , ! 0 ) : Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _VERTICAL _TOOLBOX ,
2021-09-18 14:29:06 +00:00
a . options , ! 0 ) ) ( b ) } ; Blockly . Toolbox . prototype . render = function ( a ) { this . toolboxDef _ = a ; for ( var b = 0 ; b < this . contents _ . length ; b ++ ) { var c = this . contents _ [ b ] ; c && c . dispose ( ) } this . contents _ = [ ] ; this . contentMap _ = Object . create ( null ) ; this . renderContents _ ( a . contents ) ; this . position ( ) ; this . handleToolboxItemResize ( ) } ; Blockly . Toolbox . prototype . renderContents _ = function ( a ) { for ( var b = document . createDocumentFragment ( ) , c = 0 , d ; d = a [ c ] ; c ++ ) this . createToolboxItem _ ( d , b ) ; this . contentsDiv _ . appendChild ( b ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Toolbox . prototype . createToolboxItem _ = function ( a , b ) { var c = a . kind ; "CATEGORY" == c . toUpperCase ( ) && Blockly . utils . toolbox . isCategoryCollapsible ( a ) && ( c = Blockly . CollapsibleToolboxCategory . registrationName ) ; if ( c = Blockly . registry . getClass ( Blockly . registry . Type . TOOLBOX _ITEM , c . toLowerCase ( ) ) ) a = new c ( a , this ) , this . addToolboxItem _ ( a ) , a . init ( ) , ( c = a . getDiv ( ) ) && b . appendChild ( c ) , a . getClickTarget && a . getClickTarget ( ) . setAttribute ( "id" , a . getId ( ) ) } ;
Blockly . Toolbox . prototype . addToolboxItem _ = function ( a ) { this . contents _ . push ( a ) ; this . contentMap _ [ a . getId ( ) ] = a ; if ( a . isCollapsible ( ) ) for ( var b = 0 , c ; c = a . getChildToolboxItems ( ) [ b ] ; b ++ ) this . addToolboxItem _ ( c ) } ; Blockly . Toolbox . prototype . getToolboxItems = function ( ) { return this . contents _ } ; Blockly . Toolbox . prototype . addStyle = function ( a ) { Blockly . utils . dom . addClass ( this . HtmlDiv , a ) } ; Blockly . Toolbox . prototype . removeStyle = function ( a ) { Blockly . utils . dom . removeClass ( this . HtmlDiv , a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Toolbox . prototype . getClientRect = function ( ) { if ( ! this . HtmlDiv || ! this . isVisible _ ) return null ; var a = this . HtmlDiv . getBoundingClientRect ( ) , b = a . top , c = b + a . height , d = a . left ; a = d + a . width ; return this . toolboxPosition == Blockly . utils . toolbox . Position . TOP ? new Blockly . utils . Rect ( - 1E7 , c , - 1E7 , 1E7 ) : this . toolboxPosition == Blockly . utils . toolbox . Position . BOTTOM ? new Blockly . utils . Rect ( b , 1E7 , - 1E7 , 1E7 ) : this . toolboxPosition == Blockly . utils . toolbox . Position . LEFT ? new Blockly . utils . Rect ( - 1E7 , 1E7 , - 1E7 , a ) : new Blockly . utils . Rect ( - 1E7 ,
1E7 , d , 1E7 ) } ; Blockly . Toolbox . prototype . wouldDelete = function ( a , b ) { a instanceof Blockly . BlockSvg ? this . updateWouldDelete _ ( ! a . getParent ( ) && a . isDeletable ( ) ) : this . updateWouldDelete _ ( a . isDeletable ( ) ) ; return this . wouldDelete _ } ; Blockly . Toolbox . prototype . onDragEnter = function ( a ) { this . updateCursorDeleteStyle _ ( ! 0 ) } ; Blockly . Toolbox . prototype . onDragExit = function ( a ) { this . updateCursorDeleteStyle _ ( ! 1 ) } ; Blockly . Toolbox . prototype . onDrop = function ( a ) { this . updateCursorDeleteStyle _ ( ! 1 ) } ;
Blockly . Toolbox . prototype . updateWouldDelete _ = function ( a ) { a !== this . wouldDelete _ && ( this . updateCursorDeleteStyle _ ( ! 1 ) , this . wouldDelete _ = a , this . updateCursorDeleteStyle _ ( ! 0 ) ) } ; Blockly . Toolbox . prototype . updateCursorDeleteStyle _ = function ( a ) { var b = this . wouldDelete _ ? "blocklyToolboxDelete" : "blocklyToolboxGrab" ; a ? this . addStyle ( b ) : this . removeStyle ( b ) } ; Blockly . Toolbox . prototype . getToolboxItemById = function ( a ) { return this . contentMap _ [ a ] || null } ; Blockly . Toolbox . prototype . getWidth = function ( ) { return this . width _ } ;
Blockly . Toolbox . prototype . getHeight = function ( ) { return this . height _ } ; Blockly . Toolbox . prototype . getFlyout = function ( ) { return this . flyout _ } ; Blockly . Toolbox . prototype . getWorkspace = function ( ) { return this . workspace _ } ; Blockly . Toolbox . prototype . getSelectedItem = function ( ) { return this . selectedItem _ } ; Blockly . Toolbox . prototype . getPreviouslySelectedItem = function ( ) { return this . previouslySelectedItem _ } ; Blockly . Toolbox . prototype . isHorizontal = function ( ) { return this . horizontalLayout _ } ;
2021-05-19 13:38:55 +00:00
Blockly . Toolbox . prototype . position = function ( ) { var a = this . workspace _ . getMetrics ( ) , b = this . HtmlDiv ; b && ( this . horizontalLayout _ ? ( b . style . left = "0" , b . style . height = "auto" , b . style . width = "100%" , this . height _ = b . offsetHeight , this . width _ = a . viewWidth , this . toolboxPosition == Blockly . utils . toolbox . Position . TOP ? b . style . top = "0" : b . style . bottom = "0" ) : ( this . toolboxPosition == Blockly . utils . toolbox . Position . RIGHT ? b . style . right = "0" : b . style . left = "0" , b . style . height = "100%" , this . width _ = b . offsetWidth , this . height _ = a . viewHeight ) , this . flyout _ . position ( ) ) } ;
Blockly . Toolbox . prototype . handleToolboxItemResize = function ( ) { var a = this . workspace _ , b = this . HtmlDiv . getBoundingClientRect ( ) ; a . translate ( this . toolboxPosition == Blockly . utils . toolbox . Position . LEFT ? a . scrollX + b . width : a . scrollX , this . toolboxPosition == Blockly . utils . toolbox . Position . TOP ? a . scrollY + b . height : a . scrollY ) ; Blockly . svgResize ( a ) } ; Blockly . Toolbox . prototype . clearSelection = function ( ) { this . setSelectedItem ( null ) } ;
2021-09-18 14:29:06 +00:00
Blockly . Toolbox . prototype . refreshTheme = function ( ) { for ( var a = 0 ; a < this . contents _ . length ; a ++ ) { var b = this . contents _ [ a ] ; b . refreshTheme && b . refreshTheme ( ) } } ; Blockly . Toolbox . prototype . refreshSelection = function ( ) { this . selectedItem _ && this . selectedItem _ . isSelectable ( ) && this . selectedItem _ . getContents ( ) . length && this . flyout _ . show ( this . selectedItem _ . getContents ( ) ) } ; Blockly . Toolbox . prototype . setVisible = function ( a ) { this . isVisible _ !== a && ( this . HtmlDiv . style . display = a ? "block" : "none" , this . isVisible _ = a , this . workspace _ . recordDragTargets ( ) ) } ;
Blockly . Toolbox . prototype . autoHide = function ( a ) { ! a && this . flyout _ && this . flyout _ . autoClose && this . clearSelection ( ) } ; Blockly . Toolbox . prototype . setSelectedItem = function ( a ) { var b = this . selectedItem _ ; ! a && ! b || a && ! a . isSelectable ( ) || ( this . shouldDeselectItem _ ( b , a ) && null != b && this . deselectItem _ ( b ) , this . shouldSelectItem _ ( b , a ) && null != a && this . selectItem _ ( b , a ) , this . updateFlyout _ ( b , a ) , this . fireSelectEvent _ ( b , a ) ) } ; Blockly . Toolbox . prototype . shouldDeselectItem _ = function ( a , b ) { return null != a && ( ! a . isCollapsible ( ) || a != b ) } ;
Blockly . Toolbox . prototype . shouldSelectItem _ = function ( a , b ) { return null != b && b != a } ; Blockly . Toolbox . prototype . deselectItem _ = function ( a ) { this . selectedItem _ = null ; this . previouslySelectedItem _ = a ; a . setSelected ( ! 1 ) ; Blockly . utils . aria . setState ( this . contentsDiv _ , Blockly . utils . aria . State . ACTIVEDESCENDANT , "" ) } ;
Blockly . Toolbox . prototype . selectItem _ = function ( a , b ) { this . selectedItem _ = b ; this . previouslySelectedItem _ = a ; b . setSelected ( ! 0 ) ; Blockly . utils . aria . setState ( this . contentsDiv _ , Blockly . utils . aria . State . ACTIVEDESCENDANT , b . getId ( ) ) } ; Blockly . Toolbox . prototype . selectItemByPosition = function ( a ) { - 1 < a && a < this . contents _ . length && ( a = this . contents _ [ a ] , a . isSelectable ( ) && this . setSelectedItem ( a ) ) } ;
Blockly . Toolbox . prototype . updateFlyout _ = function ( a , b ) { ( a != b || b . isCollapsible ( ) ) && b && b . getContents ( ) . length ? ( this . flyout _ . show ( b . getContents ( ) ) , this . flyout _ . scrollToStart ( ) ) : this . flyout _ . hide ( ) } ; Blockly . Toolbox . prototype . fireSelectEvent _ = function ( a , b ) { var c = a && a . getName ( ) , d = b && b . getName ( ) ; a == b && ( d = null ) ; a = new ( Blockly . Events . get ( Blockly . Events . TOOLBOX _ITEM _SELECT ) ) ( c , d , this . workspace _ . id ) ; Blockly . Events . fire ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Toolbox . prototype . selectParent _ = function ( ) { return this . selectedItem _ ? this . selectedItem _ . isCollapsible ( ) && this . selectedItem _ . isExpanded ( ) ? ( this . selectedItem _ . setExpanded ( ! 1 ) , ! 0 ) : this . selectedItem _ . getParent ( ) && this . selectedItem _ . getParent ( ) . isSelectable ( ) ? ( this . setSelectedItem ( this . selectedItem _ . getParent ( ) ) , ! 0 ) : ! 1 : ! 1 } ;
Blockly . Toolbox . prototype . selectChild _ = function ( ) { if ( ! this . selectedItem _ || ! this . selectedItem _ . isCollapsible ( ) ) return ! 1 ; var a = this . selectedItem _ ; a . isExpanded ( ) ? this . selectNext _ ( ) : a . setExpanded ( ! 0 ) ; return ! 0 } ; Blockly . Toolbox . prototype . selectNext _ = function ( ) { if ( ! this . selectedItem _ ) return ! 1 ; var a = this . contents _ . indexOf ( this . selectedItem _ ) + 1 ; if ( - 1 < a && a < this . contents _ . length ) { for ( var b = this . contents _ [ a ] ; b && ! b . isSelectable ( ) ; ) b = this . contents _ [ ++ a ] ; if ( b && b . isSelectable ( ) ) return this . setSelectedItem ( b ) , ! 0 } return ! 1 } ;
Blockly . Toolbox . prototype . selectPrevious _ = function ( ) { if ( ! this . selectedItem _ ) return ! 1 ; var a = this . contents _ . indexOf ( this . selectedItem _ ) - 1 ; if ( - 1 < a && a < this . contents _ . length ) { for ( var b = this . contents _ [ a ] ; b && ! b . isSelectable ( ) ; ) b = this . contents _ [ -- a ] ; if ( b && b . isSelectable ( ) ) return this . setSelectedItem ( b ) , ! 0 } return ! 1 } ;
2021-09-18 14:29:06 +00:00
Blockly . Toolbox . prototype . dispose = function ( ) { this . workspace _ . getComponentManager ( ) . removeComponent ( "toolbox" ) ; this . flyout _ . dispose ( ) ; for ( var a = 0 ; a < this . contents _ . length ; a ++ ) this . contents _ [ a ] . dispose ( ) ; for ( a = 0 ; a < this . boundEvents _ . length ; a ++ ) Blockly . browserEvents . unbind ( this . boundEvents _ [ a ] ) ; this . boundEvents _ = [ ] ; this . contents _ = [ ] ; this . workspace _ . getThemeManager ( ) . unsubscribe ( this . HtmlDiv ) ; Blockly . utils . dom . removeNode ( this . HtmlDiv ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Css . register ( [ ".blocklyToolboxDelete {" , 'cursor: url("<<<PATH>>>/handdelete.cur"), auto;' , "}" , ".blocklyToolboxGrab {" , 'cursor: url("<<<PATH>>>/handclosed.cur"), auto;' , "cursor: grabbing;" , "cursor: -webkit-grabbing;" , "}" , ".blocklyToolboxDiv {" , "background-color: #ddd;" , "overflow-x: visible;" , "overflow-y: auto;" , "padding: 4px 0 4px 0;" , "position: absolute;" , "z-index: 70;" , "-webkit-tap-highlight-color: transparent;" , "}" , ".blocklyToolboxContents {" , "display: flex;" , "flex-wrap: wrap;" , "flex-direction: column;" ,
"}" , ".blocklyToolboxContents:focus {" , "outline: none;" , "}" ] ) ; Blockly . registry . register ( Blockly . registry . Type . TOOLBOX , Blockly . registry . DEFAULT , Blockly . Toolbox ) ; Blockly . Events . TrashcanOpen = function ( a , b ) { Blockly . Events . TrashcanOpen . superClass _ . constructor . call ( this , b ) ; this . isOpen = a } ; Blockly . utils . object . inherits ( Blockly . Events . TrashcanOpen , Blockly . Events . UiBase ) ; Blockly . Events . TrashcanOpen . prototype . type = Blockly . Events . TRASHCAN _OPEN ; Blockly . Events . TrashcanOpen . prototype . toJson = function ( ) { var a = Blockly . Events . TrashcanOpen . superClass _ . toJson . call ( this ) ; a . isOpen = this . isOpen ; return a } ;
2021-09-18 14:29:06 +00:00
Blockly . Events . TrashcanOpen . prototype . fromJson = function ( a ) { Blockly . Events . TrashcanOpen . superClass _ . fromJson . call ( this , a ) ; this . isOpen = a . isOpen } ; Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . TRASHCAN _OPEN , Blockly . Events . TrashcanOpen ) ; Blockly . IPositionable = function ( ) { } ; Blockly . uiPosition = { } ; Blockly . uiPosition . verticalPosition = { TOP : 0 , BOTTOM : 1 } ; Blockly . uiPosition . horizontalPosition = { LEFT : 0 , RIGHT : 1 } ; Blockly . uiPosition . bumpDirection = { UP : 0 , DOWN : 1 } ;
Blockly . uiPosition . getStartPositionRect = function ( a , b , c , d , e , f ) { var g = f . scrollbar && f . scrollbar . canScrollVertically ( ) ; a . horizontal === Blockly . uiPosition . horizontalPosition . LEFT ? ( c = e . absoluteMetrics . left + c , g && f . RTL && ( c += Blockly . Scrollbar . scrollbarThickness ) ) : ( c = e . absoluteMetrics . left + e . viewMetrics . width - b . width - c , g && ! f . RTL && ( c -= Blockly . Scrollbar . scrollbarThickness ) ) ; a . vertical === Blockly . uiPosition . verticalPosition . TOP ? a = e . absoluteMetrics . top + d : ( a = e . absoluteMetrics . top + e . viewMetrics . height - b . height - d , f . scrollbar &&
f . scrollbar . canScrollHorizontally ( ) && ( a -= Blockly . Scrollbar . scrollbarThickness ) ) ; return new Blockly . utils . Rect ( a , a + b . height , c , c + b . width ) } ;
Blockly . uiPosition . getCornerOppositeToolbox = function ( a , b ) { return { horizontal : b . toolboxMetrics . position === Blockly . utils . toolbox . Position . LEFT || a . horizontalLayout && ! a . RTL ? Blockly . uiPosition . horizontalPosition . RIGHT : Blockly . uiPosition . horizontalPosition . LEFT , vertical : b . toolboxMetrics . position === Blockly . utils . toolbox . Position . BOTTOM ? Blockly . uiPosition . verticalPosition . TOP : Blockly . uiPosition . verticalPosition . BOTTOM } } ;
Blockly . uiPosition . bumpPositionRect = function ( a , b , c , d ) { for ( var e = a . left , f = a . right - a . left , g = a . bottom - a . top , h = 0 , k ; k = d [ h ] ; h ++ ) a . intersects ( k ) && ( a = c === Blockly . uiPosition . bumpDirection . UP ? k . top - g - b : k . bottom + b , a = new Blockly . utils . Rect ( a , a + g , e , e + f ) , h = - 1 ) ; return a } ; Blockly . Trashcan = function ( a ) { Blockly . Trashcan . superClass _ . constructor . call ( this ) ; this . workspace _ = a ; this . id = "trashcan" ; this . contents _ = [ ] ; this . flyout = null ; 0 >= this . workspace _ . options . maxTrashcanContents || ( a = new Blockly . Options ( { scrollbars : ! 0 , parentWorkspace : this . workspace _ , rtl : this . workspace _ . RTL , oneBasedIndex : this . workspace _ . options . oneBasedIndex , renderer : this . workspace _ . options . renderer , rendererOverrides : this . workspace _ . options . rendererOverrides , move : { scrollbars : ! 0 } } ) , this . workspace _ . horizontalLayout ?
( a . toolboxPosition = this . workspace _ . toolboxPosition == Blockly . utils . toolbox . Position . TOP ? Blockly . utils . toolbox . Position . BOTTOM : Blockly . utils . toolbox . Position . TOP , this . flyout = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _HORIZONTAL _TOOLBOX , this . workspace _ . options , ! 0 ) ) ( a ) ) : ( a . toolboxPosition = this . workspace _ . toolboxPosition == Blockly . utils . toolbox . Position . RIGHT ? Blockly . utils . toolbox . Position . LEFT : Blockly . utils . toolbox . Position . RIGHT , this . flyout = new ( Blockly . registry . getClassFromOptions ( Blockly . registry . Type . FLYOUTS _VERTICAL _TOOLBOX ,
this . workspace _ . options , ! 0 ) ) ( a ) ) , this . workspace _ . addChangeListener ( this . onDelete _ . bind ( this ) ) ) } ; Blockly . utils . object . inherits ( Blockly . Trashcan , Blockly . DeleteArea ) ; Blockly . Trashcan . prototype . WIDTH _ = 47 ; Blockly . Trashcan . prototype . BODY _HEIGHT _ = 44 ; Blockly . Trashcan . prototype . LID _HEIGHT _ = 16 ; Blockly . Trashcan . prototype . MARGIN _VERTICAL _ = 20 ; Blockly . Trashcan . prototype . MARGIN _HORIZONTAL _ = 20 ; Blockly . Trashcan . prototype . MARGIN _HOTSPOT _ = 10 ; Blockly . Trashcan . prototype . SPRITE _LEFT _ = 0 ;
Blockly . Trashcan . prototype . SPRITE _TOP _ = 32 ; Blockly . Trashcan . prototype . HAS _BLOCKS _LID _ANGLE _ = . 1 ; Blockly . Trashcan . ANIMATION _LENGTH _ = 80 ; Blockly . Trashcan . ANIMATION _FRAMES _ = 4 ; Blockly . Trashcan . OPACITY _MIN _ = . 4 ; Blockly . Trashcan . OPACITY _MAX _ = . 8 ; Blockly . Trashcan . MAX _LID _ANGLE _ = 45 ; Blockly . Trashcan . prototype . isLidOpen = ! 1 ; Blockly . Trashcan . prototype . minOpenness _ = 0 ; Blockly . Trashcan . prototype . svgGroup _ = null ; Blockly . Trashcan . prototype . svgLid _ = null ; Blockly . Trashcan . prototype . lidTask _ = 0 ;
Blockly . Trashcan . prototype . lidOpen _ = 0 ; Blockly . Trashcan . prototype . left _ = 0 ; Blockly . Trashcan . prototype . top _ = 0 ; Blockly . Trashcan . prototype . initialized _ = ! 1 ;
2021-01-16 14:07:51 +00:00
Blockly . Trashcan . prototype . createDom = function ( ) { this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyTrash" } , null ) ; var a = String ( Math . random ( ) ) . substring ( 2 ) ; var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CLIPPATH , { id : "blocklyTrashBodyClipPath" + a } , this . svgGroup _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : this . WIDTH _ , height : this . BODY _HEIGHT _ , y : this . LID _HEIGHT _ } , b ) ; var c = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { width : Blockly . SPRITE . width ,
x : - this . SPRITE _LEFT _ , height : Blockly . SPRITE . height , y : - this . SPRITE _TOP _ , "clip-path" : "url(#blocklyTrashBodyClipPath" + a + ")" } , this . svgGroup _ ) ; c . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . workspace _ . options . pathToMedia + Blockly . SPRITE . url ) ; b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CLIPPATH , { id : "blocklyTrashLidClipPath" + a } , this . svgGroup _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : this . WIDTH _ , height : this . LID _HEIGHT _ } , b ) ; this . svgLid _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE ,
2021-05-19 13:38:55 +00:00
{ width : Blockly . SPRITE . width , x : - this . SPRITE _LEFT _ , height : Blockly . SPRITE . height , y : - this . SPRITE _TOP _ , "clip-path" : "url(#blocklyTrashLidClipPath" + a + ")" } , this . svgGroup _ ) ; this . svgLid _ . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . workspace _ . options . pathToMedia + Blockly . SPRITE . url ) ; Blockly . browserEvents . bind ( this . svgGroup _ , "mousedown" , this , this . blockMouseDownWhenOpenable _ ) ; Blockly . browserEvents . bind ( this . svgGroup _ , "mouseup" , this , this . click ) ; Blockly . browserEvents . bind ( c , "mouseover" , this , this . mouseOver _ ) ;
2021-09-18 14:29:06 +00:00
Blockly . browserEvents . bind ( c , "mouseout" , this , this . mouseOut _ ) ; this . animateLid _ ( ) ; return this . svgGroup _ } ;
Blockly . Trashcan . prototype . init = function ( ) { 0 < this . workspace _ . options . maxTrashcanContents && ( Blockly . utils . dom . insertAfter ( this . flyout . createDom ( Blockly . utils . Svg . SVG ) , this . workspace _ . getParentSvg ( ) ) , this . flyout . init ( this . workspace _ ) ) ; this . workspace _ . getComponentManager ( ) . addComponent ( { component : this , weight : 1 , capabilities : [ Blockly . ComponentManager . Capability . AUTOHIDEABLE , Blockly . ComponentManager . Capability . DELETE _AREA , Blockly . ComponentManager . Capability . DRAG _TARGET , Blockly . ComponentManager . Capability . POSITIONABLE ] } ) ;
this . initialized _ = ! 0 ; this . setLidOpen ( ! 1 ) } ; Blockly . Trashcan . prototype . dispose = function ( ) { this . workspace _ . getComponentManager ( ) . removeComponent ( "trashcan" ) ; this . svgGroup _ && ( Blockly . utils . dom . removeNode ( this . svgGroup _ ) , this . svgGroup _ = null ) ; this . workspace _ = this . svgLid _ = null ; clearTimeout ( this . lidTask _ ) } ; Blockly . Trashcan . prototype . hasContents _ = function ( ) { return ! ! this . contents _ . length } ; Blockly . Trashcan . prototype . contentsIsOpen = function ( ) { return this . flyout . isVisible ( ) } ;
Blockly . Trashcan . prototype . openFlyout = function ( ) { if ( ! this . contentsIsOpen ( ) ) { var a = this . contents _ . map ( Blockly . Xml . textToDom ) ; this . flyout . show ( a ) ; this . fireUiEvent _ ( ! 0 ) } } ; Blockly . Trashcan . prototype . closeFlyout = function ( ) { this . contentsIsOpen ( ) && ( this . flyout . hide ( ) , this . fireUiEvent _ ( ! 1 ) ) } ; Blockly . Trashcan . prototype . autoHide = function ( a ) { ! a && this . flyout && this . closeFlyout ( ) } ; Blockly . Trashcan . prototype . emptyContents = function ( ) { this . hasContents _ ( ) && ( this . contents _ . length = 0 , this . setMinOpenness _ ( 0 ) , this . closeFlyout ( ) ) } ;
Blockly . Trashcan . prototype . position = function ( a , b ) { if ( this . initialized _ ) { var c = Blockly . uiPosition . getCornerOppositeToolbox ( this . workspace _ , a ) ; a = Blockly . uiPosition . getStartPositionRect ( c , new Blockly . utils . Size ( this . WIDTH _ , this . BODY _HEIGHT _ + this . LID _HEIGHT _ ) , this . MARGIN _HORIZONTAL _ , this . MARGIN _VERTICAL _ , a , this . workspace _ ) ; b = Blockly . uiPosition . bumpPositionRect ( a , this . MARGIN _VERTICAL _ , c . vertical === Blockly . uiPosition . verticalPosition . TOP ? Blockly . uiPosition . bumpDirection . DOWN : Blockly . uiPosition . bumpDirection . UP ,
b ) ; this . top _ = b . top ; this . left _ = b . left ; this . svgGroup _ . setAttribute ( "transform" , "translate(" + this . left _ + "," + this . top _ + ")" ) } } ; Blockly . Trashcan . prototype . getBoundingRectangle = function ( ) { return new Blockly . utils . Rect ( this . top _ , this . top _ + this . BODY _HEIGHT _ + this . LID _HEIGHT _ , this . left _ , this . left _ + this . WIDTH _ ) } ;
Blockly . Trashcan . prototype . getClientRect = function ( ) { if ( ! this . svgGroup _ ) return null ; var a = this . svgGroup _ . getBoundingClientRect ( ) , b = a . top + this . SPRITE _TOP _ - this . MARGIN _HOTSPOT _ ; a = a . left + this . SPRITE _LEFT _ - this . MARGIN _HOTSPOT _ ; return new Blockly . utils . Rect ( b , b + this . LID _HEIGHT _ + this . BODY _HEIGHT _ + 2 * this . MARGIN _HOTSPOT _ , a , a + this . WIDTH _ + 2 * this . MARGIN _HOTSPOT _ ) } ; Blockly . Trashcan . prototype . onDragOver = function ( a ) { this . setLidOpen ( this . wouldDelete _ ) } ; Blockly . Trashcan . prototype . onDragExit = function ( a ) { this . setLidOpen ( ! 1 ) } ;
Blockly . Trashcan . prototype . onDrop = function ( a ) { setTimeout ( this . setLidOpen . bind ( this , ! 1 ) , 100 ) } ; Blockly . Trashcan . prototype . setLidOpen = function ( a ) { this . isLidOpen != a && ( clearTimeout ( this . lidTask _ ) , this . isLidOpen = a , this . animateLid _ ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Trashcan . prototype . animateLid _ = function ( ) { var a = Blockly . Trashcan . ANIMATION _FRAMES _ , b = 1 / ( a + 1 ) ; this . lidOpen _ += this . isLidOpen ? b : - b ; this . lidOpen _ = Math . min ( Math . max ( this . lidOpen _ , this . minOpenness _ ) , 1 ) ; this . setLidAngle _ ( this . lidOpen _ * Blockly . Trashcan . MAX _LID _ANGLE _ ) ; b = Blockly . Trashcan . OPACITY _MIN _ ; this . svgGroup _ . style . opacity = b + this . lidOpen _ * ( Blockly . Trashcan . OPACITY _MAX _ - b ) ; this . lidOpen _ > this . minOpenness _ && 1 > this . lidOpen _ && ( this . lidTask _ = setTimeout ( this . animateLid _ . bind ( this ) , Blockly . Trashcan . ANIMATION _LENGTH _ /
2021-05-19 13:38:55 +00:00
a ) ) } ; Blockly . Trashcan . prototype . setLidAngle _ = function ( a ) { var b = this . workspace _ . toolboxPosition == Blockly . utils . toolbox . Position . RIGHT || this . workspace _ . horizontalLayout && this . workspace _ . RTL ; this . svgLid _ . setAttribute ( "transform" , "rotate(" + ( b ? - a : a ) + "," + ( b ? 4 : this . WIDTH _ - 4 ) + "," + ( this . LID _HEIGHT _ - 2 ) + ")" ) } ; Blockly . Trashcan . prototype . setMinOpenness _ = function ( a ) { this . minOpenness _ = a ; this . isLidOpen || this . setLidAngle _ ( a * Blockly . Trashcan . MAX _LID _ANGLE _ ) } ; Blockly . Trashcan . prototype . closeLid = function ( ) { this . setLidOpen ( ! 1 ) } ;
Blockly . Trashcan . prototype . click = function ( ) { this . hasContents _ ( ) && this . openFlyout ( ) } ; Blockly . Trashcan . prototype . fireUiEvent _ = function ( a ) { a = new ( Blockly . Events . get ( Blockly . Events . TRASHCAN _OPEN ) ) ( a , this . workspace _ . id ) ; Blockly . Events . fire ( a ) } ; Blockly . Trashcan . prototype . blockMouseDownWhenOpenable _ = function ( a ) { ! this . contentsIsOpen ( ) && this . hasContents _ ( ) && a . stopPropagation ( ) } ; Blockly . Trashcan . prototype . mouseOver _ = function ( ) { this . hasContents _ ( ) && this . setLidOpen ( ! 0 ) } ; Blockly . Trashcan . prototype . mouseOut _ = function ( ) { this . setLidOpen ( ! 1 ) } ;
2021-01-16 14:07:51 +00:00
Blockly . Trashcan . prototype . onDelete _ = function ( a ) { if ( ! ( 0 >= this . workspace _ . options . maxTrashcanContents ) && a . type == Blockly . Events . BLOCK _DELETE && a . oldXml . tagName && "shadow" != a . oldXml . tagName . toLowerCase ( ) && ( a = this . cleanBlockXML _ ( a . oldXml ) , - 1 == this . contents _ . indexOf ( a ) ) ) { for ( this . contents _ . unshift ( a ) ; this . contents _ . length > this . workspace _ . options . maxTrashcanContents ; ) this . contents _ . pop ( ) ; this . setMinOpenness _ ( this . HAS _BLOCKS _LID _ANGLE _ ) } } ;
Blockly . Trashcan . prototype . cleanBlockXML _ = function ( a ) { for ( var b = a = a . cloneNode ( ! 0 ) ; b ; ) { b . removeAttribute && ( b . removeAttribute ( "x" ) , b . removeAttribute ( "y" ) , b . removeAttribute ( "id" ) , b . removeAttribute ( "disabled" ) , "comment" == b . nodeName && ( b . removeAttribute ( "h" ) , b . removeAttribute ( "w" ) , b . removeAttribute ( "pinned" ) ) ) ; var c = b . firstChild || b . nextSibling ; if ( ! c ) for ( c = b . parentNode ; c ; ) { if ( c . nextSibling ) { c = c . nextSibling ; break } c = c . parentNode } b = c } return Blockly . Xml . domToText ( a ) } ; Blockly . VariablesDynamic = { } ; Blockly . VariablesDynamic . onCreateVariableButtonClick _String = function ( a ) { Blockly . Variables . createVariableButtonHandler ( a . getTargetWorkspace ( ) , void 0 , "String" ) } ; Blockly . VariablesDynamic . onCreateVariableButtonClick _Number = function ( a ) { Blockly . Variables . createVariableButtonHandler ( a . getTargetWorkspace ( ) , void 0 , "Number" ) } ; Blockly . VariablesDynamic . onCreateVariableButtonClick _Colour = function ( a ) { Blockly . Variables . createVariableButtonHandler ( a . getTargetWorkspace ( ) , void 0 , "Colour" ) } ;
Blockly . VariablesDynamic . flyoutCategory = function ( a ) { var b = [ ] , c = document . createElement ( "button" ) ; c . setAttribute ( "text" , Blockly . Msg . NEW _STRING _VARIABLE ) ; c . setAttribute ( "callbackKey" , "CREATE_VARIABLE_STRING" ) ; b . push ( c ) ; c = document . createElement ( "button" ) ; c . setAttribute ( "text" , Blockly . Msg . NEW _NUMBER _VARIABLE ) ; c . setAttribute ( "callbackKey" , "CREATE_VARIABLE_NUMBER" ) ; b . push ( c ) ; c = document . createElement ( "button" ) ; c . setAttribute ( "text" , Blockly . Msg . NEW _COLOUR _VARIABLE ) ; c . setAttribute ( "callbackKey" , "CREATE_VARIABLE_COLOUR" ) ;
b . push ( c ) ; a . registerButtonCallback ( "CREATE_VARIABLE_STRING" , Blockly . VariablesDynamic . onCreateVariableButtonClick _String ) ; a . registerButtonCallback ( "CREATE_VARIABLE_NUMBER" , Blockly . VariablesDynamic . onCreateVariableButtonClick _Number ) ; a . registerButtonCallback ( "CREATE_VARIABLE_COLOUR" , Blockly . VariablesDynamic . onCreateVariableButtonClick _Colour ) ; a = Blockly . VariablesDynamic . flyoutCategoryBlocks ( a ) ; return b = b . concat ( a ) } ;
Blockly . VariablesDynamic . flyoutCategoryBlocks = function ( a ) { a = a . getAllVariables ( ) ; var b = [ ] ; if ( 0 < a . length ) { if ( Blockly . Blocks . variables _set _dynamic ) { var c = a [ a . length - 1 ] , d = Blockly . utils . xml . createElement ( "block" ) ; d . setAttribute ( "type" , "variables_set_dynamic" ) ; d . setAttribute ( "gap" , 24 ) ; d . appendChild ( Blockly . Variables . generateVariableFieldDom ( c ) ) ; b . push ( d ) } if ( Blockly . Blocks . variables _get _dynamic ) { a . sort ( Blockly . VariableModel . compareByName ) ; c = 0 ; for ( var e ; e = a [ c ] ; c ++ ) d = Blockly . utils . xml . createElement ( "block" ) ,
2021-09-18 14:29:06 +00:00
d . setAttribute ( "type" , "variables_get_dynamic" ) , d . setAttribute ( "gap" , 8 ) , d . appendChild ( Blockly . Variables . generateVariableFieldDom ( e ) ) , b . push ( d ) } } return b } ; Blockly . ZoomControls = function ( a ) { this . workspace _ = a ; this . id = "zoomControls" ; this . zoomResetGroup _ = this . zoomOutGroup _ = this . zoomInGroup _ = this . onZoomOutWrapper _ = this . onZoomInWrapper _ = this . onZoomResetWrapper _ = null } ; Blockly . ZoomControls . prototype . WIDTH _ = 32 ; Blockly . ZoomControls . prototype . HEIGHT _ = 32 ; Blockly . ZoomControls . prototype . SMALL _SPACING _ = 2 ; Blockly . ZoomControls . prototype . LARGE _SPACING _ = 11 ; Blockly . ZoomControls . prototype . MARGIN _VERTICAL _ = 20 ; Blockly . ZoomControls . prototype . MARGIN _HORIZONTAL _ = 20 ;
Blockly . ZoomControls . prototype . svgGroup _ = null ; Blockly . ZoomControls . prototype . left _ = 0 ; Blockly . ZoomControls . prototype . top _ = 0 ; Blockly . ZoomControls . prototype . initialized _ = ! 1 ; Blockly . ZoomControls . prototype . createDom = function ( ) { this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { } , null ) ; var a = String ( Math . random ( ) ) . substring ( 2 ) ; this . createZoomOutSvg _ ( a ) ; this . createZoomInSvg _ ( a ) ; this . workspace _ . isMovable ( ) && this . createZoomResetSvg _ ( a ) ; return this . svgGroup _ } ;
Blockly . ZoomControls . prototype . init = function ( ) { this . workspace _ . getComponentManager ( ) . addComponent ( { component : this , weight : 2 , capabilities : [ Blockly . ComponentManager . Capability . POSITIONABLE ] } ) ; this . initialized _ = ! 0 } ;
Blockly . ZoomControls . prototype . dispose = function ( ) { this . workspace _ . getComponentManager ( ) . removeComponent ( "zoomControls" ) ; this . svgGroup _ && Blockly . utils . dom . removeNode ( this . svgGroup _ ) ; this . onZoomResetWrapper _ && Blockly . browserEvents . unbind ( this . onZoomResetWrapper _ ) ; this . onZoomInWrapper _ && Blockly . browserEvents . unbind ( this . onZoomInWrapper _ ) ; this . onZoomOutWrapper _ && Blockly . browserEvents . unbind ( this . onZoomOutWrapper _ ) } ;
Blockly . ZoomControls . prototype . getBoundingRectangle = function ( ) { var a = this . SMALL _SPACING _ + 2 * this . HEIGHT _ ; this . zoomResetGroup _ && ( a += this . LARGE _SPACING _ + this . HEIGHT _ ) ; return new Blockly . utils . Rect ( this . top _ , this . top _ + a , this . left _ , this . left _ + this . WIDTH _ ) } ;
Blockly . ZoomControls . prototype . position = function ( a , b ) { if ( this . initialized _ ) { var c = Blockly . uiPosition . getCornerOppositeToolbox ( this . workspace _ , a ) , d = this . SMALL _SPACING _ + 2 * this . HEIGHT _ ; this . zoomResetGroup _ && ( d += this . LARGE _SPACING _ + this . HEIGHT _ ) ; a = Blockly . uiPosition . getStartPositionRect ( c , new Blockly . utils . Size ( this . WIDTH _ , d ) , this . MARGIN _HORIZONTAL _ , this . MARGIN _VERTICAL _ , a , this . workspace _ ) ; c = c . vertical ; b = Blockly . uiPosition . bumpPositionRect ( a , this . MARGIN _VERTICAL _ , c === Blockly . uiPosition . verticalPosition . TOP ?
Blockly . uiPosition . bumpDirection . DOWN : Blockly . uiPosition . bumpDirection . UP , b ) ; c === Blockly . uiPosition . verticalPosition . TOP ? ( c = this . SMALL _SPACING _ + this . HEIGHT _ , this . zoomInGroup _ . setAttribute ( "transform" , "translate(0, " + c + ")" ) , this . zoomResetGroup _ && this . zoomResetGroup _ . setAttribute ( "transform" , "translate(0, " + ( c + this . LARGE _SPACING _ + this . HEIGHT _ ) + ")" ) ) : ( c = this . zoomResetGroup _ ? this . LARGE _SPACING _ + this . HEIGHT _ : 0 , this . zoomInGroup _ . setAttribute ( "transform" , "translate(0, " + c + ")" ) , this . zoomOutGroup _ . setAttribute ( "transform" ,
"translate(0, " + ( c + this . SMALL _SPACING _ + this . HEIGHT _ ) + ")" ) ) ; this . top _ = b . top ; this . left _ = b . left ; this . svgGroup _ . setAttribute ( "transform" , "translate(" + this . left _ + "," + this . top _ + ")" ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . ZoomControls . prototype . createZoomOutSvg _ = function ( a ) { this . zoomOutGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyZoom" } , this . svgGroup _ ) ; var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CLIPPATH , { id : "blocklyZoomoutClipPath" + a } , this . zoomOutGroup _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : 32 , height : 32 } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { width : Blockly . SPRITE . width , height : Blockly . SPRITE . height , x : - 64 , y : - 92 ,
2021-05-19 13:38:55 +00:00
"clip-path" : "url(#blocklyZoomoutClipPath" + a + ")" } , this . zoomOutGroup _ ) . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . workspace _ . options . pathToMedia + Blockly . SPRITE . url ) ; this . onZoomOutWrapper _ = Blockly . browserEvents . conditionalBind ( this . zoomOutGroup _ , "mousedown" , null , this . zoom _ . bind ( this , - 1 ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . ZoomControls . prototype . createZoomInSvg _ = function ( a ) { this . zoomInGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyZoom" } , this . svgGroup _ ) ; var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CLIPPATH , { id : "blocklyZoominClipPath" + a } , this . zoomInGroup _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : 32 , height : 32 } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { width : Blockly . SPRITE . width , height : Blockly . SPRITE . height , x : - 32 , y : - 92 ,
2021-05-19 13:38:55 +00:00
"clip-path" : "url(#blocklyZoominClipPath" + a + ")" } , this . zoomInGroup _ ) . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . workspace _ . options . pathToMedia + Blockly . SPRITE . url ) ; this . onZoomInWrapper _ = Blockly . browserEvents . conditionalBind ( this . zoomInGroup _ , "mousedown" , null , this . zoom _ . bind ( this , 1 ) ) } ; Blockly . ZoomControls . prototype . zoom _ = function ( a , b ) { this . workspace _ . markFocused ( ) ; this . workspace _ . zoomCenter ( a ) ; this . fireZoomEvent _ ( ) ; Blockly . Touch . clearTouchIdentifier ( ) ; b . stopPropagation ( ) ; b . preventDefault ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . ZoomControls . prototype . createZoomResetSvg _ = function ( a ) { this . zoomResetGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyZoom" } , this . svgGroup _ ) ; var b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CLIPPATH , { id : "blocklyZoomresetClipPath" + a } , this . zoomResetGroup _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : 32 , height : 32 } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { width : Blockly . SPRITE . width , height : Blockly . SPRITE . height ,
2021-05-19 13:38:55 +00:00
y : - 92 , "clip-path" : "url(#blocklyZoomresetClipPath" + a + ")" } , this . zoomResetGroup _ ) . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . workspace _ . options . pathToMedia + Blockly . SPRITE . url ) ; this . onZoomResetWrapper _ = Blockly . browserEvents . conditionalBind ( this . zoomResetGroup _ , "mousedown" , null , this . resetZoom _ . bind ( this ) ) } ;
Blockly . ZoomControls . prototype . resetZoom _ = function ( a ) { this . workspace _ . markFocused ( ) ; var b = Math . log ( this . workspace _ . options . zoomOptions . startScale / this . workspace _ . scale ) / Math . log ( this . workspace _ . options . zoomOptions . scaleSpeed ) ; this . workspace _ . beginCanvasTransition ( ) ; this . workspace _ . zoomCenter ( b ) ; this . workspace _ . scrollCenter ( ) ; setTimeout ( this . workspace _ . endCanvasTransition . bind ( this . workspace _ ) , 500 ) ; this . fireZoomEvent _ ( ) ; Blockly . Touch . clearTouchIdentifier ( ) ; a . stopPropagation ( ) ; a . preventDefault ( ) } ;
Blockly . ZoomControls . prototype . fireZoomEvent _ = function ( ) { var a = new ( Blockly . Events . get ( Blockly . Events . CLICK ) ) ( null , this . workspace _ . id , "zoom_controls" ) ; Blockly . Events . fire ( a ) } ; Blockly . Css . register ( [ ".blocklyZoom>image, .blocklyZoom>svg>image {" , "opacity: .4;" , "}" , ".blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {" , "opacity: .6;" , "}" , ".blocklyZoom>image:active, .blocklyZoom>svg>image:active {" , "opacity: .8;" , "}" ] ) ; Blockly . ShortcutItems = { } ; Blockly . ShortcutItems . names = { ESCAPE : "escape" , DELETE : "delete" , COPY : "copy" , CUT : "cut" , PASTE : "paste" , UNDO : "undo" , REDO : "redo" } ; Blockly . ShortcutItems . registerEscape = function ( ) { var a = { name : Blockly . ShortcutItems . names . ESCAPE , preconditionFn : function ( b ) { return ! b . options . readOnly } , callback : function ( ) { Blockly . hideChaff ( ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( Blockly . utils . KeyCodes . ESC , a . name ) } ;
Blockly . ShortcutItems . registerDelete = function ( ) { var a = { name : Blockly . ShortcutItems . names . DELETE , preconditionFn : function ( b ) { return ! b . options . readOnly && Blockly . selected && Blockly . selected . isDeletable ( ) } , callback : function ( b , c ) { c . preventDefault ( ) ; if ( Blockly . Gesture . inProgress ( ) ) return ! 1 ; Blockly . deleteBlock ( Blockly . selected ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( Blockly . utils . KeyCodes . DELETE , a . name ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( Blockly . utils . KeyCodes . BACKSPACE ,
a . name ) } ;
2021-09-18 14:29:06 +00:00
Blockly . ShortcutItems . registerCopy = function ( ) { var a = { name : Blockly . ShortcutItems . names . COPY , preconditionFn : function ( c ) { return ! c . options . readOnly && ! Blockly . Gesture . inProgress ( ) && Blockly . selected && Blockly . selected . isDeletable ( ) && Blockly . selected . isMovable ( ) } , callback : function ( c , d ) { d . preventDefault ( ) ; Blockly . hideChaff ( ) ; Blockly . copy ( Blockly . selected ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; var b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . C , [ Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b ,
2021-05-19 13:38:55 +00:00
a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . C , [ Blockly . utils . KeyCodes . ALT ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . C , [ Blockly . utils . KeyCodes . META ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) } ;
Blockly . ShortcutItems . registerCut = function ( ) { var a = { name : Blockly . ShortcutItems . names . CUT , preconditionFn : function ( c ) { return ! c . options . readOnly && ! Blockly . Gesture . inProgress ( ) && Blockly . selected && Blockly . selected . isDeletable ( ) && Blockly . selected . isMovable ( ) && ! Blockly . selected . workspace . isFlyout } , callback : function ( ) { Blockly . copy ( Blockly . selected ) ; Blockly . deleteBlock ( Blockly . selected ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; var b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . X ,
[ Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . X , [ Blockly . utils . KeyCodes . ALT ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . X , [ Blockly . utils . KeyCodes . META ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) } ;
Blockly . ShortcutItems . registerPaste = function ( ) { var a = { name : Blockly . ShortcutItems . names . PASTE , preconditionFn : function ( c ) { return ! c . options . readOnly && ! Blockly . Gesture . inProgress ( ) } , callback : function ( ) { return Blockly . paste ( ) } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; var b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . V , [ Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . V ,
[ Blockly . utils . KeyCodes . ALT ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . V , [ Blockly . utils . KeyCodes . META ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) } ;
Blockly . ShortcutItems . registerUndo = function ( ) { var a = { name : Blockly . ShortcutItems . names . UNDO , preconditionFn : function ( c ) { return ! c . options . readOnly && ! Blockly . Gesture . inProgress ( ) } , callback : function ( c ) { Blockly . hideChaff ( ) ; c . undo ( ! 1 ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; var b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z , [ Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z ,
[ Blockly . utils . KeyCodes . ALT ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z , [ Blockly . utils . KeyCodes . META ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) } ;
Blockly . ShortcutItems . registerRedo = function ( ) { var a = { name : Blockly . ShortcutItems . names . REDO , preconditionFn : function ( c ) { return ! Blockly . Gesture . inProgress ( ) && ! c . options . readOnly } , callback : function ( c ) { Blockly . hideChaff ( ) ; c . undo ( ! 0 ) ; return ! 0 } } ; Blockly . ShortcutRegistry . registry . register ( a ) ; var b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z , [ Blockly . utils . KeyCodes . SHIFT , Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z ,
[ Blockly . utils . KeyCodes . SHIFT , Blockly . utils . KeyCodes . ALT ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Z , [ Blockly . utils . KeyCodes . SHIFT , Blockly . utils . KeyCodes . META ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) ; b = Blockly . ShortcutRegistry . registry . createSerializedKey ( Blockly . utils . KeyCodes . Y , [ Blockly . utils . KeyCodes . CTRL ] ) ; Blockly . ShortcutRegistry . registry . addKeyMapping ( b , a . name ) } ;
Blockly . ShortcutItems . registerDefaultShortcuts = function ( ) { Blockly . ShortcutItems . registerEscape ( ) ; Blockly . ShortcutItems . registerDelete ( ) ; Blockly . ShortcutItems . registerCopy ( ) ; Blockly . ShortcutItems . registerCut ( ) ; Blockly . ShortcutItems . registerPaste ( ) ; Blockly . ShortcutItems . registerUndo ( ) ; Blockly . ShortcutItems . registerRedo ( ) } ; Blockly . ShortcutItems . registerDefaultShortcuts ( ) ; Blockly . ContextMenuItems = { } ; Blockly . ContextMenuItems . registerUndo = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . UNDO } , preconditionFn : function ( a ) { return 0 < a . workspace . getUndoStack ( ) . length ? "enabled" : "disabled" } , callback : function ( a ) { a . workspace . undo ( ! 1 ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE , id : "undoWorkspace" , weight : 1 } ) } ;
Blockly . ContextMenuItems . registerRedo = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . REDO } , preconditionFn : function ( a ) { return 0 < a . workspace . getRedoStack ( ) . length ? "enabled" : "disabled" } , callback : function ( a ) { a . workspace . undo ( ! 0 ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE , id : "redoWorkspace" , weight : 2 } ) } ;
Blockly . ContextMenuItems . registerCleanup = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . CLEAN _UP } , preconditionFn : function ( a ) { return a . workspace . isMovable ( ) ? 1 < a . workspace . getTopBlocks ( ! 1 ) . length ? "enabled" : "disabled" : "hidden" } , callback : function ( a ) { a . workspace . cleanUp ( ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE , id : "cleanWorkspace" , weight : 3 } ) } ;
Blockly . ContextMenuItems . toggleOption _ = function ( a , b ) { for ( var c = 0 , d = 0 ; d < b . length ; d ++ ) for ( var e = b [ d ] ; e ; ) setTimeout ( e . setCollapsed . bind ( e , a ) , c ) , e = e . getNextBlock ( ) , c += 10 } ;
Blockly . ContextMenuItems . registerCollapse = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . COLLAPSE _ALL } , preconditionFn : function ( a ) { if ( a . workspace . options . collapse ) { a = a . workspace . getTopBlocks ( ! 1 ) ; for ( var b = 0 ; b < a . length ; b ++ ) for ( var c = a [ b ] ; c ; ) { if ( ! c . isCollapsed ( ) ) return "enabled" ; c = c . getNextBlock ( ) } return "disabled" } return "hidden" } , callback : function ( a ) { Blockly . ContextMenuItems . toggleOption _ ( ! 0 , a . workspace . getTopBlocks ( ! 0 ) ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE ,
id : "collapseWorkspace" , weight : 4 } ) } ;
Blockly . ContextMenuItems . registerExpand = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . EXPAND _ALL } , preconditionFn : function ( a ) { if ( a . workspace . options . collapse ) { a = a . workspace . getTopBlocks ( ! 1 ) ; for ( var b = 0 ; b < a . length ; b ++ ) for ( var c = a [ b ] ; c ; ) { if ( c . isCollapsed ( ) ) return "enabled" ; c = c . getNextBlock ( ) } return "disabled" } return "hidden" } , callback : function ( a ) { Blockly . ContextMenuItems . toggleOption _ ( ! 1 , a . workspace . getTopBlocks ( ! 0 ) ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE ,
id : "expandWorkspace" , weight : 5 } ) } ; Blockly . ContextMenuItems . addDeletableBlocks _ = function ( a , b ) { if ( a . isDeletable ( ) ) Array . prototype . push . apply ( b , a . getDescendants ( ! 1 ) ) ; else { a = a . getChildren ( ! 1 ) ; for ( var c = 0 ; c < a . length ; c ++ ) Blockly . ContextMenuItems . addDeletableBlocks _ ( a [ c ] , b ) } } ; Blockly . ContextMenuItems . getDeletableBlocks _ = function ( a ) { var b = [ ] ; a = a . getTopBlocks ( ! 0 ) ; for ( var c = 0 ; c < a . length ; c ++ ) Blockly . ContextMenuItems . addDeletableBlocks _ ( a [ c ] , b ) ; return b } ;
Blockly . ContextMenuItems . deleteNext _ = function ( a , b ) { Blockly . Events . setGroup ( b ) ; var c = a . shift ( ) ; c && ( c . workspace ? ( c . dispose ( ! 1 , ! 0 ) , setTimeout ( Blockly . ContextMenuItems . deleteNext _ , 10 , a , b ) ) : Blockly . ContextMenuItems . deleteNext _ ( a , b ) ) ; Blockly . Events . setGroup ( ! 1 ) } ;
Blockly . ContextMenuItems . registerDeleteAll = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { if ( a . workspace ) return a = Blockly . ContextMenuItems . getDeletableBlocks _ ( a . workspace ) . length , 1 == a ? Blockly . Msg . DELETE _BLOCK : Blockly . Msg . DELETE _X _BLOCKS . replace ( "%1" , String ( a ) ) } , preconditionFn : function ( a ) { if ( a . workspace ) return 0 < Blockly . ContextMenuItems . getDeletableBlocks _ ( a . workspace ) . length ? "enabled" : "disabled" } , callback : function ( a ) { if ( a . workspace ) { a . workspace . cancelCurrentGesture ( ) ;
var b = Blockly . ContextMenuItems . getDeletableBlocks _ ( a . workspace ) , c = Blockly . utils . genUid ( ) ; 2 > b . length ? Blockly . ContextMenuItems . deleteNext _ ( b , c ) : Blockly . confirm ( Blockly . Msg . DELETE _ALL _BLOCKS . replace ( "%1" , b . length ) , function ( d ) { d && Blockly . ContextMenuItems . deleteNext _ ( b , c ) } ) } } , scopeType : Blockly . ContextMenuRegistry . ScopeType . WORKSPACE , id : "workspaceDelete" , weight : 6 } ) } ;
Blockly . ContextMenuItems . registerWorkspaceOptions _ = function ( ) { Blockly . ContextMenuItems . registerUndo ( ) ; Blockly . ContextMenuItems . registerRedo ( ) ; Blockly . ContextMenuItems . registerCleanup ( ) ; Blockly . ContextMenuItems . registerCollapse ( ) ; Blockly . ContextMenuItems . registerExpand ( ) ; Blockly . ContextMenuItems . registerDeleteAll ( ) } ;
Blockly . ContextMenuItems . registerDuplicate = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . DUPLICATE _BLOCK } , preconditionFn : function ( a ) { a = a . block ; return ! a . isInFlyout && a . isDeletable ( ) && a . isMovable ( ) ? a . isDuplicatable ( ) ? "enabled" : "disabled" : "hidden" } , callback : function ( a ) { a . block && Blockly . duplicate ( a . block ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockDuplicate" , weight : 1 } ) } ;
Blockly . ContextMenuItems . registerComment = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { return a . block . getCommentIcon ( ) ? Blockly . Msg . REMOVE _COMMENT : Blockly . Msg . ADD _COMMENT } , preconditionFn : function ( a ) { a = a . block ; return Blockly . utils . userAgent . IE || a . isInFlyout || ! a . workspace . options . comments || a . isCollapsed ( ) || ! a . isEditable ( ) ? "hidden" : "enabled" } , callback : function ( a ) { a = a . block ; a . getCommentIcon ( ) ? a . setCommentText ( null ) : a . setCommentText ( "" ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK ,
id : "blockComment" , weight : 2 } ) } ;
Blockly . ContextMenuItems . registerInline = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { return a . block . getInputsInline ( ) ? Blockly . Msg . EXTERNAL _INPUTS : Blockly . Msg . INLINE _INPUTS } , preconditionFn : function ( a ) { a = a . block ; if ( ! a . isInFlyout && a . isMovable ( ) && ! a . isCollapsed ( ) ) for ( var b = 1 ; b < a . inputList . length ; b ++ ) if ( a . inputList [ b - 1 ] . type != Blockly . inputTypes . STATEMENT && a . inputList [ b ] . type != Blockly . inputTypes . STATEMENT ) return "enabled" ; return "hidden" } , callback : function ( a ) { a . block . setInputsInline ( ! a . block . getInputsInline ( ) ) } ,
scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockInline" , weight : 3 } ) } ;
2021-09-18 14:29:06 +00:00
Blockly . ContextMenuItems . registerCollapseExpandBlock = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { return a . block . isCollapsed ( ) ? Blockly . Msg . EXPAND _BLOCK : Blockly . Msg . COLLAPSE _BLOCK } , preconditionFn : function ( a ) { a = a . block ; return ! a . isInFlyout && a . isMovable ( ) && a . workspace . options . collapse ? "enabled" : "hidden" } , callback : function ( a ) { a . block . setCollapsed ( ! a . block . isCollapsed ( ) ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockCollapseExpand" , weight : 4 } ) } ;
2021-05-19 13:38:55 +00:00
Blockly . ContextMenuItems . registerDisable = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { return a . block . isEnabled ( ) ? Blockly . Msg . DISABLE _BLOCK : Blockly . Msg . ENABLE _BLOCK } , preconditionFn : function ( a ) { a = a . block ; return ! a . isInFlyout && a . workspace . options . disable && a . isEditable ( ) ? a . getInheritedDisabled ( ) ? "disabled" : "enabled" : "hidden" } , callback : function ( a ) { a = a . block ; var b = Blockly . Events . getGroup ( ) ; b || Blockly . Events . setGroup ( ! 0 ) ; a . setEnabled ( ! a . isEnabled ( ) ) ; b || Blockly . Events . setGroup ( ! 1 ) } ,
scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockDisable" , weight : 5 } ) } ;
2021-09-18 14:29:06 +00:00
Blockly . ContextMenuItems . registerDelete = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( a ) { var b = a . block ; a = b . getDescendants ( ! 1 ) . length ; ( b = b . getNextBlock ( ) ) && ( a -= b . getDescendants ( ! 1 ) . length ) ; return 1 == a ? Blockly . Msg . DELETE _BLOCK : Blockly . Msg . DELETE _X _BLOCKS . replace ( "%1" , String ( a ) ) } , preconditionFn : function ( a ) { return ! a . block . isInFlyout && a . block . isDeletable ( ) ? "enabled" : "hidden" } , callback : function ( a ) { Blockly . Events . setGroup ( ! 0 ) ; a . block && Blockly . deleteBlock ( a . block ) ; Blockly . Events . setGroup ( ! 1 ) } ,
2021-05-19 13:38:55 +00:00
scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockDelete" , weight : 6 } ) } ; Blockly . ContextMenuItems . registerHelp = function ( ) { Blockly . ContextMenuRegistry . registry . register ( { displayText : function ( ) { return Blockly . Msg . HELP } , preconditionFn : function ( a ) { a = a . block ; return ( "function" == typeof a . helpUrl ? a . helpUrl ( ) : a . helpUrl ) ? "enabled" : "hidden" } , callback : function ( a ) { a . block . showHelp ( ) } , scopeType : Blockly . ContextMenuRegistry . ScopeType . BLOCK , id : "blockHelp" , weight : 7 } ) } ;
Blockly . ContextMenuItems . registerBlockOptions _ = function ( ) { Blockly . ContextMenuItems . registerDuplicate ( ) ; Blockly . ContextMenuItems . registerComment ( ) ; Blockly . ContextMenuItems . registerInline ( ) ; Blockly . ContextMenuItems . registerCollapseExpandBlock ( ) ; Blockly . ContextMenuItems . registerDisable ( ) ; Blockly . ContextMenuItems . registerDelete ( ) ; Blockly . ContextMenuItems . registerHelp ( ) } ; Blockly . ContextMenuItems . registerDefaultOptions = function ( ) { Blockly . ContextMenuItems . registerWorkspaceOptions _ ( ) ; Blockly . ContextMenuItems . registerBlockOptions _ ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . ContextMenuItems . registerDefaultOptions ( ) ; Blockly . Mutator = function ( a ) { Blockly . Mutator . superClass _ . constructor . call ( this , null ) ; this . quarkNames _ = a } ; Blockly . utils . object . inherits ( Blockly . Mutator , Blockly . Icon ) ; Blockly . Mutator . prototype . workspace _ = null ; Blockly . Mutator . prototype . workspaceWidth _ = 0 ; Blockly . Mutator . prototype . workspaceHeight _ = 0 ; Blockly . Mutator . prototype . setBlock = function ( a ) { this . block _ = a } ; Blockly . Mutator . prototype . getWorkspace = function ( ) { return this . workspace _ } ;
2021-01-16 14:07:51 +00:00
Blockly . Mutator . prototype . drawIcon _ = function ( a ) { Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blocklyIconShape" , rx : "4" , ry : "4" , height : "16" , width : "16" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyIconSymbol" , d : "m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z" } ,
a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE , { "class" : "blocklyIconShape" , r : "2.7" , cx : "8" , cy : "8" } , a ) } ; Blockly . Mutator . prototype . iconClick _ = function ( a ) { this . block _ . isEditable ( ) && Blockly . Icon . prototype . iconClick _ . call ( this , a ) } ;
Blockly . Mutator . prototype . createEditor _ = function ( ) { this . svgDialog _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { x : Blockly . Bubble . BORDER _WIDTH , y : Blockly . Bubble . BORDER _WIDTH } , null ) ; if ( this . quarkNames _ . length ) for ( var a = Blockly . utils . xml . createElement ( "xml" ) , b = 0 , c ; c = this . quarkNames _ [ b ] ; b ++ ) { var d = Blockly . utils . xml . createElement ( "block" ) ; d . setAttribute ( "type" , c ) ; a . appendChild ( d ) } else a = null ; b = new Blockly . Options ( { disable : ! 1 , parentWorkspace : this . block _ . workspace , media : this . block _ . workspace . options . pathToMedia ,
2021-05-19 13:38:55 +00:00
rtl : this . block _ . RTL , horizontalLayout : ! 1 , renderer : this . block _ . workspace . options . renderer , rendererOverrides : this . block _ . workspace . options . rendererOverrides } ) ; b . toolboxPosition = this . block _ . RTL ? Blockly . utils . toolbox . Position . RIGHT : Blockly . utils . toolbox . Position . LEFT ; if ( c = ! ! a ) b . languageTree = Blockly . utils . toolbox . convertToolboxDefToJson ( a ) ; this . workspace _ = new Blockly . WorkspaceSvg ( b ) ; this . workspace _ . isMutator = ! 0 ; this . workspace _ . addChangeListener ( Blockly . Events . disableOrphans ) ; a = c ? this . workspace _ . addFlyout ( Blockly . utils . Svg . G ) :
null ; b = this . workspace _ . createDom ( "blocklyMutatorBackground" ) ; a && b . insertBefore ( a , this . workspace _ . svgBlockCanvas _ ) ; this . svgDialog _ . appendChild ( b ) ; return this . svgDialog _ } ; Blockly . Mutator . prototype . updateEditable = function ( ) { Blockly . Mutator . superClass _ . updateEditable . call ( this ) ; this . block _ . isInFlyout || ( this . block _ . isEditable ( ) ? this . iconGroup _ && Blockly . utils . dom . removeClass ( this . iconGroup _ , "blocklyIconGroupReadonly" ) : ( this . setVisible ( ! 1 ) , this . iconGroup _ && Blockly . utils . dom . addClass ( this . iconGroup _ , "blocklyIconGroupReadonly" ) ) ) } ;
Blockly . Mutator . prototype . resizeBubble _ = function ( ) { var a = 2 * Blockly . Bubble . BORDER _WIDTH , b = this . workspace _ . getCanvas ( ) . getBBox ( ) , c = b . width + b . x , d = b . height + 3 * a , e = this . workspace _ . getFlyout ( ) ; if ( e ) { var f = e . getWorkspace ( ) . getMetricsManager ( ) . getScrollMetrics ( ) ; d = Math . max ( d , f . height + 20 ) ; c += e . getWidth ( ) } this . block _ . RTL && ( c = - b . x ) ; c += 3 * a ; if ( Math . abs ( this . workspaceWidth _ - c ) > a || Math . abs ( this . workspaceHeight _ - d ) > a ) this . workspaceWidth _ = c , this . workspaceHeight _ = d , this . bubble _ . setBubbleSize ( c + a , d + a ) , this . svgDialog _ . setAttribute ( "width" ,
2021-09-18 14:29:06 +00:00
this . workspaceWidth _ ) , this . svgDialog _ . setAttribute ( "height" , this . workspaceHeight _ ) , this . workspace _ . setCachedParentSvgSize ( this . workspaceWidth _ , this . workspaceHeight _ ) ; this . block _ . RTL && ( a = "translate(" + this . workspaceWidth _ + ",0)" , this . workspace _ . getCanvas ( ) . setAttribute ( "transform" , a ) ) ; this . workspace _ . resize ( ) } ; Blockly . Mutator . prototype . onBubbleMove _ = function ( ) { this . workspace _ && this . workspace _ . recordDragTargets ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . Mutator . prototype . setVisible = function ( a ) { if ( a != this . isVisible ( ) ) if ( Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BUBBLE _OPEN ) ) ( this . block _ , a , "mutator" ) ) , a ) { this . bubble _ = new Blockly . Bubble ( this . block _ . workspace , this . createEditor _ ( ) , this . block _ . pathObject . svgPath , this . iconXY _ , null , null ) ; this . bubble _ . setSvgId ( this . block _ . id ) ; this . bubble _ . registerMoveEvent ( this . onBubbleMove _ . bind ( this ) ) ; var b = this . workspace _ . options . languageTree ; a = this . workspace _ . getFlyout ( ) ; b && ( a . init ( this . workspace _ ) ,
a . show ( b ) ) ; this . rootBlock _ = this . block _ . decompose ( this . workspace _ ) ; b = this . rootBlock _ . getDescendants ( ! 1 ) ; for ( var c = 0 , d ; d = b [ c ] ; c ++ ) d . render ( ) ; this . rootBlock _ . setMovable ( ! 1 ) ; this . rootBlock _ . setDeletable ( ! 1 ) ; a ? ( b = 2 * a . CORNER _RADIUS , a = this . rootBlock _ . RTL ? a . getWidth ( ) + b : b ) : a = b = 16 ; this . block _ . RTL && ( a = - a ) ; this . rootBlock _ . moveBy ( a , b ) ; if ( this . block _ . saveConnections ) { var e = this , f = this . block _ ; f . saveConnections ( this . rootBlock _ ) ; this . sourceListener _ = function ( ) { f . saveConnections ( e . rootBlock _ ) } ; this . block _ . workspace . addChangeListener ( this . sourceListener _ ) } this . resizeBubble _ ( ) ;
2021-01-16 14:07:51 +00:00
this . workspace _ . addChangeListener ( this . workspaceChanged _ . bind ( this ) ) ; this . applyColour ( ) } else this . svgDialog _ = null , this . workspace _ . dispose ( ) , this . rootBlock _ = this . workspace _ = null , this . bubble _ . dispose ( ) , this . bubble _ = null , this . workspaceHeight _ = this . workspaceWidth _ = 0 , this . sourceListener _ && ( this . block _ . workspace . removeChangeListener ( this . sourceListener _ ) , this . sourceListener _ = null ) } ;
Blockly . Mutator . prototype . workspaceChanged _ = function ( a ) { if ( ! ( a . isUiEvent || a . type == Blockly . Events . CHANGE && "disabled" == a . element ) ) { if ( ! this . workspace _ . isDragging ( ) ) { a = this . workspace _ . getTopBlocks ( ! 1 ) ; for ( var b = 0 , c ; c = a [ b ] ; b ++ ) { var d = c . getRelativeToSurfaceXY ( ) ; 20 > d . y && c . moveBy ( 0 , 20 - d . y ) ; if ( c . RTL ) { var e = - 20 , f = this . workspace _ . getFlyout ( ) ; f && ( e -= f . getWidth ( ) ) ; d . x > e && c . moveBy ( e - d . x , 0 ) } else 20 > d . x && c . moveBy ( 20 - d . x , 0 ) } } if ( this . rootBlock _ . workspace == this . workspace _ ) { Blockly . Events . setGroup ( ! 0 ) ; c = this . block _ ;
2021-05-19 13:38:55 +00:00
a = ( a = c . mutationToDom ( ) ) && Blockly . Xml . domToText ( a ) ; b = c . rendered ; c . rendered = ! 1 ; c . compose ( this . rootBlock _ ) ; c . rendered = b ; c . initSvg ( ) ; c . rendered && c . render ( ) ; b = ( b = c . mutationToDom ( ) ) && Blockly . Xml . domToText ( b ) ; if ( a != b ) { Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( c , "mutation" , null , a , b ) ) ; var g = Blockly . Events . getGroup ( ) ; setTimeout ( function ( ) { Blockly . Events . setGroup ( g ) ; c . bumpNeighbours ( ) ; Blockly . Events . setGroup ( ! 1 ) } , Blockly . BUMP _DELAY ) } this . workspace _ . isDragging ( ) || this . resizeBubble _ ( ) ;
2021-09-18 14:29:06 +00:00
Blockly . Events . setGroup ( ! 1 ) } } } ; Blockly . Mutator . prototype . dispose = function ( ) { this . block _ . mutator = null ; Blockly . Icon . prototype . dispose . call ( this ) } ; Blockly . Mutator . prototype . updateBlockStyle = function ( ) { var a = this . workspace _ ; if ( a && a . getAllBlocks ( ! 1 ) ) { for ( var b = a . getAllBlocks ( ! 1 ) , c = 0 , d ; d = b [ c ] ; c ++ ) d . setStyle ( d . getStyleName ( ) ) ; if ( c = a . getFlyout ( ) ) for ( a = c . workspace _ . getAllBlocks ( ! 1 ) , c = 0 ; d = a [ c ] ; c ++ ) d . setStyle ( d . getStyleName ( ) ) } } ;
2021-01-16 14:07:51 +00:00
Blockly . Mutator . reconnect = function ( a , b , c ) { if ( ! a || ! a . getSourceBlock ( ) . workspace ) return ! 1 ; c = b . getInput ( c ) . connection ; var d = a . targetBlock ( ) ; return d && d != b || c . targetConnection == a ? ! 1 : ( c . isConnected ( ) && c . disconnect ( ) , c . connect ( a ) , ! 0 ) } ; Blockly . Mutator . findParentWs = function ( a ) { var b = null ; if ( a && a . options ) { var c = a . options . parentWorkspace ; a . isFlyout ? c && c . options && ( b = c . options . parentWorkspace ) : c && ( b = c ) } return b } ; Blockly . FieldTextInput = function ( a , b , c ) { this . spellcheck _ = ! 0 ; Blockly . FieldTextInput . superClass _ . constructor . call ( this , a , b , c ) ; this . onKeyInputWrapper _ = this . onKeyDownWrapper _ = this . htmlInput _ = null ; this . fullBlockClickTarget _ = ! 1 ; this . workspace _ = null } ; Blockly . utils . object . inherits ( Blockly . FieldTextInput , Blockly . Field ) ; Blockly . FieldTextInput . prototype . DEFAULT _VALUE = "" ;
Blockly . FieldTextInput . fromJson = function ( a ) { var b = Blockly . utils . replaceMessageReferences ( a . text ) ; return new Blockly . FieldTextInput ( b , void 0 , a ) } ; Blockly . FieldTextInput . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldTextInput . BORDERRADIUS = 4 ; Blockly . FieldTextInput . prototype . CURSOR = "text" ; Blockly . FieldTextInput . prototype . configure _ = function ( a ) { Blockly . FieldTextInput . superClass _ . configure _ . call ( this , a ) ; "boolean" == typeof a . spellcheck && ( this . spellcheck _ = a . spellcheck ) } ;
Blockly . FieldTextInput . prototype . initView = function ( ) { if ( this . getConstants ( ) . FULL _BLOCK _FIELDS ) { for ( var a = 0 , b = 0 , c = 0 , d ; d = this . sourceBlock _ . inputList [ c ] ; c ++ ) { for ( var e = 0 ; d . fieldRow [ e ] ; e ++ ) a ++ ; d . connection && b ++ } this . fullBlockClickTarget _ = 1 >= a && this . sourceBlock _ . outputConnection && ! b } else this . fullBlockClickTarget _ = ! 1 ; this . fullBlockClickTarget _ ? this . clickTarget _ = this . sourceBlock _ . getSvgRoot ( ) : this . createBorderRect _ ( ) ; this . createTextElement _ ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldTextInput . prototype . doClassValidation _ = function ( a ) { return null === a || void 0 === a ? null : String ( a ) } ; Blockly . FieldTextInput . prototype . doValueInvalid _ = function ( a ) { this . isBeingEdited _ && ( this . isTextValid _ = ! 1 , a = this . value _ , this . value _ = this . htmlInput _ . untypedDefaultValue _ , this . sourceBlock _ && Blockly . Events . isEnabled ( ) && Blockly . Events . fire ( new ( Blockly . Events . get ( Blockly . Events . BLOCK _CHANGE ) ) ( this . sourceBlock _ , "field" , this . name || null , a , this . value _ ) ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldTextInput . prototype . doValueUpdate _ = function ( a ) { this . isTextValid _ = ! 0 ; this . value _ = a ; this . isBeingEdited _ || ( this . isDirty _ = ! 0 ) } ; Blockly . FieldTextInput . prototype . applyColour = function ( ) { this . sourceBlock _ && this . getConstants ( ) . FULL _BLOCK _FIELDS && ( this . borderRect _ ? this . borderRect _ . setAttribute ( "stroke" , this . sourceBlock _ . style . colourTertiary ) : this . sourceBlock _ . pathObject . svgPath . setAttribute ( "fill" , this . getConstants ( ) . FIELD _BORDER _RECT _COLOUR ) ) } ;
Blockly . FieldTextInput . prototype . render _ = function ( ) { Blockly . FieldTextInput . superClass _ . render _ . call ( this ) ; if ( this . isBeingEdited _ ) { this . resizeEditor _ ( ) ; var a = this . htmlInput _ ; this . isTextValid _ ? ( Blockly . utils . dom . removeClass ( a , "blocklyInvalidInput" ) , Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . INVALID , ! 1 ) ) : ( Blockly . utils . dom . addClass ( a , "blocklyInvalidInput" ) , Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . INVALID , ! 0 ) ) } } ;
Blockly . FieldTextInput . prototype . setSpellcheck = function ( a ) { a != this . spellcheck _ && ( this . spellcheck _ = a , this . htmlInput _ && this . htmlInput _ . setAttribute ( "spellcheck" , this . spellcheck _ ) ) } ; Blockly . FieldTextInput . prototype . showEditor _ = function ( a , b ) { this . workspace _ = this . sourceBlock _ . workspace ; a = b || ! 1 ; ! a && ( Blockly . utils . userAgent . MOBILE || Blockly . utils . userAgent . ANDROID || Blockly . utils . userAgent . IPAD ) ? this . showPromptEditor _ ( ) : this . showInlineEditor _ ( a ) } ;
Blockly . FieldTextInput . prototype . showPromptEditor _ = function ( ) { Blockly . prompt ( Blockly . Msg . CHANGE _VALUE _TITLE , this . getText ( ) , function ( a ) { this . setValue ( this . getValueFromEditorText _ ( a ) ) } . bind ( this ) ) } ; Blockly . FieldTextInput . prototype . showInlineEditor _ = function ( a ) { Blockly . WidgetDiv . show ( this , this . sourceBlock _ . RTL , this . widgetDispose _ . bind ( this ) ) ; this . htmlInput _ = this . widgetCreate _ ( ) ; this . isBeingEdited _ = ! 0 ; a || ( this . htmlInput _ . focus ( { preventScroll : ! 0 } ) , this . htmlInput _ . select ( ) ) } ;
Blockly . FieldTextInput . prototype . widgetCreate _ = function ( ) { var a = Blockly . WidgetDiv . DIV ; Blockly . utils . dom . addClass ( this . getClickTarget _ ( ) , "editing" ) ; var b = document . createElement ( "input" ) ; b . className = "blocklyHtmlInput" ; b . setAttribute ( "spellcheck" , this . spellcheck _ ) ; var c = this . workspace _ . getScale ( ) , d = this . getConstants ( ) . FIELD _TEXT _FONTSIZE * c + "pt" ; a . style . fontSize = d ; b . style . fontSize = d ; d = Blockly . FieldTextInput . BORDERRADIUS * c + "px" ; if ( this . fullBlockClickTarget _ ) { d = this . getScaledBBox ( ) ; d = ( d . bottom - d . top ) / 2 +
"px" ; var e = this . sourceBlock _ . getParent ( ) ? this . sourceBlock _ . getParent ( ) . style . colourTertiary : this . sourceBlock _ . style . colourTertiary ; b . style . border = 1 * c + "px solid " + e ; a . style . borderRadius = d ; a . style . transition = "box-shadow 0.25s ease 0s" ; this . getConstants ( ) . FIELD _TEXTINPUT _BOX _SHADOW && ( a . style . boxShadow = "rgba(255, 255, 255, 0.3) 0px 0px 0px " + 4 * c + "px" ) } b . style . borderRadius = d ; a . appendChild ( b ) ; b . value = b . defaultValue = this . getEditorText _ ( this . value _ ) ; b . untypedDefaultValue _ = this . value _ ; b . oldValue _ = null ; this . resizeEditor _ ( ) ;
this . bindInputEvents _ ( b ) ; return b } ; Blockly . FieldTextInput . prototype . widgetDispose _ = function ( ) { this . isBeingEdited _ = ! 1 ; this . isTextValid _ = ! 0 ; this . forceRerender ( ) ; if ( this . onFinishEditing _ ) this . onFinishEditing _ ( this . value _ ) ; this . unbindInputEvents _ ( ) ; var a = Blockly . WidgetDiv . DIV . style ; a . width = "auto" ; a . height = "auto" ; a . fontSize = "" ; a . transition = "" ; a . boxShadow = "" ; this . htmlInput _ = null ; Blockly . utils . dom . removeClass ( this . getClickTarget _ ( ) , "editing" ) } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldTextInput . prototype . bindInputEvents _ = function ( a ) { this . onKeyDownWrapper _ = Blockly . browserEvents . conditionalBind ( a , "keydown" , this , this . onHtmlInputKeyDown _ ) ; this . onKeyInputWrapper _ = Blockly . browserEvents . conditionalBind ( a , "input" , this , this . onHtmlInputChange _ ) } ;
Blockly . FieldTextInput . prototype . unbindInputEvents _ = function ( ) { this . onKeyDownWrapper _ && ( Blockly . browserEvents . unbind ( this . onKeyDownWrapper _ ) , this . onKeyDownWrapper _ = null ) ; this . onKeyInputWrapper _ && ( Blockly . browserEvents . unbind ( this . onKeyInputWrapper _ ) , this . onKeyInputWrapper _ = null ) } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldTextInput . prototype . onHtmlInputKeyDown _ = function ( a ) { a . keyCode == Blockly . utils . KeyCodes . ENTER ? ( Blockly . WidgetDiv . hide ( ) , Blockly . DropDownDiv . hideWithoutAnimation ( ) ) : a . keyCode == Blockly . utils . KeyCodes . ESC ? ( this . setValue ( this . htmlInput _ . untypedDefaultValue _ ) , Blockly . WidgetDiv . hide ( ) , Blockly . DropDownDiv . hideWithoutAnimation ( ) ) : a . keyCode == Blockly . utils . KeyCodes . TAB && ( Blockly . WidgetDiv . hide ( ) , Blockly . DropDownDiv . hideWithoutAnimation ( ) , this . sourceBlock _ . tab ( this , ! a . shiftKey ) , a . preventDefault ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldTextInput . prototype . onHtmlInputChange _ = function ( a ) { a = this . htmlInput _ . value ; a !== this . htmlInput _ . oldValue _ && ( this . htmlInput _ . oldValue _ = a , Blockly . Events . setGroup ( ! 0 ) , a = this . getValueFromEditorText _ ( a ) , this . setValue ( a ) , this . forceRerender ( ) , this . resizeEditor _ ( ) , Blockly . Events . setGroup ( ! 1 ) ) } ; Blockly . FieldTextInput . prototype . setEditorValue _ = function ( a ) { this . isDirty _ = ! 0 ; this . isBeingEdited _ && ( this . htmlInput _ . value = this . getEditorText _ ( a ) ) ; this . setValue ( a ) } ;
Blockly . FieldTextInput . prototype . resizeEditor _ = function ( ) { var a = Blockly . WidgetDiv . DIV , b = this . getScaledBBox ( ) ; a . style . width = b . right - b . left + "px" ; a . style . height = b . bottom - b . top + "px" ; b = new Blockly . utils . Coordinate ( this . sourceBlock _ . RTL ? b . right - a . offsetWidth : b . left , b . top ) ; a . style . left = b . x + "px" ; a . style . top = b . y + "px" } ; Blockly . FieldTextInput . prototype . isTabNavigable = function ( ) { return ! 0 } ; Blockly . FieldTextInput . prototype . getText _ = function ( ) { return this . isBeingEdited _ && this . htmlInput _ ? this . htmlInput _ . value : null } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldTextInput . prototype . getEditorText _ = function ( a ) { return String ( a ) } ; Blockly . FieldTextInput . prototype . getValueFromEditorText _ = function ( a ) { return a } ; Blockly . fieldRegistry . register ( "field_input" , Blockly . FieldTextInput ) ; Blockly . FieldAngle = function ( a , b , c ) { this . clockwise _ = Blockly . FieldAngle . CLOCKWISE ; this . offset _ = Blockly . FieldAngle . OFFSET ; this . wrap _ = Blockly . FieldAngle . WRAP ; this . round _ = Blockly . FieldAngle . ROUND ; Blockly . FieldAngle . superClass _ . constructor . call ( this , a , b , c ) ; this . moveSurfaceWrapper _ = this . clickSurfaceWrapper _ = this . clickWrapper _ = this . line _ = this . gauge _ = this . editor _ = null } ; Blockly . utils . object . inherits ( Blockly . FieldAngle , Blockly . FieldTextInput ) ; Blockly . FieldAngle . prototype . DEFAULT _VALUE = 0 ;
2021-01-16 14:07:51 +00:00
Blockly . FieldAngle . fromJson = function ( a ) { return new Blockly . FieldAngle ( a . angle , void 0 , a ) } ; Blockly . FieldAngle . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldAngle . ROUND = 15 ; Blockly . FieldAngle . HALF = 50 ; Blockly . FieldAngle . CLOCKWISE = ! 1 ; Blockly . FieldAngle . OFFSET = 0 ; Blockly . FieldAngle . WRAP = 360 ; Blockly . FieldAngle . RADIUS = Blockly . FieldAngle . HALF - 1 ;
Blockly . FieldAngle . prototype . configure _ = function ( a ) { Blockly . FieldAngle . superClass _ . configure _ . call ( this , a ) ; switch ( a . mode ) { case "compass" : this . clockwise _ = ! 0 ; this . offset _ = 90 ; break ; case "protractor" : this . clockwise _ = ! 1 , this . offset _ = 0 } var b = a . clockwise ; "boolean" == typeof b && ( this . clockwise _ = b ) ; b = a . offset ; null != b && ( b = Number ( b ) , isNaN ( b ) || ( this . offset _ = b ) ) ; b = a . wrap ; null != b && ( b = Number ( b ) , isNaN ( b ) || ( this . wrap _ = b ) ) ; a = a . round ; null != a && ( a = Number ( a ) , isNaN ( a ) || ( this . round _ = a ) ) } ;
Blockly . FieldAngle . prototype . initView = function ( ) { Blockly . FieldAngle . superClass _ . initView . call ( this ) ; this . symbol _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TSPAN , { } , null ) ; this . symbol _ . appendChild ( document . createTextNode ( "\u00b0" ) ) ; this . textElement _ . appendChild ( this . symbol _ ) } ; Blockly . FieldAngle . prototype . render _ = function ( ) { Blockly . FieldAngle . superClass _ . render _ . call ( this ) ; this . updateGraph _ ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldAngle . prototype . showEditor _ = function ( a ) { Blockly . FieldAngle . superClass _ . showEditor _ . call ( this , a , Blockly . utils . userAgent . MOBILE || Blockly . utils . userAgent . ANDROID || Blockly . utils . userAgent . IPAD ) ; this . dropdownCreate _ ( ) ; Blockly . DropDownDiv . getContentDiv ( ) . appendChild ( this . editor _ ) ; Blockly . DropDownDiv . setColour ( this . sourceBlock _ . style . colourPrimary , this . sourceBlock _ . style . colourTertiary ) ; Blockly . DropDownDiv . showPositionedByField ( this , this . dropdownDispose _ . bind ( this ) ) ; this . updateGraph _ ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldAngle . prototype . dropdownCreate _ = function ( ) { var a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . SVG , { xmlns : Blockly . utils . dom . SVG _NS , "xmlns:html" : Blockly . utils . dom . HTML _NS , "xmlns:xlink" : Blockly . utils . dom . XLINK _NS , version : "1.1" , height : 2 * Blockly . FieldAngle . HALF + "px" , width : 2 * Blockly . FieldAngle . HALF + "px" , style : "touch-action: none" } , null ) , b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE , { cx : Blockly . FieldAngle . HALF , cy : Blockly . FieldAngle . HALF , r : Blockly . FieldAngle . RADIUS , "class" : "blocklyAngleCircle" } ,
a ) ; this . gauge _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyAngleGauge" } , a ) ; this . line _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { x1 : Blockly . FieldAngle . HALF , y1 : Blockly . FieldAngle . HALF , "class" : "blocklyAngleLine" } , a ) ; for ( var c = 0 ; 360 > c ; c += 15 ) Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . LINE , { x1 : Blockly . FieldAngle . HALF + Blockly . FieldAngle . RADIUS , y1 : Blockly . FieldAngle . HALF , x2 : Blockly . FieldAngle . HALF + Blockly . FieldAngle . RADIUS - ( 0 == c % 45 ? 10 : 5 ) , y2 : Blockly . FieldAngle . HALF ,
2021-09-18 14:29:06 +00:00
"class" : "blocklyAngleMarks" , transform : "rotate(" + c + "," + Blockly . FieldAngle . HALF + "," + Blockly . FieldAngle . HALF + ")" } , a ) ; this . clickWrapper _ = Blockly . browserEvents . conditionalBind ( a , "click" , this , this . hide _ ) ; this . clickSurfaceWrapper _ = Blockly . browserEvents . conditionalBind ( b , "click" , this , this . onMouseMove _ , ! 0 , ! 0 ) ; this . moveSurfaceWrapper _ = Blockly . browserEvents . conditionalBind ( b , "mousemove" , this , this . onMouseMove _ , ! 0 , ! 0 ) ; this . editor _ = a } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldAngle . prototype . dropdownDispose _ = function ( ) { this . clickWrapper _ && ( Blockly . browserEvents . unbind ( this . clickWrapper _ ) , this . clickWrapper _ = null ) ; this . clickSurfaceWrapper _ && ( Blockly . browserEvents . unbind ( this . clickSurfaceWrapper _ ) , this . clickSurfaceWrapper _ = null ) ; this . moveSurfaceWrapper _ && ( Blockly . browserEvents . unbind ( this . moveSurfaceWrapper _ ) , this . moveSurfaceWrapper _ = null ) ; this . line _ = this . gauge _ = null } ; Blockly . FieldAngle . prototype . hide _ = function ( ) { Blockly . DropDownDiv . hideIfOwner ( this ) ; Blockly . WidgetDiv . hide ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldAngle . prototype . onMouseMove _ = function ( a ) { var b = this . gauge _ . ownerSVGElement . getBoundingClientRect ( ) , c = a . clientX - b . left - Blockly . FieldAngle . HALF ; a = a . clientY - b . top - Blockly . FieldAngle . HALF ; b = Math . atan ( - a / c ) ; isNaN ( b ) || ( b = Blockly . utils . math . toDegrees ( b ) , 0 > c ? b += 180 : 0 < a && ( b += 360 ) , b = this . clockwise _ ? this . offset _ + 360 - b : 360 - ( this . offset _ - b ) , this . displayMouseOrKeyboardValue _ ( b ) ) } ;
Blockly . FieldAngle . prototype . displayMouseOrKeyboardValue _ = function ( a ) { this . round _ && ( a = Math . round ( a / this . round _ ) * this . round _ ) ; a = this . wrapValue _ ( a ) ; a != this . value _ && this . setEditorValue _ ( a ) } ;
Blockly . FieldAngle . prototype . updateGraph _ = function ( ) { if ( this . gauge _ ) { var a = Number ( this . getText ( ) ) + this . offset _ , b = Blockly . utils . math . toRadians ( a % 360 ) ; a = [ "M " , Blockly . FieldAngle . HALF , "," , Blockly . FieldAngle . HALF ] ; var c = Blockly . FieldAngle . HALF , d = Blockly . FieldAngle . HALF ; if ( ! isNaN ( b ) ) { var e = Number ( this . clockwise _ ) , f = Blockly . utils . math . toRadians ( this . offset _ ) , g = Math . cos ( f ) * Blockly . FieldAngle . RADIUS , h = Math . sin ( f ) * - Blockly . FieldAngle . RADIUS ; e && ( b = 2 * f - b ) ; c += Math . cos ( b ) * Blockly . FieldAngle . RADIUS ; d -= Math . sin ( b ) *
Blockly . FieldAngle . RADIUS ; b = Math . abs ( Math . floor ( ( b - f ) / Math . PI ) % 2 ) ; e && ( b = 1 - b ) ; a . push ( " l " , g , "," , h , " A " , Blockly . FieldAngle . RADIUS , "," , Blockly . FieldAngle . RADIUS , " 0 " , b , " " , e , " " , c , "," , d , " z" ) } this . gauge _ . setAttribute ( "d" , a . join ( "" ) ) ; this . line _ . setAttribute ( "x2" , c ) ; this . line _ . setAttribute ( "y2" , d ) } } ;
Blockly . FieldAngle . prototype . onHtmlInputKeyDown _ = function ( a ) { Blockly . FieldAngle . superClass _ . onHtmlInputKeyDown _ . call ( this , a ) ; var b ; a . keyCode === Blockly . utils . KeyCodes . LEFT ? b = this . sourceBlock _ . RTL ? 1 : - 1 : a . keyCode === Blockly . utils . KeyCodes . RIGHT ? b = this . sourceBlock _ . RTL ? - 1 : 1 : a . keyCode === Blockly . utils . KeyCodes . DOWN ? b = - 1 : a . keyCode === Blockly . utils . KeyCodes . UP && ( b = 1 ) ; if ( b ) { var c = this . getValue ( ) ; this . displayMouseOrKeyboardValue _ ( c + b * this . round _ ) ; a . preventDefault ( ) ; a . stopPropagation ( ) } } ;
Blockly . FieldAngle . prototype . doClassValidation _ = function ( a ) { a = Number ( a ) ; return isNaN ( a ) || ! isFinite ( a ) ? null : this . wrapValue _ ( a ) } ; Blockly . FieldAngle . prototype . wrapValue _ = function ( a ) { a %= 360 ; 0 > a && ( a += 360 ) ; a > this . wrap _ && ( a -= 360 ) ; return a } ; Blockly . Css . register ( ".blocklyAngleCircle {,stroke: #444;,stroke-width: 1;,fill: #ddd;,fill-opacity: .8;,},.blocklyAngleMarks {,stroke: #444;,stroke-width: 1;,},.blocklyAngleGauge {,fill: #f88;,fill-opacity: .8;,pointer-events: none;,},.blocklyAngleLine {,stroke: #f00;,stroke-width: 2;,stroke-linecap: round;,pointer-events: none;,}" . split ( "," ) ) ;
Blockly . fieldRegistry . register ( "field_angle" , Blockly . FieldAngle ) ; Blockly . FieldCheckbox = function ( a , b , c ) { this . checkChar _ = null ; Blockly . FieldCheckbox . superClass _ . constructor . call ( this , a , b , c ) } ; Blockly . utils . object . inherits ( Blockly . FieldCheckbox , Blockly . Field ) ; Blockly . FieldCheckbox . prototype . DEFAULT _VALUE = ! 1 ; Blockly . FieldCheckbox . fromJson = function ( a ) { return new Blockly . FieldCheckbox ( a . checked , void 0 , a ) } ; Blockly . FieldCheckbox . CHECK _CHAR = "\u2713" ; Blockly . FieldCheckbox . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldCheckbox . prototype . CURSOR = "default" ;
Blockly . FieldCheckbox . prototype . configure _ = function ( a ) { Blockly . FieldCheckbox . superClass _ . configure _ . call ( this , a ) ; a . checkCharacter && ( this . checkChar _ = a . checkCharacter ) } ; Blockly . FieldCheckbox . prototype . initView = function ( ) { Blockly . FieldCheckbox . superClass _ . initView . call ( this ) ; Blockly . utils . dom . addClass ( this . textElement _ , "blocklyCheckbox" ) ; this . textElement _ . style . display = this . value _ ? "block" : "none" } ;
Blockly . FieldCheckbox . prototype . render _ = function ( ) { this . textContent _ && ( this . textContent _ . nodeValue = this . getDisplayText _ ( ) ) ; this . updateSize _ ( this . getConstants ( ) . FIELD _CHECKBOX _X _OFFSET ) } ; Blockly . FieldCheckbox . prototype . getDisplayText _ = function ( ) { return this . checkChar _ || Blockly . FieldCheckbox . CHECK _CHAR } ; Blockly . FieldCheckbox . prototype . setCheckCharacter = function ( a ) { this . checkChar _ = a ; this . forceRerender ( ) } ; Blockly . FieldCheckbox . prototype . showEditor _ = function ( ) { this . setValue ( ! this . value _ ) } ;
Blockly . FieldCheckbox . prototype . doClassValidation _ = function ( a ) { return ! 0 === a || "TRUE" === a ? "TRUE" : ! 1 === a || "FALSE" === a ? "FALSE" : null } ; Blockly . FieldCheckbox . prototype . doValueUpdate _ = function ( a ) { this . value _ = this . convertValueToBool _ ( a ) ; this . textElement _ && ( this . textElement _ . style . display = this . value _ ? "block" : "none" ) } ; Blockly . FieldCheckbox . prototype . getValue = function ( ) { return this . value _ ? "TRUE" : "FALSE" } ; Blockly . FieldCheckbox . prototype . getValueBoolean = function ( ) { return this . value _ } ;
Blockly . FieldCheckbox . prototype . getText = function ( ) { return String ( this . convertValueToBool _ ( this . value _ ) ) } ; Blockly . FieldCheckbox . prototype . convertValueToBool _ = function ( a ) { return "string" == typeof a ? "TRUE" == a : ! ! a } ; Blockly . fieldRegistry . register ( "field_checkbox" , Blockly . FieldCheckbox ) ; Blockly . FieldColour = function ( a , b , c ) { Blockly . FieldColour . superClass _ . constructor . call ( this , a , b , c ) ; this . onKeyDownWrapper _ = this . onMouseLeaveWrapper _ = this . onMouseEnterWrapper _ = this . onMouseMoveWrapper _ = this . onClickWrapper _ = this . highlightedIndex _ = this . picker _ = null } ; Blockly . utils . object . inherits ( Blockly . FieldColour , Blockly . Field ) ; Blockly . FieldColour . fromJson = function ( a ) { return new Blockly . FieldColour ( a . colour , void 0 , a ) } ; Blockly . FieldColour . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldColour . prototype . CURSOR = "default" ;
Blockly . FieldColour . prototype . isDirty _ = ! 1 ; Blockly . FieldColour . prototype . colours _ = null ; Blockly . FieldColour . prototype . titles _ = null ; Blockly . FieldColour . prototype . columns _ = 0 ; Blockly . FieldColour . prototype . configure _ = function ( a ) { Blockly . FieldColour . superClass _ . configure _ . call ( this , a ) ; a . colourOptions && ( this . colours _ = a . colourOptions , this . titles _ = a . colourTitles ) ; a . columns && ( this . columns _ = a . columns ) } ;
Blockly . FieldColour . prototype . initView = function ( ) { this . size _ = new Blockly . utils . Size ( this . getConstants ( ) . FIELD _COLOUR _DEFAULT _WIDTH , this . getConstants ( ) . FIELD _COLOUR _DEFAULT _HEIGHT ) ; this . getConstants ( ) . FIELD _COLOUR _FULL _BLOCK ? this . clickTarget _ = this . sourceBlock _ . getSvgRoot ( ) : ( this . createBorderRect _ ( ) , this . borderRect _ . style . fillOpacity = "1" ) } ;
Blockly . FieldColour . prototype . applyColour = function ( ) { this . getConstants ( ) . FIELD _COLOUR _FULL _BLOCK ? ( this . sourceBlock _ . pathObject . svgPath . setAttribute ( "fill" , this . getValue ( ) ) , this . sourceBlock _ . pathObject . svgPath . setAttribute ( "stroke" , "#fff" ) ) : this . borderRect _ && ( this . borderRect _ . style . fill = this . getValue ( ) ) } ; Blockly . FieldColour . prototype . doClassValidation _ = function ( a ) { return "string" != typeof a ? null : Blockly . utils . colour . parse ( a ) } ;
Blockly . FieldColour . prototype . doValueUpdate _ = function ( a ) { this . value _ = a ; this . borderRect _ ? this . borderRect _ . style . fill = a : this . sourceBlock _ && this . sourceBlock _ . rendered && ( this . sourceBlock _ . pathObject . svgPath . setAttribute ( "fill" , a ) , this . sourceBlock _ . pathObject . svgPath . setAttribute ( "stroke" , "#fff" ) ) } ; Blockly . FieldColour . prototype . getText = function ( ) { var a = this . value _ ; /^#(.)\1(.)\2(.)\3$/ . test ( a ) && ( a = "#" + a [ 1 ] + a [ 3 ] + a [ 5 ] ) ; return a } ; Blockly . FieldColour . COLOURS = "#ffffff #cccccc #c0c0c0 #999999 #666666 #333333 #000000 #ffcccc #ff6666 #ff0000 #cc0000 #990000 #660000 #330000 #ffcc99 #ff9966 #ff9900 #ff6600 #cc6600 #993300 #663300 #ffff99 #ffff66 #ffcc66 #ffcc33 #cc9933 #996633 #663333 #ffffcc #ffff33 #ffff00 #ffcc00 #999900 #666600 #333300 #99ff99 #66ff99 #33ff33 #33cc00 #009900 #006600 #003300 #99ffff #33ffff #66cccc #00cccc #339999 #336666 #003333 #ccffff #66ffff #33ccff #3366ff #3333ff #000099 #000066 #ccccff #9999ff #6666cc #6633ff #6600cc #333399 #330099 #ffccff #ff99ff #cc66cc #cc33cc #993399 #663366 #330033" . split ( " " ) ;
Blockly . FieldColour . prototype . DEFAULT _VALUE = Blockly . FieldColour . COLOURS [ 0 ] ; Blockly . FieldColour . TITLES = [ ] ; Blockly . FieldColour . COLUMNS = 7 ; Blockly . FieldColour . prototype . setColours = function ( a , b ) { this . colours _ = a ; b && ( this . titles _ = b ) ; return this } ; Blockly . FieldColour . prototype . setColumns = function ( a ) { this . columns _ = a ; return this } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldColour . prototype . showEditor _ = function ( ) { this . dropdownCreate _ ( ) ; Blockly . DropDownDiv . getContentDiv ( ) . appendChild ( this . picker _ ) ; Blockly . DropDownDiv . showPositionedByField ( this , this . dropdownDispose _ . bind ( this ) ) ; this . picker _ . focus ( { preventScroll : ! 0 } ) } ; Blockly . FieldColour . prototype . onClick _ = function ( a ) { a = ( a = a . target ) && a . label ; null !== a && ( this . setValue ( a ) , Blockly . DropDownDiv . hideIfOwner ( this ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldColour . prototype . onKeyDown _ = function ( a ) { var b = ! 1 ; if ( a . keyCode === Blockly . utils . KeyCodes . UP ) this . moveHighlightBy _ ( 0 , - 1 ) , b = ! 0 ; else if ( a . keyCode === Blockly . utils . KeyCodes . DOWN ) this . moveHighlightBy _ ( 0 , 1 ) , b = ! 0 ; else if ( a . keyCode === Blockly . utils . KeyCodes . LEFT ) this . moveHighlightBy _ ( - 1 , 0 ) , b = ! 0 ; else if ( a . keyCode === Blockly . utils . KeyCodes . RIGHT ) this . moveHighlightBy _ ( 1 , 0 ) , b = ! 0 ; else if ( a . keyCode === Blockly . utils . KeyCodes . ENTER ) { if ( b = this . getHighlighted _ ( ) ) b = b && b . label , null !== b && this . setValue ( b ) ; Blockly . DropDownDiv . hideWithoutAnimation ( ) ;
b = ! 0 } b && a . stopPropagation ( ) } ;
Blockly . FieldColour . prototype . moveHighlightBy _ = function ( a , b ) { var c = this . colours _ || Blockly . FieldColour . COLOURS , d = this . columns _ || Blockly . FieldColour . COLUMNS , e = this . highlightedIndex _ % d , f = Math . floor ( this . highlightedIndex _ / d ) ; e += a ; f += b ; 0 > a ? 0 > e && 0 < f ? ( e = d - 1 , f -- ) : 0 > e && ( e = 0 ) : 0 < a ? e > d - 1 && f < Math . floor ( c . length / d ) - 1 ? ( e = 0 , f ++ ) : e > d - 1 && e -- : 0 > b ? 0 > f && ( f = 0 ) : 0 < b && f > Math . floor ( c . length / d ) - 1 && ( f = Math . floor ( c . length / d ) - 1 ) ; this . setHighlightedCell _ ( this . picker _ . childNodes [ f ] . childNodes [ e ] , f * d + e ) } ;
Blockly . FieldColour . prototype . onMouseMove _ = function ( a ) { var b = ( a = a . target ) && Number ( a . getAttribute ( "data-index" ) ) ; null !== b && b !== this . highlightedIndex _ && this . setHighlightedCell _ ( a , b ) } ; Blockly . FieldColour . prototype . onMouseEnter _ = function ( ) { this . picker _ . focus ( { preventScroll : ! 0 } ) } ; Blockly . FieldColour . prototype . onMouseLeave _ = function ( ) { this . picker _ . blur ( ) ; var a = this . getHighlighted _ ( ) ; a && Blockly . utils . dom . removeClass ( a , "blocklyColourHighlighted" ) } ;
Blockly . FieldColour . prototype . getHighlighted _ = function ( ) { var a = this . columns _ || Blockly . FieldColour . COLUMNS , b = this . picker _ . childNodes [ Math . floor ( this . highlightedIndex _ / a ) ] ; return b ? b . childNodes [ this . highlightedIndex _ % a ] : null } ;
Blockly . FieldColour . prototype . setHighlightedCell _ = function ( a , b ) { var c = this . getHighlighted _ ( ) ; c && Blockly . utils . dom . removeClass ( c , "blocklyColourHighlighted" ) ; Blockly . utils . dom . addClass ( a , "blocklyColourHighlighted" ) ; this . highlightedIndex _ = b ; Blockly . utils . aria . setState ( this . picker _ , Blockly . utils . aria . State . ACTIVEDESCENDANT , a . getAttribute ( "id" ) ) } ;
Blockly . FieldColour . prototype . dropdownCreate _ = function ( ) { var a = this . columns _ || Blockly . FieldColour . COLUMNS , b = this . colours _ || Blockly . FieldColour . COLOURS , c = this . titles _ || Blockly . FieldColour . TITLES , d = this . getValue ( ) , e = document . createElement ( "table" ) ; e . className = "blocklyColourTable" ; e . tabIndex = 0 ; e . dir = "ltr" ; Blockly . utils . aria . setRole ( e , Blockly . utils . aria . Role . GRID ) ; Blockly . utils . aria . setState ( e , Blockly . utils . aria . State . EXPANDED , ! 0 ) ; Blockly . utils . aria . setState ( e , Blockly . utils . aria . State . ROWCOUNT , Math . floor ( b . length /
a ) ) ; Blockly . utils . aria . setState ( e , Blockly . utils . aria . State . COLCOUNT , a ) ; for ( var f , g = 0 ; g < b . length ; g ++ ) { 0 == g % a && ( f = document . createElement ( "tr" ) , Blockly . utils . aria . setRole ( f , Blockly . utils . aria . Role . ROW ) , e . appendChild ( f ) ) ; var h = document . createElement ( "td" ) ; f . appendChild ( h ) ; h . label = b [ g ] ; h . title = c [ g ] || b [ g ] ; h . id = Blockly . utils . IdGenerator . getNextUniqueId ( ) ; h . setAttribute ( "data-index" , g ) ; Blockly . utils . aria . setRole ( h , Blockly . utils . aria . Role . GRIDCELL ) ; Blockly . utils . aria . setState ( h , Blockly . utils . aria . State . LABEL ,
2021-05-19 13:38:55 +00:00
b [ g ] ) ; Blockly . utils . aria . setState ( h , Blockly . utils . aria . State . SELECTED , b [ g ] == d ) ; h . style . backgroundColor = b [ g ] ; b [ g ] == d && ( h . className = "blocklyColourSelected" , this . highlightedIndex _ = g ) } this . onClickWrapper _ = Blockly . browserEvents . conditionalBind ( e , "click" , this , this . onClick _ , ! 0 ) ; this . onMouseMoveWrapper _ = Blockly . browserEvents . conditionalBind ( e , "mousemove" , this , this . onMouseMove _ , ! 0 ) ; this . onMouseEnterWrapper _ = Blockly . browserEvents . conditionalBind ( e , "mouseenter" , this , this . onMouseEnter _ , ! 0 ) ; this . onMouseLeaveWrapper _ =
2021-09-18 14:29:06 +00:00
Blockly . browserEvents . conditionalBind ( e , "mouseleave" , this , this . onMouseLeave _ , ! 0 ) ; this . onKeyDownWrapper _ = Blockly . browserEvents . conditionalBind ( e , "keydown" , this , this . onKeyDown _ ) ; this . picker _ = e } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldColour . prototype . dropdownDispose _ = function ( ) { this . onClickWrapper _ && ( Blockly . browserEvents . unbind ( this . onClickWrapper _ ) , this . onClickWrapper _ = null ) ; this . onMouseMoveWrapper _ && ( Blockly . browserEvents . unbind ( this . onMouseMoveWrapper _ ) , this . onMouseMoveWrapper _ = null ) ; this . onMouseEnterWrapper _ && ( Blockly . browserEvents . unbind ( this . onMouseEnterWrapper _ ) , this . onMouseEnterWrapper _ = null ) ; this . onMouseLeaveWrapper _ && ( Blockly . browserEvents . unbind ( this . onMouseLeaveWrapper _ ) , this . onMouseLeaveWrapper _ = null ) ;
this . onKeyDownWrapper _ && ( Blockly . browserEvents . unbind ( this . onKeyDownWrapper _ ) , this . onKeyDownWrapper _ = null ) ; this . highlightedIndex _ = this . picker _ = null } ;
2021-01-16 14:07:51 +00:00
Blockly . Css . register ( [ ".blocklyColourTable {" , "border-collapse: collapse;" , "display: block;" , "outline: none;" , "padding: 1px;" , "}" , ".blocklyColourTable>tr>td {" , "border: .5px solid #888;" , "box-sizing: border-box;" , "cursor: pointer;" , "display: inline-block;" , "height: 20px;" , "padding: 0;" , "width: 20px;" , "}" , ".blocklyColourTable>tr>td.blocklyColourHighlighted {" , "border-color: #eee;" , "box-shadow: 2px 2px 7px 2px rgba(0,0,0,.3);" , "position: relative;" , "}" , ".blocklyColourSelected, .blocklyColourSelected:hover {" ,
"border-color: #eee !important;" , "outline: 1px solid #333;" , "position: relative;" , "}" ] ) ; Blockly . fieldRegistry . register ( "field_colour" , Blockly . FieldColour ) ; Blockly . FieldDropdown = function ( a , b , c ) { "function" != typeof a && Blockly . FieldDropdown . validateOptions _ ( a ) ; this . menuGenerator _ = a ; this . suffixField = this . prefixField = this . generatedOptions _ = null ; this . trimOptions _ ( ) ; this . selectedOption _ = this . getOptions ( ! 1 ) [ 0 ] ; Blockly . FieldDropdown . superClass _ . constructor . call ( this , this . selectedOption _ [ 1 ] , b , c ) ; this . svgArrow _ = this . arrow _ = this . imageElement _ = this . menu _ = this . selectedMenuItem _ = null } ; Blockly . utils . object . inherits ( Blockly . FieldDropdown , Blockly . Field ) ;
2021-05-19 13:38:55 +00:00
Blockly . FieldDropdown . fromJson = function ( a ) { return new Blockly . FieldDropdown ( a . options , void 0 , a ) } ; Blockly . FieldDropdown . prototype . fromXml = function ( a ) { this . isOptionListDynamic ( ) && this . getOptions ( ! 1 ) ; this . setValue ( a . textContent ) } ; Blockly . FieldDropdown . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldDropdown . CHECKMARK _OVERHANG = 25 ; Blockly . FieldDropdown . MAX _MENU _HEIGHT _VH = . 45 ; Blockly . FieldDropdown . IMAGE _Y _OFFSET = 5 ; Blockly . FieldDropdown . IMAGE _Y _PADDING = 2 * Blockly . FieldDropdown . IMAGE _Y _OFFSET ;
Blockly . FieldDropdown . ARROW _CHAR = Blockly . utils . userAgent . ANDROID ? "\u25bc" : "\u25be" ; Blockly . FieldDropdown . prototype . CURSOR = "default" ;
2021-01-16 14:07:51 +00:00
Blockly . FieldDropdown . prototype . initView = function ( ) { this . shouldAddBorderRect _ ( ) ? this . createBorderRect _ ( ) : this . clickTarget _ = this . sourceBlock _ . getSvgRoot ( ) ; this . createTextElement _ ( ) ; this . imageElement _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { } , this . fieldGroup _ ) ; this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW ? this . createSVGArrow _ ( ) : this . createTextArrow _ ( ) ; this . borderRect _ && Blockly . utils . dom . addClass ( this . borderRect _ , "blocklyDropdownRect" ) } ;
Blockly . FieldDropdown . prototype . shouldAddBorderRect _ = function ( ) { return ! this . getConstants ( ) . FIELD _DROPDOWN _NO _BORDER _RECT _SHADOW || this . getConstants ( ) . FIELD _DROPDOWN _NO _BORDER _RECT _SHADOW && ! this . sourceBlock _ . isShadow ( ) } ;
Blockly . FieldDropdown . prototype . createTextArrow _ = function ( ) { this . arrow _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TSPAN , { } , this . textElement _ ) ; this . arrow _ . appendChild ( document . createTextNode ( this . sourceBlock _ . RTL ? Blockly . FieldDropdown . ARROW _CHAR + " " : " " + Blockly . FieldDropdown . ARROW _CHAR ) ) ; this . sourceBlock _ . RTL ? this . textElement _ . insertBefore ( this . arrow _ , this . textContent _ ) : this . textElement _ . appendChild ( this . arrow _ ) } ;
Blockly . FieldDropdown . prototype . createSVGArrow _ = function ( ) { this . svgArrow _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { height : this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _SIZE + "px" , width : this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _SIZE + "px" } , this . fieldGroup _ ) ; this . svgArrow _ . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _DATAURI ) } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldDropdown . prototype . showEditor _ = function ( a ) { this . dropdownCreate _ ( ) ; this . menu _ . openingCoords = a && "number" === typeof a . clientX ? new Blockly . utils . Coordinate ( a . clientX , a . clientY ) : null ; this . menu _ . render ( Blockly . DropDownDiv . getContentDiv ( ) ) ; a = this . menu _ . getElement ( ) ; Blockly . utils . dom . addClass ( a , "blocklyDropdownMenu" ) ; if ( this . getConstants ( ) . FIELD _DROPDOWN _COLOURED _DIV ) { a = this . sourceBlock _ . isShadow ( ) ? this . sourceBlock _ . getParent ( ) . getColour ( ) : this . sourceBlock _ . getColour ( ) ; var b = this . sourceBlock _ . isShadow ( ) ?
2021-01-16 14:07:51 +00:00
this . sourceBlock _ . getParent ( ) . style . colourTertiary : this . sourceBlock _ . style . colourTertiary ; Blockly . DropDownDiv . setColour ( a , b ) } Blockly . DropDownDiv . showPositionedByField ( this , this . dropdownDispose _ . bind ( this ) ) ; this . menu _ . focus ( ) ; this . selectedMenuItem _ && this . menu _ . setHighlighted ( this . selectedMenuItem _ ) ; this . applyColour ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldDropdown . prototype . dropdownCreate _ = function ( ) { var a = new Blockly . Menu ; a . setRole ( Blockly . utils . aria . Role . LISTBOX ) ; this . menu _ = a ; var b = this . getOptions ( ! 1 ) ; this . selectedMenuItem _ = null ; for ( var c = 0 ; c < b . length ; c ++ ) { var d = b [ c ] [ 0 ] , e = b [ c ] [ 1 ] ; if ( "object" == typeof d ) { var f = new Image ( d . width , d . height ) ; f . src = d . src ; f . alt = d . alt || "" ; d = f } d = new Blockly . MenuItem ( d , e ) ; d . setRole ( Blockly . utils . aria . Role . OPTION ) ; d . setRightToLeft ( this . sourceBlock _ . RTL ) ; d . setCheckable ( ! 0 ) ; a . addChild ( d ) ; d . setChecked ( e == this . value _ ) ;
e == this . value _ && ( this . selectedMenuItem _ = d ) ; d . onAction ( this . handleMenuActionEvent _ , this ) } } ; Blockly . FieldDropdown . prototype . dropdownDispose _ = function ( ) { this . menu _ && this . menu _ . dispose ( ) ; this . selectedMenuItem _ = this . menu _ = null ; this . applyColour ( ) } ; Blockly . FieldDropdown . prototype . handleMenuActionEvent _ = function ( a ) { Blockly . DropDownDiv . hideIfOwner ( this , ! 0 ) ; this . onItemSelected _ ( this . menu _ , a ) } ; Blockly . FieldDropdown . prototype . onItemSelected _ = function ( a , b ) { this . setValue ( b . getValue ( ) ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldDropdown . prototype . trimOptions _ = function ( ) { var a = this . menuGenerator _ ; if ( Array . isArray ( a ) ) { for ( var b = ! 1 , c = 0 ; c < a . length ; c ++ ) { var d = a [ c ] [ 0 ] ; "string" == typeof d ? a [ c ] [ 0 ] = Blockly . utils . replaceMessageReferences ( d ) : ( null != d . alt && ( a [ c ] [ 0 ] . alt = Blockly . utils . replaceMessageReferences ( d . alt ) ) , b = ! 0 ) } if ( ! ( b || 2 > a . length ) ) { b = [ ] ; for ( c = 0 ; c < a . length ; c ++ ) b . push ( a [ c ] [ 0 ] ) ; c = Blockly . utils . string . shortestStringLength ( b ) ; d = Blockly . utils . string . commonWordPrefix ( b , c ) ; var e = Blockly . utils . string . commonWordSuffix ( b ,
c ) ; ! d && ! e || c <= d + e || ( d && ( this . prefixField = b [ 0 ] . substring ( 0 , d - 1 ) ) , e && ( this . suffixField = b [ 0 ] . substr ( 1 - e ) ) , this . menuGenerator _ = Blockly . FieldDropdown . applyTrim _ ( a , d , e ) ) } } } ; Blockly . FieldDropdown . applyTrim _ = function ( a , b , c ) { for ( var d = [ ] , e = 0 ; e < a . length ; e ++ ) { var f = a [ e ] [ 0 ] , g = a [ e ] [ 1 ] ; f = f . substring ( b , f . length - c ) ; d [ e ] = [ f , g ] } return d } ; Blockly . FieldDropdown . prototype . isOptionListDynamic = function ( ) { return "function" == typeof this . menuGenerator _ } ;
Blockly . FieldDropdown . prototype . getOptions = function ( a ) { return this . isOptionListDynamic ( ) ? ( this . generatedOptions _ && a || ( this . generatedOptions _ = this . menuGenerator _ . call ( this ) , Blockly . FieldDropdown . validateOptions _ ( this . generatedOptions _ ) ) , this . generatedOptions _ ) : this . menuGenerator _ } ;
Blockly . FieldDropdown . prototype . doClassValidation _ = function ( a ) { for ( var b = ! 1 , c = this . getOptions ( ! 0 ) , d = 0 , e ; e = c [ d ] ; d ++ ) if ( e [ 1 ] == a ) { b = ! 0 ; break } return b ? a : ( this . sourceBlock _ && console . warn ( "Cannot set the dropdown's value to an unavailable option. Block type: " + this . sourceBlock _ . type + ", Field name: " + this . name + ", Value: " + a ) , null ) } ;
Blockly . FieldDropdown . prototype . doValueUpdate _ = function ( a ) { Blockly . FieldDropdown . superClass _ . doValueUpdate _ . call ( this , a ) ; a = this . getOptions ( ! 0 ) ; for ( var b = 0 , c ; c = a [ b ] ; b ++ ) c [ 1 ] == this . value _ && ( this . selectedOption _ = c ) } ;
Blockly . FieldDropdown . prototype . applyColour = function ( ) { this . borderRect _ && ( this . borderRect _ . setAttribute ( "stroke" , this . sourceBlock _ . style . colourTertiary ) , this . menu _ ? this . borderRect _ . setAttribute ( "fill" , this . sourceBlock _ . style . colourTertiary ) : this . borderRect _ . setAttribute ( "fill" , "transparent" ) ) ; this . sourceBlock _ && this . arrow _ && ( this . sourceBlock _ . isShadow ( ) ? this . arrow _ . style . fill = this . sourceBlock _ . style . colourSecondary : this . arrow _ . style . fill = this . sourceBlock _ . style . colourPrimary ) } ;
Blockly . FieldDropdown . prototype . render _ = function ( ) { this . textContent _ . nodeValue = "" ; this . imageElement _ . style . display = "none" ; var a = this . selectedOption _ && this . selectedOption _ [ 0 ] ; a && "object" == typeof a ? this . renderSelectedImage _ ( a ) : this . renderSelectedText _ ( ) ; this . positionBorderRect _ ( ) } ;
Blockly . FieldDropdown . prototype . renderSelectedImage _ = function ( a ) { this . imageElement _ . style . display = "" ; this . imageElement _ . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , a . src ) ; this . imageElement _ . setAttribute ( "height" , a . height ) ; this . imageElement _ . setAttribute ( "width" , a . width ) ; var b = Number ( a . height ) ; a = Number ( a . width ) ; var c = ! ! this . borderRect _ , d = Math . max ( c ? this . getConstants ( ) . FIELD _DROPDOWN _BORDER _RECT _HEIGHT : 0 , b + Blockly . FieldDropdown . IMAGE _Y _PADDING ) ; c = c ? this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING :
0 ; var e = this . svgArrow _ ? this . positionSVGArrow _ ( a + c , d / 2 - this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _SIZE / 2 ) : Blockly . utils . dom . getFastTextWidth ( this . arrow _ , this . getConstants ( ) . FIELD _TEXT _FONTSIZE , this . getConstants ( ) . FIELD _TEXT _FONTWEIGHT , this . getConstants ( ) . FIELD _TEXT _FONTFAMILY ) ; this . size _ . width = a + e + 2 * c ; this . size _ . height = d ; var f = 0 ; this . sourceBlock _ . RTL ? this . imageElement _ . setAttribute ( "x" , c + e ) : ( f = a + e , this . textElement _ . setAttribute ( "text-anchor" , "end" ) , this . imageElement _ . setAttribute ( "x" , c ) ) ; this . imageElement _ . setAttribute ( "y" ,
d / 2 - b / 2 ) ; this . positionTextElement _ ( f + c , a + e ) } ;
Blockly . FieldDropdown . prototype . renderSelectedText _ = function ( ) { this . textContent _ . nodeValue = this . getDisplayText _ ( ) ; Blockly . utils . dom . addClass ( this . textElement _ , "blocklyDropdownText" ) ; this . textElement _ . setAttribute ( "text-anchor" , "start" ) ; var a = ! ! this . borderRect _ , b = Math . max ( a ? this . getConstants ( ) . FIELD _DROPDOWN _BORDER _RECT _HEIGHT : 0 , this . getConstants ( ) . FIELD _TEXT _HEIGHT ) , c = Blockly . utils . dom . getFastTextWidth ( this . textElement _ , this . getConstants ( ) . FIELD _TEXT _FONTSIZE , this . getConstants ( ) . FIELD _TEXT _FONTWEIGHT ,
this . getConstants ( ) . FIELD _TEXT _FONTFAMILY ) ; a = a ? this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING : 0 ; var d = 0 ; this . svgArrow _ && ( d = this . positionSVGArrow _ ( c + a , b / 2 - this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _SIZE / 2 ) ) ; this . size _ . width = c + d + 2 * a ; this . size _ . height = b ; this . positionTextElement _ ( a , c ) } ;
Blockly . FieldDropdown . prototype . positionSVGArrow _ = function ( a , b ) { if ( ! this . svgArrow _ ) return 0 ; var c = this . borderRect _ ? this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING : 0 , d = this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _PADDING , e = this . getConstants ( ) . FIELD _DROPDOWN _SVG _ARROW _SIZE ; this . svgArrow _ . setAttribute ( "transform" , "translate(" + ( this . sourceBlock _ . RTL ? c : a + d ) + "," + b + ")" ) ; return e + d } ;
Blockly . FieldDropdown . prototype . getText _ = function ( ) { if ( ! this . selectedOption _ ) return null ; var a = this . selectedOption _ [ 0 ] ; return "object" == typeof a ? a . alt : a } ;
Blockly . FieldDropdown . validateOptions _ = function ( a ) { if ( ! Array . isArray ( a ) ) throw TypeError ( "FieldDropdown options must be an array." ) ; if ( ! a . length ) throw TypeError ( "FieldDropdown options must not be an empty array." ) ; for ( var b = ! 1 , c = 0 ; c < a . length ; ++ c ) { var d = a [ c ] ; Array . isArray ( d ) ? "string" != typeof d [ 1 ] ? ( b = ! 0 , console . error ( "Invalid option[" + c + "]: Each FieldDropdown option id must be a string. Found " + d [ 1 ] + " in: " , d ) ) : d [ 0 ] && "string" != typeof d [ 0 ] && "string" != typeof d [ 0 ] . src && ( b = ! 0 , console . error ( "Invalid option[" +
2021-05-19 13:38:55 +00:00
c + "]: Each FieldDropdown option must have a string label or image description. Found" + d [ 0 ] + " in: " , d ) ) : ( b = ! 0 , console . error ( "Invalid option[" + c + "]: Each FieldDropdown option must be an array. Found: " , d ) ) } if ( b ) throw TypeError ( "Found invalid FieldDropdown options." ) ; } ; Blockly . fieldRegistry . register ( "field_dropdown" , Blockly . FieldDropdown ) ; Blockly . FieldLabelSerializable = function ( a , b , c ) { Blockly . FieldLabelSerializable . superClass _ . constructor . call ( this , a , b , c ) } ; Blockly . utils . object . inherits ( Blockly . FieldLabelSerializable , Blockly . FieldLabel ) ; Blockly . FieldLabelSerializable . fromJson = function ( a ) { var b = Blockly . utils . replaceMessageReferences ( a . text ) ; return new Blockly . FieldLabelSerializable ( b , void 0 , a ) } ; Blockly . FieldLabelSerializable . prototype . EDITABLE = ! 1 ; Blockly . FieldLabelSerializable . prototype . SERIALIZABLE = ! 0 ;
2021-01-16 14:07:51 +00:00
Blockly . fieldRegistry . register ( "field_label_serializable" , Blockly . FieldLabelSerializable ) ; Blockly . FieldImage = function ( a , b , c , d , e , f , g ) { if ( ! a ) throw Error ( "Src value of an image field is required" ) ; a = Blockly . utils . replaceMessageReferences ( a ) ; c = Number ( Blockly . utils . replaceMessageReferences ( c ) ) ; b = Number ( Blockly . utils . replaceMessageReferences ( b ) ) ; if ( isNaN ( c ) || isNaN ( b ) ) throw Error ( "Height and width values of an image field must cast to numbers." ) ; if ( 0 >= c || 0 >= b ) throw Error ( "Height and width values of an image field must be greater than 0." ) ; this . flipRtl _ = ! 1 ; this . altText _ = "" ; Blockly . FieldImage . superClass _ . constructor . call ( this ,
a , null , g ) ; g || ( this . flipRtl _ = ! ! f , this . altText _ = Blockly . utils . replaceMessageReferences ( d ) || "" ) ; this . size _ = new Blockly . utils . Size ( b , c + Blockly . FieldImage . Y _PADDING ) ; this . imageHeight _ = c ; this . clickHandler _ = null ; "function" == typeof e && ( this . clickHandler _ = e ) ; this . imageElement _ = null } ; Blockly . utils . object . inherits ( Blockly . FieldImage , Blockly . Field ) ; Blockly . FieldImage . prototype . DEFAULT _VALUE = "" ; Blockly . FieldImage . fromJson = function ( a ) { return new Blockly . FieldImage ( a . src , a . width , a . height , void 0 , void 0 , void 0 , a ) } ;
Blockly . FieldImage . Y _PADDING = 1 ; Blockly . FieldImage . prototype . EDITABLE = ! 1 ; Blockly . FieldImage . prototype . isDirty _ = ! 1 ; Blockly . FieldImage . prototype . configure _ = function ( a ) { Blockly . FieldImage . superClass _ . configure _ . call ( this , a ) ; this . flipRtl _ = ! ! a . flipRtl ; this . altText _ = Blockly . utils . replaceMessageReferences ( a . alt ) || "" } ;
Blockly . FieldImage . prototype . initView = function ( ) { this . imageElement _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . IMAGE , { height : this . imageHeight _ + "px" , width : this . size _ . width + "px" , alt : this . altText _ } , this . fieldGroup _ ) ; this . imageElement _ . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , this . value _ ) ; this . clickHandler _ && ( this . imageElement _ . style . cursor = "pointer" ) } ; Blockly . FieldImage . prototype . updateSize _ = function ( ) { } ;
Blockly . FieldImage . prototype . doClassValidation _ = function ( a ) { return "string" != typeof a ? null : a } ; Blockly . FieldImage . prototype . doValueUpdate _ = function ( a ) { this . value _ = a ; this . imageElement _ && this . imageElement _ . setAttributeNS ( Blockly . utils . dom . XLINK _NS , "xlink:href" , String ( this . value _ ) ) } ; Blockly . FieldImage . prototype . getFlipRtl = function ( ) { return this . flipRtl _ } ; Blockly . FieldImage . prototype . setAlt = function ( a ) { a != this . altText _ && ( this . altText _ = a || "" , this . imageElement _ && this . imageElement _ . setAttribute ( "alt" , this . altText _ ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldImage . prototype . showEditor _ = function ( ) { this . clickHandler _ && this . clickHandler _ ( this ) } ; Blockly . FieldImage . prototype . setOnClickHandler = function ( a ) { this . clickHandler _ = a } ; Blockly . FieldImage . prototype . getText _ = function ( ) { return this . altText _ } ; Blockly . fieldRegistry . register ( "field_image" , Blockly . FieldImage ) ; Blockly . FieldMultilineInput = function ( a , b , c ) { Blockly . FieldMultilineInput . superClass _ . constructor . call ( this , a , b , c ) ; this . textGroup _ = null ; this . maxLines _ = Infinity ; this . isOverflowedY _ = ! 1 } ; Blockly . utils . object . inherits ( Blockly . FieldMultilineInput , Blockly . FieldTextInput ) ; Blockly . FieldMultilineInput . prototype . configure _ = function ( a ) { Blockly . FieldMultilineInput . superClass _ . configure _ . call ( this , a ) ; a . maxLines && this . setMaxLines ( a . maxLines ) } ;
Blockly . FieldMultilineInput . fromJson = function ( a ) { var b = Blockly . utils . replaceMessageReferences ( a . text ) ; return new Blockly . FieldMultilineInput ( b , void 0 , a ) } ; Blockly . FieldMultilineInput . prototype . toXml = function ( a ) { a . textContent = this . getValue ( ) . replace ( /\n/g , " " ) ; return a } ; Blockly . FieldMultilineInput . prototype . fromXml = function ( a ) { this . setValue ( a . textContent . replace ( / /g , "\n" ) ) } ;
Blockly . FieldMultilineInput . prototype . initView = function ( ) { this . createBorderRect _ ( ) ; this . textGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : "blocklyEditableText" } , this . fieldGroup _ ) } ;
Blockly . FieldMultilineInput . prototype . getDisplayText _ = function ( ) { var a = this . getText ( ) ; if ( ! a ) return Blockly . Field . NBSP ; var b = a . split ( "\n" ) ; a = "" ; for ( var c = this . isOverflowedY _ ? this . maxLines _ : b . length , d = 0 ; d < c ; d ++ ) { var e = b [ d ] ; e . length > this . maxDisplayLength ? e = e . substring ( 0 , this . maxDisplayLength - 4 ) + "..." : this . isOverflowedY _ && d === c - 1 && ( e = e . substring ( 0 , e . length - 3 ) + "..." ) ; e = e . replace ( /\s/g , Blockly . Field . NBSP ) ; a += e ; d !== c - 1 && ( a += "\n" ) } this . sourceBlock _ . RTL && ( a += "\u200f" ) ; return a } ;
Blockly . FieldMultilineInput . prototype . doValueUpdate _ = function ( a ) { Blockly . FieldMultilineInput . superClass _ . doValueUpdate _ . call ( this , a ) ; this . isOverflowedY _ = this . value _ . split ( "\n" ) . length > this . maxLines _ } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldMultilineInput . prototype . render _ = function ( ) { for ( var a ; a = this . textGroup _ . firstChild ; ) this . textGroup _ . removeChild ( a ) ; a = this . getDisplayText _ ( ) . split ( "\n" ) ; for ( var b = 0 , c = 0 ; c < a . length ; c ++ ) { var d = this . getConstants ( ) . FIELD _TEXT _HEIGHT + this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TEXT , { "class" : "blocklyText blocklyMultilineText" , x : this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING , y : b + this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING , dy : this . getConstants ( ) . FIELD _TEXT _BASELINE } ,
2021-05-19 13:38:55 +00:00
this . textGroup _ ) . appendChild ( document . createTextNode ( a [ c ] ) ) ; b += d } this . isBeingEdited _ && ( a = this . htmlInput _ , this . isOverflowedY _ ? Blockly . utils . dom . addClass ( a , "blocklyHtmlTextAreaInputOverflowedY" ) : Blockly . utils . dom . removeClass ( a , "blocklyHtmlTextAreaInputOverflowedY" ) ) ; this . updateSize _ ( ) ; this . isBeingEdited _ && ( this . sourceBlock _ . RTL ? setTimeout ( this . resizeEditor _ . bind ( this ) , 0 ) : this . resizeEditor _ ( ) , a = this . htmlInput _ , this . isTextValid _ ? ( Blockly . utils . dom . removeClass ( a , "blocklyInvalidInput" ) , Blockly . utils . aria . setState ( a ,
Blockly . utils . aria . State . INVALID , ! 1 ) ) : ( Blockly . utils . dom . addClass ( a , "blocklyInvalidInput" ) , Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . INVALID , ! 0 ) ) ) } ;
Blockly . FieldMultilineInput . prototype . updateSize _ = function ( ) { for ( var a = this . textGroup _ . childNodes , b = 0 , c = 0 , d = 0 ; d < a . length ; d ++ ) { var e = Blockly . utils . dom . getTextWidth ( a [ d ] ) ; e > b && ( b = e ) ; c += this . getConstants ( ) . FIELD _TEXT _HEIGHT + ( 0 < d ? this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING : 0 ) } if ( this . isBeingEdited _ ) { a = this . value _ . split ( "\n" ) ; e = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . TEXT , { "class" : "blocklyText blocklyMultilineText" } ) ; var f = this . getConstants ( ) . FIELD _TEXT _FONTSIZE , g = this . getConstants ( ) . FIELD _TEXT _FONTWEIGHT ,
h = this . getConstants ( ) . FIELD _TEXT _FONTFAMILY ; for ( d = 0 ; d < a . length ; d ++ ) { a [ d ] . length > this . maxDisplayLength && ( a [ d ] = a [ d ] . substring ( 0 , this . maxDisplayLength ) ) ; e . textContent = a [ d ] ; var k = Blockly . utils . dom . getFastTextWidth ( e , f , g , h ) ; k > b && ( b = k ) } b += this . htmlInput _ . offsetWidth - this . htmlInput _ . clientWidth } this . borderRect _ && ( c += 2 * this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING , b += 2 * this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING , this . borderRect _ . setAttribute ( "width" , b ) , this . borderRect _ . setAttribute ( "height" , c ) ) ; this . size _ . width =
b ; this . size _ . height = c ; this . positionBorderRect _ ( ) } ; Blockly . FieldMultilineInput . prototype . showEditor _ = function ( a , b ) { Blockly . FieldMultilineInput . superClass _ . showEditor _ . call ( this , a , b ) ; this . forceRerender ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldMultilineInput . prototype . widgetCreate _ = function ( ) { var a = Blockly . WidgetDiv . DIV , b = this . workspace _ . getScale ( ) , c = document . createElement ( "textarea" ) ; c . className = "blocklyHtmlInput blocklyHtmlTextAreaInput" ; c . setAttribute ( "spellcheck" , this . spellcheck _ ) ; var d = this . getConstants ( ) . FIELD _TEXT _FONTSIZE * b + "pt" ; a . style . fontSize = d ; c . style . fontSize = d ; c . style . borderRadius = Blockly . FieldTextInput . BORDERRADIUS * b + "px" ; d = this . getConstants ( ) . FIELD _BORDER _RECT _X _PADDING * b ; var e = this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING *
b / 2 ; c . style . padding = e + "px " + d + "px " + e + "px " + d + "px" ; d = this . getConstants ( ) . FIELD _TEXT _HEIGHT + this . getConstants ( ) . FIELD _BORDER _RECT _Y _PADDING ; c . style . lineHeight = d * b + "px" ; a . appendChild ( c ) ; c . value = c . defaultValue = this . getEditorText _ ( this . value _ ) ; c . untypedDefaultValue _ = this . value _ ; c . oldValue _ = null ; Blockly . utils . userAgent . GECKO ? setTimeout ( this . resizeEditor _ . bind ( this ) , 0 ) : this . resizeEditor _ ( ) ; this . bindInputEvents _ ( c ) ; return c } ;
2021-05-19 13:38:55 +00:00
Blockly . FieldMultilineInput . prototype . setMaxLines = function ( a ) { "number" === typeof a && 0 < a && a !== this . maxLines _ && ( this . maxLines _ = a , this . forceRerender ( ) ) } ; Blockly . FieldMultilineInput . prototype . getMaxLines = function ( ) { return this . maxLines _ } ; Blockly . FieldMultilineInput . prototype . onHtmlInputKeyDown _ = function ( a ) { a . keyCode !== Blockly . utils . KeyCodes . ENTER && Blockly . FieldMultilineInput . superClass _ . onHtmlInputKeyDown _ . call ( this , a ) } ; Blockly . Css . register ( ".blocklyHtmlTextAreaInput {,font-family: monospace;,resize: none;,overflow: hidden;,height: 100%;,text-align: left;,},.blocklyHtmlTextAreaInputOverflowedY {,overflow-y: scroll;,}" . split ( "," ) ) ;
Blockly . fieldRegistry . register ( "field_multilinetext" , Blockly . FieldMultilineInput ) ; Blockly . FieldNumber = function ( a , b , c , d , e , f ) { this . min _ = - Infinity ; this . max _ = Infinity ; this . precision _ = 0 ; this . decimalPlaces _ = null ; Blockly . FieldNumber . superClass _ . constructor . call ( this , a , e , f ) ; f || this . setConstraints ( b , c , d ) } ; Blockly . utils . object . inherits ( Blockly . FieldNumber , Blockly . FieldTextInput ) ; Blockly . FieldNumber . prototype . DEFAULT _VALUE = 0 ; Blockly . FieldNumber . fromJson = function ( a ) { return new Blockly . FieldNumber ( a . value , void 0 , void 0 , void 0 , void 0 , a ) } ; Blockly . FieldNumber . prototype . SERIALIZABLE = ! 0 ;
2021-01-16 14:07:51 +00:00
Blockly . FieldNumber . prototype . configure _ = function ( a ) { Blockly . FieldNumber . superClass _ . configure _ . call ( this , a ) ; this . setMinInternal _ ( a . min ) ; this . setMaxInternal _ ( a . max ) ; this . setPrecisionInternal _ ( a . precision ) } ; Blockly . FieldNumber . prototype . setConstraints = function ( a , b , c ) { this . setMinInternal _ ( a ) ; this . setMaxInternal _ ( b ) ; this . setPrecisionInternal _ ( c ) ; this . setValue ( this . getValue ( ) ) } ; Blockly . FieldNumber . prototype . setMin = function ( a ) { this . setMinInternal _ ( a ) ; this . setValue ( this . getValue ( ) ) } ;
Blockly . FieldNumber . prototype . setMinInternal _ = function ( a ) { null == a ? this . min _ = - Infinity : ( a = Number ( a ) , isNaN ( a ) || ( this . min _ = a ) ) } ; Blockly . FieldNumber . prototype . getMin = function ( ) { return this . min _ } ; Blockly . FieldNumber . prototype . setMax = function ( a ) { this . setMaxInternal _ ( a ) ; this . setValue ( this . getValue ( ) ) } ; Blockly . FieldNumber . prototype . setMaxInternal _ = function ( a ) { null == a ? this . max _ = Infinity : ( a = Number ( a ) , isNaN ( a ) || ( this . max _ = a ) ) } ; Blockly . FieldNumber . prototype . getMax = function ( ) { return this . max _ } ;
2021-09-18 14:29:06 +00:00
Blockly . FieldNumber . prototype . setPrecision = function ( a ) { this . setPrecisionInternal _ ( a ) ; this . setValue ( this . getValue ( ) ) } ; Blockly . FieldNumber . prototype . setPrecisionInternal _ = function ( a ) { this . precision _ = Number ( a ) || 0 ; var b = String ( this . precision _ ) ; - 1 != b . indexOf ( "e" ) && ( b = this . precision _ . toLocaleString ( "en-US" , { maximumFractionDigits : 20 } ) ) ; var c = b . indexOf ( "." ) ; this . decimalPlaces _ = - 1 == c ? a ? 0 : null : b . length - c - 1 } ; Blockly . FieldNumber . prototype . getPrecision = function ( ) { return this . precision _ } ;
2021-01-16 14:07:51 +00:00
Blockly . FieldNumber . prototype . doClassValidation _ = function ( a ) { if ( null === a ) return null ; a = String ( a ) ; a = a . replace ( /O/ig , "0" ) ; a = a . replace ( /,/g , "" ) ; a = a . replace ( /infinity/i , "Infinity" ) ; a = Number ( a || 0 ) ; if ( isNaN ( a ) ) return null ; a = Math . min ( Math . max ( a , this . min _ ) , this . max _ ) ; this . precision _ && isFinite ( a ) && ( a = Math . round ( a / this . precision _ ) * this . precision _ ) ; null != this . decimalPlaces _ && ( a = Number ( a . toFixed ( this . decimalPlaces _ ) ) ) ; return a } ;
Blockly . FieldNumber . prototype . widgetCreate _ = function ( ) { var a = Blockly . FieldNumber . superClass _ . widgetCreate _ . call ( this ) ; - Infinity < this . min _ && Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . VALUEMIN , this . min _ ) ; Infinity > this . max _ && Blockly . utils . aria . setState ( a , Blockly . utils . aria . State . VALUEMAX , this . max _ ) ; return a } ; Blockly . fieldRegistry . register ( "field_number" , Blockly . FieldNumber ) ; Blockly . FieldVariable = function ( a , b , c , d , e ) { this . menuGenerator _ = Blockly . FieldVariable . dropdownCreate ; this . defaultVariableName = "string" === typeof a ? a : "" ; this . size _ = new Blockly . utils . Size ( 0 , 0 ) ; e && this . configure _ ( e ) ; b && this . setValidator ( b ) ; e || this . setTypes _ ( c , d ) } ; Blockly . utils . object . inherits ( Blockly . FieldVariable , Blockly . FieldDropdown ) ; Blockly . FieldVariable . fromJson = function ( a ) { var b = Blockly . utils . replaceMessageReferences ( a . variable ) ; return new Blockly . FieldVariable ( b , void 0 , void 0 , void 0 , a ) } ;
Blockly . FieldVariable . prototype . SERIALIZABLE = ! 0 ; Blockly . FieldVariable . prototype . configure _ = function ( a ) { Blockly . FieldVariable . superClass _ . configure _ . call ( this , a ) ; this . setTypes _ ( a . variableTypes , a . defaultType ) } ; Blockly . FieldVariable . prototype . initModel = function ( ) { if ( ! this . variable _ ) { var a = Blockly . Variables . getOrCreateVariablePackage ( this . sourceBlock _ . workspace , null , this . defaultVariableName , this . defaultType _ ) ; this . doValueUpdate _ ( a . getId ( ) ) } } ;
Blockly . FieldVariable . prototype . shouldAddBorderRect _ = function ( ) { return Blockly . FieldVariable . superClass _ . shouldAddBorderRect _ . call ( this ) && ( ! this . getConstants ( ) . FIELD _DROPDOWN _NO _BORDER _RECT _SHADOW || "variables_get" != this . sourceBlock _ . type ) } ;
Blockly . FieldVariable . prototype . fromXml = function ( a ) { var b = a . getAttribute ( "id" ) , c = a . textContent , d = a . getAttribute ( "variabletype" ) || a . getAttribute ( "variableType" ) || "" ; b = Blockly . Variables . getOrCreateVariablePackage ( this . sourceBlock _ . workspace , b , c , d ) ; if ( null != d && d !== b . type ) throw Error ( "Serialized variable type with id '" + b . getId ( ) + "' had type " + b . type + ", and does not match variable field that references it: " + Blockly . Xml . domToText ( a ) + "." ) ; this . setValue ( b . getId ( ) ) } ;
Blockly . FieldVariable . prototype . toXml = function ( a ) { this . initModel ( ) ; a . id = this . variable _ . getId ( ) ; a . textContent = this . variable _ . name ; this . variable _ . type && a . setAttribute ( "variabletype" , this . variable _ . type ) ; return a } ; Blockly . FieldVariable . prototype . setSourceBlock = function ( a ) { if ( a . isShadow ( ) ) throw Error ( "Variable fields are not allowed to exist on shadow blocks." ) ; Blockly . FieldVariable . superClass _ . setSourceBlock . call ( this , a ) } ;
Blockly . FieldVariable . prototype . getValue = function ( ) { return this . variable _ ? this . variable _ . getId ( ) : null } ; Blockly . FieldVariable . prototype . getText = function ( ) { return this . variable _ ? this . variable _ . name : "" } ; Blockly . FieldVariable . prototype . getVariable = function ( ) { return this . variable _ } ; Blockly . FieldVariable . prototype . getValidator = function ( ) { return this . variable _ ? this . validator _ : null } ;
Blockly . FieldVariable . prototype . doClassValidation _ = function ( a ) { if ( null === a ) return null ; var b = Blockly . Variables . getVariable ( this . sourceBlock _ . workspace , a ) ; if ( ! b ) return console . warn ( "Variable id doesn't point to a real variable! ID was " + a ) , null ; b = b . type ; return this . typeIsAllowed _ ( b ) ? a : ( console . warn ( "Variable type doesn't match this field! Type was " + b ) , null ) } ;
Blockly . FieldVariable . prototype . doValueUpdate _ = function ( a ) { this . variable _ = Blockly . Variables . getVariable ( this . sourceBlock _ . workspace , a ) ; Blockly . FieldVariable . superClass _ . doValueUpdate _ . call ( this , a ) } ; Blockly . FieldVariable . prototype . typeIsAllowed _ = function ( a ) { var b = this . getVariableTypes _ ( ) ; if ( ! b ) return ! 0 ; for ( var c = 0 ; c < b . length ; c ++ ) if ( a == b [ c ] ) return ! 0 ; return ! 1 } ;
Blockly . FieldVariable . prototype . getVariableTypes _ = function ( ) { var a = this . variableTypes ; if ( null === a && this . sourceBlock _ && this . sourceBlock _ . workspace ) return this . sourceBlock _ . workspace . getVariableTypes ( ) ; a = a || [ "" ] ; if ( 0 == a . length ) throw a = this . getText ( ) , Error ( "'variableTypes' of field variable " + a + " was an empty list" ) ; return a } ;
Blockly . FieldVariable . prototype . setTypes _ = function ( a , b ) { b = b || "" ; if ( null == a || void 0 == a ) a = null ; else if ( Array . isArray ( a ) ) { for ( var c = ! 1 , d = 0 ; d < a . length ; d ++ ) a [ d ] == b && ( c = ! 0 ) ; if ( ! c ) throw Error ( "Invalid default type '" + b + "' in the definition of a FieldVariable" ) ; } else throw Error ( "'variableTypes' was not an array in the definition of a FieldVariable" ) ; this . defaultType _ = b ; this . variableTypes = a } ; Blockly . FieldVariable . prototype . refreshVariableName = function ( ) { this . forceRerender ( ) } ;
Blockly . FieldVariable . dropdownCreate = function ( ) { if ( ! this . variable _ ) throw Error ( "Tried to call dropdownCreate on a variable field with no variable selected." ) ; var a = this . getText ( ) , b = [ ] ; if ( this . sourceBlock _ && this . sourceBlock _ . workspace ) for ( var c = this . getVariableTypes _ ( ) , d = 0 ; d < c . length ; d ++ ) { var e = this . sourceBlock _ . workspace . getVariablesOfType ( c [ d ] ) ; b = b . concat ( e ) } b . sort ( Blockly . VariableModel . compareByName ) ; c = [ ] ; for ( d = 0 ; d < b . length ; d ++ ) c [ d ] = [ b [ d ] . name , b [ d ] . getId ( ) ] ; c . push ( [ Blockly . Msg . RENAME _VARIABLE , Blockly . RENAME _VARIABLE _ID ] ) ;
Blockly . Msg . DELETE _VARIABLE && c . push ( [ Blockly . Msg . DELETE _VARIABLE . replace ( "%1" , a ) , Blockly . DELETE _VARIABLE _ID ] ) ; return c } ; Blockly . FieldVariable . prototype . onItemSelected _ = function ( a , b ) { a = b . getValue ( ) ; if ( this . sourceBlock _ && this . sourceBlock _ . workspace ) { if ( a == Blockly . RENAME _VARIABLE _ID ) { Blockly . Variables . renameVariable ( this . sourceBlock _ . workspace , this . variable _ ) ; return } if ( a == Blockly . DELETE _VARIABLE _ID ) { this . sourceBlock _ . workspace . deleteVariableById ( this . variable _ . getId ( ) ) ; return } } this . setValue ( a ) } ;
Blockly . FieldVariable . prototype . referencesVariables = function ( ) { return ! 0 } ; Blockly . fieldRegistry . register ( "field_variable" , Blockly . FieldVariable ) ; Blockly . utils . svgPaths = { } ; Blockly . utils . svgPaths . point = function ( a , b ) { return " " + a + "," + b + " " } ; Blockly . utils . svgPaths . curve = function ( a , b ) { return " " + a + b . join ( "" ) } ; Blockly . utils . svgPaths . moveTo = function ( a , b ) { return " M " + a + "," + b + " " } ; Blockly . utils . svgPaths . moveBy = function ( a , b ) { return " m " + a + "," + b + " " } ; Blockly . utils . svgPaths . lineTo = function ( a , b ) { return " l " + a + "," + b + " " } ; Blockly . utils . svgPaths . line = function ( a ) { return " l" + a . join ( "" ) } ; Blockly . utils . svgPaths . lineOnAxis = function ( a , b ) { return " " + a + " " + b + " " } ;
Blockly . utils . svgPaths . arc = function ( a , b , c , d ) { return a + " " + c + " " + c + " " + b + d } ; Blockly . blockRendering . ConstantProvider = function ( ) { this . NO _PADDING = 0 ; this . SMALL _PADDING = 3 ; this . MEDIUM _PADDING = 5 ; this . MEDIUM _LARGE _PADDING = 8 ; this . LARGE _PADDING = 10 ; this . TALL _INPUT _FIELD _OFFSET _Y = this . MEDIUM _PADDING ; this . TAB _HEIGHT = 15 ; this . TAB _OFFSET _FROM _TOP = 5 ; this . TAB _VERTICAL _OVERLAP = 2.5 ; this . TAB _WIDTH = 8 ; this . NOTCH _WIDTH = 15 ; this . NOTCH _HEIGHT = 4 ; this . MIN _BLOCK _WIDTH = 12 ; this . EMPTY _BLOCK _SPACER _HEIGHT = 16 ; this . DUMMY _INPUT _SHADOW _MIN _HEIGHT = this . DUMMY _INPUT _MIN _HEIGHT = this . TAB _HEIGHT ; this . CORNER _RADIUS =
8 ; this . STATEMENT _INPUT _NOTCH _OFFSET = this . NOTCH _OFFSET _LEFT = 15 ; this . STATEMENT _BOTTOM _SPACER = 0 ; this . STATEMENT _INPUT _PADDING _LEFT = 20 ; this . BETWEEN _STATEMENT _PADDING _Y = 4 ; this . TOP _ROW _MIN _HEIGHT = this . MEDIUM _PADDING ; this . TOP _ROW _PRECEDES _STATEMENT _MIN _HEIGHT = this . LARGE _PADDING ; this . BOTTOM _ROW _MIN _HEIGHT = this . MEDIUM _PADDING ; this . BOTTOM _ROW _AFTER _STATEMENT _MIN _HEIGHT = this . LARGE _PADDING ; this . ADD _START _HATS = ! 1 ; this . START _HAT _HEIGHT = 15 ; this . START _HAT _WIDTH = 100 ; this . SPACER _DEFAULT _HEIGHT = 15 ; this . MIN _BLOCK _HEIGHT =
24 ; this . EMPTY _INLINE _INPUT _PADDING = 14.5 ; this . EMPTY _INLINE _INPUT _HEIGHT = this . TAB _HEIGHT + 11 ; this . EXTERNAL _VALUE _INPUT _PADDING = 2 ; this . EMPTY _STATEMENT _INPUT _HEIGHT = this . MIN _BLOCK _HEIGHT ; this . START _POINT = Blockly . utils . svgPaths . moveBy ( 0 , 0 ) ; this . JAGGED _TEETH _HEIGHT = 12 ; this . JAGGED _TEETH _WIDTH = 6 ; this . FIELD _TEXT _FONTSIZE = 11 ; this . FIELD _TEXT _FONTWEIGHT = "normal" ; this . FIELD _TEXT _FONTFAMILY = "sans-serif" ; this . FIELD _TEXT _BASELINE = this . FIELD _TEXT _HEIGHT = - 1 ; this . FIELD _BORDER _RECT _RADIUS = 4 ; this . FIELD _BORDER _RECT _HEIGHT =
16 ; this . FIELD _BORDER _RECT _X _PADDING = 5 ; this . FIELD _BORDER _RECT _Y _PADDING = 3 ; this . FIELD _BORDER _RECT _COLOUR = "#fff" ; this . FIELD _TEXT _BASELINE _CENTER = ! Blockly . utils . userAgent . IE && ! Blockly . utils . userAgent . EDGE ; this . FIELD _DROPDOWN _BORDER _RECT _HEIGHT = this . FIELD _BORDER _RECT _HEIGHT ; this . FIELD _DROPDOWN _SVG _ARROW = this . FIELD _DROPDOWN _COLOURED _DIV = this . FIELD _DROPDOWN _NO _BORDER _RECT _SHADOW = ! 1 ; this . FIELD _DROPDOWN _SVG _ARROW _PADDING = this . FIELD _BORDER _RECT _X _PADDING ; this . FIELD _DROPDOWN _SVG _ARROW _SIZE = 12 ; this . FIELD _DROPDOWN _SVG _ARROW _DATAURI =
"data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=" ;
this . FIELD _COLOUR _FULL _BLOCK = this . FIELD _TEXTINPUT _BOX _SHADOW = ! 1 ; this . FIELD _COLOUR _DEFAULT _WIDTH = 26 ; this . FIELD _COLOUR _DEFAULT _HEIGHT = this . FIELD _BORDER _RECT _HEIGHT ; this . FIELD _CHECKBOX _X _OFFSET = this . FIELD _BORDER _RECT _X _PADDING - 3 ; this . randomIdentifier = String ( Math . random ( ) ) . substring ( 2 ) ; this . embossFilterId = "" ; this . embossFilter _ = null ; this . disabledPatternId = "" ; this . disabledPattern _ = null ; this . debugFilterId = "" ; this . cssNode _ = this . debugFilter _ = null ; this . CURSOR _COLOUR = "#cc0a0a" ; this . MARKER _COLOUR = "#4286f4" ; this . CURSOR _WS _WIDTH =
100 ; this . WS _CURSOR _HEIGHT = 5 ; this . CURSOR _STACK _PADDING = 10 ; this . CURSOR _BLOCK _PADDING = 2 ; this . CURSOR _STROKE _WIDTH = 4 ; this . FULL _BLOCK _FIELDS = ! 1 ; this . INSERTION _MARKER _COLOUR = "#000000" ; this . INSERTION _MARKER _OPACITY = . 2 ; this . SHAPES = { PUZZLE : 1 , NOTCH : 2 } } ;
2021-09-18 14:29:06 +00:00
Blockly . blockRendering . ConstantProvider . prototype . init = function ( ) { this . JAGGED _TEETH = this . makeJaggedTeeth ( ) ; this . NOTCH = this . makeNotch ( ) ; this . START _HAT = this . makeStartHat ( ) ; this . PUZZLE _TAB = this . makePuzzleTab ( ) ; this . INSIDE _CORNERS = this . makeInsideCorners ( ) ; this . OUTSIDE _CORNERS = this . makeOutsideCorners ( ) } ; Blockly . blockRendering . ConstantProvider . prototype . setTheme = function ( a ) { this . blockStyles = Object . create ( null ) ; var b = a . blockStyles , c ; for ( c in b ) this . blockStyles [ c ] = this . validatedBlockStyle _ ( b [ c ] ) ; this . setDynamicProperties _ ( a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . ConstantProvider . prototype . setDynamicProperties _ = function ( a ) { this . setFontConstants _ ( a ) ; this . setComponentConstants _ ( a ) ; this . ADD _START _HATS = null != a . startHats ? a . startHats : this . ADD _START _HATS } ;
Blockly . blockRendering . ConstantProvider . prototype . setFontConstants _ = function ( a ) { this . FIELD _TEXT _FONTFAMILY = a . fontStyle && void 0 != a . fontStyle . family ? a . fontStyle . family : this . FIELD _TEXT _FONTFAMILY ; this . FIELD _TEXT _FONTWEIGHT = a . fontStyle && void 0 != a . fontStyle . weight ? a . fontStyle . weight : this . FIELD _TEXT _FONTWEIGHT ; this . FIELD _TEXT _FONTSIZE = a . fontStyle && void 0 != a . fontStyle . size ? a . fontStyle . size : this . FIELD _TEXT _FONTSIZE ; a = Blockly . utils . dom . measureFontMetrics ( "Hg" , this . FIELD _TEXT _FONTSIZE + "pt" , this . FIELD _TEXT _FONTWEIGHT ,
this . FIELD _TEXT _FONTFAMILY ) ; this . FIELD _TEXT _HEIGHT = a . height ; this . FIELD _TEXT _BASELINE = a . baseline } ;
Blockly . blockRendering . ConstantProvider . prototype . setComponentConstants _ = function ( a ) { this . CURSOR _COLOUR = a . getComponentStyle ( "cursorColour" ) || this . CURSOR _COLOUR ; this . MARKER _COLOUR = a . getComponentStyle ( "markerColour" ) || this . MARKER _COLOUR ; this . INSERTION _MARKER _COLOUR = a . getComponentStyle ( "insertionMarkerColour" ) || this . INSERTION _MARKER _COLOUR ; this . INSERTION _MARKER _OPACITY = Number ( a . getComponentStyle ( "insertionMarkerOpacity" ) ) || this . INSERTION _MARKER _OPACITY } ;
Blockly . blockRendering . ConstantProvider . prototype . getBlockStyleForColour = function ( a ) { var b = "auto_" + a ; this . blockStyles [ b ] || ( this . blockStyles [ b ] = this . createBlockStyle _ ( a ) ) ; return { style : this . blockStyles [ b ] , name : b } } ; Blockly . blockRendering . ConstantProvider . prototype . getBlockStyle = function ( a ) { return this . blockStyles [ a || "" ] || ( a && 0 == a . indexOf ( "auto_" ) ? this . getBlockStyleForColour ( a . substring ( 5 ) ) . style : this . createBlockStyle _ ( "#000000" ) ) } ; Blockly . blockRendering . ConstantProvider . prototype . createBlockStyle _ = function ( a ) { return this . validatedBlockStyle _ ( { colourPrimary : a } ) } ;
Blockly . blockRendering . ConstantProvider . prototype . validatedBlockStyle _ = function ( a ) { var b = { } ; a && Blockly . utils . object . mixin ( b , a ) ; a = Blockly . utils . parseBlockColour ( b . colourPrimary || "#000" ) ; b . colourPrimary = a . hex ; b . colourSecondary = b . colourSecondary ? Blockly . utils . parseBlockColour ( b . colourSecondary ) . hex : this . generateSecondaryColour _ ( b . colourPrimary ) ; b . colourTertiary = b . colourTertiary ? Blockly . utils . parseBlockColour ( b . colourTertiary ) . hex : this . generateTertiaryColour _ ( b . colourPrimary ) ; b . hat = b . hat || "" ; return b } ;
Blockly . blockRendering . ConstantProvider . prototype . generateSecondaryColour _ = function ( a ) { return Blockly . utils . colour . blend ( "#fff" , a , . 6 ) || a } ; Blockly . blockRendering . ConstantProvider . prototype . generateTertiaryColour _ = function ( a ) { return Blockly . utils . colour . blend ( "#fff" , a , . 3 ) || a } ;
Blockly . blockRendering . ConstantProvider . prototype . dispose = function ( ) { this . embossFilter _ && Blockly . utils . dom . removeNode ( this . embossFilter _ ) ; this . disabledPattern _ && Blockly . utils . dom . removeNode ( this . disabledPattern _ ) ; this . debugFilter _ && Blockly . utils . dom . removeNode ( this . debugFilter _ ) ; this . cssNode _ = null } ;
Blockly . blockRendering . ConstantProvider . prototype . makeJaggedTeeth = function ( ) { var a = this . JAGGED _TEETH _HEIGHT , b = this . JAGGED _TEETH _WIDTH , c = Blockly . utils . svgPaths . line ( [ Blockly . utils . svgPaths . point ( b , a / 4 ) , Blockly . utils . svgPaths . point ( 2 * - b , a / 2 ) , Blockly . utils . svgPaths . point ( b , a / 4 ) ] ) ; return { height : a , width : b , path : c } } ;
Blockly . blockRendering . ConstantProvider . prototype . makeStartHat = function ( ) { var a = this . START _HAT _HEIGHT , b = this . START _HAT _WIDTH , c = Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( 30 , - a ) , Blockly . utils . svgPaths . point ( 70 , - a ) , Blockly . utils . svgPaths . point ( b , 0 ) ] ) ; return { height : a , width : b , path : c } } ;
Blockly . blockRendering . ConstantProvider . prototype . makePuzzleTab = function ( ) { function a ( f ) { f = f ? - 1 : 1 ; var g = - f , h = c / 2 , k = h + 2.5 , l = h + . 5 , m = Blockly . utils . svgPaths . point ( - b , f * h ) ; h = Blockly . utils . svgPaths . point ( b , f * h ) ; return Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( 0 , f * k ) , Blockly . utils . svgPaths . point ( - b , g * l ) , m ] ) + Blockly . utils . svgPaths . curve ( "s" , [ Blockly . utils . svgPaths . point ( b , 2.5 * g ) , h ] ) } var b = this . TAB _WIDTH , c = this . TAB _HEIGHT , d = a ( ! 0 ) , e = a ( ! 1 ) ; return { type : this . SHAPES . PUZZLE , width : b , height : c ,
pathDown : e , pathUp : d } } ; Blockly . blockRendering . ConstantProvider . prototype . makeNotch = function ( ) { function a ( g ) { return Blockly . utils . svgPaths . line ( [ Blockly . utils . svgPaths . point ( g * d , c ) , Blockly . utils . svgPaths . point ( 3 * g , 0 ) , Blockly . utils . svgPaths . point ( g * d , - c ) ] ) } var b = this . NOTCH _WIDTH , c = this . NOTCH _HEIGHT , d = ( b - 3 ) / 2 , e = a ( 1 ) , f = a ( - 1 ) ; return { type : this . SHAPES . NOTCH , width : b , height : c , pathLeft : e , pathRight : f } } ;
Blockly . blockRendering . ConstantProvider . prototype . makeInsideCorners = function ( ) { var a = this . CORNER _RADIUS , b = Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a , Blockly . utils . svgPaths . point ( - a , a ) ) , c = Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a , Blockly . utils . svgPaths . point ( a , a ) ) ; return { width : a , height : a , pathTop : b , pathBottom : c } } ;
Blockly . blockRendering . ConstantProvider . prototype . makeOutsideCorners = function ( ) { var a = this . CORNER _RADIUS , b = Blockly . utils . svgPaths . moveBy ( 0 , a ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( a , - a ) ) , c = Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( a , a ) ) , d = Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( - a , - a ) ) , e = Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( - a , a ) ) ; return { topLeft : b , topRight : c , bottomRight : e , bottomLeft : d ,
2021-05-19 13:38:55 +00:00
rightHeight : a } } ; Blockly . blockRendering . ConstantProvider . prototype . shapeFor = function ( a ) { switch ( a . type ) { case Blockly . connectionTypes . INPUT _VALUE : case Blockly . connectionTypes . OUTPUT _VALUE : return this . PUZZLE _TAB ; case Blockly . connectionTypes . PREVIOUS _STATEMENT : case Blockly . connectionTypes . NEXT _STATEMENT : return this . NOTCH ; default : throw Error ( "Unknown connection type" ) ; } } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . ConstantProvider . prototype . createDom = function ( a , b , c ) { this . injectCSS _ ( b , c ) ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . DEFS , { } , a ) ; b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FILTER , { id : "blocklyEmbossFilter" + this . randomIdentifier } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEGAUSSIANBLUR , { "in" : "SourceAlpha" , stdDeviation : 1 , result : "blur" } , b ) ; c = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FESPECULARLIGHTING , { "in" : "blur" , surfaceScale : 1 , specularConstant : . 5 ,
specularExponent : 10 , "lighting-color" : "white" , result : "specOut" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEPOINTLIGHT , { x : - 5E3 , y : - 1E4 , z : 2E4 } , c ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "specOut" , in2 : "SourceAlpha" , operator : "in" , result : "specOut" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "SourceGraphic" , in2 : "specOut" , operator : "arithmetic" , k1 : 0 , k2 : 1 , k3 : 1 , k4 : 0 } , b ) ; this . embossFilterId = b . id ; this . embossFilter _ = b ; b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATTERN ,
{ id : "blocklyDisabledPattern" + this . randomIdentifier , patternUnits : "userSpaceOnUse" , width : 10 , height : 10 } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : 10 , height : 10 , fill : "#aaa" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { d : "M 0 0 L 10 10 M 10 0 L 0 10" , stroke : "#cc0" } , b ) ; this . disabledPatternId = b . id ; this . disabledPattern _ = b ; Blockly . blockRendering . Debug && ( a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FILTER , { id : "blocklyDebugFilter" + this . randomIdentifier , height : "160%" ,
width : "180%" , y : "-30%" , x : "-40%" } , a ) , b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPONENTTRANSFER , { result : "outBlur" } , a ) , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFUNCA , { type : "table" , tableValues : "0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" } , b ) , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFLOOD , { "flood-color" : "#ff0000" , "flood-opacity" : . 5 , result : "outColor" } , a ) , Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "outColor" , in2 : "outBlur" , operator : "in" , result : "outGlow" } ,
a ) , this . debugFilterId = a . id , this . debugFilter _ = a ) } ; Blockly . blockRendering . ConstantProvider . prototype . injectCSS _ = function ( a , b ) { b = this . getCSS _ ( b ) ; a = "blockly-renderer-style-" + a ; this . cssNode _ = document . getElementById ( a ) ; var c = b . join ( "\n" ) ; this . cssNode _ ? this . cssNode _ . firstChild . textContent = c : ( b = document . createElement ( "style" ) , b . id = a , a = document . createTextNode ( c ) , b . appendChild ( a ) , document . head . insertBefore ( b , document . head . firstChild ) , this . cssNode _ = b ) } ;
Blockly . blockRendering . ConstantProvider . prototype . getCSS _ = function ( a ) { return [ a + " .blocklyText, " , a + " .blocklyFlyoutLabelText {" , "font: " + this . FIELD _TEXT _FONTWEIGHT + " " + this . FIELD _TEXT _FONTSIZE + "pt " + this . FIELD _TEXT _FONTFAMILY + ";" , "}" , a + " .blocklyText {" , "fill: #fff;" , "}" , a + " .blocklyNonEditableText>rect," , a + " .blocklyEditableText>rect {" , "fill: " + this . FIELD _BORDER _RECT _COLOUR + ";" , "fill-opacity: .6;" , "stroke: none;" , "}" , a + " .blocklyNonEditableText>text," , a + " .blocklyEditableText>text {" , "fill: #000;" ,
"}" , a + " .blocklyFlyoutLabelText {" , "fill: #000;" , "}" , a + " .blocklyText.blocklyBubbleText {" , "fill: #000;" , "}" , a + " .blocklyEditableText:not(.editing):hover>rect {" , "stroke: #fff;" , "stroke-width: 2;" , "}" , a + " .blocklyHtmlInput {" , "font-family: " + this . FIELD _TEXT _FONTFAMILY + ";" , "font-weight: " + this . FIELD _TEXT _FONTWEIGHT + ";" , "}" , a + " .blocklySelected>.blocklyPath {" , "stroke: #fc3;" , "stroke-width: 3px;" , "}" , a + " .blocklyHighlightedConnectionPath {" , "stroke: #fc3;" , "}" , a + " .blocklyReplaceable .blocklyPath {" ,
2021-05-19 13:38:55 +00:00
"fill-opacity: .5;" , "}" , a + " .blocklyReplaceable .blocklyPathLight," , a + " .blocklyReplaceable .blocklyPathDark {" , "display: none;" , "}" , a + " .blocklyInsertionMarker>.blocklyPath {" , "fill-opacity: " + this . INSERTION _MARKER _OPACITY + ";" , "stroke: none;" , "}" ] } ; Blockly . blockRendering . Types = { NONE : 0 , FIELD : 1 , HAT : 2 , ICON : 4 , SPACER : 8 , BETWEEN _ROW _SPACER : 16 , IN _ROW _SPACER : 32 , EXTERNAL _VALUE _INPUT : 64 , INPUT : 128 , INLINE _INPUT : 256 , STATEMENT _INPUT : 512 , CONNECTION : 1024 , PREVIOUS _CONNECTION : 2048 , NEXT _CONNECTION : 4096 , OUTPUT _CONNECTION : 8192 , CORNER : 16384 , LEFT _SQUARE _CORNER : 32768 , LEFT _ROUND _CORNER : 65536 , RIGHT _SQUARE _CORNER : 131072 , RIGHT _ROUND _CORNER : 262144 , JAGGED _EDGE : 524288 , ROW : 1048576 , TOP _ROW : 2097152 , BOTTOM _ROW : 4194304 , INPUT _ROW : 8388608 } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . Types . LEFT _CORNER = Blockly . blockRendering . Types . LEFT _SQUARE _CORNER | Blockly . blockRendering . Types . LEFT _ROUND _CORNER ; Blockly . blockRendering . Types . RIGHT _CORNER = Blockly . blockRendering . Types . RIGHT _SQUARE _CORNER | Blockly . blockRendering . Types . RIGHT _ROUND _CORNER ; Blockly . blockRendering . Types . nextTypeValue _ = 16777216 ;
Blockly . blockRendering . Types . getType = function ( a ) { Object . prototype . hasOwnProperty . call ( Blockly . blockRendering . Types , a ) || ( Blockly . blockRendering . Types [ a ] = Blockly . blockRendering . Types . nextTypeValue _ , Blockly . blockRendering . Types . nextTypeValue _ <<= 1 ) ; return Blockly . blockRendering . Types [ a ] } ; Blockly . blockRendering . Types . isField = function ( a ) { return a . type & Blockly . blockRendering . Types . FIELD } ; Blockly . blockRendering . Types . isHat = function ( a ) { return a . type & Blockly . blockRendering . Types . HAT } ;
Blockly . blockRendering . Types . isIcon = function ( a ) { return a . type & Blockly . blockRendering . Types . ICON } ; Blockly . blockRendering . Types . isSpacer = function ( a ) { return a . type & Blockly . blockRendering . Types . SPACER } ; Blockly . blockRendering . Types . isInRowSpacer = function ( a ) { return a . type & Blockly . blockRendering . Types . IN _ROW _SPACER } ; Blockly . blockRendering . Types . isInput = function ( a ) { return a . type & Blockly . blockRendering . Types . INPUT } ; Blockly . blockRendering . Types . isExternalInput = function ( a ) { return a . type & Blockly . blockRendering . Types . EXTERNAL _VALUE _INPUT } ;
Blockly . blockRendering . Types . isInlineInput = function ( a ) { return a . type & Blockly . blockRendering . Types . INLINE _INPUT } ; Blockly . blockRendering . Types . isStatementInput = function ( a ) { return a . type & Blockly . blockRendering . Types . STATEMENT _INPUT } ; Blockly . blockRendering . Types . isPreviousConnection = function ( a ) { return a . type & Blockly . blockRendering . Types . PREVIOUS _CONNECTION } ; Blockly . blockRendering . Types . isNextConnection = function ( a ) { return a . type & Blockly . blockRendering . Types . NEXT _CONNECTION } ;
Blockly . blockRendering . Types . isPreviousOrNextConnection = function ( a ) { return a . type & ( Blockly . blockRendering . Types . PREVIOUS _CONNECTION | Blockly . blockRendering . Types . NEXT _CONNECTION ) } ; Blockly . blockRendering . Types . isLeftRoundedCorner = function ( a ) { return a . type & Blockly . blockRendering . Types . LEFT _ROUND _CORNER } ; Blockly . blockRendering . Types . isRightRoundedCorner = function ( a ) { return a . type & Blockly . blockRendering . Types . RIGHT _ROUND _CORNER } ;
Blockly . blockRendering . Types . isLeftSquareCorner = function ( a ) { return a . type & Blockly . blockRendering . Types . LEFT _SQUARE _CORNER } ; Blockly . blockRendering . Types . isRightSquareCorner = function ( a ) { return a . type & Blockly . blockRendering . Types . RIGHT _SQUARE _CORNER } ; Blockly . blockRendering . Types . isCorner = function ( a ) { return a . type & Blockly . blockRendering . Types . CORNER } ; Blockly . blockRendering . Types . isJaggedEdge = function ( a ) { return a . type & Blockly . blockRendering . Types . JAGGED _EDGE } ;
Blockly . blockRendering . Types . isRow = function ( a ) { return a . type & Blockly . blockRendering . Types . ROW } ; Blockly . blockRendering . Types . isBetweenRowSpacer = function ( a ) { return a . type & Blockly . blockRendering . Types . BETWEEN _ROW _SPACER } ; Blockly . blockRendering . Types . isTopRow = function ( a ) { return a . type & Blockly . blockRendering . Types . TOP _ROW } ; Blockly . blockRendering . Types . isBottomRow = function ( a ) { return a . type & Blockly . blockRendering . Types . BOTTOM _ROW } ;
Blockly . blockRendering . Types . isTopOrBottomRow = function ( a ) { return a . type & ( Blockly . blockRendering . Types . TOP _ROW | Blockly . blockRendering . Types . BOTTOM _ROW ) } ; Blockly . blockRendering . Types . isInputRow = function ( a ) { return a . type & Blockly . blockRendering . Types . INPUT _ROW } ; Blockly . blockRendering . Measurable = function ( a ) { this . height = this . width = 0 ; this . type = Blockly . blockRendering . Types . NONE ; this . centerline = this . xPos = 0 ; this . constants _ = a ; this . notchOffset = this . constants _ . NOTCH _OFFSET _LEFT } ; Blockly . blockRendering . Connection = function ( a , b ) { Blockly . blockRendering . Connection . superClass _ . constructor . call ( this , a ) ; this . connectionModel = b ; this . shape = this . constants _ . shapeFor ( b ) ; this . isDynamicShape = ! ! this . shape . isDynamic ; this . type |= Blockly . blockRendering . Types . CONNECTION } ; Blockly . utils . object . inherits ( Blockly . blockRendering . Connection , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . OutputConnection = function ( a , b ) { Blockly . blockRendering . OutputConnection . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . OUTPUT _CONNECTION ; this . height = this . isDynamicShape ? 0 : this . shape . height ; this . startX = this . width = this . isDynamicShape ? 0 : this . shape . width ; this . connectionOffsetY = this . constants _ . TAB _OFFSET _FROM _TOP ; this . connectionOffsetX = 0 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . OutputConnection , Blockly . blockRendering . Connection ) ;
Blockly . blockRendering . PreviousConnection = function ( a , b ) { Blockly . blockRendering . PreviousConnection . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . PREVIOUS _CONNECTION ; this . height = this . shape . height ; this . width = this . shape . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . PreviousConnection , Blockly . blockRendering . Connection ) ;
Blockly . blockRendering . NextConnection = function ( a , b ) { Blockly . blockRendering . NextConnection . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . NEXT _CONNECTION ; this . height = this . shape . height ; this . width = this . shape . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . NextConnection , Blockly . blockRendering . Connection ) ; Blockly . blockRendering . InputConnection = function ( a , b ) { Blockly . blockRendering . InputConnection . superClass _ . constructor . call ( this , a , b . connection ) ; this . type |= Blockly . blockRendering . Types . INPUT ; this . input = b ; this . align = b . align ; ( this . connectedBlock = b . connection && b . connection . targetBlock ( ) ? b . connection . targetBlock ( ) : null ) ? ( a = this . connectedBlock . getHeightWidth ( ) , this . connectedBlockWidth = a . width , this . connectedBlockHeight = a . height ) : this . connectedBlockHeight = this . connectedBlockWidth = 0 ; this . connectionOffsetY = this . connectionOffsetX =
0 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . InputConnection , Blockly . blockRendering . Connection ) ;
Blockly . blockRendering . InlineInput = function ( a , b ) { Blockly . blockRendering . InlineInput . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . INLINE _INPUT ; this . connectedBlock ? ( this . width = this . connectedBlockWidth , this . height = this . connectedBlockHeight ) : ( this . height = this . constants _ . EMPTY _INLINE _INPUT _HEIGHT , this . width = this . constants _ . EMPTY _INLINE _INPUT _PADDING ) ; this . connectionHeight = this . isDynamicShape ? this . shape . height ( this . height ) : this . shape . height ; this . connectionWidth = this . isDynamicShape ?
this . shape . width ( this . height ) : this . shape . width ; this . connectedBlock || ( this . width += this . connectionWidth * ( this . isDynamicShape ? 2 : 1 ) ) ; this . connectionOffsetY = this . isDynamicShape ? this . shape . connectionOffsetY ( this . connectionHeight ) : this . constants _ . TAB _OFFSET _FROM _TOP ; this . connectionOffsetX = this . isDynamicShape ? this . shape . connectionOffsetX ( this . connectionWidth ) : 0 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . InlineInput , Blockly . blockRendering . InputConnection ) ;
Blockly . blockRendering . StatementInput = function ( a , b ) { Blockly . blockRendering . StatementInput . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . STATEMENT _INPUT ; this . height = this . connectedBlock ? this . connectedBlockHeight + this . constants _ . STATEMENT _BOTTOM _SPACER : this . constants _ . EMPTY _STATEMENT _INPUT _HEIGHT ; this . width = this . constants _ . STATEMENT _INPUT _NOTCH _OFFSET + this . shape . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . StatementInput , Blockly . blockRendering . InputConnection ) ;
Blockly . blockRendering . ExternalValueInput = function ( a , b ) { Blockly . blockRendering . ExternalValueInput . superClass _ . constructor . call ( this , a , b ) ; this . type |= Blockly . blockRendering . Types . EXTERNAL _VALUE _INPUT ; this . height = this . connectedBlock ? this . connectedBlockHeight - this . constants _ . TAB _OFFSET _FROM _TOP - this . constants _ . MEDIUM _PADDING : this . shape . height ; this . width = this . shape . width + this . constants _ . EXTERNAL _VALUE _INPUT _PADDING ; this . connectionOffsetY = this . constants _ . TAB _OFFSET _FROM _TOP ; this . connectionHeight = this . shape . height ;
this . connectionWidth = this . shape . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . ExternalValueInput , Blockly . blockRendering . InputConnection ) ; Blockly . blockRendering . Icon = function ( a , b ) { Blockly . blockRendering . Icon . superClass _ . constructor . call ( this , a ) ; this . icon = b ; this . isVisible = b . isVisible ( ) ; this . type |= Blockly . blockRendering . Types . ICON ; a = b . getCorrectedSize ( ) ; this . height = a . height ; this . width = a . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . Icon , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . JaggedEdge = function ( a ) { Blockly . blockRendering . JaggedEdge . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . JAGGED _EDGE ; this . height = this . constants _ . JAGGED _TEETH . height ; this . width = this . constants _ . JAGGED _TEETH . width } ; Blockly . utils . object . inherits ( Blockly . blockRendering . JaggedEdge , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . Field = function ( a , b , c ) { Blockly . blockRendering . Field . superClass _ . constructor . call ( this , a ) ; this . field = b ; this . isEditable = b . EDITABLE ; this . flipRtl = b . getFlipRtl ( ) ; this . type |= Blockly . blockRendering . Types . FIELD ; a = this . field . getSize ( ) ; this . height = a . height ; this . width = a . width ; this . parentInput = c } ; Blockly . utils . object . inherits ( Blockly . blockRendering . Field , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . Hat = function ( a ) { Blockly . blockRendering . Hat . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . HAT ; this . height = this . constants _ . START _HAT . height ; this . width = this . constants _ . START _HAT . width ; this . ascenderHeight = this . height } ; Blockly . utils . object . inherits ( Blockly . blockRendering . Hat , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . SquareCorner = function ( a , b ) { Blockly . blockRendering . SquareCorner . superClass _ . constructor . call ( this , a ) ; this . type = ( b && "left" != b ? Blockly . blockRendering . Types . RIGHT _SQUARE _CORNER : Blockly . blockRendering . Types . LEFT _SQUARE _CORNER ) | Blockly . blockRendering . Types . CORNER ; this . width = this . height = this . constants _ . NO _PADDING } ; Blockly . utils . object . inherits ( Blockly . blockRendering . SquareCorner , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . RoundCorner = function ( a , b ) { Blockly . blockRendering . RoundCorner . superClass _ . constructor . call ( this , a ) ; this . type = ( b && "left" != b ? Blockly . blockRendering . Types . RIGHT _ROUND _CORNER : Blockly . blockRendering . Types . LEFT _ROUND _CORNER ) | Blockly . blockRendering . Types . CORNER ; this . width = this . constants _ . CORNER _RADIUS ; this . height = this . constants _ . CORNER _RADIUS / 2 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . RoundCorner , Blockly . blockRendering . Measurable ) ;
Blockly . blockRendering . InRowSpacer = function ( a , b ) { Blockly . blockRendering . InRowSpacer . superClass _ . constructor . call ( this , a ) ; this . type = this . type | Blockly . blockRendering . Types . SPACER | Blockly . blockRendering . Types . IN _ROW _SPACER ; this . width = b ; this . height = this . constants _ . SPACER _DEFAULT _HEIGHT } ; Blockly . utils . object . inherits ( Blockly . blockRendering . InRowSpacer , Blockly . blockRendering . Measurable ) ; Blockly . blockRendering . Row = function ( a ) { this . type = Blockly . blockRendering . Types . ROW ; this . elements = [ ] ; this . xPos = this . yPos = this . widthWithConnectedBlocks = this . minWidth = this . minHeight = this . width = this . height = 0 ; this . hasJaggedEdge = this . hasDummyInput = this . hasInlineInput = this . hasStatement = this . hasExternalInput = ! 1 ; this . constants _ = a ; this . notchOffset = this . constants _ . NOTCH _OFFSET _LEFT ; this . align = null } ;
Blockly . blockRendering . Row . prototype . measure = function ( ) { throw Error ( "Unexpected attempt to measure a base Row." ) ; } ; Blockly . blockRendering . Row . prototype . getLastInput = function ( ) { for ( var a = this . elements . length - 1 , b ; b = this . elements [ a ] ; a -- ) if ( Blockly . blockRendering . Types . isInput ( b ) ) return b ; return null } ; Blockly . blockRendering . Row . prototype . startsWithElemSpacer = function ( ) { return ! 0 } ; Blockly . blockRendering . Row . prototype . endsWithElemSpacer = function ( ) { return ! 0 } ;
Blockly . blockRendering . Row . prototype . getFirstSpacer = function ( ) { for ( var a = 0 , b ; b = this . elements [ a ] ; a ++ ) if ( Blockly . blockRendering . Types . isSpacer ( b ) ) return b ; return null } ; Blockly . blockRendering . Row . prototype . getLastSpacer = function ( ) { for ( var a = this . elements . length - 1 , b ; b = this . elements [ a ] ; a -- ) if ( Blockly . blockRendering . Types . isSpacer ( b ) ) return b ; return null } ;
Blockly . blockRendering . TopRow = function ( a ) { Blockly . blockRendering . TopRow . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . TOP _ROW ; this . ascenderHeight = this . capline = 0 ; this . hasPreviousConnection = ! 1 ; this . connection = null } ; Blockly . utils . object . inherits ( Blockly . blockRendering . TopRow , Blockly . blockRendering . Row ) ;
Blockly . blockRendering . TopRow . prototype . hasLeftSquareCorner = function ( a ) { var b = ( a . hat ? "cap" === a . hat : this . constants _ . ADD _START _HATS ) && ! a . outputConnection && ! a . previousConnection , c = a . getPreviousBlock ( ) ; return ! ! a . outputConnection || b || ( c ? c . getNextBlock ( ) == a : ! 1 ) } ; Blockly . blockRendering . TopRow . prototype . hasRightSquareCorner = function ( a ) { return ! 0 } ;
Blockly . blockRendering . TopRow . prototype . measure = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d = 0 , e ; e = this . elements [ d ] ; d ++ ) b += e . width , Blockly . blockRendering . Types . isSpacer ( e ) || ( Blockly . blockRendering . Types . isHat ( e ) ? c = Math . max ( c , e . ascenderHeight ) : a = Math . max ( a , e . height ) ) ; this . width = Math . max ( this . minWidth , b ) ; this . height = Math . max ( this . minHeight , a ) + c ; this . capline = this . ascenderHeight = c ; this . widthWithConnectedBlocks = this . width } ; Blockly . blockRendering . TopRow . prototype . startsWithElemSpacer = function ( ) { return ! 1 } ;
Blockly . blockRendering . TopRow . prototype . endsWithElemSpacer = function ( ) { return ! 1 } ; Blockly . blockRendering . BottomRow = function ( a ) { Blockly . blockRendering . BottomRow . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . BOTTOM _ROW ; this . hasNextConnection = ! 1 ; this . connection = null ; this . baseline = this . descenderHeight = 0 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . BottomRow , Blockly . blockRendering . Row ) ;
Blockly . blockRendering . BottomRow . prototype . hasLeftSquareCorner = function ( a ) { return ! ! a . outputConnection || ! ! a . getNextBlock ( ) } ; Blockly . blockRendering . BottomRow . prototype . hasRightSquareCorner = function ( a ) { return ! 0 } ;
Blockly . blockRendering . BottomRow . prototype . measure = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d = 0 , e ; e = this . elements [ d ] ; d ++ ) b += e . width , Blockly . blockRendering . Types . isSpacer ( e ) || ( Blockly . blockRendering . Types . isNextConnection ( e ) ? c = Math . max ( c , e . height ) : a = Math . max ( a , e . height ) ) ; this . width = Math . max ( this . minWidth , b ) ; this . height = Math . max ( this . minHeight , a ) + c ; this . descenderHeight = c ; this . widthWithConnectedBlocks = this . width } ; Blockly . blockRendering . BottomRow . prototype . startsWithElemSpacer = function ( ) { return ! 1 } ;
Blockly . blockRendering . BottomRow . prototype . endsWithElemSpacer = function ( ) { return ! 1 } ; Blockly . blockRendering . SpacerRow = function ( a , b , c ) { Blockly . blockRendering . SpacerRow . superClass _ . constructor . call ( this , a ) ; this . type = this . type | Blockly . blockRendering . Types . SPACER | Blockly . blockRendering . Types . BETWEEN _ROW _SPACER ; this . width = c ; this . height = b ; this . followsStatement = ! 1 ; this . widthWithConnectedBlocks = 0 ; this . elements = [ new Blockly . blockRendering . InRowSpacer ( this . constants _ , c ) ] } ;
Blockly . utils . object . inherits ( Blockly . blockRendering . SpacerRow , Blockly . blockRendering . Row ) ; Blockly . blockRendering . SpacerRow . prototype . measure = function ( ) { } ; Blockly . blockRendering . InputRow = function ( a ) { Blockly . blockRendering . InputRow . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . INPUT _ROW ; this . connectedBlockWidths = 0 } ; Blockly . utils . object . inherits ( Blockly . blockRendering . InputRow , Blockly . blockRendering . Row ) ;
Blockly . blockRendering . InputRow . prototype . measure = function ( ) { this . width = this . minWidth ; this . height = this . minHeight ; for ( var a = 0 , b = 0 , c ; c = this . elements [ b ] ; b ++ ) this . width += c . width , Blockly . blockRendering . Types . isInput ( c ) && ( Blockly . blockRendering . Types . isStatementInput ( c ) ? a += c . connectedBlockWidth : Blockly . blockRendering . Types . isExternalInput ( c ) && 0 != c . connectedBlockWidth && ( a += c . connectedBlockWidth - c . connectionWidth ) ) , Blockly . blockRendering . Types . isSpacer ( c ) || ( this . height = Math . max ( this . height , c . height ) ) ; this . connectedBlockWidths =
a ; this . widthWithConnectedBlocks = this . width + a } ; Blockly . blockRendering . InputRow . prototype . endsWithElemSpacer = function ( ) { return ! this . hasExternalInput && ! this . hasStatement } ; Blockly . blockRendering . RenderInfo = function ( a , b ) { this . block _ = b ; this . renderer _ = a ; this . constants _ = this . renderer _ . getConstants ( ) ; this . outputConnection = b . outputConnection ? new Blockly . blockRendering . OutputConnection ( this . constants _ , b . outputConnection ) : null ; this . isInline = b . getInputsInline ( ) && ! b . isCollapsed ( ) ; this . isCollapsed = b . isCollapsed ( ) ; this . isInsertionMarker = b . isInsertionMarker ( ) ; this . RTL = b . RTL ; this . statementEdge = this . width = this . widthWithChildren = this . height = 0 ; this . rows = [ ] ; this . inputRows = [ ] ; this . hiddenIcons =
[ ] ; this . topRow = new Blockly . blockRendering . TopRow ( this . constants _ ) ; this . bottomRow = new Blockly . blockRendering . BottomRow ( this . constants _ ) ; this . startY = this . startX = 0 } ; Blockly . blockRendering . RenderInfo . prototype . getRenderer = function ( ) { return this . renderer _ } ; Blockly . blockRendering . RenderInfo . prototype . measure = function ( ) { this . createRows _ ( ) ; this . addElemSpacing _ ( ) ; this . addRowSpacing _ ( ) ; this . computeBounds _ ( ) ; this . alignRowElements _ ( ) ; this . finalize _ ( ) } ;
2021-09-18 14:29:06 +00:00
Blockly . blockRendering . RenderInfo . prototype . createRows _ = function ( ) { this . populateTopRow _ ( ) ; this . rows . push ( this . topRow ) ; var a = new Blockly . blockRendering . InputRow ( this . constants _ ) ; this . inputRows . push ( a ) ; for ( var b = this . block _ . getIcons ( ) , c = 0 , d ; d = b [ c ] ; c ++ ) { var e = new Blockly . blockRendering . Icon ( this . constants _ , d ) ; this . isCollapsed && d . collapseHidden ? this . hiddenIcons . push ( e ) : a . elements . push ( e ) } d = null ; for ( c = 0 ; b = this . block _ . inputList [ c ] ; c ++ ) if ( b . isVisible ( ) ) { this . shouldStartNewRow _ ( b , d ) && ( this . rows . push ( a ) , a =
new Blockly . blockRendering . InputRow ( this . constants _ ) , this . inputRows . push ( a ) ) ; for ( d = 0 ; e = b . fieldRow [ d ] ; d ++ ) a . elements . push ( new Blockly . blockRendering . Field ( this . constants _ , e , b ) ) ; this . addInput _ ( b , a ) ; d = b } this . isCollapsed && ( a . hasJaggedEdge = ! 0 , a . elements . push ( new Blockly . blockRendering . JaggedEdge ( this . constants _ ) ) ) ; ( a . elements . length || a . hasDummyInput ) && this . rows . push ( a ) ; this . populateBottomRow _ ( ) ; this . rows . push ( this . bottomRow ) } ;
Blockly . blockRendering . RenderInfo . prototype . populateTopRow _ = function ( ) { var a = ! ! this . block _ . previousConnection , b = ( this . block _ . hat ? "cap" === this . block _ . hat : this . constants _ . ADD _START _HATS ) && ! this . outputConnection && ! a , c = this . topRow . hasLeftSquareCorner ( this . block _ ) ? Blockly . blockRendering . SquareCorner : Blockly . blockRendering . RoundCorner ; this . topRow . elements . push ( new c ( this . constants _ ) ) ; b ? ( a = new Blockly . blockRendering . Hat ( this . constants _ ) , this . topRow . elements . push ( a ) , this . topRow . capline = a . ascenderHeight ) :
a && ( this . topRow . hasPreviousConnection = ! 0 , this . topRow . connection = new Blockly . blockRendering . PreviousConnection ( this . constants _ , this . block _ . previousConnection ) , this . topRow . elements . push ( this . topRow . connection ) ) ; this . block _ . inputList . length && this . block _ . inputList [ 0 ] . type == Blockly . inputTypes . STATEMENT && ! this . block _ . isCollapsed ( ) ? this . topRow . minHeight = this . constants _ . TOP _ROW _PRECEDES _STATEMENT _MIN _HEIGHT : this . topRow . minHeight = this . constants _ . TOP _ROW _MIN _HEIGHT ; c = this . topRow . hasRightSquareCorner ( this . block _ ) ?
Blockly . blockRendering . SquareCorner : Blockly . blockRendering . RoundCorner ; this . topRow . elements . push ( new c ( this . constants _ , "right" ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . RenderInfo . prototype . populateBottomRow _ = function ( ) { this . bottomRow . hasNextConnection = ! ! this . block _ . nextConnection ; this . bottomRow . minHeight = this . block _ . inputList . length && this . block _ . inputList [ this . block _ . inputList . length - 1 ] . type == Blockly . inputTypes . STATEMENT ? this . constants _ . BOTTOM _ROW _AFTER _STATEMENT _MIN _HEIGHT : this . constants _ . BOTTOM _ROW _MIN _HEIGHT ; this . bottomRow . hasLeftSquareCorner ( this . block _ ) ? this . bottomRow . elements . push ( new Blockly . blockRendering . SquareCorner ( this . constants _ ) ) :
2021-01-16 14:07:51 +00:00
this . bottomRow . elements . push ( new Blockly . blockRendering . RoundCorner ( this . constants _ ) ) ; this . bottomRow . hasNextConnection && ( this . bottomRow . connection = new Blockly . blockRendering . NextConnection ( this . constants _ , this . block _ . nextConnection ) , this . bottomRow . elements . push ( this . bottomRow . connection ) ) ; this . bottomRow . hasRightSquareCorner ( this . block _ ) ? this . bottomRow . elements . push ( new Blockly . blockRendering . SquareCorner ( this . constants _ , "right" ) ) : this . bottomRow . elements . push ( new Blockly . blockRendering . RoundCorner ( this . constants _ ,
"right" ) ) } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . RenderInfo . prototype . addInput _ = function ( a , b ) { this . isInline && a . type == Blockly . inputTypes . VALUE ? ( b . elements . push ( new Blockly . blockRendering . InlineInput ( this . constants _ , a ) ) , b . hasInlineInput = ! 0 ) : a . type == Blockly . inputTypes . STATEMENT ? ( b . elements . push ( new Blockly . blockRendering . StatementInput ( this . constants _ , a ) ) , b . hasStatement = ! 0 ) : a . type == Blockly . inputTypes . VALUE ? ( b . elements . push ( new Blockly . blockRendering . ExternalValueInput ( this . constants _ , a ) ) , b . hasExternalInput = ! 0 ) : a . type == Blockly . inputTypes . DUMMY &&
( b . minHeight = Math . max ( b . minHeight , a . getSourceBlock ( ) && a . getSourceBlock ( ) . isShadow ( ) ? this . constants _ . DUMMY _INPUT _SHADOW _MIN _HEIGHT : this . constants _ . DUMMY _INPUT _MIN _HEIGHT ) , b . hasDummyInput = ! 0 ) ; null == b . align && ( b . align = a . align ) } ; Blockly . blockRendering . RenderInfo . prototype . shouldStartNewRow _ = function ( a , b ) { return b ? a . type == Blockly . inputTypes . STATEMENT || b . type == Blockly . inputTypes . STATEMENT ? ! 0 : a . type == Blockly . inputTypes . VALUE || a . type == Blockly . inputTypes . DUMMY ? ! this . isInline : ! 1 : ! 1 } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . RenderInfo . prototype . addElemSpacing _ = function ( ) { for ( var a = 0 , b ; b = this . rows [ a ] ; a ++ ) { var c = b . elements ; b . elements = [ ] ; b . startsWithElemSpacer ( ) && b . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , this . getInRowSpacing _ ( null , c [ 0 ] ) ) ) ; if ( c . length ) { for ( var d = 0 ; d < c . length - 1 ; d ++ ) { b . elements . push ( c [ d ] ) ; var e = this . getInRowSpacing _ ( c [ d ] , c [ d + 1 ] ) ; b . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , e ) ) } b . elements . push ( c [ c . length - 1 ] ) ; b . endsWithElemSpacer ( ) &&
b . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , this . getInRowSpacing _ ( c [ c . length - 1 ] , null ) ) ) } } } ;
Blockly . blockRendering . RenderInfo . prototype . getInRowSpacing _ = function ( a , b ) { if ( ! a && b && Blockly . blockRendering . Types . isStatementInput ( b ) ) return this . constants _ . STATEMENT _INPUT _PADDING _LEFT ; if ( a && Blockly . blockRendering . Types . isInput ( a ) && ! b ) { if ( Blockly . blockRendering . Types . isExternalInput ( a ) ) return this . constants _ . NO _PADDING ; if ( Blockly . blockRendering . Types . isInlineInput ( a ) ) return this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isStatementInput ( a ) ) return this . constants _ . NO _PADDING } return a &&
Blockly . blockRendering . Types . isLeftSquareCorner ( a ) && b && ( Blockly . blockRendering . Types . isPreviousConnection ( b ) || Blockly . blockRendering . Types . isNextConnection ( b ) ) ? b . notchOffset : a && Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) && b && ( Blockly . blockRendering . Types . isPreviousConnection ( b ) || Blockly . blockRendering . Types . isNextConnection ( b ) ) ? b . notchOffset - this . constants _ . CORNER _RADIUS : this . constants _ . MEDIUM _PADDING } ;
Blockly . blockRendering . RenderInfo . prototype . computeBounds _ = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d = 0 , e ; e = this . rows [ d ] ; d ++ ) { e . measure ( ) ; b = Math . max ( b , e . width ) ; if ( e . hasStatement ) { var f = e . getLastInput ( ) ; a = Math . max ( a , e . width - f . width ) } c = Math . max ( c , e . widthWithConnectedBlocks ) } this . statementEdge = a ; this . width = b ; for ( d = 0 ; e = this . rows [ d ] ; d ++ ) e . hasStatement && ( e . statementEdge = this . statementEdge ) ; this . widthWithChildren = Math . max ( b , c ) ; this . outputConnection && ( this . startX = this . outputConnection . width , this . width += this . outputConnection . width ,
this . widthWithChildren += this . outputConnection . width ) } ; Blockly . blockRendering . RenderInfo . prototype . alignRowElements _ = function ( ) { for ( var a = 0 , b ; b = this . rows [ a ] ; a ++ ) if ( b . hasStatement ) this . alignStatementRow _ ( b ) ; else { var c = b . width ; c = this . getDesiredRowWidth _ ( b ) - c ; 0 < c && this . addAlignmentPadding _ ( b , c ) ; Blockly . blockRendering . Types . isTopOrBottomRow ( b ) && ( b . widthWithConnectedBlocks = b . width ) } } ; Blockly . blockRendering . RenderInfo . prototype . getDesiredRowWidth _ = function ( a ) { return this . width - this . startX } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . RenderInfo . prototype . addAlignmentPadding _ = function ( a , b ) { var c = a . getFirstSpacer ( ) , d = a . getLastSpacer ( ) ; if ( a . hasExternalInput || a . hasStatement ) a . widthWithConnectedBlocks += b ; a . align == Blockly . constants . ALIGN . LEFT ? d . width += b : a . align == Blockly . constants . ALIGN . CENTRE ? ( c . width += b / 2 , d . width += b / 2 ) : a . align == Blockly . constants . ALIGN . RIGHT ? c . width += b : d . width += b ; a . width += b } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . RenderInfo . prototype . alignStatementRow _ = function ( a ) { var b = a . getLastInput ( ) , c = a . width - b . width , d = this . statementEdge ; c = d - c ; 0 < c && this . addAlignmentPadding _ ( a , c ) ; c = a . width ; d = this . getDesiredRowWidth _ ( a ) ; b . width += d - c ; b . height = Math . max ( b . height , a . height ) ; a . width += d - c ; a . widthWithConnectedBlocks = Math . max ( a . width , this . statementEdge + a . connectedBlockWidths ) } ;
Blockly . blockRendering . RenderInfo . prototype . addRowSpacing _ = function ( ) { var a = this . rows ; this . rows = [ ] ; for ( var b = 0 ; b < a . length ; b ++ ) this . rows . push ( a [ b ] ) , b != a . length - 1 && this . rows . push ( this . makeSpacerRow _ ( a [ b ] , a [ b + 1 ] ) ) } ; Blockly . blockRendering . RenderInfo . prototype . makeSpacerRow _ = function ( a , b ) { var c = this . getSpacerRowHeight _ ( a , b ) , d = this . getSpacerRowWidth _ ( a , b ) ; c = new Blockly . blockRendering . SpacerRow ( this . constants _ , c , d ) ; a . hasStatement && ( c . followsStatement = ! 0 ) ; b . hasStatement && ( c . precedesStatement = ! 0 ) ; return c } ;
Blockly . blockRendering . RenderInfo . prototype . getSpacerRowWidth _ = function ( a , b ) { return this . width - this . startX } ; Blockly . blockRendering . RenderInfo . prototype . getSpacerRowHeight _ = function ( a , b ) { return this . constants _ . MEDIUM _PADDING } ;
Blockly . blockRendering . RenderInfo . prototype . getElemCenterline _ = function ( a , b ) { return Blockly . blockRendering . Types . isSpacer ( b ) ? a . yPos + b . height / 2 : Blockly . blockRendering . Types . isBottomRow ( a ) ? ( a = a . yPos + a . height - a . descenderHeight , Blockly . blockRendering . Types . isNextConnection ( b ) ? a + b . height / 2 : a - b . height / 2 ) : Blockly . blockRendering . Types . isTopRow ( a ) ? Blockly . blockRendering . Types . isHat ( b ) ? a . capline - b . height / 2 : a . capline + b . height / 2 : a . yPos + a . height / 2 } ;
Blockly . blockRendering . RenderInfo . prototype . recordElemPositions _ = function ( a ) { for ( var b = a . xPos , c = 0 , d ; d = a . elements [ c ] ; c ++ ) Blockly . blockRendering . Types . isSpacer ( d ) && ( d . height = a . height ) , d . xPos = b , d . centerline = this . getElemCenterline _ ( a , d ) , b += d . width } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . RenderInfo . prototype . finalize _ = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d ; d = this . rows [ c ] ; c ++ ) d . yPos = b , d . xPos = this . startX , b += d . height , a = Math . max ( a , d . widthWithConnectedBlocks ) , this . recordElemPositions _ ( d ) ; this . outputConnection && this . block _ . nextConnection && this . block _ . nextConnection . isConnected ( ) && ( a = Math . max ( a , this . block _ . nextConnection . targetBlock ( ) . getHeightWidth ( ) . width ) ) ; this . widthWithChildren = a + this . startX ; this . height = b ; this . startY = this . topRow . capline ; this . bottomRow . baseline = b - this . bottomRow . descenderHeight } ; Blockly . blockRendering . Debug = function ( a ) { this . debugElements _ = [ ] ; this . svgRoot _ = null ; this . constants _ = a } ; Blockly . blockRendering . Debug . config = { rowSpacers : ! 0 , elemSpacers : ! 0 , rows : ! 0 , elems : ! 0 , connections : ! 0 , blockBounds : ! 0 , connectedBlockBounds : ! 0 , render : ! 0 } ; Blockly . blockRendering . Debug . prototype . clearElems = function ( ) { for ( var a = 0 , b ; b = this . debugElements _ [ a ] ; a ++ ) Blockly . utils . dom . removeNode ( b ) ; this . debugElements _ = [ ] } ;
Blockly . blockRendering . Debug . prototype . drawSpacerRow = function ( a , b , c ) { if ( Blockly . blockRendering . Debug . config . rowSpacers ) { var d = Math . abs ( a . height ) , e = 0 > a . height ; e && ( b -= d ) ; this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "rowSpacerRect blockRenderDebug" , x : c ? - ( a . xPos + a . width ) : a . xPos , y : b , width : a . width , height : d , stroke : e ? "black" : "blue" , fill : "blue" , "fill-opacity" : "0.5" , "stroke-width" : "1px" } , this . svgRoot _ ) ) } } ;
Blockly . blockRendering . Debug . prototype . drawSpacerElem = function ( a , b , c ) { if ( Blockly . blockRendering . Debug . config . elemSpacers ) { b = Math . abs ( a . width ) ; var d = 0 > a . width , e = d ? a . xPos - b : a . xPos ; c && ( e = - ( e + b ) ) ; this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "elemSpacerRect blockRenderDebug" , x : e , y : a . centerline - a . height / 2 , width : b , height : a . height , stroke : "pink" , fill : d ? "black" : "pink" , "fill-opacity" : "0.5" , "stroke-width" : "1px" } , this . svgRoot _ ) ) } } ;
Blockly . blockRendering . Debug . prototype . drawRenderedElem = function ( a , b ) { if ( Blockly . blockRendering . Debug . config . elems ) { var c = a . xPos ; b && ( c = - ( c + a . width ) ) ; b = a . centerline - a . height / 2 ; this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "rowRenderingRect blockRenderDebug" , x : c , y : b , width : a . width , height : a . height , stroke : "black" , fill : "none" , "stroke-width" : "1px" } , this . svgRoot _ ) ) ; Blockly . blockRendering . Types . isField ( a ) && a . field instanceof Blockly . FieldLabel && this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT ,
{ "class" : "rowRenderingRect blockRenderDebug" , x : c , y : b + this . constants _ . FIELD _TEXT _BASELINE , width : a . width , height : "0.1px" , stroke : "red" , fill : "none" , "stroke-width" : "0.5px" } , this . svgRoot _ ) ) } Blockly . blockRendering . Types . isInput ( a ) && Blockly . blockRendering . Debug . config . connections && this . drawConnection ( a . connectionModel ) } ;
Blockly . blockRendering . Debug . prototype . drawConnection = function ( a ) { if ( Blockly . blockRendering . Debug . config . connections ) { if ( a . type == Blockly . connectionTypes . INPUT _VALUE ) { var b = 4 ; var c = "magenta" ; var d = "none" } else a . type == Blockly . connectionTypes . OUTPUT _VALUE ? ( b = 2 , d = c = "magenta" ) : a . type == Blockly . connectionTypes . NEXT _STATEMENT ? ( b = 4 , c = "goldenrod" , d = "none" ) : a . type == Blockly . connectionTypes . PREVIOUS _STATEMENT && ( b = 2 , d = c = "goldenrod" ) ; this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE ,
{ "class" : "blockRenderDebug" , cx : a . offsetInBlock _ . x , cy : a . offsetInBlock _ . y , r : b , fill : d , stroke : c } , this . svgRoot _ ) ) } } ;
Blockly . blockRendering . Debug . prototype . drawRenderedRow = function ( a , b , c ) { Blockly . blockRendering . Debug . config . rows && ( this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "elemRenderingRect blockRenderDebug" , x : c ? - ( a . xPos + a . width ) : a . xPos , y : a . yPos , width : a . width , height : a . height , stroke : "red" , fill : "none" , "stroke-width" : "1px" } , this . svgRoot _ ) ) , Blockly . blockRendering . Types . isTopOrBottomRow ( a ) || Blockly . blockRendering . Debug . config . connectedBlockBounds && this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT ,
{ "class" : "connectedBlockWidth blockRenderDebug" , x : c ? - ( a . xPos + a . widthWithConnectedBlocks ) : a . xPos , y : a . yPos , width : a . widthWithConnectedBlocks , height : a . height , stroke : this . randomColour _ , fill : "none" , "stroke-width" : "1px" , "stroke-dasharray" : "3,3" } , this . svgRoot _ ) ) ) } ;
Blockly . blockRendering . Debug . prototype . drawRowWithElements = function ( a , b , c ) { for ( var d = 0 , e = a . elements . length ; d < e ; d ++ ) { var f = a . elements [ d ] ; f ? Blockly . blockRendering . Types . isSpacer ( f ) ? this . drawSpacerElem ( f , a . height , c ) : this . drawRenderedElem ( f , c ) : console . warn ( "A row has an undefined or null element." , a , f ) } this . drawRenderedRow ( a , b , c ) } ;
Blockly . blockRendering . Debug . prototype . drawBoundingBox = function ( a ) { if ( Blockly . blockRendering . Debug . config . blockBounds ) { var b = a . RTL ? - a . width : 0 ; this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { "class" : "blockBoundingBox blockRenderDebug" , x : b , y : 0 , width : a . width , height : a . height , stroke : "black" , fill : "none" , "stroke-width" : "1px" , "stroke-dasharray" : "5,5" } , this . svgRoot _ ) ) ; Blockly . blockRendering . Debug . config . connectedBlockBounds && ( b = a . RTL ? - a . widthWithChildren : 0 , this . debugElements _ . push ( Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT ,
{ "class" : "blockRenderDebug" , x : b , y : 0 , width : a . widthWithChildren , height : a . height , stroke : "#DF57BC" , fill : "none" , "stroke-width" : "1px" , "stroke-dasharray" : "3,3" } , this . svgRoot _ ) ) ) } } ;
Blockly . blockRendering . Debug . prototype . drawDebug = function ( a , b ) { this . clearElems ( ) ; this . svgRoot _ = a . getSvgRoot ( ) ; this . randomColour _ = "#" + Math . floor ( 16777215 * Math . random ( ) ) . toString ( 16 ) ; for ( var c = 0 , d = 0 , e ; e = b . rows [ d ] ; d ++ ) Blockly . blockRendering . Types . isBetweenRowSpacer ( e ) ? this . drawSpacerRow ( e , c , b . RTL ) : this . drawRowWithElements ( e , c , b . RTL ) , c += e . height ; a . previousConnection && this . drawConnection ( a . previousConnection ) ; a . nextConnection && this . drawConnection ( a . nextConnection ) ; a . outputConnection && this . drawConnection ( a . outputConnection ) ;
b . rightSide && this . drawRenderedElem ( b . rightSide , b . RTL ) ; this . drawBoundingBox ( b ) ; this . drawRender ( a . pathObject . svgPath ) } ; Blockly . blockRendering . Debug . prototype . drawRender = function ( a ) { Blockly . blockRendering . Debug . config . render && ( a . setAttribute ( "filter" , "url(#" + this . constants _ . debugFilterId + ")" ) , setTimeout ( function ( ) { a . setAttribute ( "filter" , "" ) } , 100 ) ) } ; Blockly . blockRendering . Drawer = function ( a , b ) { this . block _ = a ; this . info _ = b ; this . topLeft _ = a . getRelativeToSurfaceXY ( ) ; this . inlinePath _ = this . outlinePath _ = "" ; this . constants _ = b . getRenderer ( ) . getConstants ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . Drawer . prototype . draw = function ( ) { this . hideHiddenIcons _ ( ) ; this . drawOutline _ ( ) ; this . drawInternals _ ( ) ; this . block _ . pathObject . setPath ( this . outlinePath _ + "\n" + this . inlinePath _ ) ; this . info _ . RTL && this . block _ . pathObject . flipRTL ( ) ; Blockly . blockRendering . useDebugger && this . block _ . renderingDebugger . drawDebug ( this . block _ , this . info _ ) ; this . recordSizeOnBlock _ ( ) } ; Blockly . blockRendering . Drawer . prototype . recordSizeOnBlock _ = function ( ) { this . block _ . height = this . info _ . height ; this . block _ . width = this . info _ . widthWithChildren } ;
Blockly . blockRendering . Drawer . prototype . hideHiddenIcons _ = function ( ) { for ( var a = 0 , b ; b = this . info _ . hiddenIcons [ a ] ; a ++ ) b . icon . iconGroup _ . setAttribute ( "display" , "none" ) } ; Blockly . blockRendering . Drawer . prototype . drawOutline _ = function ( ) { this . drawTop _ ( ) ; for ( var a = 1 ; a < this . info _ . rows . length - 1 ; a ++ ) { var b = this . info _ . rows [ a ] ; b . hasJaggedEdge ? this . drawJaggedEdge _ ( b ) : b . hasStatement ? this . drawStatementInput _ ( b ) : b . hasExternalInput ? this . drawValueInput _ ( b ) : this . drawRightSideRow _ ( b ) } this . drawBottom _ ( ) ; this . drawLeft _ ( ) } ;
Blockly . blockRendering . Drawer . prototype . drawTop _ = function ( ) { var a = this . info _ . topRow , b = a . elements ; this . positionPreviousConnection _ ( ) ; this . outlinePath _ += Blockly . utils . svgPaths . moveBy ( a . xPos , this . info _ . startY ) ; for ( var c = 0 , d ; d = b [ c ] ; c ++ ) Blockly . blockRendering . Types . isLeftRoundedCorner ( d ) ? this . outlinePath _ += this . constants _ . OUTSIDE _CORNERS . topLeft : Blockly . blockRendering . Types . isRightRoundedCorner ( d ) ? this . outlinePath _ += this . constants _ . OUTSIDE _CORNERS . topRight : Blockly . blockRendering . Types . isPreviousConnection ( d ) ?
this . outlinePath _ += d . shape . pathLeft : Blockly . blockRendering . Types . isHat ( d ) ? this . outlinePath _ += this . constants _ . START _HAT . path : Blockly . blockRendering . Types . isSpacer ( d ) && ( this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "h" , d . width ) ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "v" , a . height ) } ; Blockly . blockRendering . Drawer . prototype . drawJaggedEdge _ = function ( a ) { this . outlinePath _ += this . constants _ . JAGGED _TEETH . path + Blockly . utils . svgPaths . lineOnAxis ( "v" , a . height - this . constants _ . JAGGED _TEETH . height ) } ;
Blockly . blockRendering . Drawer . prototype . drawValueInput _ = function ( a ) { var b = a . getLastInput ( ) ; this . positionExternalValueConnection _ ( a ) ; var c = "function" == typeof b . shape . pathDown ? b . shape . pathDown ( b . height ) : b . shape . pathDown ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , b . xPos + b . width ) + c + Blockly . utils . svgPaths . lineOnAxis ( "v" , a . height - b . connectionHeight ) } ;
Blockly . blockRendering . Drawer . prototype . drawStatementInput _ = function ( a ) { var b = a . getLastInput ( ) , c = b . xPos + b . notchOffset + b . shape . width ; b = b . shape . pathRight + Blockly . utils . svgPaths . lineOnAxis ( "h" , - ( b . notchOffset - this . constants _ . INSIDE _CORNERS . width ) ) + this . constants _ . INSIDE _CORNERS . pathTop ; var d = a . height - 2 * this . constants _ . INSIDE _CORNERS . height ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , c ) + b + Blockly . utils . svgPaths . lineOnAxis ( "v" , d ) + this . constants _ . INSIDE _CORNERS . pathBottom + Blockly . utils . svgPaths . lineOnAxis ( "H" ,
a . xPos + a . width ) ; this . positionStatementInputConnection _ ( a ) } ; Blockly . blockRendering . Drawer . prototype . drawRightSideRow _ = function ( a ) { this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . yPos + a . height ) } ;
Blockly . blockRendering . Drawer . prototype . drawBottom _ = function ( ) { var a = this . info _ . bottomRow , b = a . elements ; this . positionNextConnection _ ( ) ; for ( var c = 0 , d = "" , e = b . length - 1 , f ; f = b [ e ] ; e -- ) Blockly . blockRendering . Types . isNextConnection ( f ) ? d += f . shape . pathRight : Blockly . blockRendering . Types . isLeftSquareCorner ( f ) ? d += Blockly . utils . svgPaths . lineOnAxis ( "H" , a . xPos ) : Blockly . blockRendering . Types . isLeftRoundedCorner ( f ) ? d += this . constants _ . OUTSIDE _CORNERS . bottomLeft : Blockly . blockRendering . Types . isRightRoundedCorner ( f ) ? ( d +=
this . constants _ . OUTSIDE _CORNERS . bottomRight , c = this . constants _ . OUTSIDE _CORNERS . rightHeight ) : Blockly . blockRendering . Types . isSpacer ( f ) && ( d += Blockly . utils . svgPaths . lineOnAxis ( "h" , - 1 * f . width ) ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . baseline - c ) ; this . outlinePath _ += d } ;
Blockly . blockRendering . Drawer . prototype . drawLeft _ = function ( ) { var a = this . info _ . outputConnection ; this . positionOutputConnection _ ( ) ; if ( a ) { var b = a . connectionOffsetY + a . height ; a = "function" == typeof a . shape . pathUp ? a . shape . pathUp ( a . height ) : a . shape . pathUp ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , b ) + a } this . outlinePath _ += "z" } ;
Blockly . blockRendering . Drawer . prototype . drawInternals _ = function ( ) { for ( var a = 0 , b ; b = this . info _ . rows [ a ] ; a ++ ) for ( var c = 0 , d ; d = b . elements [ c ] ; c ++ ) Blockly . blockRendering . Types . isInlineInput ( d ) ? this . drawInlineInput _ ( d ) : ( Blockly . blockRendering . Types . isIcon ( d ) || Blockly . blockRendering . Types . isField ( d ) ) && this . layoutField _ ( d ) } ;
Blockly . blockRendering . Drawer . prototype . layoutField _ = function ( a ) { if ( Blockly . blockRendering . Types . isField ( a ) ) var b = a . field . getSvgRoot ( ) ; else Blockly . blockRendering . Types . isIcon ( a ) && ( b = a . icon . iconGroup _ ) ; var c = a . centerline - a . height / 2 , d = a . xPos , e = "" ; this . info _ . RTL && ( d = - ( d + a . width ) , a . flipRtl && ( d += a . width , e = "scale(-1 1)" ) ) ; Blockly . blockRendering . Types . isIcon ( a ) ? ( b . setAttribute ( "display" , "block" ) , b . setAttribute ( "transform" , "translate(" + d + "," + c + ")" ) , a . icon . computeIconLocation ( ) ) : b . setAttribute ( "transform" ,
"translate(" + d + "," + c + ")" + e ) ; this . info _ . isInsertionMarker && b . setAttribute ( "display" , "none" ) } ;
Blockly . blockRendering . Drawer . prototype . drawInlineInput _ = function ( a ) { var b = a . width , c = a . height , d = a . connectionOffsetY , e = a . connectionHeight + d ; this . inlinePath _ += Blockly . utils . svgPaths . moveTo ( a . xPos + a . connectionWidth , a . centerline - c / 2 ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , d ) + a . shape . pathDown + Blockly . utils . svgPaths . lineOnAxis ( "v" , c - e ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , b - a . connectionWidth ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , - c ) + "z" ; this . positionInlineInputConnection _ ( a ) } ;
Blockly . blockRendering . Drawer . prototype . positionInlineInputConnection _ = function ( a ) { var b = a . centerline - a . height / 2 ; if ( a . connectionModel ) { var c = a . xPos + a . connectionWidth + a . connectionOffsetX ; this . info _ . RTL && ( c *= - 1 ) ; a . connectionModel . setOffsetInBlock ( c , b + a . connectionOffsetY ) } } ;
Blockly . blockRendering . Drawer . prototype . positionStatementInputConnection _ = function ( a ) { var b = a . getLastInput ( ) ; if ( b . connectionModel ) { var c = a . xPos + a . statementEdge + b . notchOffset ; this . info _ . RTL && ( c *= - 1 ) ; b . connectionModel . setOffsetInBlock ( c , a . yPos ) } } ; Blockly . blockRendering . Drawer . prototype . positionExternalValueConnection _ = function ( a ) { var b = a . getLastInput ( ) ; if ( b . connectionModel ) { var c = a . xPos + a . width ; this . info _ . RTL && ( c *= - 1 ) ; b . connectionModel . setOffsetInBlock ( c , a . yPos ) } } ;
Blockly . blockRendering . Drawer . prototype . positionPreviousConnection _ = function ( ) { var a = this . info _ . topRow ; if ( a . connection ) { var b = a . xPos + a . notchOffset ; a . connection . connectionModel . setOffsetInBlock ( this . info _ . RTL ? - b : b , 0 ) } } ; Blockly . blockRendering . Drawer . prototype . positionNextConnection _ = function ( ) { var a = this . info _ . bottomRow ; if ( a . connection ) { var b = a . connection , c = b . xPos ; b . connectionModel . setOffsetInBlock ( this . info _ . RTL ? - c : c , a . baseline ) } } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . Drawer . prototype . positionOutputConnection _ = function ( ) { if ( this . info _ . outputConnection ) { var a = this . info _ . startX + this . info _ . outputConnection . connectionOffsetX ; this . block _ . outputConnection . setOffsetInBlock ( this . info _ . RTL ? - a : a , this . info _ . outputConnection . connectionOffsetY ) } } ; Blockly . Events . MarkerMove = function ( a , b , c , d ) { var e = a ? a . workspace . id : void 0 ; d && d . getType ( ) == Blockly . ASTNode . types . WORKSPACE && ( e = d . getLocation ( ) . id ) ; Blockly . Events . MarkerMove . superClass _ . constructor . call ( this , e ) ; this . blockId = a ? a . id : null ; this . oldNode = c ; this . newNode = d ; this . isCursor = b } ; Blockly . utils . object . inherits ( Blockly . Events . MarkerMove , Blockly . Events . UiBase ) ; Blockly . Events . MarkerMove . prototype . type = Blockly . Events . MARKER _MOVE ;
Blockly . Events . MarkerMove . prototype . toJson = function ( ) { var a = Blockly . Events . MarkerMove . superClass _ . toJson . call ( this ) ; a . isCursor = this . isCursor ; a . blockId = this . blockId ; a . oldNode = this . oldNode ; a . newNode = this . newNode ; return a } ; Blockly . Events . MarkerMove . prototype . fromJson = function ( a ) { Blockly . Events . MarkerMove . superClass _ . fromJson . call ( this , a ) ; this . isCursor = a . isCursor ; this . blockId = a . blockId ; this . oldNode = a . oldNode ; this . newNode = a . newNode } ;
Blockly . registry . register ( Blockly . registry . Type . EVENT , Blockly . Events . MARKER _MOVE , Blockly . Events . MarkerMove ) ; Blockly . blockRendering . MarkerSvg = function ( a , b , c ) { this . workspace _ = a ; this . marker _ = c ; this . parent _ = null ; this . constants _ = b ; this . currentMarkerSvg = null ; a = this . isCursor ( ) ? this . constants _ . CURSOR _COLOUR : this . constants _ . MARKER _COLOUR ; this . colour _ = c . colour || a } ; Blockly . blockRendering . MarkerSvg . CURSOR _CLASS = "blocklyCursor" ; Blockly . blockRendering . MarkerSvg . MARKER _CLASS = "blocklyMarker" ; Blockly . blockRendering . MarkerSvg . HEIGHT _MULTIPLIER = . 75 ; Blockly . blockRendering . MarkerSvg . prototype . getSvgRoot = function ( ) { return this . svgGroup _ } ;
Blockly . blockRendering . MarkerSvg . prototype . getMarker = function ( ) { return this . marker _ } ; Blockly . blockRendering . MarkerSvg . prototype . isCursor = function ( ) { return "cursor" == this . marker _ . type } ; Blockly . blockRendering . MarkerSvg . prototype . createDom = function ( ) { var a = this . isCursor ( ) ? Blockly . blockRendering . MarkerSvg . CURSOR _CLASS : Blockly . blockRendering . MarkerSvg . MARKER _CLASS ; this . svgGroup _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { "class" : a } , null ) ; this . createDomInternal _ ( ) ; return this . svgGroup _ } ;
Blockly . blockRendering . MarkerSvg . prototype . setParent _ = function ( a ) { this . isCursor ( ) ? ( this . parent _ && this . parent _ . setCursorSvg ( null ) , a . setCursorSvg ( this . getSvgRoot ( ) ) ) : ( this . parent _ && this . parent _ . setMarkerSvg ( null ) , a . setMarkerSvg ( this . getSvgRoot ( ) ) ) ; this . parent _ = a } ;
Blockly . blockRendering . MarkerSvg . prototype . draw = function ( a , b ) { if ( b ) { this . constants _ = this . workspace _ . getRenderer ( ) . getConstants ( ) ; var c = this . isCursor ( ) ? this . constants _ . CURSOR _COLOUR : this . constants _ . MARKER _COLOUR ; this . colour _ = this . marker _ . colour || c ; this . applyColour _ ( b ) ; this . showAtLocation _ ( b ) ; this . fireMarkerEvent _ ( a , b ) ; a = this . currentMarkerSvg . childNodes [ 0 ] ; void 0 !== a && a . beginElement && a . beginElement ( ) } else this . hide ( ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showAtLocation _ = function ( a ) { var b = a . getLocation ( ) . type ; a . getType ( ) == Blockly . ASTNode . types . BLOCK ? this . showWithBlock _ ( a ) : a . getType ( ) == Blockly . ASTNode . types . OUTPUT ? this . showWithOutput _ ( a ) : b == Blockly . connectionTypes . INPUT _VALUE ? this . showWithInput _ ( a ) : b == Blockly . connectionTypes . NEXT _STATEMENT ? this . showWithNext _ ( a ) : a . getType ( ) == Blockly . ASTNode . types . PREVIOUS ? this . showWithPrevious _ ( a ) : a . getType ( ) == Blockly . ASTNode . types . FIELD ? this . showWithField _ ( a ) : a . getType ( ) ==
Blockly . ASTNode . types . WORKSPACE ? this . showWithCoordinates _ ( a ) : a . getType ( ) == Blockly . ASTNode . types . STACK && this . showWithStack _ ( a ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showWithBlockPrevOutput _ = function ( a ) { a = a . getSourceBlock ( ) ; var b = a . width , c = a . height , d = c * Blockly . blockRendering . MarkerSvg . HEIGHT _MULTIPLIER , e = this . constants _ . CURSOR _BLOCK _PADDING ; if ( a . previousConnection ) { var f = this . constants _ . shapeFor ( a . previousConnection ) ; this . positionPrevious _ ( b , e , d , f ) } else a . outputConnection ? ( f = this . constants _ . shapeFor ( a . outputConnection ) , this . positionOutput _ ( b , c , f ) ) : this . positionBlock _ ( b , e , d ) ; this . setParent _ ( a ) ; this . showCurrent _ ( ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showWithBlock _ = function ( a ) { this . showWithBlockPrevOutput _ ( a ) } ; Blockly . blockRendering . MarkerSvg . prototype . showWithPrevious _ = function ( a ) { this . showWithBlockPrevOutput _ ( a ) } ; Blockly . blockRendering . MarkerSvg . prototype . showWithOutput _ = function ( a ) { this . showWithBlockPrevOutput _ ( a ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showWithCoordinates _ = function ( a ) { var b = a . getWsCoordinate ( ) ; a = b . x ; b = b . y ; this . workspace _ . RTL && ( a -= this . constants _ . CURSOR _WS _WIDTH ) ; this . positionLine _ ( a , b , this . constants _ . CURSOR _WS _WIDTH ) ; this . setParent _ ( this . workspace _ ) ; this . showCurrent _ ( ) } ; Blockly . blockRendering . MarkerSvg . prototype . showWithField _ = function ( a ) { a = a . getLocation ( ) ; var b = a . getSize ( ) . width , c = a . getSize ( ) . height ; this . positionRect _ ( 0 , 0 , b , c ) ; this . setParent _ ( a ) ; this . showCurrent _ ( ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showWithInput _ = function ( a ) { a = a . getLocation ( ) ; var b = a . getSourceBlock ( ) ; this . positionInput _ ( a ) ; this . setParent _ ( b ) ; this . showCurrent _ ( ) } ; Blockly . blockRendering . MarkerSvg . prototype . showWithNext _ = function ( a ) { var b = a . getLocation ( ) ; a = b . getSourceBlock ( ) ; var c = 0 ; b = b . getOffsetInBlock ( ) . y ; var d = a . getHeightWidth ( ) . width ; this . workspace _ . RTL && ( c = - d ) ; this . positionLine _ ( c , b , d ) ; this . setParent _ ( a ) ; this . showCurrent _ ( ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showWithStack _ = function ( a ) { a = a . getLocation ( ) ; var b = a . getHeightWidth ( ) , c = b . width + this . constants _ . CURSOR _STACK _PADDING ; b = b . height + this . constants _ . CURSOR _STACK _PADDING ; var d = - this . constants _ . CURSOR _STACK _PADDING / 2 , e = - this . constants _ . CURSOR _STACK _PADDING / 2 , f = d ; this . workspace _ . RTL && ( f = - ( c + d ) ) ; this . positionRect _ ( f , e , c , b ) ; this . setParent _ ( a ) ; this . showCurrent _ ( ) } ;
Blockly . blockRendering . MarkerSvg . prototype . showCurrent _ = function ( ) { this . hide ( ) ; this . currentMarkerSvg . style . display = "" } ; Blockly . blockRendering . MarkerSvg . prototype . positionBlock _ = function ( a , b , c ) { a = Blockly . utils . svgPaths . moveBy ( - b , c ) + Blockly . utils . svgPaths . lineOnAxis ( "V" , - b ) + Blockly . utils . svgPaths . lineOnAxis ( "H" , a + 2 * b ) + Blockly . utils . svgPaths . lineOnAxis ( "V" , c ) ; this . markerBlock _ . setAttribute ( "d" , a ) ; this . workspace _ . RTL && this . flipRtl _ ( this . markerBlock _ ) ; this . currentMarkerSvg = this . markerBlock _ } ;
Blockly . blockRendering . MarkerSvg . prototype . positionInput _ = function ( a ) { var b = a . getOffsetInBlock ( ) . x , c = a . getOffsetInBlock ( ) . y ; a = Blockly . utils . svgPaths . moveTo ( 0 , 0 ) + this . constants _ . shapeFor ( a ) . pathDown ; this . markerInput _ . setAttribute ( "d" , a ) ; this . markerInput _ . setAttribute ( "transform" , "translate(" + b + "," + c + ")" + ( this . workspace _ . RTL ? " scale(-1 1)" : "" ) ) ; this . currentMarkerSvg = this . markerInput _ } ;
Blockly . blockRendering . MarkerSvg . prototype . positionLine _ = function ( a , b , c ) { this . markerSvgLine _ . setAttribute ( "x" , a ) ; this . markerSvgLine _ . setAttribute ( "y" , b ) ; this . markerSvgLine _ . setAttribute ( "width" , c ) ; this . currentMarkerSvg = this . markerSvgLine _ } ;
Blockly . blockRendering . MarkerSvg . prototype . positionOutput _ = function ( a , b , c ) { a = Blockly . utils . svgPaths . moveBy ( a , 0 ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , - ( a - c . width ) ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , this . constants _ . TAB _OFFSET _FROM _TOP ) + c . pathDown + Blockly . utils . svgPaths . lineOnAxis ( "V" , b ) + Blockly . utils . svgPaths . lineOnAxis ( "H" , a ) ; this . markerBlock _ . setAttribute ( "d" , a ) ; this . workspace _ . RTL && this . flipRtl _ ( this . markerBlock _ ) ; this . currentMarkerSvg = this . markerBlock _ } ;
Blockly . blockRendering . MarkerSvg . prototype . positionPrevious _ = function ( a , b , c , d ) { a = Blockly . utils . svgPaths . moveBy ( - b , c ) + Blockly . utils . svgPaths . lineOnAxis ( "V" , - b ) + Blockly . utils . svgPaths . lineOnAxis ( "H" , this . constants _ . NOTCH _OFFSET _LEFT ) + d . pathLeft + Blockly . utils . svgPaths . lineOnAxis ( "H" , a + 2 * b ) + Blockly . utils . svgPaths . lineOnAxis ( "V" , c ) ; this . markerBlock _ . setAttribute ( "d" , a ) ; this . workspace _ . RTL && this . flipRtl _ ( this . markerBlock _ ) ; this . currentMarkerSvg = this . markerBlock _ } ;
Blockly . blockRendering . MarkerSvg . prototype . positionRect _ = function ( a , b , c , d ) { this . markerSvgRect _ . setAttribute ( "x" , a ) ; this . markerSvgRect _ . setAttribute ( "y" , b ) ; this . markerSvgRect _ . setAttribute ( "width" , c ) ; this . markerSvgRect _ . setAttribute ( "height" , d ) ; this . currentMarkerSvg = this . markerSvgRect _ } ; Blockly . blockRendering . MarkerSvg . prototype . flipRtl _ = function ( a ) { a . setAttribute ( "transform" , "scale(-1 1)" ) } ;
Blockly . blockRendering . MarkerSvg . prototype . hide = function ( ) { this . markerSvgLine _ . style . display = "none" ; this . markerSvgRect _ . style . display = "none" ; this . markerInput _ . style . display = "none" ; this . markerBlock _ . style . display = "none" } ; Blockly . blockRendering . MarkerSvg . prototype . fireMarkerEvent _ = function ( a , b ) { var c = b . getSourceBlock ( ) ; a = new ( Blockly . Events . get ( Blockly . Events . MARKER _MOVE ) ) ( c , this . isCursor ( ) , a , b ) ; Blockly . Events . fire ( a ) } ;
Blockly . blockRendering . MarkerSvg . prototype . getBlinkProperties _ = function ( ) { return { attributeType : "XML" , attributeName : "fill" , dur : "1s" , values : this . colour _ + ";transparent;transparent;" , repeatCount : "indefinite" } } ;
Blockly . blockRendering . MarkerSvg . prototype . createDomInternal _ = function ( ) { this . markerSvg _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , { width : this . constants _ . CURSOR _WS _WIDTH , height : this . constants _ . WS _CURSOR _HEIGHT } , this . svgGroup _ ) ; this . markerSvgLine _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT , { width : this . constants _ . CURSOR _WS _WIDTH , height : this . constants _ . WS _CURSOR _HEIGHT , style : "display: none" } , this . markerSvg _ ) ; this . markerSvgRect _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . RECT ,
{ "class" : "blocklyVerticalMarker" , rx : 10 , ry : 10 , style : "display: none" } , this . markerSvg _ ) ; this . markerInput _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { transform : "" , style : "display: none" } , this . markerSvg _ ) ; this . markerBlock _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { transform : "" , style : "display: none" , fill : "none" , "stroke-width" : this . constants _ . CURSOR _STROKE _WIDTH } , this . markerSvg _ ) ; if ( this . isCursor ( ) ) { var a = this . getBlinkProperties _ ( ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . ANIMATE ,
a , this . markerSvgLine _ ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . ANIMATE , a , this . markerInput _ ) ; a . attributeName = "stroke" ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . ANIMATE , a , this . markerBlock _ ) } return this . markerSvg _ } ;
Blockly . blockRendering . MarkerSvg . prototype . applyColour _ = function ( a ) { this . markerSvgLine _ . setAttribute ( "fill" , this . colour _ ) ; this . markerSvgRect _ . setAttribute ( "stroke" , this . colour _ ) ; this . markerInput _ . setAttribute ( "fill" , this . colour _ ) ; this . markerBlock _ . setAttribute ( "stroke" , this . colour _ ) ; this . isCursor ( ) && ( a = this . colour _ + ";transparent;transparent;" , this . markerSvgLine _ . firstChild . setAttribute ( "values" , a ) , this . markerInput _ . firstChild . setAttribute ( "values" , a ) , this . markerBlock _ . firstChild . setAttribute ( "values" ,
a ) ) } ; Blockly . blockRendering . MarkerSvg . prototype . dispose = function ( ) { this . svgGroup _ && Blockly . utils . dom . removeNode ( this . svgGroup _ ) } ; Blockly . blockRendering . PathObject = function ( a , b , c ) { this . constants = c ; this . svgRoot = a ; this . svgPath = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyPath" } , this . svgRoot ) ; this . style = b ; this . markerSvg = this . cursorSvg = null } ; Blockly . blockRendering . PathObject . prototype . setPath = function ( a ) { this . svgPath . setAttribute ( "d" , a ) } ; Blockly . blockRendering . PathObject . prototype . flipRTL = function ( ) { this . svgPath . setAttribute ( "transform" , "scale(-1 1)" ) } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . PathObject . prototype . setCursorSvg = function ( a ) { a ? ( this . svgRoot . appendChild ( a ) , this . cursorSvg = a ) : this . cursorSvg = null } ; Blockly . blockRendering . PathObject . prototype . setMarkerSvg = function ( a ) { a ? ( this . cursorSvg ? this . svgRoot . insertBefore ( a , this . cursorSvg ) : this . svgRoot . appendChild ( a ) , this . markerSvg = a ) : this . markerSvg = null } ;
Blockly . blockRendering . PathObject . prototype . applyColour = function ( a ) { this . svgPath . setAttribute ( "stroke" , this . style . colourTertiary ) ; this . svgPath . setAttribute ( "fill" , this . style . colourPrimary ) ; this . updateShadow _ ( a . isShadow ( ) ) ; this . updateDisabled _ ( ! a . isEnabled ( ) || a . getInheritedDisabled ( ) ) } ; Blockly . blockRendering . PathObject . prototype . setStyle = function ( a ) { this . style = a } ;
Blockly . blockRendering . PathObject . prototype . setClass _ = function ( a , b ) { b ? Blockly . utils . dom . addClass ( this . svgRoot , a ) : Blockly . utils . dom . removeClass ( this . svgRoot , a ) } ; Blockly . blockRendering . PathObject . prototype . updateHighlighted = function ( a ) { a ? this . svgPath . setAttribute ( "filter" , "url(#" + this . constants . embossFilterId + ")" ) : this . svgPath . setAttribute ( "filter" , "none" ) } ;
Blockly . blockRendering . PathObject . prototype . updateShadow _ = function ( a ) { a && ( this . svgPath . setAttribute ( "stroke" , "none" ) , this . svgPath . setAttribute ( "fill" , this . style . colourSecondary ) ) } ; Blockly . blockRendering . PathObject . prototype . updateDisabled _ = function ( a ) { this . setClass _ ( "blocklyDisabled" , a ) ; a && this . svgPath . setAttribute ( "fill" , "url(#" + this . constants . disabledPatternId + ")" ) } ; Blockly . blockRendering . PathObject . prototype . updateSelected = function ( a ) { this . setClass _ ( "blocklySelected" , a ) } ;
Blockly . blockRendering . PathObject . prototype . updateDraggingDelete = function ( a ) { this . setClass _ ( "blocklyDraggingDelete" , a ) } ; Blockly . blockRendering . PathObject . prototype . updateInsertionMarker = function ( a ) { this . setClass _ ( "blocklyInsertionMarker" , a ) } ; Blockly . blockRendering . PathObject . prototype . updateMovable = function ( a ) { this . setClass _ ( "blocklyDraggable" , a ) } ; Blockly . blockRendering . PathObject . prototype . updateReplacementFade = function ( a ) { this . setClass _ ( "blocklyReplaceable" , a ) } ;
2021-09-18 14:29:06 +00:00
Blockly . blockRendering . PathObject . prototype . updateShapeForInputHighlight = function ( a , b ) { } ; Blockly . blockRendering . Renderer = function ( a ) { this . name = a ; this . overrides = this . constants _ = null } ; Blockly . blockRendering . Renderer . prototype . getClassName = function ( ) { return this . name + "-renderer" } ; Blockly . blockRendering . Renderer . prototype . init = function ( a , b ) { this . constants _ = this . makeConstants _ ( ) ; b && ( this . overrides = b , Blockly . utils . object . mixin ( this . constants _ , b ) ) ; this . constants _ . setTheme ( a ) ; this . constants _ . init ( ) } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . Renderer . prototype . createDom = function ( a , b ) { this . constants _ . createDom ( a , this . name + "-" + b . name , "." + this . getClassName ( ) + "." + b . getClassName ( ) ) } ; Blockly . blockRendering . Renderer . prototype . refreshDom = function ( a , b ) { var c = this . getConstants ( ) ; c . dispose ( ) ; this . constants _ = this . makeConstants _ ( ) ; this . overrides && Blockly . utils . object . mixin ( this . constants _ , this . overrides ) ; this . constants _ . randomIdentifier = c . randomIdentifier ; this . constants _ . setTheme ( b ) ; this . constants _ . init ( ) ; this . createDom ( a , b ) } ;
Blockly . blockRendering . Renderer . prototype . dispose = function ( ) { this . constants _ && this . constants _ . dispose ( ) } ; Blockly . blockRendering . Renderer . prototype . makeConstants _ = function ( ) { return new Blockly . blockRendering . ConstantProvider } ; Blockly . blockRendering . Renderer . prototype . makeRenderInfo _ = function ( a ) { return new Blockly . blockRendering . RenderInfo ( this , a ) } ; Blockly . blockRendering . Renderer . prototype . makeDrawer _ = function ( a , b ) { return new Blockly . blockRendering . Drawer ( a , b ) } ;
Blockly . blockRendering . Renderer . prototype . makeDebugger _ = function ( ) { if ( ! Blockly . blockRendering . Debug ) throw Error ( "Missing require for Blockly.blockRendering.Debug" ) ; return new Blockly . blockRendering . Debug ( this . getConstants ( ) ) } ; Blockly . blockRendering . Renderer . prototype . makeMarkerDrawer = function ( a , b ) { return new Blockly . blockRendering . MarkerSvg ( a , this . getConstants ( ) , b ) } ; Blockly . blockRendering . Renderer . prototype . makePathObject = function ( a , b ) { return new Blockly . blockRendering . PathObject ( a , b , this . constants _ ) } ;
2021-09-18 14:29:06 +00:00
Blockly . blockRendering . Renderer . prototype . getConstants = function ( ) { return this . constants _ } ; Blockly . blockRendering . Renderer . prototype . shouldHighlightConnection = function ( a ) { return ! 0 } ; Blockly . blockRendering . Renderer . prototype . orphanCanConnectAtEnd = function ( a , b , c ) { return ! ! Blockly . Connection . getConnectionForOrphanedConnection ( a , c === Blockly . connectionTypes . OUTPUT _VALUE ? b . outputConnection : b . previousConnection ) } ;
2021-05-19 13:38:55 +00:00
Blockly . blockRendering . Renderer . prototype . getConnectionPreviewMethod = function ( a , b , c ) { return b . type == Blockly . connectionTypes . OUTPUT _VALUE || b . type == Blockly . connectionTypes . PREVIOUS _STATEMENT ? ! a . isConnected ( ) || this . orphanCanConnectAtEnd ( c , a . targetBlock ( ) , b . type ) ? Blockly . InsertionMarkerManager . PREVIEW _TYPE . INSERTION _MARKER : Blockly . InsertionMarkerManager . PREVIEW _TYPE . REPLACEMENT _FADE : Blockly . InsertionMarkerManager . PREVIEW _TYPE . INSERTION _MARKER } ;
2021-01-16 14:07:51 +00:00
Blockly . blockRendering . Renderer . prototype . render = function ( a ) { Blockly . blockRendering . useDebugger && ! a . renderingDebugger && ( a . renderingDebugger = this . makeDebugger _ ( ) ) ; var b = this . makeRenderInfo _ ( a ) ; b . measure ( ) ; this . makeDrawer _ ( a , b ) . draw ( ) } ; Blockly . geras = { } ; Blockly . geras . ConstantProvider = function ( ) { Blockly . geras . ConstantProvider . superClass _ . constructor . call ( this ) ; this . FIELD _TEXT _BASELINE _CENTER = ! 1 ; this . DARK _PATH _OFFSET = 1 ; this . MAX _BOTTOM _WIDTH = 30 ; this . STATEMENT _BOTTOM _SPACER = - this . NOTCH _HEIGHT / 2 } ; Blockly . utils . object . inherits ( Blockly . geras . ConstantProvider , Blockly . blockRendering . ConstantProvider ) ;
Blockly . geras . ConstantProvider . prototype . getCSS _ = function ( a ) { return Blockly . geras . ConstantProvider . superClass _ . getCSS _ . call ( this , a ) . concat ( [ a + " .blocklyInsertionMarker>.blocklyPathLight," , a + " .blocklyInsertionMarker>.blocklyPathDark {" , "fill-opacity: " + this . INSERTION _MARKER _OPACITY + ";" , "stroke: none;" , "}" ] ) } ; Blockly . geras . Highlighter = function ( a ) { this . info _ = a ; this . inlineSteps _ = this . steps _ = "" ; this . RTL _ = this . info _ . RTL ; a = a . getRenderer ( ) ; this . constants _ = a . getConstants ( ) ; this . highlightConstants _ = a . getHighlightConstants ( ) ; this . highlightOffset _ = this . highlightConstants _ . OFFSET ; this . outsideCornerPaths _ = this . highlightConstants _ . OUTSIDE _CORNER ; this . insideCornerPaths _ = this . highlightConstants _ . INSIDE _CORNER ; this . puzzleTabPaths _ = this . highlightConstants _ . PUZZLE _TAB ; this . notchPaths _ = this . highlightConstants _ . NOTCH ; this . startPaths _ =
this . highlightConstants _ . START _HAT ; this . jaggedTeethPaths _ = this . highlightConstants _ . JAGGED _TEETH } ; Blockly . geras . Highlighter . prototype . getPath = function ( ) { return this . steps _ + "\n" + this . inlineSteps _ } ;
Blockly . geras . Highlighter . prototype . drawTopCorner = function ( a ) { this . steps _ += Blockly . utils . svgPaths . moveBy ( a . xPos , this . info _ . startY ) ; for ( var b = 0 , c ; c = a . elements [ b ] ; b ++ ) Blockly . blockRendering . Types . isLeftSquareCorner ( c ) ? this . steps _ += this . highlightConstants _ . START _POINT : Blockly . blockRendering . Types . isLeftRoundedCorner ( c ) ? this . steps _ += this . outsideCornerPaths _ . topLeft ( this . RTL _ ) : Blockly . blockRendering . Types . isPreviousConnection ( c ) ? this . steps _ += this . notchPaths _ . pathLeft : Blockly . blockRendering . Types . isHat ( c ) ?
this . steps _ += this . startPaths _ . path ( this . RTL _ ) : Blockly . blockRendering . Types . isSpacer ( c ) && 0 != c . width && ( this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , c . xPos + c . width - this . highlightOffset _ ) ) ; this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , a . xPos + a . width - this . highlightOffset _ ) } ; Blockly . geras . Highlighter . prototype . drawJaggedEdge _ = function ( a ) { this . info _ . RTL && ( this . steps _ += this . jaggedTeethPaths _ . pathLeft + Blockly . utils . svgPaths . lineOnAxis ( "v" , a . height - this . jaggedTeethPaths _ . height - this . highlightOffset _ ) ) } ;
Blockly . geras . Highlighter . prototype . drawValueInput = function ( a ) { var b = a . getLastInput ( ) ; if ( this . RTL _ ) { var c = a . height - b . connectionHeight ; this . steps _ += Blockly . utils . svgPaths . moveTo ( b . xPos + b . width - this . highlightOffset _ , a . yPos ) + this . puzzleTabPaths _ . pathDown ( this . RTL _ ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , c ) } else this . steps _ += Blockly . utils . svgPaths . moveTo ( b . xPos + b . width , a . yPos ) + this . puzzleTabPaths _ . pathDown ( this . RTL _ ) } ;
Blockly . geras . Highlighter . prototype . drawStatementInput = function ( a ) { var b = a . getLastInput ( ) ; if ( this . RTL _ ) { var c = a . height - 2 * this . insideCornerPaths _ . height ; this . steps _ += Blockly . utils . svgPaths . moveTo ( b . xPos , a . yPos ) + this . insideCornerPaths _ . pathTop ( this . RTL _ ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , c ) + this . insideCornerPaths _ . pathBottom ( this . RTL _ ) + Blockly . utils . svgPaths . lineTo ( a . width - b . xPos - this . insideCornerPaths _ . width , 0 ) } else this . steps _ += Blockly . utils . svgPaths . moveTo ( b . xPos , a . yPos + a . height ) + this . insideCornerPaths _ . pathBottom ( this . RTL _ ) +
Blockly . utils . svgPaths . lineTo ( a . width - b . xPos - this . insideCornerPaths _ . width , 0 ) } ; Blockly . geras . Highlighter . prototype . drawRightSideRow = function ( a ) { var b = a . xPos + a . width - this . highlightOffset _ ; a . followsStatement && ( this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , b ) ) ; this . RTL _ && ( this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , b ) , a . height > this . highlightOffset _ && ( this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . yPos + a . height - this . highlightOffset _ ) ) ) } ;
Blockly . geras . Highlighter . prototype . drawBottomRow = function ( a ) { if ( this . RTL _ ) this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . baseline - this . highlightOffset _ ) ; else { var b = this . info _ . bottomRow . elements [ 0 ] ; Blockly . blockRendering . Types . isLeftSquareCorner ( b ) ? this . steps _ += Blockly . utils . svgPaths . moveTo ( a . xPos + this . highlightOffset _ , a . baseline - this . highlightOffset _ ) : Blockly . blockRendering . Types . isLeftRoundedCorner ( b ) && ( this . steps _ += Blockly . utils . svgPaths . moveTo ( a . xPos , a . baseline ) , this . steps _ += this . outsideCornerPaths _ . bottomLeft ( ) ) } } ;
Blockly . geras . Highlighter . prototype . drawLeft = function ( ) { var a = this . info _ . outputConnection ; a && ( a = a . connectionOffsetY + a . height , this . RTL _ ? this . steps _ += Blockly . utils . svgPaths . moveTo ( this . info _ . startX , a ) : ( this . steps _ += Blockly . utils . svgPaths . moveTo ( this . info _ . startX + this . highlightOffset _ , this . info _ . bottomRow . baseline - this . highlightOffset _ ) , this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a ) ) , this . steps _ += this . puzzleTabPaths _ . pathUp ( this . RTL _ ) ) ; this . RTL _ || ( a = this . info _ . topRow , Blockly . blockRendering . Types . isLeftRoundedCorner ( a . elements [ 0 ] ) ?
this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , this . outsideCornerPaths _ . height ) : this . steps _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . capline + this . highlightOffset _ ) ) } ;
Blockly . geras . Highlighter . prototype . drawInlineInput = function ( a ) { var b = this . highlightOffset _ , c = a . xPos + a . connectionWidth , d = a . centerline - a . height / 2 , e = a . width - a . connectionWidth , f = d + b ; this . RTL _ ? ( d = a . connectionOffsetY - b , a = a . height - ( a . connectionOffsetY + a . connectionHeight ) + b , this . inlineSteps _ += Blockly . utils . svgPaths . moveTo ( c - b , f ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , d ) + this . puzzleTabPaths _ . pathDown ( this . RTL _ ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , a ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , e ) ) : this . inlineSteps _ +=
Blockly . utils . svgPaths . moveTo ( a . xPos + a . width + b , f ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , a . height ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , - e ) + Blockly . utils . svgPaths . moveTo ( c , d + a . connectionOffsetY ) + this . puzzleTabPaths _ . pathDown ( this . RTL _ ) } ; Blockly . geras . InlineInput = function ( a , b ) { Blockly . geras . InlineInput . superClass _ . constructor . call ( this , a , b ) ; this . connectedBlock && ( this . width += this . constants _ . DARK _PATH _OFFSET , this . height += this . constants _ . DARK _PATH _OFFSET ) } ; Blockly . utils . object . inherits ( Blockly . geras . InlineInput , Blockly . blockRendering . InlineInput ) ; Blockly . geras . StatementInput = function ( a , b ) { Blockly . geras . StatementInput . superClass _ . constructor . call ( this , a , b ) ; this . connectedBlock && ( this . height += this . constants _ . DARK _PATH _OFFSET ) } ;
Blockly . utils . object . inherits ( Blockly . geras . StatementInput , Blockly . blockRendering . StatementInput ) ; Blockly . geras . RenderInfo = function ( a , b ) { Blockly . geras . RenderInfo . superClass _ . constructor . call ( this , a , b ) } ; Blockly . utils . object . inherits ( Blockly . geras . RenderInfo , Blockly . blockRendering . RenderInfo ) ; Blockly . geras . RenderInfo . prototype . getRenderer = function ( ) { return this . renderer _ } ;
2021-05-19 13:38:55 +00:00
Blockly . geras . RenderInfo . prototype . populateBottomRow _ = function ( ) { Blockly . geras . RenderInfo . superClass _ . populateBottomRow _ . call ( this ) ; this . block _ . inputList . length && this . block _ . inputList [ this . block _ . inputList . length - 1 ] . type == Blockly . inputTypes . STATEMENT || ( this . bottomRow . minHeight = this . constants _ . MEDIUM _PADDING - this . constants _ . DARK _PATH _OFFSET ) } ;
Blockly . geras . RenderInfo . prototype . addInput _ = function ( a , b ) { this . isInline && a . type == Blockly . inputTypes . VALUE ? ( b . elements . push ( new Blockly . geras . InlineInput ( this . constants _ , a ) ) , b . hasInlineInput = ! 0 ) : a . type == Blockly . inputTypes . STATEMENT ? ( b . elements . push ( new Blockly . geras . StatementInput ( this . constants _ , a ) ) , b . hasStatement = ! 0 ) : a . type == Blockly . inputTypes . VALUE ? ( b . elements . push ( new Blockly . blockRendering . ExternalValueInput ( this . constants _ , a ) ) , b . hasExternalInput = ! 0 ) : a . type == Blockly . inputTypes . DUMMY && ( b . minHeight =
Math . max ( b . minHeight , this . constants _ . DUMMY _INPUT _MIN _HEIGHT ) , b . hasDummyInput = ! 0 ) ; this . isInline || null != b . align || ( b . align = a . align ) } ;
2021-01-16 14:07:51 +00:00
Blockly . geras . RenderInfo . prototype . addElemSpacing _ = function ( ) { for ( var a = ! 1 , b = 0 , c ; c = this . rows [ b ] ; b ++ ) c . hasExternalInput && ( a = ! 0 ) ; for ( b = 0 ; c = this . rows [ b ] ; b ++ ) { var d = c . elements ; c . elements = [ ] ; c . startsWithElemSpacer ( ) && c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , this . getInRowSpacing _ ( null , d [ 0 ] ) ) ) ; if ( d . length ) { for ( var e = 0 ; e < d . length - 1 ; e ++ ) { c . elements . push ( d [ e ] ) ; var f = this . getInRowSpacing _ ( d [ e ] , d [ e + 1 ] ) ; c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , f ) ) } c . elements . push ( d [ d . length -
1 ] ) ; c . endsWithElemSpacer ( ) && ( f = this . getInRowSpacing _ ( d [ d . length - 1 ] , null ) , a && c . hasDummyInput && ( f += this . constants _ . TAB _WIDTH ) , c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , f ) ) ) } } } ;
Blockly . geras . RenderInfo . prototype . getInRowSpacing _ = function ( a , b ) { if ( ! a ) return b && Blockly . blockRendering . Types . isField ( b ) && b . isEditable ? this . constants _ . MEDIUM _PADDING : b && Blockly . blockRendering . Types . isInlineInput ( b ) ? this . constants _ . MEDIUM _LARGE _PADDING : b && Blockly . blockRendering . Types . isStatementInput ( b ) ? this . constants _ . STATEMENT _INPUT _PADDING _LEFT : this . constants _ . LARGE _PADDING ; if ( ! Blockly . blockRendering . Types . isInput ( a ) && ( ! b || Blockly . blockRendering . Types . isStatementInput ( b ) ) ) return Blockly . blockRendering . Types . isField ( a ) &&
a . isEditable ? this . constants _ . MEDIUM _PADDING : Blockly . blockRendering . Types . isIcon ( a ) ? 2 * this . constants _ . LARGE _PADDING + 1 : Blockly . blockRendering . Types . isHat ( a ) ? this . constants _ . NO _PADDING : Blockly . blockRendering . Types . isPreviousOrNextConnection ( a ) ? this . constants _ . LARGE _PADDING : Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) ? this . constants _ . MIN _BLOCK _WIDTH : Blockly . blockRendering . Types . isJaggedEdge ( a ) ? this . constants _ . NO _PADDING : this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isInput ( a ) &&
! b ) { if ( Blockly . blockRendering . Types . isExternalInput ( a ) ) return this . constants _ . NO _PADDING ; if ( Blockly . blockRendering . Types . isInlineInput ( a ) ) return this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isStatementInput ( a ) ) return this . constants _ . NO _PADDING } if ( ! Blockly . blockRendering . Types . isInput ( a ) && b && Blockly . blockRendering . Types . isInput ( b ) ) { if ( Blockly . blockRendering . Types . isField ( a ) && a . isEditable ) { if ( Blockly . blockRendering . Types . isInlineInput ( b ) || Blockly . blockRendering . Types . isExternalInput ( b ) ) return this . constants _ . SMALL _PADDING } else { if ( Blockly . blockRendering . Types . isInlineInput ( b ) ||
Blockly . blockRendering . Types . isExternalInput ( b ) ) return this . constants _ . MEDIUM _LARGE _PADDING ; if ( Blockly . blockRendering . Types . isStatementInput ( b ) ) return this . constants _ . LARGE _PADDING } return this . constants _ . LARGE _PADDING - 1 } if ( Blockly . blockRendering . Types . isIcon ( a ) && b && ! Blockly . blockRendering . Types . isInput ( b ) ) return this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isInlineInput ( a ) && b && Blockly . blockRendering . Types . isField ( b ) ) return b . isEditable ? this . constants _ . MEDIUM _PADDING : this . constants _ . LARGE _PADDING ;
if ( Blockly . blockRendering . Types . isLeftSquareCorner ( a ) && b ) { if ( Blockly . blockRendering . Types . isHat ( b ) ) return this . constants _ . NO _PADDING ; if ( Blockly . blockRendering . Types . isPreviousConnection ( b ) ) return b . notchOffset ; if ( Blockly . blockRendering . Types . isNextConnection ( b ) ) return a = ( this . RTL ? 1 : - 1 ) * this . constants _ . DARK _PATH _OFFSET / 2 , b . notchOffset + a } if ( Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) && b ) { if ( Blockly . blockRendering . Types . isPreviousConnection ( b ) ) return b . notchOffset - this . constants _ . CORNER _RADIUS ;
if ( Blockly . blockRendering . Types . isNextConnection ( b ) ) return a = ( this . RTL ? 1 : - 1 ) * this . constants _ . DARK _PATH _OFFSET / 2 , b . notchOffset - this . constants _ . CORNER _RADIUS + a } return Blockly . blockRendering . Types . isField ( a ) && b && Blockly . blockRendering . Types . isField ( b ) && a . isEditable == b . isEditable || b && Blockly . blockRendering . Types . isJaggedEdge ( b ) ? this . constants _ . LARGE _PADDING : this . constants _ . MEDIUM _PADDING } ;
Blockly . geras . RenderInfo . prototype . getSpacerRowHeight _ = function ( a , b ) { return Blockly . blockRendering . Types . isTopRow ( a ) && Blockly . blockRendering . Types . isBottomRow ( b ) ? this . constants _ . EMPTY _BLOCK _SPACER _HEIGHT : Blockly . blockRendering . Types . isTopRow ( a ) || Blockly . blockRendering . Types . isBottomRow ( b ) ? this . constants _ . NO _PADDING : a . hasExternalInput && b . hasExternalInput ? this . constants _ . LARGE _PADDING : ! a . hasStatement && b . hasStatement ? this . constants _ . BETWEEN _STATEMENT _PADDING _Y : a . hasStatement && b . hasStatement || ! a . hasStatement &&
b . hasDummyInput || a . hasDummyInput ? this . constants _ . LARGE _PADDING : this . constants _ . MEDIUM _PADDING } ;
Blockly . geras . RenderInfo . prototype . getElemCenterline _ = function ( a , b ) { if ( Blockly . blockRendering . Types . isSpacer ( b ) ) return a . yPos + b . height / 2 ; if ( Blockly . blockRendering . Types . isBottomRow ( a ) ) return a = a . yPos + a . height - a . descenderHeight , Blockly . blockRendering . Types . isNextConnection ( b ) ? a + b . height / 2 : a - b . height / 2 ; if ( Blockly . blockRendering . Types . isTopRow ( a ) ) return Blockly . blockRendering . Types . isHat ( b ) ? a . capline - b . height / 2 : a . capline + b . height / 2 ; var c = a . yPos ; Blockly . blockRendering . Types . isField ( b ) || Blockly . blockRendering . Types . isIcon ( b ) ?
( c += b . height / 2 , ( a . hasInlineInput || a . hasStatement ) && b . height + this . constants _ . TALL _INPUT _FIELD _OFFSET _Y <= a . height && ( c += this . constants _ . TALL _INPUT _FIELD _OFFSET _Y ) ) : c = Blockly . blockRendering . Types . isInlineInput ( b ) ? c + b . height / 2 : c + a . height / 2 ; return c } ;
Blockly . geras . RenderInfo . prototype . alignRowElements _ = function ( ) { if ( this . isInline ) { for ( var a = 0 , b = null , c = this . rows . length - 1 , d ; d = this . rows [ c ] ; c -- ) d . nextRightEdge = a , Blockly . blockRendering . Types . isInputRow ( d ) && ( d . hasStatement && this . alignStatementRow _ ( d ) , b && b . hasStatement && d . width < b . width ? d . nextRightEdge = b . width : a = d . width , b = d ) ; for ( c = a = 0 ; d = this . rows [ c ] ; c ++ ) d . hasStatement ? a = this . getDesiredRowWidth _ ( d ) : Blockly . blockRendering . Types . isSpacer ( d ) ? d . width = Math . max ( a , d . nextRightEdge ) : ( a = Math . max ( a , d . nextRightEdge ) -
d . width , 0 < a && this . addAlignmentPadding _ ( d , a ) , a = d . width ) } else Blockly . geras . RenderInfo . superClass _ . alignRowElements _ . call ( this ) } ; Blockly . geras . RenderInfo . prototype . getDesiredRowWidth _ = function ( a ) { return this . isInline && a . hasStatement ? this . statementEdge + this . constants _ . MAX _BOTTOM _WIDTH + this . startX : Blockly . geras . RenderInfo . superClass _ . getDesiredRowWidth _ . call ( this , a ) } ;
Blockly . geras . RenderInfo . prototype . finalize _ = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d ; d = this . rows [ c ] ; c ++ ) { d . yPos = b ; d . xPos = this . startX ; b += d . height ; a = Math . max ( a , d . widthWithConnectedBlocks ) ; var e = b - this . topRow . ascenderHeight ; d == this . bottomRow && e < this . constants _ . MIN _BLOCK _HEIGHT && ( e = this . constants _ . MIN _BLOCK _HEIGHT - e , this . bottomRow . height += e , b += e ) ; this . recordElemPositions _ ( d ) } this . outputConnection && this . block _ . nextConnection && this . block _ . nextConnection . isConnected ( ) && ( a = Math . max ( a , this . block _ . nextConnection . targetBlock ( ) . getHeightWidth ( ) . width -
this . constants _ . DARK _PATH _OFFSET ) ) ; this . bottomRow . baseline = b - this . bottomRow . descenderHeight ; this . widthWithChildren = a + this . startX + this . constants _ . DARK _PATH _OFFSET ; this . width += this . constants _ . DARK _PATH _OFFSET ; this . height = b + this . constants _ . DARK _PATH _OFFSET ; this . startY = this . topRow . capline } ; Blockly . geras . Drawer = function ( a , b ) { Blockly . geras . Drawer . superClass _ . constructor . call ( this , a , b ) ; this . highlighter _ = new Blockly . geras . Highlighter ( b ) } ; Blockly . utils . object . inherits ( Blockly . geras . Drawer , Blockly . blockRendering . Drawer ) ;
Blockly . geras . Drawer . prototype . draw = function ( ) { this . hideHiddenIcons _ ( ) ; this . drawOutline _ ( ) ; this . drawInternals _ ( ) ; var a = this . block _ . pathObject ; a . setPath ( this . outlinePath _ + "\n" + this . inlinePath _ ) ; a . setHighlightPath ( this . highlighter _ . getPath ( ) ) ; this . info _ . RTL && a . flipRTL ( ) ; Blockly . blockRendering . useDebugger && this . block _ . renderingDebugger . drawDebug ( this . block _ , this . info _ ) ; this . recordSizeOnBlock _ ( ) } ;
Blockly . geras . Drawer . prototype . drawTop _ = function ( ) { this . highlighter _ . drawTopCorner ( this . info _ . topRow ) ; this . highlighter _ . drawRightSideRow ( this . info _ . topRow ) ; Blockly . geras . Drawer . superClass _ . drawTop _ . call ( this ) } ; Blockly . geras . Drawer . prototype . drawJaggedEdge _ = function ( a ) { this . highlighter _ . drawJaggedEdge _ ( a ) ; Blockly . geras . Drawer . superClass _ . drawJaggedEdge _ . call ( this , a ) } ;
Blockly . geras . Drawer . prototype . drawValueInput _ = function ( a ) { this . highlighter _ . drawValueInput ( a ) ; Blockly . geras . Drawer . superClass _ . drawValueInput _ . call ( this , a ) } ; Blockly . geras . Drawer . prototype . drawStatementInput _ = function ( a ) { this . highlighter _ . drawStatementInput ( a ) ; Blockly . geras . Drawer . superClass _ . drawStatementInput _ . call ( this , a ) } ;
Blockly . geras . Drawer . prototype . drawRightSideRow _ = function ( a ) { this . highlighter _ . drawRightSideRow ( a ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , a . xPos + a . width ) + Blockly . utils . svgPaths . lineOnAxis ( "V" , a . yPos + a . height ) } ; Blockly . geras . Drawer . prototype . drawBottom _ = function ( ) { this . highlighter _ . drawBottomRow ( this . info _ . bottomRow ) ; Blockly . geras . Drawer . superClass _ . drawBottom _ . call ( this ) } ; Blockly . geras . Drawer . prototype . drawLeft _ = function ( ) { this . highlighter _ . drawLeft ( ) ; Blockly . geras . Drawer . superClass _ . drawLeft _ . call ( this ) } ;
Blockly . geras . Drawer . prototype . drawInlineInput _ = function ( a ) { this . highlighter _ . drawInlineInput ( a ) ; Blockly . geras . Drawer . superClass _ . drawInlineInput _ . call ( this , a ) } ; Blockly . geras . Drawer . prototype . positionInlineInputConnection _ = function ( a ) { var b = a . centerline - a . height / 2 ; if ( a . connectionModel ) { var c = a . xPos + a . connectionWidth + this . constants _ . DARK _PATH _OFFSET ; this . info _ . RTL && ( c *= - 1 ) ; a . connectionModel . setOffsetInBlock ( c , b + a . connectionOffsetY + this . constants _ . DARK _PATH _OFFSET ) } } ;
Blockly . geras . Drawer . prototype . positionStatementInputConnection _ = function ( a ) { var b = a . getLastInput ( ) ; if ( b . connectionModel ) { var c = a . xPos + a . statementEdge + b . notchOffset ; c = this . info _ . RTL ? - 1 * c : c + this . constants _ . DARK _PATH _OFFSET ; b . connectionModel . setOffsetInBlock ( c , a . yPos + this . constants _ . DARK _PATH _OFFSET ) } } ;
Blockly . geras . Drawer . prototype . positionExternalValueConnection _ = function ( a ) { var b = a . getLastInput ( ) ; if ( b . connectionModel ) { var c = a . xPos + a . width + this . constants _ . DARK _PATH _OFFSET ; this . info _ . RTL && ( c *= - 1 ) ; b . connectionModel . setOffsetInBlock ( c , a . yPos ) } } ; Blockly . geras . Drawer . prototype . positionNextConnection _ = function ( ) { var a = this . info _ . bottomRow ; if ( a . connection ) { var b = a . connection , c = b . xPos ; b . connectionModel . setOffsetInBlock ( ( this . info _ . RTL ? - c : c ) + this . constants _ . DARK _PATH _OFFSET / 2 , a . baseline + this . constants _ . DARK _PATH _OFFSET ) } } ; Blockly . geras . HighlightConstantProvider = function ( a ) { this . constantProvider = a ; this . OFFSET = . 5 ; this . START _POINT = Blockly . utils . svgPaths . moveBy ( this . OFFSET , this . OFFSET ) } ; Blockly . geras . HighlightConstantProvider . prototype . init = function ( ) { this . INSIDE _CORNER = this . makeInsideCorner ( ) ; this . OUTSIDE _CORNER = this . makeOutsideCorner ( ) ; this . PUZZLE _TAB = this . makePuzzleTab ( ) ; this . NOTCH = this . makeNotch ( ) ; this . JAGGED _TEETH = this . makeJaggedTeeth ( ) ; this . START _HAT = this . makeStartHat ( ) } ;
Blockly . geras . HighlightConstantProvider . prototype . makeInsideCorner = function ( ) { var a = this . constantProvider . CORNER _RADIUS , b = this . OFFSET , c = ( 1 - Math . SQRT1 _2 ) * ( a + b ) - b , d = Blockly . utils . svgPaths . moveBy ( c , c ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a , Blockly . utils . svgPaths . point ( - c - b , a - c ) ) , e = Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a + b , Blockly . utils . svgPaths . point ( a + b , a + b ) ) , f = Blockly . utils . svgPaths . moveBy ( c , - c ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a + b , Blockly . utils . svgPaths . point ( a - c , c + b ) ) ; return { width : a + b , height : a ,
pathTop : function ( g ) { return g ? d : "" } , pathBottom : function ( g ) { return g ? e : f } } } ;
Blockly . geras . HighlightConstantProvider . prototype . makeOutsideCorner = function ( ) { var a = this . constantProvider . CORNER _RADIUS , b = this . OFFSET , c = ( 1 - Math . SQRT1 _2 ) * ( a - b ) + b , d = Blockly . utils . svgPaths . moveBy ( c , c ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a - b , Blockly . utils . svgPaths . point ( a - c , - c + b ) ) , e = Blockly . utils . svgPaths . moveBy ( b , a ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a - b , Blockly . utils . svgPaths . point ( a , - a + b ) ) , f = - c , g = Blockly . utils . svgPaths . moveBy ( c , f ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a - b , Blockly . utils . svgPaths . point ( - c +
b , - f - a ) ) ; return { height : a , topLeft : function ( h ) { return h ? d : e } , bottomLeft : function ( ) { return g } } } ;
Blockly . geras . HighlightConstantProvider . prototype . makePuzzleTab = function ( ) { var a = this . constantProvider . TAB _WIDTH , b = this . constantProvider . TAB _HEIGHT , c = Blockly . utils . svgPaths . moveBy ( - 2 , - b + 3.4 ) + Blockly . utils . svgPaths . lineTo ( - . 45 * a , - 2.1 ) , d = Blockly . utils . svgPaths . lineOnAxis ( "v" , 2.5 ) + Blockly . utils . svgPaths . moveBy ( . 97 * - a , 2.5 ) + Blockly . utils . svgPaths . curve ( "q" , [ Blockly . utils . svgPaths . point ( . 05 * - a , 10 ) , Blockly . utils . svgPaths . point ( . 3 * a , 9.5 ) ] ) + Blockly . utils . svgPaths . moveBy ( . 67 * a , - 1.9 ) + Blockly . utils . svgPaths . lineOnAxis ( "v" ,
2.5 ) , e = Blockly . utils . svgPaths . lineOnAxis ( "v" , - 1.5 ) + Blockly . utils . svgPaths . moveBy ( - . 92 * a , - . 5 ) + Blockly . utils . svgPaths . curve ( "q" , [ Blockly . utils . svgPaths . point ( - . 19 * a , - 5.5 ) , Blockly . utils . svgPaths . point ( 0 , - 11 ) ] ) + Blockly . utils . svgPaths . moveBy ( . 92 * a , 1 ) , f = Blockly . utils . svgPaths . moveBy ( - 5 , b - . 7 ) + Blockly . utils . svgPaths . lineTo ( . 46 * a , - 2.1 ) ; return { width : a , height : b , pathUp : function ( g ) { return g ? c : e } , pathDown : function ( g ) { return g ? d : f } } } ;
Blockly . geras . HighlightConstantProvider . prototype . makeNotch = function ( ) { return { pathLeft : Blockly . utils . svgPaths . lineOnAxis ( "h" , this . OFFSET ) + this . constantProvider . NOTCH . pathLeft } } ; Blockly . geras . HighlightConstantProvider . prototype . makeJaggedTeeth = function ( ) { return { pathLeft : Blockly . utils . svgPaths . lineTo ( 5.1 , 2.6 ) + Blockly . utils . svgPaths . moveBy ( - 10.2 , 6.8 ) + Blockly . utils . svgPaths . lineTo ( 5.1 , 2.6 ) , height : 12 , width : 10.2 } } ;
Blockly . geras . HighlightConstantProvider . prototype . makeStartHat = function ( ) { var a = this . constantProvider . START _HAT . height , b = Blockly . utils . svgPaths . moveBy ( 25 , - 8.7 ) + Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( 29.7 , - 6.2 ) , Blockly . utils . svgPaths . point ( 57.2 , - . 5 ) , Blockly . utils . svgPaths . point ( 75 , 8.7 ) ] ) , c = Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( 17.8 , - 9.2 ) , Blockly . utils . svgPaths . point ( 45.3 , - 14.9 ) , Blockly . utils . svgPaths . point ( 75 , - 8.7 ) ] ) + Blockly . utils . svgPaths . moveTo ( 100.5 ,
a + . 5 ) ; return { path : function ( d ) { return d ? b : c } } } ; Blockly . geras . PathObject = function ( a , b , c ) { this . constants = c ; this . svgRoot = a ; this . svgPathDark = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyPathDark" , transform : "translate(1,1)" } , this . svgRoot ) ; this . svgPath = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyPath" } , this . svgRoot ) ; this . svgPathLight = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyPathLight" } , this . svgRoot ) ; this . colourDark = "#000000" ; this . style = b } ;
Blockly . utils . object . inherits ( Blockly . geras . PathObject , Blockly . blockRendering . PathObject ) ; Blockly . geras . PathObject . prototype . setPath = function ( a ) { this . svgPath . setAttribute ( "d" , a ) ; this . svgPathDark . setAttribute ( "d" , a ) } ; Blockly . geras . PathObject . prototype . setHighlightPath = function ( a ) { this . svgPathLight . setAttribute ( "d" , a ) } ;
Blockly . geras . PathObject . prototype . flipRTL = function ( ) { this . svgPath . setAttribute ( "transform" , "scale(-1 1)" ) ; this . svgPathLight . setAttribute ( "transform" , "scale(-1 1)" ) ; this . svgPathDark . setAttribute ( "transform" , "translate(1,1) scale(-1 1)" ) } ;
Blockly . geras . PathObject . prototype . applyColour = function ( a ) { this . svgPathLight . style . display = "" ; this . svgPathDark . style . display = "" ; this . svgPathLight . setAttribute ( "stroke" , this . style . colourTertiary ) ; this . svgPathDark . setAttribute ( "fill" , this . colourDark ) ; Blockly . geras . PathObject . superClass _ . applyColour . call ( this , a ) ; this . svgPath . setAttribute ( "stroke" , "none" ) } ;
Blockly . geras . PathObject . prototype . setStyle = function ( a ) { this . style = a ; this . colourDark = Blockly . utils . colour . blend ( "#000" , this . style . colourPrimary , . 2 ) || this . colourDark } ; Blockly . geras . PathObject . prototype . updateHighlighted = function ( a ) { a ? ( this . svgPath . setAttribute ( "filter" , "url(#" + this . constants . embossFilterId + ")" ) , this . svgPathLight . style . display = "none" ) : ( this . svgPath . setAttribute ( "filter" , "none" ) , this . svgPathLight . style . display = "inline" ) } ;
Blockly . geras . PathObject . prototype . updateShadow _ = function ( a ) { a && ( this . svgPathLight . style . display = "none" , this . svgPathDark . setAttribute ( "fill" , this . style . colourSecondary ) , this . svgPath . setAttribute ( "stroke" , "none" ) , this . svgPath . setAttribute ( "fill" , this . style . colourSecondary ) ) } ; Blockly . geras . PathObject . prototype . updateDisabled _ = function ( a ) { Blockly . geras . PathObject . superClass _ . updateDisabled _ . call ( this , a ) ; a && this . svgPath . setAttribute ( "stroke" , "none" ) } ; Blockly . geras . Renderer = function ( a ) { Blockly . geras . Renderer . superClass _ . constructor . call ( this , a ) ; this . highlightConstants _ = null } ; Blockly . utils . object . inherits ( Blockly . geras . Renderer , Blockly . blockRendering . Renderer ) ; Blockly . geras . Renderer . prototype . init = function ( a , b ) { Blockly . geras . Renderer . superClass _ . init . call ( this , a , b ) ; this . highlightConstants _ = this . makeHighlightConstants _ ( ) ; this . highlightConstants _ . init ( ) } ;
Blockly . geras . Renderer . prototype . refreshDom = function ( a , b ) { Blockly . geras . Renderer . superClass _ . refreshDom . call ( this , a , b ) ; this . getHighlightConstants ( ) . init ( ) } ; Blockly . geras . Renderer . prototype . makeConstants _ = function ( ) { return new Blockly . geras . ConstantProvider } ; Blockly . geras . Renderer . prototype . makeRenderInfo _ = function ( a ) { return new Blockly . geras . RenderInfo ( this , a ) } ; Blockly . geras . Renderer . prototype . makeDrawer _ = function ( a , b ) { return new Blockly . geras . Drawer ( a , b ) } ;
Blockly . geras . Renderer . prototype . makePathObject = function ( a , b ) { return new Blockly . geras . PathObject ( a , b , this . getConstants ( ) ) } ; Blockly . geras . Renderer . prototype . makeHighlightConstants _ = function ( ) { return new Blockly . geras . HighlightConstantProvider ( this . getConstants ( ) ) } ; Blockly . geras . Renderer . prototype . getHighlightConstants = function ( ) { return this . highlightConstants _ } ; Blockly . blockRendering . register ( "geras" , Blockly . geras . Renderer ) ; Blockly . thrasos = { } ; Blockly . thrasos . RenderInfo = function ( a , b ) { Blockly . thrasos . RenderInfo . superClass _ . constructor . call ( this , a , b ) } ; Blockly . utils . object . inherits ( Blockly . thrasos . RenderInfo , Blockly . blockRendering . RenderInfo ) ; Blockly . thrasos . RenderInfo . prototype . getRenderer = function ( ) { return this . renderer _ } ;
Blockly . thrasos . RenderInfo . prototype . addElemSpacing _ = function ( ) { for ( var a = ! 1 , b = 0 , c ; c = this . rows [ b ] ; b ++ ) c . hasExternalInput && ( a = ! 0 ) ; for ( b = 0 ; c = this . rows [ b ] ; b ++ ) { var d = c . elements ; c . elements = [ ] ; c . startsWithElemSpacer ( ) && c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , this . getInRowSpacing _ ( null , d [ 0 ] ) ) ) ; for ( var e = 0 ; e < d . length - 1 ; e ++ ) { c . elements . push ( d [ e ] ) ; var f = this . getInRowSpacing _ ( d [ e ] , d [ e + 1 ] ) ; c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , f ) ) } c . elements . push ( d [ d . length -
1 ] ) ; c . endsWithElemSpacer ( ) && ( f = this . getInRowSpacing _ ( d [ d . length - 1 ] , null ) , a && c . hasDummyInput && ( f += this . constants _ . TAB _WIDTH ) , c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , f ) ) ) } } ;
Blockly . thrasos . RenderInfo . prototype . getInRowSpacing _ = function ( a , b ) { if ( ! a ) return b && Blockly . blockRendering . Types . isField ( b ) && b . isEditable ? this . constants _ . MEDIUM _PADDING : b && Blockly . blockRendering . Types . isInlineInput ( b ) ? this . constants _ . MEDIUM _LARGE _PADDING : b && Blockly . blockRendering . Types . isStatementInput ( b ) ? this . constants _ . STATEMENT _INPUT _PADDING _LEFT : this . constants _ . LARGE _PADDING ; if ( ! Blockly . blockRendering . Types . isInput ( a ) && ! b ) return Blockly . blockRendering . Types . isField ( a ) && a . isEditable ? this . constants _ . MEDIUM _PADDING :
Blockly . blockRendering . Types . isIcon ( a ) ? 2 * this . constants _ . LARGE _PADDING + 1 : Blockly . blockRendering . Types . isHat ( a ) ? this . constants _ . NO _PADDING : Blockly . blockRendering . Types . isPreviousOrNextConnection ( a ) ? this . constants _ . LARGE _PADDING : Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) ? this . constants _ . MIN _BLOCK _WIDTH : Blockly . blockRendering . Types . isJaggedEdge ( a ) ? this . constants _ . NO _PADDING : this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isInput ( a ) && ! b ) { if ( Blockly . blockRendering . Types . isExternalInput ( a ) ) return this . constants _ . NO _PADDING ;
if ( Blockly . blockRendering . Types . isInlineInput ( a ) ) return this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isStatementInput ( a ) ) return this . constants _ . NO _PADDING } if ( ! Blockly . blockRendering . Types . isInput ( a ) && b && Blockly . blockRendering . Types . isInput ( b ) ) { if ( Blockly . blockRendering . Types . isField ( a ) && a . isEditable ) { if ( Blockly . blockRendering . Types . isInlineInput ( b ) || Blockly . blockRendering . Types . isExternalInput ( b ) ) return this . constants _ . SMALL _PADDING } else { if ( Blockly . blockRendering . Types . isInlineInput ( b ) ||
Blockly . blockRendering . Types . isExternalInput ( b ) ) return this . constants _ . MEDIUM _LARGE _PADDING ; if ( Blockly . blockRendering . Types . isStatementInput ( b ) ) return this . constants _ . LARGE _PADDING } return this . constants _ . LARGE _PADDING - 1 } if ( Blockly . blockRendering . Types . isIcon ( a ) && b && ! Blockly . blockRendering . Types . isInput ( b ) ) return this . constants _ . LARGE _PADDING ; if ( Blockly . blockRendering . Types . isInlineInput ( a ) && b && Blockly . blockRendering . Types . isField ( b ) ) return b . isEditable ? this . constants _ . MEDIUM _PADDING : this . constants _ . LARGE _PADDING ;
if ( Blockly . blockRendering . Types . isLeftSquareCorner ( a ) && b ) { if ( Blockly . blockRendering . Types . isHat ( b ) ) return this . constants _ . NO _PADDING ; if ( Blockly . blockRendering . Types . isPreviousConnection ( b ) || Blockly . blockRendering . Types . isNextConnection ( b ) ) return b . notchOffset } return Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) && b ? b . notchOffset - this . constants _ . CORNER _RADIUS : Blockly . blockRendering . Types . isField ( a ) && b && Blockly . blockRendering . Types . isField ( b ) && a . isEditable == b . isEditable || b && Blockly . blockRendering . Types . isJaggedEdge ( b ) ?
this . constants _ . LARGE _PADDING : this . constants _ . MEDIUM _PADDING } ;
Blockly . thrasos . RenderInfo . prototype . getSpacerRowHeight _ = function ( a , b ) { return Blockly . blockRendering . Types . isTopRow ( a ) && Blockly . blockRendering . Types . isBottomRow ( b ) ? this . constants _ . EMPTY _BLOCK _SPACER _HEIGHT : Blockly . blockRendering . Types . isTopRow ( a ) || Blockly . blockRendering . Types . isBottomRow ( b ) ? this . constants _ . NO _PADDING : a . hasExternalInput && b . hasExternalInput ? this . constants _ . LARGE _PADDING : ! a . hasStatement && b . hasStatement ? this . constants _ . BETWEEN _STATEMENT _PADDING _Y : a . hasStatement && b . hasStatement || a . hasDummyInput ||
b . hasDummyInput ? this . constants _ . LARGE _PADDING : this . constants _ . MEDIUM _PADDING } ;
Blockly . thrasos . RenderInfo . prototype . getElemCenterline _ = function ( a , b ) { if ( Blockly . blockRendering . Types . isSpacer ( b ) ) return a . yPos + b . height / 2 ; if ( Blockly . blockRendering . Types . isBottomRow ( a ) ) return a = a . yPos + a . height - a . descenderHeight , Blockly . blockRendering . Types . isNextConnection ( b ) ? a + b . height / 2 : a - b . height / 2 ; if ( Blockly . blockRendering . Types . isTopRow ( a ) ) return Blockly . blockRendering . Types . isHat ( b ) ? a . capline - b . height / 2 : a . capline + b . height / 2 ; var c = a . yPos ; return c = Blockly . blockRendering . Types . isField ( b ) && a . hasStatement ?
c + ( this . constants _ . TALL _INPUT _FIELD _OFFSET _Y + b . height / 2 ) : c + a . height / 2 } ;
Blockly . thrasos . RenderInfo . prototype . finalize _ = function ( ) { for ( var a = 0 , b = 0 , c = 0 , d ; d = this . rows [ c ] ; c ++ ) { d . yPos = b ; d . xPos = this . startX ; b += d . height ; a = Math . max ( a , d . widthWithConnectedBlocks ) ; var e = b - this . topRow . ascenderHeight ; d == this . bottomRow && e < this . constants _ . MIN _BLOCK _HEIGHT && ( e = this . constants _ . MIN _BLOCK _HEIGHT - e , this . bottomRow . height += e , b += e ) ; this . recordElemPositions _ ( d ) } this . outputConnection && this . block _ . nextConnection && this . block _ . nextConnection . isConnected ( ) && ( a = Math . max ( a , this . block _ . nextConnection . targetBlock ( ) . getHeightWidth ( ) . width ) ) ;
this . bottomRow . baseline = b - this . bottomRow . descenderHeight ; this . widthWithChildren = a + this . startX ; this . height = b ; this . startY = this . topRow . capline } ; Blockly . thrasos . Renderer = function ( a ) { Blockly . thrasos . Renderer . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . thrasos . Renderer , Blockly . blockRendering . Renderer ) ; Blockly . thrasos . Renderer . prototype . makeRenderInfo _ = function ( a ) { return new Blockly . thrasos . RenderInfo ( this , a ) } ; Blockly . blockRendering . register ( "thrasos" , Blockly . thrasos . Renderer ) ; Blockly . zelos = { } ;
Blockly . zelos . ConstantProvider = function ( ) { Blockly . zelos . ConstantProvider . superClass _ . constructor . call ( this ) ; this . SMALL _PADDING = this . GRID _UNIT = 4 ; this . MEDIUM _PADDING = 2 * this . GRID _UNIT ; this . MEDIUM _LARGE _PADDING = 3 * this . GRID _UNIT ; this . LARGE _PADDING = 4 * this . GRID _UNIT ; this . CORNER _RADIUS = 1 * this . GRID _UNIT ; this . NOTCH _WIDTH = 9 * this . GRID _UNIT ; this . NOTCH _HEIGHT = 2 * this . GRID _UNIT ; this . STATEMENT _INPUT _NOTCH _OFFSET = this . NOTCH _OFFSET _LEFT = 3 * this . GRID _UNIT ; this . MIN _BLOCK _WIDTH = 2 * this . GRID _UNIT ; this . MIN _BLOCK _HEIGHT = 12 *
this . GRID _UNIT ; this . EMPTY _STATEMENT _INPUT _HEIGHT = 6 * this . GRID _UNIT ; this . TAB _OFFSET _FROM _TOP = 0 ; this . TOP _ROW _MIN _HEIGHT = this . CORNER _RADIUS ; this . TOP _ROW _PRECEDES _STATEMENT _MIN _HEIGHT = this . LARGE _PADDING ; this . BOTTOM _ROW _MIN _HEIGHT = this . CORNER _RADIUS ; this . BOTTOM _ROW _AFTER _STATEMENT _MIN _HEIGHT = 6 * this . GRID _UNIT ; this . STATEMENT _BOTTOM _SPACER = - this . NOTCH _HEIGHT ; this . STATEMENT _INPUT _SPACER _MIN _WIDTH = 40 * this . GRID _UNIT ; this . STATEMENT _INPUT _PADDING _LEFT = 4 * this . GRID _UNIT ; this . EMPTY _INLINE _INPUT _PADDING = 4 * this . GRID _UNIT ;
this . EMPTY _INLINE _INPUT _HEIGHT = 8 * this . GRID _UNIT ; this . DUMMY _INPUT _MIN _HEIGHT = 8 * this . GRID _UNIT ; this . DUMMY _INPUT _SHADOW _MIN _HEIGHT = 6 * this . GRID _UNIT ; this . CURSOR _WS _WIDTH = 20 * this . GRID _UNIT ; this . CURSOR _COLOUR = "#ffa200" ; this . CURSOR _RADIUS = 5 ; this . JAGGED _TEETH _WIDTH = this . JAGGED _TEETH _HEIGHT = 0 ; this . START _HAT _HEIGHT = 22 ; this . START _HAT _WIDTH = 96 ; this . SHAPES = { HEXAGONAL : 1 , ROUND : 2 , SQUARE : 3 , PUZZLE : 4 , NOTCH : 5 } ; this . SHAPE _IN _SHAPE _PADDING = { 1 : { 0 : 5 * this . GRID _UNIT , 1 : 2 * this . GRID _UNIT , 2 : 5 * this . GRID _UNIT , 3 : 5 * this . GRID _UNIT } ,
2 : { 0 : 3 * this . GRID _UNIT , 1 : 3 * this . GRID _UNIT , 2 : 1 * this . GRID _UNIT , 3 : 2 * this . GRID _UNIT } , 3 : { 0 : 2 * this . GRID _UNIT , 1 : 2 * this . GRID _UNIT , 2 : 2 * this . GRID _UNIT , 3 : 2 * this . GRID _UNIT } } ; this . FULL _BLOCK _FIELDS = ! 0 ; this . FIELD _TEXT _FONTSIZE = 3 * this . GRID _UNIT ; this . FIELD _TEXT _FONTWEIGHT = "bold" ; this . FIELD _TEXT _FONTFAMILY = '"Helvetica Neue", "Segoe UI", Helvetica, sans-serif' ; this . FIELD _BORDER _RECT _RADIUS = this . CORNER _RADIUS ; this . FIELD _BORDER _RECT _X _PADDING = 2 * this . GRID _UNIT ; this . FIELD _BORDER _RECT _Y _PADDING = 1.625 * this . GRID _UNIT ; this . FIELD _BORDER _RECT _HEIGHT =
8 * this . GRID _UNIT ; this . FIELD _DROPDOWN _BORDER _RECT _HEIGHT = 8 * this . GRID _UNIT ; this . FIELD _DROPDOWN _SVG _ARROW = this . FIELD _DROPDOWN _COLOURED _DIV = this . FIELD _DROPDOWN _NO _BORDER _RECT _SHADOW = ! 0 ; this . FIELD _DROPDOWN _SVG _ARROW _PADDING = this . FIELD _BORDER _RECT _X _PADDING ; this . FIELD _COLOUR _FULL _BLOCK = this . FIELD _TEXTINPUT _BOX _SHADOW = ! 0 ; this . FIELD _COLOUR _DEFAULT _WIDTH = 2 * this . GRID _UNIT ; this . FIELD _COLOUR _DEFAULT _HEIGHT = 4 * this . GRID _UNIT ; this . FIELD _CHECKBOX _X _OFFSET = 1 * this . GRID _UNIT ; this . MAX _DYNAMIC _CONNECTION _SHAPE _WIDTH =
12 * this . GRID _UNIT ; this . SELECTED _GLOW _COLOUR = "#fff200" ; this . SELECTED _GLOW _SIZE = . 5 ; this . REPLACEMENT _GLOW _COLOUR = "#fff200" ; this . REPLACEMENT _GLOW _SIZE = 2 ; this . selectedGlowFilterId = "" ; this . selectedGlowFilter _ = null ; this . replacementGlowFilterId = "" ; this . replacementGlowFilter _ = null } ; Blockly . utils . object . inherits ( Blockly . zelos . ConstantProvider , Blockly . blockRendering . ConstantProvider ) ;
Blockly . zelos . ConstantProvider . prototype . setFontConstants _ = function ( a ) { Blockly . zelos . ConstantProvider . superClass _ . setFontConstants _ . call ( this , a ) ; this . FIELD _DROPDOWN _BORDER _RECT _HEIGHT = this . FIELD _BORDER _RECT _HEIGHT = this . FIELD _TEXT _HEIGHT + 2 * this . FIELD _BORDER _RECT _Y _PADDING } ;
Blockly . zelos . ConstantProvider . prototype . init = function ( ) { Blockly . zelos . ConstantProvider . superClass _ . init . call ( this ) ; this . HEXAGONAL = this . makeHexagonal ( ) ; this . ROUNDED = this . makeRounded ( ) ; this . SQUARED = this . makeSquared ( ) ; this . STATEMENT _INPUT _NOTCH _OFFSET = this . NOTCH _OFFSET _LEFT + this . INSIDE _CORNERS . rightWidth } ;
Blockly . zelos . ConstantProvider . prototype . setDynamicProperties _ = function ( a ) { Blockly . zelos . ConstantProvider . superClass _ . setDynamicProperties _ . call ( this , a ) ; this . SELECTED _GLOW _COLOUR = a . getComponentStyle ( "selectedGlowColour" ) || this . SELECTED _GLOW _COLOUR ; var b = Number ( a . getComponentStyle ( "selectedGlowSize" ) ) ; this . SELECTED _GLOW _SIZE = b && ! isNaN ( b ) ? b : this . SELECTED _GLOW _SIZE ; this . REPLACEMENT _GLOW _COLOUR = a . getComponentStyle ( "replacementGlowColour" ) || this . REPLACEMENT _GLOW _COLOUR ; this . REPLACEMENT _GLOW _SIZE = ( a = Number ( a . getComponentStyle ( "replacementGlowSize" ) ) ) &&
! isNaN ( a ) ? a : this . REPLACEMENT _GLOW _SIZE } ; Blockly . zelos . ConstantProvider . prototype . dispose = function ( ) { Blockly . zelos . ConstantProvider . superClass _ . dispose . call ( this ) ; this . selectedGlowFilter _ && Blockly . utils . dom . removeNode ( this . selectedGlowFilter _ ) ; this . replacementGlowFilter _ && Blockly . utils . dom . removeNode ( this . replacementGlowFilter _ ) } ;
Blockly . zelos . ConstantProvider . prototype . makeStartHat = function ( ) { var a = this . START _HAT _HEIGHT , b = this . START _HAT _WIDTH , c = Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( 25 , - a ) , Blockly . utils . svgPaths . point ( 71 , - a ) , Blockly . utils . svgPaths . point ( b , 0 ) ] ) ; return { height : a , width : b , path : c } } ;
Blockly . zelos . ConstantProvider . prototype . makeHexagonal = function ( ) { function a ( c , d , e ) { var f = c / 2 ; f = f > b ? b : f ; e = e ? - 1 : 1 ; c = ( d ? - 1 : 1 ) * c / 2 ; return Blockly . utils . svgPaths . lineTo ( - e * f , c ) + Blockly . utils . svgPaths . lineTo ( e * f , c ) } var b = this . MAX _DYNAMIC _CONNECTION _SHAPE _WIDTH ; return { type : this . SHAPES . HEXAGONAL , isDynamic : ! 0 , width : function ( c ) { c /= 2 ; return c > b ? b : c } , height : function ( c ) { return c } , connectionOffsetY : function ( c ) { return c / 2 } , connectionOffsetX : function ( c ) { return - c } , pathDown : function ( c ) { return a ( c , ! 1 , ! 1 ) } , pathUp : function ( c ) { return a ( c ,
! 0 , ! 1 ) } , pathRightDown : function ( c ) { return a ( c , ! 1 , ! 0 ) } , pathRightUp : function ( c ) { return a ( c , ! 1 , ! 0 ) } } } ;
Blockly . zelos . ConstantProvider . prototype . makeRounded = function ( ) { function a ( d , e , f ) { var g = d > c ? d - c : 0 ; d = ( d > c ? c : d ) / 2 ; return Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , d , Blockly . utils . svgPaths . point ( ( e ? - 1 : 1 ) * d , ( e ? - 1 : 1 ) * d ) ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , ( f ? 1 : - 1 ) * g ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , d , Blockly . utils . svgPaths . point ( ( e ? 1 : - 1 ) * d , ( e ? - 1 : 1 ) * d ) ) } var b = this . MAX _DYNAMIC _CONNECTION _SHAPE _WIDTH , c = 2 * b ; return { type : this . SHAPES . ROUND , isDynamic : ! 0 , width : function ( d ) { d /= 2 ; return d > b ? b : d } , height : function ( d ) { return d } ,
connectionOffsetY : function ( d ) { return d / 2 } , connectionOffsetX : function ( d ) { return - d } , pathDown : function ( d ) { return a ( d , ! 1 , ! 1 ) } , pathUp : function ( d ) { return a ( d , ! 0 , ! 1 ) } , pathRightDown : function ( d ) { return a ( d , ! 1 , ! 0 ) } , pathRightUp : function ( d ) { return a ( d , ! 1 , ! 0 ) } } } ;
Blockly . zelos . ConstantProvider . prototype . makeSquared = function ( ) { function a ( c , d , e ) { c -= 2 * b ; return Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , b , Blockly . utils . svgPaths . point ( ( d ? - 1 : 1 ) * b , ( d ? - 1 : 1 ) * b ) ) + Blockly . utils . svgPaths . lineOnAxis ( "v" , ( e ? 1 : - 1 ) * c ) + Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , b , Blockly . utils . svgPaths . point ( ( d ? 1 : - 1 ) * b , ( d ? - 1 : 1 ) * b ) ) } var b = this . CORNER _RADIUS ; return { type : this . SHAPES . SQUARE , isDynamic : ! 0 , width : function ( c ) { return b } , height : function ( c ) { return c } , connectionOffsetY : function ( c ) { return c / 2 } ,
connectionOffsetX : function ( c ) { return - c } , pathDown : function ( c ) { return a ( c , ! 1 , ! 1 ) } , pathUp : function ( c ) { return a ( c , ! 0 , ! 1 ) } , pathRightDown : function ( c ) { return a ( c , ! 1 , ! 0 ) } , pathRightUp : function ( c ) { return a ( c , ! 1 , ! 0 ) } } } ;
2021-05-19 13:38:55 +00:00
Blockly . zelos . ConstantProvider . prototype . shapeFor = function ( a ) { var b = a . getCheck ( ) ; ! b && a . targetConnection && ( b = a . targetConnection . getCheck ( ) ) ; switch ( a . type ) { case Blockly . connectionTypes . INPUT _VALUE : case Blockly . connectionTypes . OUTPUT _VALUE : a = a . getSourceBlock ( ) . getOutputShape ( ) ; if ( null != a ) switch ( a ) { case this . SHAPES . HEXAGONAL : return this . HEXAGONAL ; case this . SHAPES . ROUND : return this . ROUNDED ; case this . SHAPES . SQUARE : return this . SQUARED } if ( b && - 1 != b . indexOf ( "Boolean" ) ) return this . HEXAGONAL ; if ( b && - 1 != b . indexOf ( "Number" ) ) return this . ROUNDED ;
b && b . indexOf ( "String" ) ; return this . ROUNDED ; case Blockly . connectionTypes . PREVIOUS _STATEMENT : case Blockly . connectionTypes . NEXT _STATEMENT : return this . NOTCH ; default : throw Error ( "Unknown type" ) ; } } ;
2021-01-16 14:07:51 +00:00
Blockly . zelos . ConstantProvider . prototype . makeNotch = function ( ) { function a ( l ) { return Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( l * e / 2 , 0 ) , Blockly . utils . svgPaths . point ( l * e * 3 / 4 , g / 2 ) , Blockly . utils . svgPaths . point ( l * e , g ) ] ) + Blockly . utils . svgPaths . line ( [ Blockly . utils . svgPaths . point ( l * e , f ) ] ) + Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( l * e / 4 , g / 2 ) , Blockly . utils . svgPaths . point ( l * e / 2 , g ) , Blockly . utils . svgPaths . point ( l * e , g ) ] ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , l * d ) + Blockly . utils . svgPaths . curve ( "c" ,
[ Blockly . utils . svgPaths . point ( l * e / 2 , 0 ) , Blockly . utils . svgPaths . point ( l * e * 3 / 4 , - ( g / 2 ) ) , Blockly . utils . svgPaths . point ( l * e , - g ) ] ) + Blockly . utils . svgPaths . line ( [ Blockly . utils . svgPaths . point ( l * e , - f ) ] ) + Blockly . utils . svgPaths . curve ( "c" , [ Blockly . utils . svgPaths . point ( l * e / 4 , - ( g / 2 ) ) , Blockly . utils . svgPaths . point ( l * e / 2 , - g ) , Blockly . utils . svgPaths . point ( l * e , - g ) ] ) } var b = this . NOTCH _WIDTH , c = this . NOTCH _HEIGHT , d = b / 3 , e = d / 3 , f = c / 2 , g = f / 2 , h = a ( 1 ) , k = a ( - 1 ) ; return { type : this . SHAPES . NOTCH , width : b , height : c , pathLeft : h , pathRight : k } } ;
Blockly . zelos . ConstantProvider . prototype . makeInsideCorners = function ( ) { var a = this . CORNER _RADIUS , b = Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a , Blockly . utils . svgPaths . point ( - a , a ) ) , c = Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( - a , a ) ) , d = Blockly . utils . svgPaths . arc ( "a" , "0 0,0" , a , Blockly . utils . svgPaths . point ( a , a ) ) , e = Blockly . utils . svgPaths . arc ( "a" , "0 0,1" , a , Blockly . utils . svgPaths . point ( a , a ) ) ; return { width : a , height : a , pathTop : b , pathBottom : d , rightWidth : a , rightHeight : a , pathTopRight : c , pathBottomRight : e } } ;
Blockly . zelos . ConstantProvider . prototype . generateSecondaryColour _ = function ( a ) { return Blockly . utils . colour . blend ( "#000" , a , . 15 ) || a } ; Blockly . zelos . ConstantProvider . prototype . generateTertiaryColour _ = function ( a ) { return Blockly . utils . colour . blend ( "#000" , a , . 25 ) || a } ;
Blockly . zelos . ConstantProvider . prototype . createDom = function ( a , b , c ) { Blockly . zelos . ConstantProvider . superClass _ . createDom . call ( this , a , b , c ) ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . DEFS , { } , a ) ; b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FILTER , { id : "blocklySelectedGlowFilter" + this . randomIdentifier , height : "160%" , width : "180%" , y : "-30%" , x : "-40%" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEGAUSSIANBLUR , { "in" : "SourceGraphic" , stdDeviation : this . SELECTED _GLOW _SIZE } , b ) ; c =
Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPONENTTRANSFER , { result : "outBlur" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFUNCA , { type : "table" , tableValues : "0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" } , c ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFLOOD , { "flood-color" : this . SELECTED _GLOW _COLOUR , "flood-opacity" : 1 , result : "outColor" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "outColor" , in2 : "outBlur" , operator : "in" , result : "outGlow" } , b ) ; this . selectedGlowFilterId =
b . id ; this . selectedGlowFilter _ = b ; a = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FILTER , { id : "blocklyReplacementGlowFilter" + this . randomIdentifier , height : "160%" , width : "180%" , y : "-30%" , x : "-40%" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEGAUSSIANBLUR , { "in" : "SourceGraphic" , stdDeviation : this . REPLACEMENT _GLOW _SIZE } , a ) ; b = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPONENTTRANSFER , { result : "outBlur" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFUNCA , { type : "table" ,
tableValues : "0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" } , b ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FEFLOOD , { "flood-color" : this . REPLACEMENT _GLOW _COLOUR , "flood-opacity" : 1 , result : "outColor" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "outColor" , in2 : "outBlur" , operator : "in" , result : "outGlow" } , a ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . FECOMPOSITE , { "in" : "SourceGraphic" , in2 : "outGlow" , operator : "over" } , a ) ; this . replacementGlowFilterId = a . id ; this . replacementGlowFilter _ =
a } ;
Blockly . zelos . ConstantProvider . prototype . getCSS _ = function ( a ) { return [ a + " .blocklyText," , a + " .blocklyFlyoutLabelText {" , "font: " + this . FIELD _TEXT _FONTWEIGHT + " " + this . FIELD _TEXT _FONTSIZE + "pt " + this . FIELD _TEXT _FONTFAMILY + ";" , "}" , a + " .blocklyText {" , "fill: #fff;" , "}" , a + " .blocklyNonEditableText>rect:not(.blocklyDropdownRect)," , a + " .blocklyEditableText>rect:not(.blocklyDropdownRect) {" , "fill: " + this . FIELD _BORDER _RECT _COLOUR + ";" , "}" , a + " .blocklyNonEditableText>text," , a + " .blocklyEditableText>text," , a + " .blocklyNonEditableText>g>text," ,
a + " .blocklyEditableText>g>text {" , "fill: #575E75;" , "}" , a + " .blocklyFlyoutLabelText {" , "fill: #575E75;" , "}" , a + " .blocklyText.blocklyBubbleText {" , "fill: #575E75;" , "}" , a + " .blocklyDraggable:not(.blocklyDisabled)" , " .blocklyEditableText:not(.editing):hover>rect," , a + " .blocklyDraggable:not(.blocklyDisabled)" , " .blocklyEditableText:not(.editing):hover>.blocklyPath {" , "stroke: #fff;" , "stroke-width: 2;" , "}" , a + " .blocklyHtmlInput {" , "font-family: " + this . FIELD _TEXT _FONTFAMILY + ";" , "font-weight: " + this . FIELD _TEXT _FONTWEIGHT +
";" , "color: #575E75;" , "}" , a + " .blocklyDropdownText {" , "fill: #fff !important;" , "}" , a + ".blocklyWidgetDiv .goog-menuitem," , a + ".blocklyDropDownDiv .goog-menuitem {" , "font-family: " + this . FIELD _TEXT _FONTFAMILY + ";" , "}" , a + ".blocklyDropDownDiv .goog-menuitem-content {" , "color: #fff;" , "}" , a + " .blocklyHighlightedConnectionPath {" , "stroke: " + this . SELECTED _GLOW _COLOUR + ";" , "}" , a + " .blocklyDisabled > .blocklyOutlinePath {" , "fill: url(#blocklyDisabledPattern" + this . randomIdentifier + ")" , "}" , a + " .blocklyInsertionMarker>.blocklyPath {" ,
"fill-opacity: " + this . INSERTION _MARKER _OPACITY + ";" , "stroke: none;" , "}" ] } ; Blockly . zelos . TopRow = function ( a ) { Blockly . zelos . TopRow . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . zelos . TopRow , Blockly . blockRendering . TopRow ) ; Blockly . zelos . TopRow . prototype . endsWithElemSpacer = function ( ) { return ! 1 } ; Blockly . zelos . TopRow . prototype . hasLeftSquareCorner = function ( a ) { var b = ( a . hat ? "cap" === a . hat : this . constants _ . ADD _START _HATS ) && ! a . outputConnection && ! a . previousConnection ; return ! ! a . outputConnection || b } ;
Blockly . zelos . TopRow . prototype . hasRightSquareCorner = function ( a ) { return ! ! a . outputConnection && ! a . statementInputCount && ! a . nextConnection } ; Blockly . zelos . BottomRow = function ( a ) { Blockly . zelos . BottomRow . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . zelos . BottomRow , Blockly . blockRendering . BottomRow ) ; Blockly . zelos . BottomRow . prototype . endsWithElemSpacer = function ( ) { return ! 1 } ; Blockly . zelos . BottomRow . prototype . hasLeftSquareCorner = function ( a ) { return ! ! a . outputConnection } ;
2021-05-19 13:38:55 +00:00
Blockly . zelos . BottomRow . prototype . hasRightSquareCorner = function ( a ) { return ! ! a . outputConnection && ! a . statementInputCount && ! a . nextConnection } ; Blockly . zelos . RightConnectionShape = function ( a ) { Blockly . zelos . RightConnectionShape . superClass _ . constructor . call ( this , a ) ; this . type |= Blockly . blockRendering . Types . getType ( "RIGHT_CONNECTION" ) ; this . width = this . height = 0 } ; Blockly . utils . object . inherits ( Blockly . zelos . RightConnectionShape , Blockly . blockRendering . Measurable ) ; Blockly . zelos . RenderInfo = function ( a , b ) { Blockly . zelos . RenderInfo . superClass _ . constructor . call ( this , a , b ) ; this . topRow = new Blockly . zelos . TopRow ( this . constants _ ) ; this . bottomRow = new Blockly . zelos . BottomRow ( this . constants _ ) ; this . isInline = ! 0 ; this . isMultiRow = ! b . getInputsInline ( ) || b . isCollapsed ( ) ; this . hasStatementInput = 0 < b . statementInputCount ; this . rightSide = this . outputConnection ? new Blockly . zelos . RightConnectionShape ( this . constants _ ) : null } ; Blockly . utils . object . inherits ( Blockly . zelos . RenderInfo , Blockly . blockRendering . RenderInfo ) ;
2021-01-16 14:07:51 +00:00
Blockly . zelos . RenderInfo . prototype . getRenderer = function ( ) { return this . renderer _ } ; Blockly . zelos . RenderInfo . prototype . measure = function ( ) { this . createRows _ ( ) ; this . addElemSpacing _ ( ) ; this . addRowSpacing _ ( ) ; this . adjustXPosition _ ( ) ; this . computeBounds _ ( ) ; this . alignRowElements _ ( ) ; this . finalize _ ( ) } ;
2021-05-19 13:38:55 +00:00
Blockly . zelos . RenderInfo . prototype . shouldStartNewRow _ = function ( a , b ) { return b ? a . type == Blockly . inputTypes . STATEMENT || b . type == Blockly . inputTypes . STATEMENT ? ! 0 : a . type == Blockly . inputTypes . VALUE || a . type == Blockly . inputTypes . DUMMY ? ! this . isInline || this . isMultiRow : ! 1 : ! 1 } ; Blockly . zelos . RenderInfo . prototype . getDesiredRowWidth _ = function ( a ) { return a . hasStatement ? this . width - this . startX - ( this . constants _ . INSIDE _CORNERS . rightWidth || 0 ) : Blockly . zelos . RenderInfo . superClass _ . getDesiredRowWidth _ . call ( this , a ) } ;
2021-01-16 14:07:51 +00:00
Blockly . zelos . RenderInfo . prototype . getInRowSpacing _ = function ( a , b ) { return a && b || ! this . outputConnection || ! this . outputConnection . isDynamicShape || this . hasStatementInput || this . bottomRow . hasNextConnection ? ! a && b && Blockly . blockRendering . Types . isStatementInput ( b ) ? this . constants _ . STATEMENT _INPUT _PADDING _LEFT : a && Blockly . blockRendering . Types . isLeftRoundedCorner ( a ) && b && ( Blockly . blockRendering . Types . isPreviousConnection ( b ) || Blockly . blockRendering . Types . isNextConnection ( b ) ) ? b . notchOffset - this . constants _ . CORNER _RADIUS :
a && Blockly . blockRendering . Types . isLeftSquareCorner ( a ) && b && Blockly . blockRendering . Types . isHat ( b ) ? this . constants _ . NO _PADDING : this . constants _ . MEDIUM _PADDING : this . constants _ . NO _PADDING } ;
Blockly . zelos . RenderInfo . prototype . getSpacerRowHeight _ = function ( a , b ) { if ( Blockly . blockRendering . Types . isTopRow ( a ) && Blockly . blockRendering . Types . isBottomRow ( b ) ) return this . constants _ . EMPTY _BLOCK _SPACER _HEIGHT ; var c = Blockly . blockRendering . Types . isInputRow ( a ) && a . hasStatement , d = Blockly . blockRendering . Types . isInputRow ( b ) && b . hasStatement ; return d || c ? ( a = Math . max ( this . constants _ . NOTCH _HEIGHT , this . constants _ . INSIDE _CORNERS . rightHeight || 0 ) , d && c ? Math . max ( a , this . constants _ . DUMMY _INPUT _MIN _HEIGHT ) : a ) : Blockly . blockRendering . Types . isTopRow ( a ) ?
a . hasPreviousConnection || this . outputConnection && ! this . hasStatementInput ? this . constants _ . NO _PADDING : Math . abs ( this . constants _ . NOTCH _HEIGHT - this . constants _ . CORNER _RADIUS ) : Blockly . blockRendering . Types . isBottomRow ( b ) ? this . outputConnection ? ! b . hasNextConnection && this . hasStatementInput ? Math . abs ( this . constants _ . NOTCH _HEIGHT - this . constants _ . CORNER _RADIUS ) : this . constants _ . NO _PADDING : Math . max ( this . topRow . minHeight , Math . max ( this . constants _ . NOTCH _HEIGHT , this . constants _ . CORNER _RADIUS ) ) - this . constants _ . CORNER _RADIUS :
this . constants _ . MEDIUM _PADDING } ; Blockly . zelos . RenderInfo . prototype . getSpacerRowWidth _ = function ( a , b ) { var c = this . width - this . startX ; return Blockly . blockRendering . Types . isInputRow ( a ) && a . hasStatement || Blockly . blockRendering . Types . isInputRow ( b ) && b . hasStatement ? Math . max ( c , this . constants _ . STATEMENT _INPUT _SPACER _MIN _WIDTH ) : c } ;
Blockly . zelos . RenderInfo . prototype . getElemCenterline _ = function ( a , b ) { if ( a . hasStatement && ! Blockly . blockRendering . Types . isSpacer ( b ) && ! Blockly . blockRendering . Types . isStatementInput ( b ) ) return a . yPos + this . constants _ . EMPTY _STATEMENT _INPUT _HEIGHT / 2 ; if ( Blockly . blockRendering . Types . isInlineInput ( b ) ) { var c = b . connectedBlock ; if ( c && c . outputConnection && c . nextConnection ) return a . yPos + c . height / 2 } return Blockly . zelos . RenderInfo . superClass _ . getElemCenterline _ . call ( this , a , b ) } ;
2021-05-19 13:38:55 +00:00
Blockly . zelos . RenderInfo . prototype . addInput _ = function ( a , b ) { a . type == Blockly . inputTypes . DUMMY && b . hasDummyInput && b . align == Blockly . constants . ALIGN . LEFT && a . align == Blockly . constants . ALIGN . RIGHT && ( b . rightAlignedDummyInput = a ) ; Blockly . zelos . RenderInfo . superClass _ . addInput _ . call ( this , a , b ) } ;
2021-01-16 14:07:51 +00:00
Blockly . zelos . RenderInfo . prototype . addAlignmentPadding _ = function ( a , b ) { if ( a . rightAlignedDummyInput ) { for ( var c , d = 0 , e ; ( e = a . elements [ d ] ) && ( Blockly . blockRendering . Types . isSpacer ( e ) && ( c = e ) , ! Blockly . blockRendering . Types . isField ( e ) || e . parentInput != a . rightAlignedDummyInput ) ; d ++ ) ; if ( c ) { c . width += b ; a . width += b ; return } } Blockly . zelos . RenderInfo . superClass _ . addAlignmentPadding _ . call ( this , a , b ) } ;
Blockly . zelos . RenderInfo . prototype . adjustXPosition _ = function ( ) { for ( var a = this . constants _ . NOTCH _OFFSET _LEFT + this . constants _ . NOTCH _WIDTH , b = a , c = 2 ; c < this . rows . length - 1 ; c += 2 ) { var d = this . rows [ c - 1 ] , e = this . rows [ c ] , f = this . rows [ c + 1 ] ; d = 2 == c ? ! ! this . topRow . hasPreviousConnection : ! ! d . followsStatement ; f = c + 2 >= this . rows . length - 1 ? ! ! this . bottomRow . hasNextConnection : ! ! f . precedesStatement ; if ( Blockly . blockRendering . Types . isInputRow ( e ) && e . hasStatement ) e . measure ( ) , b = e . width - e . getLastInput ( ) . width + a ; else if ( d && ( 2 == c || f ) &&
Blockly . blockRendering . Types . isInputRow ( e ) && ! e . hasStatement ) { f = e . xPos ; d = null ; for ( var g = 0 , h ; h = e . elements [ g ] ; g ++ ) Blockly . blockRendering . Types . isSpacer ( h ) && ( d = h ) , ! ( d && ( Blockly . blockRendering . Types . isField ( h ) || Blockly . blockRendering . Types . isInput ( h ) ) && f < b ) || Blockly . blockRendering . Types . isField ( h ) && ( h . field instanceof Blockly . FieldLabel || h . field instanceof Blockly . FieldImage ) || ( d . width += b - f ) , f += h . width } } } ;
Blockly . zelos . RenderInfo . prototype . finalizeOutputConnection _ = function ( ) { if ( this . outputConnection && this . outputConnection . isDynamicShape ) { for ( var a = 0 , b = 0 , c ; c = this . rows [ b ] ; b ++ ) c . yPos = a , a += c . height ; this . height = a ; b = this . bottomRow . hasNextConnection ? this . height - this . bottomRow . descenderHeight : this . height ; a = this . outputConnection . shape . height ( b ) ; b = this . outputConnection . shape . width ( b ) ; this . outputConnection . height = a ; this . outputConnection . width = b ; this . outputConnection . startX = b ; this . outputConnection . connectionOffsetY =
this . outputConnection . shape . connectionOffsetY ( a ) ; this . outputConnection . connectionOffsetX = this . outputConnection . shape . connectionOffsetX ( b ) ; c = 0 ; this . hasStatementInput || this . bottomRow . hasNextConnection || ( c = b , this . rightSide . height = a , this . rightSide . width = c , this . rightSide . centerline = a / 2 , this . rightSide . xPos = this . width + c ) ; this . startX = b ; this . width += b + c ; this . widthWithChildren += b + c } } ;
Blockly . zelos . RenderInfo . prototype . finalizeHorizontalAlignment _ = function ( ) { if ( this . outputConnection && ! this . hasStatementInput && ! this . bottomRow . hasNextConnection ) { for ( var a = 0 , b = 0 , c ; c = this . rows [ b ] ; b ++ ) if ( Blockly . blockRendering . Types . isInputRow ( c ) ) { a = c . elements [ c . elements . length - 2 ] ; var d = this . getNegativeSpacing _ ( c . elements [ 1 ] ) , e = this . getNegativeSpacing _ ( a ) ; a = d + e ; var f = this . constants _ . MIN _BLOCK _WIDTH + 2 * this . outputConnection . width ; this . width - a < f && ( a = this . width - f , d = a / 2 , e = a / 2 ) ; c . elements . unshift ( new Blockly . blockRendering . InRowSpacer ( this . constants _ ,
- d ) ) ; c . elements . push ( new Blockly . blockRendering . InRowSpacer ( this . constants _ , - e ) ) } if ( a ) for ( this . width -= a , this . widthWithChildren -= a , this . rightSide . xPos -= a , b = 0 ; c = this . rows [ b ] ; b ++ ) Blockly . blockRendering . Types . isTopOrBottomRow ( c ) && ( c . elements [ 1 ] . width -= a , c . elements [ 1 ] . widthWithConnectedBlocks -= a ) , c . width -= a , c . widthWithConnectedBlocks -= a } } ;
Blockly . zelos . RenderInfo . prototype . getNegativeSpacing _ = function ( a ) { if ( ! a ) return 0 ; var b = this . outputConnection . width , c = this . outputConnection . shape . type , d = this . constants _ ; if ( this . isMultiRow && 1 < this . inputRows . length ) switch ( c ) { case d . SHAPES . ROUND : return c = this . constants _ . MAX _DYNAMIC _CONNECTION _SHAPE _WIDTH , c = this . height / 2 > c ? c : this . height / 2 , b - c * ( 1 - Math . sin ( Math . acos ( ( c - this . constants _ . SMALL _PADDING ) / c ) ) ) ; default : return 0 } if ( Blockly . blockRendering . Types . isInlineInput ( a ) ) { var e = a . connectedBlock ; a = e ? e . pathObject . outputShapeType :
a . shape . type ; return e && e . outputConnection && ( e . statementInputCount || e . nextConnection ) || c == d . SHAPES . HEXAGONAL && c != a ? 0 : b - this . constants _ . SHAPE _IN _SHAPE _PADDING [ c ] [ a ] } return Blockly . blockRendering . Types . isField ( a ) ? c == d . SHAPES . ROUND && a . field instanceof Blockly . FieldTextInput ? b - 2.75 * d . GRID _UNIT : b - this . constants _ . SHAPE _IN _SHAPE _PADDING [ c ] [ 0 ] : Blockly . blockRendering . Types . isIcon ( a ) ? this . constants _ . SMALL _PADDING : 0 } ;
Blockly . zelos . RenderInfo . prototype . finalizeVerticalAlignment _ = function ( ) { if ( ! this . outputConnection ) for ( var a = 2 ; a < this . rows . length - 1 ; a += 2 ) { var b = this . rows [ a - 1 ] , c = this . rows [ a ] , d = this . rows [ a + 1 ] , e = 2 == a , f = a + 2 >= this . rows . length - 1 ? ! ! this . bottomRow . hasNextConnection : ! ! d . precedesStatement ; if ( e ? this . topRow . hasPreviousConnection : b . followsStatement ) { var g = 3 == c . elements . length && ( c . elements [ 1 ] . field instanceof Blockly . FieldLabel || c . elements [ 1 ] . field instanceof Blockly . FieldImage ) ; if ( ! e && g ) b . height -= this . constants _ . SMALL _PADDING ,
d . height -= this . constants _ . SMALL _PADDING , c . height -= this . constants _ . MEDIUM _PADDING ; else if ( ! e && ! f ) b . height += this . constants _ . SMALL _PADDING ; else if ( f ) { e = ! 1 ; for ( f = 0 ; g = c . elements [ f ] ; f ++ ) if ( Blockly . blockRendering . Types . isInlineInput ( g ) && g . connectedBlock && ! g . connectedBlock . isShadow ( ) && 40 <= g . connectedBlock . getHeightWidth ( ) . height ) { e = ! 0 ; break } e && ( b . height -= this . constants _ . SMALL _PADDING , d . height -= this . constants _ . SMALL _PADDING ) } } } } ;
Blockly . zelos . RenderInfo . prototype . finalize _ = function ( ) { this . finalizeOutputConnection _ ( ) ; this . finalizeHorizontalAlignment _ ( ) ; this . finalizeVerticalAlignment _ ( ) ; Blockly . zelos . RenderInfo . superClass _ . finalize _ . call ( this ) ; this . rightSide && ( this . widthWithChildren += this . rightSide . width ) } ; Blockly . zelos . Drawer = function ( a , b ) { Blockly . zelos . Drawer . superClass _ . constructor . call ( this , a , b ) } ; Blockly . utils . object . inherits ( Blockly . zelos . Drawer , Blockly . blockRendering . Drawer ) ;
Blockly . zelos . Drawer . prototype . draw = function ( ) { var a = this . block _ . pathObject ; a . beginDrawing ( ) ; this . hideHiddenIcons _ ( ) ; this . drawOutline _ ( ) ; this . drawInternals _ ( ) ; a . setPath ( this . outlinePath _ + "\n" + this . inlinePath _ ) ; this . info _ . RTL && a . flipRTL ( ) ; Blockly . blockRendering . useDebugger && this . block _ . renderingDebugger . drawDebug ( this . block _ , this . info _ ) ; this . recordSizeOnBlock _ ( ) ; this . info _ . outputConnection && ( a . outputShapeType = this . info _ . outputConnection . shape . type ) ; a . endDrawing ( ) } ;
Blockly . zelos . Drawer . prototype . drawOutline _ = function ( ) { this . info _ . outputConnection && this . info _ . outputConnection . isDynamicShape && ! this . info _ . hasStatementInput && ! this . info _ . bottomRow . hasNextConnection ? ( this . drawFlatTop _ ( ) , this . drawRightDynamicConnection _ ( ) , this . drawFlatBottom _ ( ) , this . drawLeftDynamicConnection _ ( ) ) : Blockly . zelos . Drawer . superClass _ . drawOutline _ . call ( this ) } ;
Blockly . zelos . Drawer . prototype . drawLeft _ = function ( ) { this . info _ . outputConnection && this . info _ . outputConnection . isDynamicShape ? this . drawLeftDynamicConnection _ ( ) : Blockly . zelos . Drawer . superClass _ . drawLeft _ . call ( this ) } ;
Blockly . zelos . Drawer . prototype . drawRightSideRow _ = function ( a ) { if ( ! ( 0 >= a . height ) ) if ( a . precedesStatement || a . followsStatement ) { var b = this . constants _ . INSIDE _CORNERS . rightHeight ; b = a . height - ( a . precedesStatement ? b : 0 ) ; this . outlinePath _ += ( a . followsStatement ? this . constants _ . INSIDE _CORNERS . pathBottomRight : "" ) + ( 0 < b ? Blockly . utils . svgPaths . lineOnAxis ( "V" , a . yPos + b ) : "" ) + ( a . precedesStatement ? this . constants _ . INSIDE _CORNERS . pathTopRight : "" ) } else this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . yPos + a . height ) } ;
Blockly . zelos . Drawer . prototype . drawRightDynamicConnection _ = function ( ) { this . outlinePath _ += this . info _ . outputConnection . shape . pathRightDown ( this . info _ . outputConnection . height ) } ; Blockly . zelos . Drawer . prototype . drawLeftDynamicConnection _ = function ( ) { this . positionOutputConnection _ ( ) ; this . outlinePath _ += this . info _ . outputConnection . shape . pathUp ( this . info _ . outputConnection . height ) ; this . outlinePath _ += "z" } ;
Blockly . zelos . Drawer . prototype . drawFlatTop _ = function ( ) { var a = this . info _ . topRow ; this . positionPreviousConnection _ ( ) ; this . outlinePath _ += Blockly . utils . svgPaths . moveBy ( a . xPos , this . info _ . startY ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "h" , a . width ) } ; Blockly . zelos . Drawer . prototype . drawFlatBottom _ = function ( ) { var a = this . info _ . bottomRow ; this . positionNextConnection _ ( ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "V" , a . baseline ) ; this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "h" , - a . width ) } ;
Blockly . zelos . Drawer . prototype . drawInlineInput _ = function ( a ) { this . positionInlineInputConnection _ ( a ) ; var b = a . input . name ; if ( ! a . connectedBlock && ! this . info _ . isInsertionMarker ) { var c = a . width - 2 * a . connectionWidth ; a = Blockly . utils . svgPaths . moveTo ( a . xPos + a . connectionWidth , a . centerline - a . height / 2 ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , c ) + a . shape . pathRightDown ( a . height ) + Blockly . utils . svgPaths . lineOnAxis ( "h" , - c ) + a . shape . pathUp ( a . height ) + "z" ; this . block _ . pathObject . setOutlinePath ( b , a ) } } ;
Blockly . zelos . Drawer . prototype . drawStatementInput _ = function ( a ) { var b = a . getLastInput ( ) , c = b . xPos + b . notchOffset + b . shape . width , d = b . shape . pathRight + Blockly . utils . svgPaths . lineOnAxis ( "h" , - ( b . notchOffset - this . constants _ . INSIDE _CORNERS . width ) ) + this . constants _ . INSIDE _CORNERS . pathTop , e = a . height - 2 * this . constants _ . INSIDE _CORNERS . height ; b = this . constants _ . INSIDE _CORNERS . pathBottom + Blockly . utils . svgPaths . lineOnAxis ( "h" , b . notchOffset - this . constants _ . INSIDE _CORNERS . width ) + ( b . connectedBottomNextConnection ? "" : b . shape . pathLeft ) ;
2021-05-19 13:38:55 +00:00
this . outlinePath _ += Blockly . utils . svgPaths . lineOnAxis ( "H" , c ) + d + Blockly . utils . svgPaths . lineOnAxis ( "v" , e ) + b + Blockly . utils . svgPaths . lineOnAxis ( "H" , a . xPos + a . width ) ; this . positionStatementInputConnection _ ( a ) } ; Blockly . zelos . MarkerSvg = function ( a , b , c ) { Blockly . zelos . MarkerSvg . superClass _ . constructor . call ( this , a , b , c ) } ; Blockly . utils . object . inherits ( Blockly . zelos . MarkerSvg , Blockly . blockRendering . MarkerSvg ) ; Blockly . zelos . MarkerSvg . prototype . showWithInputOutput _ = function ( a ) { var b = a . getSourceBlock ( ) ; a = a . getLocation ( ) . getOffsetInBlock ( ) ; this . positionCircle _ ( a . x , a . y ) ; this . setParent _ ( b ) ; this . showCurrent _ ( ) } ; Blockly . zelos . MarkerSvg . prototype . showWithOutput _ = function ( a ) { this . showWithInputOutput _ ( a ) } ;
Blockly . zelos . MarkerSvg . prototype . showWithInput _ = function ( a ) { this . showWithInputOutput _ ( a ) } ; Blockly . zelos . MarkerSvg . prototype . showWithBlock _ = function ( a ) { a = a . getLocation ( ) ; var b = a . getHeightWidth ( ) ; this . positionRect _ ( 0 , 0 , b . width , b . height ) ; this . setParent _ ( a ) ; this . showCurrent _ ( ) } ; Blockly . zelos . MarkerSvg . prototype . positionCircle _ = function ( a , b ) { this . markerCircle _ . setAttribute ( "cx" , a ) ; this . markerCircle _ . setAttribute ( "cy" , b ) ; this . currentMarkerSvg = this . markerCircle _ } ;
Blockly . zelos . MarkerSvg . prototype . hide = function ( ) { Blockly . zelos . MarkerSvg . superClass _ . hide . call ( this ) ; this . markerCircle _ . style . display = "none" } ;
Blockly . zelos . MarkerSvg . prototype . createDomInternal _ = function ( ) { Blockly . zelos . MarkerSvg . superClass _ . createDomInternal _ . call ( this ) ; this . markerCircle _ = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . CIRCLE , { r : this . constants _ . CURSOR _RADIUS , style : "display: none" , "stroke-width" : this . constants _ . CURSOR _STROKE _WIDTH } , this . markerSvg _ ) ; if ( this . isCursor ( ) ) { var a = this . getBlinkProperties _ ( ) ; Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . ANIMATE , a , this . markerCircle _ ) } return this . markerSvg _ } ;
2021-09-18 14:29:06 +00:00
Blockly . zelos . MarkerSvg . prototype . applyColour _ = function ( a ) { Blockly . zelos . MarkerSvg . superClass _ . applyColour _ . call ( this , a ) ; this . markerCircle _ . setAttribute ( "fill" , this . colour _ ) ; this . markerCircle _ . setAttribute ( "stroke" , this . colour _ ) ; this . isCursor ( ) && this . markerCircle _ . firstChild . setAttribute ( "values" , this . colour _ + ";transparent;transparent;" ) } ; Blockly . zelos . PathObject = function ( a , b , c ) { Blockly . zelos . PathObject . superClass _ . constructor . call ( this , a , b , c ) ; this . constants = c ; this . svgPathSelected _ = null ; this . outlines _ = Object . create ( null ) ; this . outputShapeType = this . remainingOutlines _ = null } ; Blockly . utils . object . inherits ( Blockly . zelos . PathObject , Blockly . blockRendering . PathObject ) ;
Blockly . zelos . PathObject . prototype . setPath = function ( a ) { Blockly . zelos . PathObject . superClass _ . setPath . call ( this , a ) ; this . svgPathSelected _ && this . svgPathSelected _ . setAttribute ( "d" , a ) } ; Blockly . zelos . PathObject . prototype . applyColour = function ( a ) { Blockly . zelos . PathObject . superClass _ . applyColour . call ( this , a ) ; a . isShadow ( ) && a . getParent ( ) && this . svgPath . setAttribute ( "stroke" , a . getParent ( ) . style . colourTertiary ) ; for ( var b in this . outlines _ ) this . outlines _ [ b ] . setAttribute ( "fill" , this . style . colourTertiary ) } ;
Blockly . zelos . PathObject . prototype . flipRTL = function ( ) { Blockly . zelos . PathObject . superClass _ . flipRTL . call ( this ) ; for ( var a in this . outlines _ ) this . outlines _ [ a ] . setAttribute ( "transform" , "scale(-1 1)" ) } ;
2021-01-16 14:07:51 +00:00
Blockly . zelos . PathObject . prototype . updateSelected = function ( a ) { this . setClass _ ( "blocklySelected" , a ) ; a ? this . svgPathSelected _ || ( this . svgPathSelected _ = this . svgPath . cloneNode ( ! 0 ) , this . svgPathSelected _ . setAttribute ( "fill" , "none" ) , this . svgPathSelected _ . setAttribute ( "filter" , "url(#" + this . constants . selectedGlowFilterId + ")" ) , this . svgRoot . appendChild ( this . svgPathSelected _ ) ) : this . svgPathSelected _ && ( this . svgRoot . removeChild ( this . svgPathSelected _ ) , this . svgPathSelected _ = null ) } ;
Blockly . zelos . PathObject . prototype . updateReplacementFade = function ( a ) { this . setClass _ ( "blocklyReplaceable" , a ) ; a ? this . svgPath . setAttribute ( "filter" , "url(#" + this . constants . replacementGlowFilterId + ")" ) : this . svgPath . removeAttribute ( "filter" ) } ; Blockly . zelos . PathObject . prototype . updateShapeForInputHighlight = function ( a , b ) { a = a . getParentInput ( ) . name ; ( a = this . getOutlinePath _ ( a ) ) && ( b ? a . setAttribute ( "filter" , "url(#" + this . constants . replacementGlowFilterId + ")" ) : a . removeAttribute ( "filter" ) ) } ;
2021-09-18 14:29:06 +00:00
Blockly . zelos . PathObject . prototype . beginDrawing = function ( ) { this . remainingOutlines _ = Object . create ( null ) ; for ( var a in this . outlines _ ) this . remainingOutlines _ [ a ] = 1 } ; Blockly . zelos . PathObject . prototype . endDrawing = function ( ) { if ( this . remainingOutlines _ ) for ( var a in this . remainingOutlines _ ) this . removeOutlinePath _ ( a ) ; this . remainingOutlines _ = null } ; Blockly . zelos . PathObject . prototype . setOutlinePath = function ( a , b ) { a = this . getOutlinePath _ ( a ) ; a . setAttribute ( "d" , b ) ; a . setAttribute ( "fill" , this . style . colourTertiary ) } ;
Blockly . zelos . PathObject . prototype . getOutlinePath _ = function ( a ) { this . outlines _ [ a ] || ( this . outlines _ [ a ] = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . PATH , { "class" : "blocklyOutlinePath" , d : "" } , this . svgRoot ) ) ; this . remainingOutlines _ && delete this . remainingOutlines _ [ a ] ; return this . outlines _ [ a ] } ; Blockly . zelos . PathObject . prototype . removeOutlinePath _ = function ( a ) { this . outlines _ [ a ] . parentNode . removeChild ( this . outlines _ [ a ] ) ; delete this . outlines _ [ a ] } ; Blockly . zelos . Renderer = function ( a ) { Blockly . zelos . Renderer . superClass _ . constructor . call ( this , a ) } ; Blockly . utils . object . inherits ( Blockly . zelos . Renderer , Blockly . blockRendering . Renderer ) ; Blockly . zelos . Renderer . prototype . makeConstants _ = function ( ) { return new Blockly . zelos . ConstantProvider } ; Blockly . zelos . Renderer . prototype . makeRenderInfo _ = function ( a ) { return new Blockly . zelos . RenderInfo ( this , a ) } ; Blockly . zelos . Renderer . prototype . makeDrawer _ = function ( a , b ) { return new Blockly . zelos . Drawer ( a , b ) } ;
2021-05-19 13:38:55 +00:00
Blockly . zelos . Renderer . prototype . makeMarkerDrawer = function ( a , b ) { return new Blockly . zelos . MarkerSvg ( a , this . getConstants ( ) , b ) } ; Blockly . zelos . Renderer . prototype . makePathObject = function ( a , b ) { return new Blockly . zelos . PathObject ( a , b , this . getConstants ( ) ) } ; Blockly . zelos . Renderer . prototype . shouldHighlightConnection = function ( a ) { return a . type != Blockly . connectionTypes . INPUT _VALUE && a . type !== Blockly . connectionTypes . OUTPUT _VALUE } ;
Blockly . zelos . Renderer . prototype . getConnectionPreviewMethod = function ( a , b , c ) { return b . type == Blockly . connectionTypes . OUTPUT _VALUE ? a . isConnected ( ) ? Blockly . InsertionMarkerManager . PREVIEW _TYPE . REPLACEMENT _FADE : Blockly . InsertionMarkerManager . PREVIEW _TYPE . INPUT _OUTLINE : Blockly . zelos . Renderer . superClass _ . getConnectionPreviewMethod ( a , b , c ) } ; Blockly . blockRendering . register ( "zelos" , Blockly . zelos . Renderer ) ; Blockly . Themes . Dark = Blockly . Theme . defineTheme ( "dark" , { base : Blockly . Themes . Classic , componentStyles : { workspaceBackgroundColour : "#1e1e1e" , toolboxBackgroundColour : "blackBackground" , toolboxForegroundColour : "#fff" , flyoutBackgroundColour : "#252526" , flyoutForegroundColour : "#ccc" , flyoutOpacity : 1 , scrollbarColour : "#797979" , insertionMarkerColour : "#fff" , insertionMarkerOpacity : . 3 , scrollbarOpacity : . 4 , cursorColour : "#d0d0d0" , blackBackground : "#333" } } ) ; Blockly . Themes . Deuteranopia = { } ;
2021-01-16 14:07:51 +00:00
Blockly . Themes . Deuteranopia . defaultBlockStyles = { colour _blocks : { colourPrimary : "#f2a72c" , colourSecondary : "#f1c172" , colourTertiary : "#da921c" } , list _blocks : { colourPrimary : "#7d65ab" , colourSecondary : "#a88be0" , colourTertiary : "#66518e" } , logic _blocks : { colourPrimary : "#9fd2f1" , colourSecondary : "#c0e0f4" , colourTertiary : "#74bae5" } , loop _blocks : { colourPrimary : "#795a07" , colourSecondary : "#ac8726" , colourTertiary : "#c4a03f" } , math _blocks : { colourPrimary : "#e6da39" , colourSecondary : "#f3ec8e" , colourTertiary : "#f2eeb7" } , procedure _blocks : { colourPrimary : "#590721" ,
colourSecondary : "#8c475d" , colourTertiary : "#885464" } , text _blocks : { colourPrimary : "#058863" , colourSecondary : "#5ecfaf" , colourTertiary : "#04684c" } , variable _blocks : { colourPrimary : "#47025a" , colourSecondary : "#820fa1" , colourTertiary : "#8e579d" } , variable _dynamic _blocks : { colourPrimary : "#47025a" , colourSecondary : "#820fa1" , colourTertiary : "#8e579d" } } ;
Blockly . Themes . Deuteranopia . categoryStyles = { colour _category : { colour : "#f2a72c" } , list _category : { colour : "#7d65ab" } , logic _category : { colour : "#9fd2f1" } , loop _category : { colour : "#795a07" } , math _category : { colour : "#e6da39" } , procedure _category : { colour : "#590721" } , text _category : { colour : "#058863" } , variable _category : { colour : "#47025a" } , variable _dynamic _category : { colour : "#47025a" } } ; Blockly . Themes . Deuteranopia = new Blockly . Theme ( "deuteranopia" , Blockly . Themes . Deuteranopia . defaultBlockStyles , Blockly . Themes . Deuteranopia . categoryStyles ) ; Blockly . Themes . HighContrast = { } ;
Blockly . Themes . HighContrast . defaultBlockStyles = { colour _blocks : { colourPrimary : "#a52714" , colourSecondary : "#FB9B8C" , colourTertiary : "#FBE1DD" } , list _blocks : { colourPrimary : "#4a148c" , colourSecondary : "#AD7BE9" , colourTertiary : "#CDB6E9" } , logic _blocks : { colourPrimary : "#01579b" , colourSecondary : "#64C7FF" , colourTertiary : "#C5EAFF" } , loop _blocks : { colourPrimary : "#33691e" , colourSecondary : "#9AFF78" , colourTertiary : "#E1FFD7" } , math _blocks : { colourPrimary : "#1a237e" , colourSecondary : "#8A9EFF" , colourTertiary : "#DCE2FF" } , procedure _blocks : { colourPrimary : "#006064" ,
colourSecondary : "#77E6EE" , colourTertiary : "#CFECEE" } , text _blocks : { colourPrimary : "#004d40" , colourSecondary : "#5ae27c" , colourTertiary : "#D2FFDD" } , variable _blocks : { colourPrimary : "#880e4f" , colourSecondary : "#FF73BE" , colourTertiary : "#FFD4EB" } , variable _dynamic _blocks : { colourPrimary : "#880e4f" , colourSecondary : "#FF73BE" , colourTertiary : "#FFD4EB" } , hat _blocks : { colourPrimary : "#880e4f" , colourSecondary : "#FF73BE" , colourTertiary : "#FFD4EB" , hat : "cap" } } ;
Blockly . Themes . HighContrast . categoryStyles = { colour _category : { colour : "#a52714" } , list _category : { colour : "#4a148c" } , logic _category : { colour : "#01579b" } , loop _category : { colour : "#33691e" } , math _category : { colour : "#1a237e" } , procedure _category : { colour : "#006064" } , text _category : { colour : "#004d40" } , variable _category : { colour : "#880e4f" } , variable _dynamic _category : { colour : "#880e4f" } } ; Blockly . Themes . HighContrast = new Blockly . Theme ( "highcontrast" , Blockly . Themes . HighContrast . defaultBlockStyles , Blockly . Themes . HighContrast . categoryStyles ) ;
Blockly . Themes . HighContrast . setComponentStyle ( "selectedGlowColour" , "#000000" ) ; Blockly . Themes . HighContrast . setComponentStyle ( "selectedGlowSize" , 1 ) ; Blockly . Themes . HighContrast . setComponentStyle ( "replacementGlowColour" , "#000000" ) ; Blockly . Themes . HighContrast . setFontStyle ( { family : null , weight : null , size : 16 } ) ; Blockly . Themes . Tritanopia = { } ;
Blockly . Themes . Tritanopia . defaultBlockStyles = { colour _blocks : { colourPrimary : "#05427f" , colourSecondary : "#2974c0" , colourTertiary : "#2d74bb" } , list _blocks : { colourPrimary : "#b69ce8" , colourSecondary : "#ccbaef" , colourTertiary : "#9176c5" } , logic _blocks : { colourPrimary : "#9fd2f1" , colourSecondary : "#c0e0f4" , colourTertiary : "#74bae5" } , loop _blocks : { colourPrimary : "#aa1846" , colourSecondary : "#d36185" , colourTertiary : "#7c1636" } , math _blocks : { colourPrimary : "#e6da39" , colourSecondary : "#f3ec8e" , colourTertiary : "#f2eeb7" } , procedure _blocks : { colourPrimary : "#590721" ,
colourSecondary : "#8c475d" , colourTertiary : "#885464" } , text _blocks : { colourPrimary : "#058863" , colourSecondary : "#5ecfaf" , colourTertiary : "#04684c" } , variable _blocks : { colourPrimary : "#4b2d84" , colourSecondary : "#816ea7" , colourTertiary : "#83759e" } , variable _dynamic _blocks : { colourPrimary : "#4b2d84" , colourSecondary : "#816ea7" , colourTertiary : "#83759e" } } ;
Blockly . Themes . Tritanopia . categoryStyles = { colour _category : { colour : "#05427f" } , list _category : { colour : "#b69ce8" } , logic _category : { colour : "#9fd2f1" } , loop _category : { colour : "#aa1846" } , math _category : { colour : "#e6da39" } , procedure _category : { colour : "#590721" } , text _category : { colour : "#058863" } , variable _category : { colour : "#4b2d84" } , variable _dynamic _category : { colour : "#4b2d84" } } ; Blockly . Themes . Tritanopia = new Blockly . Theme ( "tritanopia" , Blockly . Themes . Tritanopia . defaultBlockStyles , Blockly . Themes . Tritanopia . categoryStyles ) ; Blockly . requires = { } ;
return Blockly ;
} ) ) ;
//# sourceMappingURL=blockly_compressed.js.map